description = IPFire Development Repository
#url = http://mirror0.ipfire.org/pakfire3/$name/$arch
-url = file:///ipfire-3.x/build/packages/i686
+#url = file:///ipfire-3.x/build/packages/i686
+url = file:///tmp/pakfire3
gpgkey = /not/yet/existant
k, v = m.groups()
pkg[k] = v.strip("\"")
+ # Create a dummy repository to link the virtual packages to
+ repo = repository.DummyRepository(self.pakfire)
+
self._packages = []
for pkg in pkgs:
- pkg = packages.VirtualPackage(pkg)
+ pkg = packages.VirtualPackage(self.pakfire, repo, pkg)
self._packages.append(pkg)
return self._packages
pkg = os.path.abspath(pkg)
if pkg.endswith(MAKEFILE_EXTENSION):
- pkg = packages.Makefile(pkg)
+ pkg = packages.Makefile(self.pakfire, pkg)
elif pkg.endswith(PACKAGE_EXTENSION):
- pkg = packages.SourcePackage(pkg)
+ repo = repository.FileSystemRepository(self.pakfire)
+ pkg = packages.SourcePackage(self.pakfire, repo, pkg)
else:
# XXX walk through the source tree and find a matching makefile
pkg = os.path.abspath(pkg)
if pkg.endswith(MAKEFILE_EXTENSION):
- pkg = packages.Makefile(pkg)
+ pkg = packages.Makefile(self.pakfire, pkg)
elif pkg.endswith(PACKAGE_EXTENSION):
- pkg = packages.SourcePackage(pkg)
+ repo = repository.FileSystemRepository(self.pakfire)
+ pkg = packages.SourcePackage(self.pakfire, repo, pkg)
else:
# XXX walk through the source tree and find a matching makefile
pkg = os.path.abspath(pkg)
if pkg.endswith(MAKEFILE_EXTENSION):
- pkg = packages.Makefile(pkg)
+ pkg = packages.Makefile(self.pakfire, pkg)
else:
# XXX walk through the source tree and find a matching makefile
import packages
class Database(object):
- def __init__(self, filename):
+ def __init__(self, pakfire, filename):
+ self.pakfire = pakfire
self.filename = filename
self._db = None
ret = None
for pkg in c:
- ret = packages.InstalledPackage(self, pkg)
+ ret = packages.InstalledPackage(self.pakfire, self, pkg)
break
assert ret
import packages
class Index(object):
- def __init__(self, pakfire):
+ def __init__(self, pakfire, repo):
self.pakfire = pakfire
+ self.repo = repo
self.arch = self.pakfire.distro.arch # XXX ???
class DirectoryIndex(Index):
- def __init__(self, pakfire, path):
+ def __init__(self, pakfire, repo, path):
self.path = path
- Index.__init__(self, pakfire)
+ Index.__init__(self, pakfire, repo)
def update(self, force=False):
logging.debug("Updating repository index '%s' (force=%s)" % (self.path, force))
for file in files:
file = os.path.join(dir, file)
- package = packages.BinaryPackage(file)
+ package = packages.BinaryPackage(self.pakfire, self.repo, file)
if not package.arch in (self.arch, "noarch"):
logging.warning("Skipped package with wrong architecture: %s (%s)" \
class InstalledIndex(Index):
- def __init__(self, pakfire, db):
+ def __init__(self, pakfire, repo, db):
self.db = db
- Index.__init__(self, pakfire)
+ Index.__init__(self, pakfire, repo)
def get_all_by_name(self, name):
c = self.db.cursor()
c.execute("SELECT * FROM packages WHERE name = ?", name)
for pkg in c:
- yield package.InstalledPackage(self.db, pkg)
+ yield package.InstalledPackage(self.pakfire, self.db, pkg)
c.close()
c.execute("SELECT * FROM packages")
for pkg in c:
- yield packages.InstalledPackage(self.db, pkg)
+ yield packages.InstalledPackage(self.pakfire, self.db, pkg)
c.close()
-
-
-
-
-if __name__ == "__main__":
- di = DirectoryIndex("/ipfire-3.x/build/packages/i686", "i686")
-
- for package in di.packages:
- print package
-
- print di.package_names
- print di.get_latest_by_name("ccache")
- print [p for p in di.get_all_by_name("ccache")]
class Package(object):
type = None # either "bin", "src" or "virt"
- def __init__(self, filename):
- self.filename = filename
+ def __init__(self, pakfire, repo):
+ self.pakfire = pakfire
+ self._repo = repo
def __repr__(self):
- return "<%s %s>" % (self.__class__.__name__, self.filename)
+ return "<%s %s>" % (self.__class__.__name__, self.friendly_name)
def __cmp__(self, other):
# if packages differ names return in alphabetical order
def get_extractor(self, pakfire):
return packager.Extractor(pakfire, self)
-
-if __name__ == "__main__":
- for pkg in sys.argv[1:]:
- pkg = BinaryPackage(pkg)
-
- fmt = "%-10s : %s"
-
- items = (
- ("Name", pkg.name),
- ("Version", pkg.version),
- ("Release", pkg.release),
- ("Epoch", pkg.epoch),
- ("Size", pkg.size),
- ("Arch", pkg.arch),
- ("Signature", pkg.signature),
- )
-
- for item in items:
- print fmt % item
-
- print fmt % ("Filelist", "")
- print "\n".join([" %s" % f for f in pkg.filelist])
-
- print pkg.filelist
-
- print
-
This class is a wrapper that reads package data from the (outer)
tarball and should never be used solely.
"""
- def __init__(self, filename):
+ def __init__(self, pakfire, repo, filename):
+ Package.__init__(self, pakfire, repo)
self.filename = filename
# Place to keep the tarfile handle and cache the metadata
class InstalledPackage(Package):
type = "installed"
- def __init__(self, db, data):
+ def __init__(self, pakfire, db, data):
+ Package.__init__(self, pakfire, pakfire.repos.local)
+
self.db = db
self._data = {}
from urlgrabber.progress import TextMeter
import packager
+import pakfire.repository as repository
from base import Package
from source import SourcePackage
class Makefile(Package):
+ def __init__(self, pakfire, filename):
+ repo = repository.DummyRepository(pakfire)
+
+ Package.__init__(self, pakfire, repo)
+ self.filename = filename
+
@property
def files(self):
basedir = os.path.dirname(self.filename)
f = open(files["signature"], "w")
f.close()
- pkg = VirtualPackage(env.make_info)
+ pkg = VirtualPackage(self.pakfire, env.make_info)
# Save meta information.
f = open(files["info"], "w")
class VirtualPackage(Package):
type = "virt"
- def __init__(self, data):
+ def __init__(self, pakfire, data):
+ self.pakfire = pakfire
self._data = {}
for key in data.keys():
return self.index.packages
+class DummyRepository(RepositoryFactory):
+ """
+ Just a dummy repository that actually does nothing.
+ """
+ def __init__(self, pakfire):
+ RepositoryFactory.__init__(self, pakfire, "dummy",
+ "This is a dummy repository.")
+
+
+class FileSystemRepository(RepositoryFactory):
+ """
+ Dummy repository to indicate that a specific package came from the
+ filesystem.
+ """
+ def __init__(self, pakfire):
+ RepositoryFactory.__init__(self, pakfire, "filesystem",
+ "Filesystem repository")
+
+
class LocalRepository(RepositoryFactory):
def __init__(self, pakfire):
RepositoryFactory.__init__(self, pakfire, "installed", "Installed packages")
self.path = os.path.join(self.pakfire.path, PACKAGES_DB)
- self.db = database.LocalPackageDatabase(self.path)
+ self.db = database.LocalPackageDatabase(self.pakfire, self.path)
- self.index = index.InstalledIndex(self.pakfire, self.db)
+ self.index = index.InstalledIndex(self.pakfire, self, self.db)
@property
def priority(self):
self.enabled = False
if self.url.startswith("file://"):
- self.index = index.DirectoryIndex(self.pakfire, self.url[7:])
+ self.index = index.DirectoryIndex(self.pakfire, self, self.url[7:])
else:
self.index = None