diff --git a/pisi/index.py b/pisi/index.py index 41e5c1ad..22b8e52a 100644 --- a/pisi/index.py +++ b/pisi/index.py @@ -58,7 +58,7 @@ class Index(XmlFile): for fn in files: if fn.endswith(const.package_prefix): ui.info('Adding ' + fn + ' to package index\n') - self.add_package(os.path.join(root, fn)) + self.add_package(os.path.join(root, fn), repo_uri) def update_db(self, repo): pkgdb = packagedb.get_db(repo) @@ -66,7 +66,7 @@ class Index(XmlFile): for pkg in self.packages: pkgdb.add_package(pkg) - def add_package(self, path): + def add_package(self, path, repo_uri): package = Package(path, 'r') # extract control files util.clean_dir(config.install_dir()) @@ -75,7 +75,9 @@ class Index(XmlFile): md = metadata.MetaData() md.read(os.path.join(config.install_dir(), const.metadata_xml)) # TODO: in the future we'll do all of this with purl/pfile/&helpers - md.package.packageURI = path + # After that, we'll remove the ugly repo_uri parameter from this + # function. + md.package.packageURI = util.removepathprefix(repo_uri, path) # check package semantics if md.verify(): self.packages.append(md.package) diff --git a/pisi/operations.py b/pisi/operations.py index 2f8d73a8..1feb0bf2 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -57,10 +57,22 @@ def install_single_name(name): # find package in repository repo = packagedb.which_repo(name) if repo: + # TODO: Allright this is ugly, but works. Eventually, we'll + # change this... + from repodb import repodb + repo = repodb.get_repo(repo) pkg = packagedb.get_package(name) - ui.info("Installing %s from repository %s\n" %(name, repo)) - ui.debug("Package URI: %s\n" % pkg.packageURI) - install_single_file(pkg.packageURI) + + if repo.indexuri.isLocalFile(): + pkg_path = pkg.packageURI + else: + pkg_path = os.path.join(os.path.dirname(repo.indexuri.getUri()), + pkg.packageURI) + + ui.debug("Package URI: %s\n" % pkg_path) + + # Package will handle remote file for us! + install_single_file(pkg_path) else: ui.error("Package %s not found in the repository file.\n" % pkg)