diff options
Diffstat (limited to 'test/pacman/pmdb.py')
-rwxr-xr-x | test/pacman/pmdb.py | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py index 8cb1b832..af5525cf 100755 --- a/test/pacman/pmdb.py +++ b/test/pacman/pmdb.py @@ -81,11 +81,15 @@ class pmdb: """Database object """ - def __init__(self, treename, dbdir): + def __init__(self, treename, root): self.treename = treename - self.dbdir = dbdir self.pkgs = [] self.option = {} + if self.treename == "local": + self.dbdir = os.path.join(root, PM_DBPATH, treename) + else: + self.dbdir = os.path.join(root, PM_SYNCDBPATH, treename) + self.dbfile = os.path.join(root, PM_SYNCDBPATH, treename + ".db") def __str__(self): return "%s" % self.treename @@ -101,7 +105,7 @@ class pmdb: """ """ - path = os.path.join(self.dbdir, self.treename) + path = self.dbdir if not os.path.isdir(path): return None @@ -154,6 +158,8 @@ class pmdb: pkg.md5sum = fd.readline().strip("\n") elif line == "%REPLACES%": pkg.replaces = _getsection(fd) + elif line == "%EPOCH%": + pkg.epoch = int(fd.readline().strip("\n")) elif line == "%FORCE%": fd.readline() pkg.force = 1 @@ -202,12 +208,6 @@ class pmdb: pkg.conflicts = _getsection(fd) elif line == "%PROVIDES%": pkg.provides = _getsection(fd) - # TODO this was going to be changed, but isn't anymore - #elif line == "%REPLACES%": - # pkg.replaces = _getsection(fd) - #elif line == "%FORCE%": - # fd.readline() - # pkg.force = 1 fd.close() pkg.checksum["depends"] = getmd5sum(filename) pkg.mtime["depends"] = getmtime(filename) @@ -227,10 +227,7 @@ class pmdb: """ """ - if self.treename == "local": - path = os.path.join(self.dbdir, self.treename, pkg.fullname()) - else: - path = os.path.join(self.dbdir, "sync", self.treename, pkg.fullname()) + path = os.path.join(self.dbdir, pkg.fullname()) mkdir(path) # desc @@ -266,6 +263,11 @@ class pmdb: data.append(_mksection("FILENAME", pkg.filename())) if pkg.replaces: data.append(_mksection("REPLACES", pkg.replaces)) + if pkg.epoch: + data.append(_mksection("EPOCH", pkg.epoch)) + # for backward compatibility + if not pkg.force: + data.append(_mksection("FORCE", "")) if pkg.force: data.append(_mksection("FORCE", "")) if pkg.csize: @@ -307,11 +309,6 @@ class pmdb: data.append(_mksection("CONFLICTS", pkg.conflicts)) if pkg.provides: data.append(_mksection("PROVIDES", pkg.provides)) - #if self.treename != "local": - # if pkg.replaces: - # data.append(_mksection("REPLACES", pkg.replaces)) - # if pkg.force: - # data.append(_mksection("FORCE", "")) if data: data.append("") filename = os.path.join(path, "depends") @@ -331,30 +328,22 @@ class pmdb: pkg.checksum["install"] = getmd5sum(filename) pkg.mtime["install"] = getmtime(filename) - def gensync(self, path): + def gensync(self): """ """ + if not self.dbfile: + return curdir = os.getcwd() - tmpdir = tempfile.mkdtemp() - os.chdir(tmpdir) - - for pkg in self.pkgs: - mkdescfile(pkg.fullname(), pkg) + os.chdir(self.dbdir) # Generate database archive - mkdir(path) - archive = os.path.join(path, "%s%s" % (self.treename, PM_EXT_DB)) - tar = tarfile.open(archive, "w:gz") - for root, dirs, files in os.walk('.'): - for d in dirs: - tar.add(os.path.join(root, d), recursive=False) - for f in files: - tar.add(os.path.join(root, f)) + tar = tarfile.open(self.dbfile, "w:gz") + for i in os.listdir("."): + tar.add(i) tar.close() os.chdir(curdir) - shutil.rmtree(tmpdir) def ispkgmodified(self, pkg): """ |