def testManifest(self):
+ distfiles = {
+ 'B-2.tar.bz2': b'binary\0content',
+ 'C-2.zip': b'binary\0content',
+ 'C-2.tar.bz2': b'binary\0content',
+ }
+
ebuilds = {
"dev-libs/A-1::old_repo": { },
"dev-libs/A-2::new_repo": { },
+ "dev-libs/B-2::new_repo": {"SRC_URI" : "B-2.tar.bz2"},
+ "dev-libs/C-2::new_repo": {"SRC_URI" : "C-2.zip C-2.tar.bz2"},
}
repo_configs = {
success = True),
)
- playground = ResolverPlayground(ebuilds=ebuilds, repo_configs=repo_configs)
+ playground = ResolverPlayground(ebuilds=ebuilds,
+ repo_configs=repo_configs, distfiles=distfiles)
new_manifest_file = os.path.join(playground.repo_dirs["new_repo"], "dev-libs", "A", "Manifest")
self.assertEqual(os.path.exists(new_manifest_file), False)
+ new_manifest_file = os.path.join(playground.repo_dirs["new_repo"], "dev-libs", "B", "Manifest")
+ f = open(new_manifest_file)
+ self.assertEqual(len(list(f)), 1)
+ f.close()
+
+ new_manifest_file = os.path.join(playground.repo_dirs["new_repo"], "dev-libs", "C", "Manifest")
+ f = open(new_manifest_file)
+ self.assertEqual(len(list(f)), 2)
+ f.close()
+
old_manifest_file = os.path.join(playground.repo_dirs["old_repo"], "dev-libs", "A", "Manifest")
f = open(old_manifest_file)
self.assertEqual(len(list(f)), 1)
"""
def __init__(self, ebuilds={}, installed={}, profile={}, repo_configs={}, \
- user_config={}, sets={}, world=[], debug=False):
+ user_config={}, sets={}, world=[], distfiles={}, debug=False):
"""
ebuilds: cpv -> metadata mapping simulating available ebuilds.
installed: cpv -> metadata mapping simulating installed packages.
self.root = "/"
self.eprefix = tempfile.mkdtemp()
self.eroot = self.root + self.eprefix.lstrip(os.sep) + os.sep
+ self.distdir = os.path.join(self.eroot, "var", "portage", "distfiles")
self.portdir = os.path.join(self.eroot, "usr/portage")
self.vdbdir = os.path.join(self.eroot, "var/db/pkg")
os.makedirs(self.portdir)
#Make sure the main repo is always created
self._get_repo_dir("test_repo")
+ self._create_distfiles(distfiles)
self._create_ebuilds(ebuilds)
self._create_installed(installed)
self._create_profile(ebuilds, installed, profile, repo_configs, user_config, sets)
return self.repo_dirs[repo]
+ def _create_distfiles(self, distfiles):
+ os.makedirs(self.distdir)
+ for k, v in distfiles.items():
+ with open(os.path.join(self.distdir, k), 'wb') as f:
+ f.write(v)
+
def _create_ebuilds(self, ebuilds):
for cpv in ebuilds:
a = Atom("=" + cpv, allow_repo=True)
slot = metadata.pop("SLOT", 0)
keywords = metadata.pop("KEYWORDS", "x86")
homepage = metadata.pop("HOMEPAGE", None)
+ src_uri = metadata.pop("SRC_URI", None)
iuse = metadata.pop("IUSE", "")
depend = metadata.pop("DEPEND", "")
rdepend = metadata.pop("RDEPEND", None)
f.write('DESCRIPTION="%s"\n' % desc)
if homepage is not None:
f.write('HOMEPAGE="%s"\n' % homepage)
+ if src_uri is not None:
+ f.write('SRC_URI="%s"\n' % src_uri)
f.write('LICENSE="' + str(lic) + '"\n')
f.write('PROPERTIES="' + str(properties) + '"\n')
f.write('SLOT="' + str(slot) + '"\n')
env = {
"ACCEPT_KEYWORDS": "x86",
+ "DISTDIR" : self.distdir,
"PORTDIR": self.portdir,
"PORTDIR_OVERLAY": " ".join(portdir_overlay),
'PORTAGE_TMPDIR' : os.path.join(self.eroot, 'var/tmp'),