1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-16 06:15:08 -05:00

pactest: refactor install file creation

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-06-22 15:11:56 -05:00
parent f15cce1d41
commit 63335859d1
3 changed files with 10 additions and 14 deletions

View File

@ -72,15 +72,11 @@ class pmdb(object):
return "Never"
def getpkg(self, name):
"""
"""
for pkg in self.pkgs:
if name == pkg.name:
return pkg
def db_read(self, name):
"""
"""
path = self.dbdir
if not os.path.isdir(path):
return None
@ -226,7 +222,7 @@ class pmdb(object):
if any(pkg.install.values()):
filename = os.path.join(path, "install")
util.mkinstallfile(filename, pkg.install)
util.mkfile(filename, pkg.installfile())
def gensync(self):
if not self.dbfile:

View File

@ -147,7 +147,7 @@ class pmpkg(object):
# .INSTALL
if any(self.install.values()):
util.mkinstallfile(".INSTALL", self.install)
util.mkfile(".INSTALL", self.installfile())
# safely create the dir
util.mkdir(os.path.dirname(self.path))
@ -186,4 +186,12 @@ class pmpkg(object):
def local_backup_entries(self):
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:

View File

@ -91,14 +91,6 @@ def mkfile(name, data = ""):
if setperms:
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):
# Options
data = ["[options]"]