diff --git a/pisi/build.py b/pisi/build.py index 1b99c756..a38f2332 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -243,13 +243,13 @@ class PisiBuild: self.genFilesXml(package) ui.info(" done.\n") - # testing - pkgName = package.name + '-' + self.spec.source.version +\ - '-' + self.spec.source.release + const.package_prefix + name = util.package_name(package.name, + self.spec.source.version, + self.spec.source.release) - ui.info("Creating PISI package %s\n" % pkgName) + ui.info("Creating PISI package %s\n" % name) - pkg = Package(pkgName, 'w') + pkg = Package(name, 'w') c = os.getcwd() # add comar files to package diff --git a/pisi/metadata.py b/pisi/metadata.py index bd9dda6b..be908730 100644 --- a/pisi/metadata.py +++ b/pisi/metadata.py @@ -88,6 +88,7 @@ class MetaData(XmlFile): self.readxml(filename) self.source = SourceInfo(self.getNode("Source")) self.package = PackageInfo(self.getNode("Package")) + self.package.version = self.package.history[0].version self.package.release = self.package.history[0].release diff --git a/pisi/operations.py b/pisi/operations.py index c502710b..ec1e0851 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -4,6 +4,7 @@ from config import config from constants import const from ui import ui from purl import PUrl +import util # all package operation interfaces are here @@ -23,35 +24,31 @@ def remove(package_name): def install(pkg): url = PUrl(pkg) - # check if we are dealing with a remote file or a real path of - # package filename. If we are working with a remote file - # install_package() will handle it. + # Check if we are dealing with a remote file or a real path of + # package filename. Otherwise we'll try installing a package from + # the package repository. if url.isRemoteFile() or os.path.exists(url.uri): install_package(pkg) else: from os.path import join from index import Index - # no pisi package is specified. We are goin to install a - # package from the repository. + + # TODO: Currently we're supporting for only one + # repository. We'll extend this functionality soon. repo_url = config.values.repos.default index = Index() indexpath = join(config.index_dir(), const.pisi_index) index.read(indexpath) - # search package in index file, if it's present in the - # repository + + # search pkg in index for it's presence in repository for package in index.packages: if package.name == pkg: - # As we have no Version tag we need to get - # the last version and release information - # from the first child of History/Update. And it works :) version = package.history[0].version release = package.history[0].release - pkg_name = package.name + '-' + version +\ - '-' + release + const.package_prefix - package_uri = join(repo_url, pkg[0], pkg_name) - ui.info("Installing %s from repository %s\n" % - (pkg_name, repo_url)) + name = util.package_name(pkg, version, release) + package_uri = join(repo_url, name[0], name) + ui.info("Installing %s from repository %s\n" %(name, repo_url)) install_package(package_uri) return ui.error("Package %s not found in the index file.\n" %pkg) @@ -77,7 +74,6 @@ def index(repo_dir = '.'): ui.info('* Building index of PISI files under %s\n' % repo_dir) index = Index() index.index(repo_dir) - print const.pisi_index index.write(const.pisi_index) ui.info('* Index file written\n') diff --git a/pisi/util.py b/pisi/util.py index 7b9b943d..82e925bf 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -15,6 +15,7 @@ import statvfs # pisi modules from ui import ui +from constants import const class FileError(Exception): pass @@ -245,3 +246,10 @@ def partition_freespace(directory): """ returns free space of given directory's partition """ st = os.statvfs(directory) return st[statvfs.F_BSIZE] * st[statvfs.F_BFREE] + +############################# +# Package Related Functions # +############################# + +def package_name(name, version, release): + return name + '-' + version + '-' + release + const.package_prefix