1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-01-08 12:28:00 -05:00

pactest: fix gensync

gensync generated a sync.db file with PKGINFO syntax, this is not quite what
pacman expects.

Also the file was only added to the Server path:
	root/var/pub/sync/sync.db
but it was not available in the normal sync db path:
	root/var/lib/pacman/sync/sync.db

Change gensync() to generate var/lib/pacman/sync/sync.db and then copy it to
var/pub/sync/sync.db (this is used by sync200 -Sy test).

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Xavier Chantry 2010-10-11 01:05:04 +02:00 committed by Dan McGee
parent 67068b64b9
commit fa933df65b
3 changed files with 21 additions and 22 deletions

View File

@ -81,11 +81,15 @@ class pmdb:
"""Database object """Database object
""" """
def __init__(self, treename, dbdir): def __init__(self, treename, root):
self.treename = treename self.treename = treename
self.dbdir = dbdir
self.pkgs = [] self.pkgs = []
self.option = {} 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): def __str__(self):
return "%s" % self.treename 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): if not os.path.isdir(path):
return None return None
@ -227,10 +231,7 @@ class pmdb:
""" """
""" """
if self.treename == "local": path = os.path.join(self.dbdir, pkg.fullname())
path = os.path.join(self.dbdir, self.treename, pkg.fullname())
else:
path = os.path.join(self.dbdir, "sync", self.treename, pkg.fullname())
mkdir(path) mkdir(path)
# desc # desc
@ -331,27 +332,22 @@ class pmdb:
pkg.checksum["install"] = getmd5sum(filename) pkg.checksum["install"] = getmd5sum(filename)
pkg.mtime["install"] = getmtime(filename) pkg.mtime["install"] = getmtime(filename)
def gensync(self, path): def gensync(self):
""" """
""" """
if not self.dbfile:
return
curdir = os.getcwd() curdir = os.getcwd()
tmpdir = tempfile.mkdtemp() os.chdir(self.dbdir)
os.chdir(tmpdir)
for pkg in self.pkgs:
mkdescfile(pkg.fullname(), pkg)
# Generate database archive # Generate database archive
mkdir(path) tar = tarfile.open(self.dbfile, "w:gz")
archive = os.path.join(path, "%s.db" % (self.treename))
tar = tarfile.open(archive, "w:gz")
for i in os.listdir("."): for i in os.listdir("."):
tar.add(i) tar.add(i)
tar.close() tar.close()
os.chdir(curdir) os.chdir(curdir)
shutil.rmtree(tmpdir)
def ispkgmodified(self, pkg): def ispkgmodified(self, pkg):
""" """

View File

@ -47,7 +47,7 @@ class pmtest:
""" """
""" """
if not treename in self.db: if not treename in self.db:
self.db[treename] = pmdb.pmdb(treename, os.path.join(self.root, PM_DBPATH)) self.db[treename] = pmdb.pmdb(treename, self.root)
self.db[treename].pkgs.append(pkg) self.db[treename].pkgs.append(pkg)
def addpkg(self, pkg): def addpkg(self, pkg):
@ -73,7 +73,7 @@ class pmtest:
self.args = "" self.args = ""
self.retcode = 0 self.retcode = 0
self.db = { self.db = {
"local": pmdb.pmdb("local", os.path.join(self.root, PM_DBPATH)) "local": pmdb.pmdb("local", self.root)
} }
self.localpkgs = [] self.localpkgs = []
self.filesystem = [] self.filesystem = []
@ -152,9 +152,11 @@ class pmtest:
vprint(" Creating sync database archives") vprint(" Creating sync database archives")
for key, value in self.db.iteritems(): for key, value in self.db.iteritems():
if key == "local": continue if key == "local": continue
archive = value.treename + ".db" vprint("\t" + value.treename)
vprint("\t" + os.path.join(SYNCREPO, archive)) value.gensync()
value.gensync(os.path.join(syncdir, value.treename)) serverpath = os.path.join(syncdir, value.treename)
mkdir(serverpath)
shutil.copy(value.dbfile, serverpath)
# Filesystem # Filesystem
vprint(" Populating file system") vprint(" Populating file system")

View File

@ -25,6 +25,7 @@ import stat
# ALPM # ALPM
PM_ROOT = "/" PM_ROOT = "/"
PM_DBPATH = "var/lib/pacman" PM_DBPATH = "var/lib/pacman"
PM_SYNCDBPATH = "var/lib/pacman/sync"
PM_LOCK = "var/lib/pacman/db.lck" PM_LOCK = "var/lib/pacman/db.lck"
PM_CACHEDIR = "var/cache/pacman/pkg" PM_CACHEDIR = "var/cache/pacman/pkg"
PM_EXT_PKG = ".pkg.tar.gz" PM_EXT_PKG = ".pkg.tar.gz"