def testMakeZip(self): # first unpack our dear sandbox.zip bctx = BuildContext("tests/pccts/pspec.xml") targetDir = bctx.pkg_work_dir() achv = sourcearchive.SourceArchive(bctx) achv.fetch(interactive=False) achv.unpack(clean_dir=True) del achv newZip = targetDir + "/new.zip" zip = archive.ArchiveZip(newZip, 'zip', 'w') sourceDir = targetDir + "/pccts" zip.add_to_archive(sourceDir) zip.close()
def testUnpackZipCond(self): bctx = BuildContext("tests/pccts/pspec.xml") url = uri.URI(bctx.spec.source.archive.uri) targetDir = bctx.pkg_work_dir() filePath = join(ctx.config.archives_dir(), url.filename()) # check cached if util.sha1_file(filePath) != bctx.spec.source.archive.sha1sum: fetch = fetcher.Fetcher(bctx.spec.source.archive.uri, targetDir) fetch.fetch() assert bctx.spec.source.archive.type == "zip" achv = archive.Archive(filePath, bctx.spec.source.archive.type) achv.unpack_files(["pccts/history.txt"], targetDir) assert pathexists(targetDir + "/pccts") testfile = targetDir + "/pccts/history.txt" assert pathexists(testfile)
def testUnpackZip(self): bctx = BuildContext("tests/pccts/pspec.xml") assert bctx.spec.source.archive.type == "zip" achv = sourcearchive.SourceArchive(bctx) achv.fetch(interactive=False) achv.unpack(clean_dir=True) targetDir = bctx.pkg_work_dir() assert pathexists(targetDir + "/pccts") testfile = targetDir + "/pccts/history.txt" assert pathexists(testfile) # check file integrity self.assertEqual(util.sha1_file(testfile), "f2be0f9783e84e98fe4e2b8201a8f506fcc07a4d")
def testUnpackTar(self): bctx = BuildContext("tests/popt/pspec.xml") achv = sourcearchive.SourceArchive(bctx) assert bctx.spec.source.archive.type == "targz" # skip fetching and directly unpack the previously fetched (by # fetchertests) archive if not achv.is_cached(interactive=False): achv.fetch(interactive=False) achv.unpack() targetDir = bctx.pkg_work_dir() # but testing is hard # "var/tmp/pisi/popt-1.7-3/work" (targetDir) assert pathexists(targetDir + "/popt-1.7") testfile = targetDir + "/popt-1.7/Makefile.am" assert pathexists(testfile) # check file integrity self.assertEqual(util.sha1_file(testfile), "5af9dd7d754f788cf511c57ce0af3d555fed009d")