mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
pactest: refactor install file creation
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
f15cce1d41
commit
63335859d1
@ -72,15 +72,11 @@ class pmdb(object):
|
|||||||
return "Never"
|
return "Never"
|
||||||
|
|
||||||
def getpkg(self, name):
|
def getpkg(self, name):
|
||||||
"""
|
|
||||||
"""
|
|
||||||
for pkg in self.pkgs:
|
for pkg in self.pkgs:
|
||||||
if name == pkg.name:
|
if name == pkg.name:
|
||||||
return pkg
|
return pkg
|
||||||
|
|
||||||
def db_read(self, name):
|
def db_read(self, name):
|
||||||
"""
|
|
||||||
"""
|
|
||||||
path = self.dbdir
|
path = self.dbdir
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
return None
|
return None
|
||||||
@ -226,7 +222,7 @@ class pmdb(object):
|
|||||||
|
|
||||||
if any(pkg.install.values()):
|
if any(pkg.install.values()):
|
||||||
filename = os.path.join(path, "install")
|
filename = os.path.join(path, "install")
|
||||||
util.mkinstallfile(filename, pkg.install)
|
util.mkfile(filename, pkg.installfile())
|
||||||
|
|
||||||
def gensync(self):
|
def gensync(self):
|
||||||
if not self.dbfile:
|
if not self.dbfile:
|
||||||
|
@ -147,7 +147,7 @@ class pmpkg(object):
|
|||||||
|
|
||||||
# .INSTALL
|
# .INSTALL
|
||||||
if any(self.install.values()):
|
if any(self.install.values()):
|
||||||
util.mkinstallfile(".INSTALL", self.install)
|
util.mkfile(".INSTALL", self.installfile())
|
||||||
|
|
||||||
# safely create the dir
|
# safely create the dir
|
||||||
util.mkdir(os.path.dirname(self.path))
|
util.mkdir(os.path.dirname(self.path))
|
||||||
@ -186,4 +186,12 @@ class pmpkg(object):
|
|||||||
def local_backup_entries(self):
|
def local_backup_entries(self):
|
||||||
return ["%s\t%s" % (self.parse_filename(i), util.mkmd5sum(i)) for i in self.backup]
|
return ["%s\t%s" % (self.parse_filename(i), util.mkmd5sum(i)) for i in self.backup]
|
||||||
|
|
||||||
|
def installfile(self):
|
||||||
|
data = []
|
||||||
|
for key, value in self.install.iteritems():
|
||||||
|
if value:
|
||||||
|
data.append("%s() {\n%s\n}" % (key, value))
|
||||||
|
|
||||||
|
return "\n".join(data)
|
||||||
|
|
||||||
# vim: set ts=4 sw=4 et:
|
# vim: set ts=4 sw=4 et:
|
||||||
|
@ -91,14 +91,6 @@ def mkfile(name, data = ""):
|
|||||||
if setperms:
|
if setperms:
|
||||||
os.chmod(filename, int(perms, 8))
|
os.chmod(filename, int(perms, 8))
|
||||||
|
|
||||||
def mkinstallfile(filename, install):
|
|
||||||
data = []
|
|
||||||
for key, value in install.iteritems():
|
|
||||||
if value:
|
|
||||||
data.append("%s() {\n%s\n}" % (key, value))
|
|
||||||
|
|
||||||
mkfile(filename, "\n".join(data))
|
|
||||||
|
|
||||||
def mkcfgfile(filename, root, option, db):
|
def mkcfgfile(filename, root, option, db):
|
||||||
# Options
|
# Options
|
||||||
data = ["[options]"]
|
data = ["[options]"]
|
||||||
|
Loading…
Reference in New Issue
Block a user