diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2017-06-24 03:56:30 +0300 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2017-06-24 03:56:30 +0300 |
commit | b15a23c6f398987fbbf76e1330a6ce29aba9859d (patch) | |
tree | c6b97dda392c485038cf2a7d854360e9913d580c /pomu/source | |
parent | Implemented manifest writing (diff) | |
download | pomu-b15a23c6f398987fbbf76e1330a6ce29aba9859d.tar.gz pomu-b15a23c6f398987fbbf76e1330a6ce29aba9859d.tar.bz2 pomu-b15a23c6f398987fbbf76e1330a6ce29aba9859d.zip |
Implemented package-specific metadata
Started integrating the metadata with pomu APIs
Diffstat (limited to 'pomu/source')
-rw-r--r-- | pomu/source/portage.py | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/pomu/source/portage.py b/pomu/source/portage.py index fe0f4ce..2dcef72 100644 --- a/pomu/source/portage.py +++ b/pomu/source/portage.py @@ -25,11 +25,33 @@ class PortagePackage(): self.slot = slot def fetch(self): - return Package(self.name, portage_repo_path(self.repo), + return Package(self, self.name, portage_repo_path(self.repo), category=self.category, version=self.version, slot=self.slot, files=[path.join(self.category, self.name, 'metadata.xml'), path.join(self.category, self.name, self.name + '-' + self.version + '.ebuild')]) + def write_meta(self, pkgdir): + with open(path.join(pkgdir, 'PORTAGE_DATA'), 'w') as f: + f.write(self.repo + '\n') + f.write(self.category + '\n') + f.write(self.name + '\n') + f.write(self.version + '\n') + f.write(self.slot + '\n') + + @staticmethod + def from_data_file(path): + try: + lines = [x.strip() for x in open(path, 'r')] + except: + return Result.Err('Could not read data file') + if len(lines) < 5: + return Result.Err('Invalid data provided') + res = PortagePackage() + res.repo, res.category, res.name, res.version, res.slot, *_ = lines + if sanity_check(res.repo, res.category, res.name, None, None, None, res.slot, ver=res.version): + return Result.Ok(res) + return Result.Err('Package {} not found'.format(res)) + def __str__(self): return '{}/{}-{}{}::{}'.format(self.category, self.name, self.version, '' if self.slot == '0' else ':' + self.slot, self.repo) @@ -78,7 +100,7 @@ class PortageSource(): return pkg.fetch() -def sanity_check(repo, category, name, vernum, suff, rev, slot): +def sanity_check(repo, category, name, vernum, suff, rev, slot, ver=None): """ Checks whether a package descriptor is valid and corresponds to a package in a configured portage repository @@ -87,12 +109,13 @@ def sanity_check(repo, category, name, vernum, suff, rev, slot): return False if repo and repo not in list(portage_repos()): return False - if (rev or suff) and not vernum: - return False - if vernum: - ver = ver_str(vernum, suff, rev) - else: - ver = None + if not ver: + if (rev or suff) and not vernum: + return False + if vernum: + ver = ver_str(vernum, suff, rev) + else: + ver = None pkgs = repo_pkgs(repo, category, name, ver, slot) if not pkgs: return False |