def testTarUnpack(self): spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') targetDir = '/tmp/tests' archives = sourcearchive.SourceArchives(spec) archives.unpack(targetDir) for archive in spec.source.archive: assert archive.type == 'targz'
def testZipUnpack(self): spec = SpecFile('repos/pardus-2007/system/base/openssl/pspec.xml') targetDir = '/tmp/tests' archives = sourcearchive.SourceArchives(spec) archives.fetch() archives.unpack(targetDir) assert not exists(targetDir + '/openssl')
def getVersion(pspecList): sources = {} for pspec in pspecList: specFile = SpecFile(join_path(pspec, "pspec.xml")) sources[specFile.source.name] = (specFile.source.version, specFile.source.release) return sources
def getPackages(pspecList): packages = [] for pspec in pspecList: specFile = SpecFile(join_path(pspec, "pspec.xml")) for p in specFile.packages: packages += [p.name] return packages
def testSetUri(self): self.spec = SpecFile() self.url = uri.URI(self.spec.source.archive.uri) self.url.set_uri('uri') assert 'uri' == self.url.get_uri() self.url.set_uri('urix') assert 'urix' == self.url.get_uri()
def set_spec_file(self, specuri): if not specuri.is_remote_file(): specuri = URI(os.path.realpath( specuri.get_uri())) # FIXME: doesn't work for file:// self.specuri = specuri spec = SpecFile() spec.read(specuri, ctx.config.tmp_dir()) self.spec = spec
def setUp(self): testcase.TestCase.setUp(self, database = False) self.spec = SpecFile() self.spec.read("tests/helloworld/pspec.xml") self.url = uri.URI(self.spec.source.archive.uri) self.destpath = ctx.config.archives_dir() self.fetch = fetcher.Fetcher(self.url, self.destpath)
def setUp(self): unittest.TestCase.setUp(self) self.spec = SpecFile() self.spec.read('repos/pardus-2007/system/base/curl/pspec.xml') self.url = uri.URI(self.spec.source.archive.uri) self.url.set_auth_info(("user", "pass")) self.destpath = ctx.config.archives_dir() self.fetch = Fetcher(self.url, self.destpath)
def getPackages(pspecList): packages = [] for pspec in pspecList: specFile = SpecFile(join_path(pspec, "pspec.xml")) for p in specFile.packages: packages += [(p.name, "%s-%s" % (specFile.history[0].version, specFile.history[0].release), specFile.source.name)] return packages
def setUp(self): testcase.TestCase.setUp(self) self.sourcedb = pisi.sourcedb.init() self.spec = SpecFile() self.spec.read("tests/popt/pspec.xml") if not ctx.repodb.has_repo('test'): ctx.repodb.add_repo('test', pisi.repodb.Repo(pisi.uri.URI('fakerepo.xml')))
def testUnpackTarCond(self): spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') targetDir = '/tmp' archiv = sourcearchive.SourceArchive(spec, targetDir) url = uri.URI(spec.source.archive.uri) filePath = join(pisi.context.config.archives_dir(), url.filename()) if util.sha1_file(filePath) != spec.source.archive.sha1sum: fetch = fetcher.Fetcher(spec.source.archive.uri, targetDir) fetch.fetch() assert spec.source.archive.type == 'targz'
def testMakeZip(self): spec = SpecFile('repos/pardus-2007/system/base/openssl/pspec.xml') targetDir = '/tmp/tests' archives = sourcearchive.SourceArchives(spec) archives.fetch(interactive=False) archives.unpack(targetDir, clean_dir=True) del archives newDir = targetDir + '/newZip' zip = archive.ArchiveZip(newDir, 'zip', 'w') sourceDir = '/tmp/pisi-root' zip.add_to_archive(sourceDir) zip.close()
def testMakeZip(self): # first unpack our dear sandbox.zip spec = SpecFile("tests/pccts/pspec.xml") targetDir = '/tmp/pisitest' achv = sourcearchive.SourceArchive(spec, targetDir) 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() self.assertEqual(os.path.exists(newZip), True) self.assertEqual(len(zip.list_archive()), 326)
def testUnpackZipCond(self): spec = SpecFile("tests/pccts/pspec.xml") targetDir = '/tmp' achv = sourcearchive.SourceArchive(spec, targetDir) url = uri.URI(spec.source.archive.uri) filePath = join(ctx.config.archives_dir(), url.filename()) # check cached if util.sha1_file(filePath) != spec.source.archive.sha1sum: fetch = fetcher.Fetcher(spec.source.archive.uri, targetDir) fetch.fetch() assert spec.source.archive.type == "zip" achv = archive.Archive(filePath, 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): spec = SpecFile("tests/pccts/pspec.xml") targetDir = '/tmp/pisitest' assert spec.source.archive.type == "zip" achv = sourcearchive.SourceArchive(spec, targetDir) achv.fetch(interactive=False) achv.unpack(clean_dir=True) 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): spec = SpecFile("tests/popt/pspec.xml") targetDir = '/tmp/pisitest' achv = sourcearchive.SourceArchive(spec, targetDir) assert 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() # 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")
def read(filepath): spec = SpecFile() spec.read(filepath) tmp = Pspec(spec.source.name, filepath) tmp.pspec.source.packager = spec.source.packager tmp.pspec.source.homepage = spec.source.homepage tmp.pspec.source.archive = spec.source.archive tmp.pspec.source.name = spec.source.name tmp.pspec.source.license = spec.source.license tmp.pspec.source.partOf = spec.source.partOf tmp.pspec.source.summary = spec.source.summary tmp.pspec.source.description = spec.source.description for pkg in spec.packages: p = Package() p.name = pkg.name p.files = pkg.files p.conflicts = pkg.conflicts p.packageDependencies = pkg.packageDependencies tmp.pspec.packages.append(p) tmp.pspec.history = spec.history return tmp
def __init__(self, pkgname, filepath): self.pspec = SpecFile() self.package = Package() self.update = Update() self.filepath = filepath self.name = pkgname
def testIscached(self): spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') targetDir = '/tmp/tests' srcarch = pisi.sourcearchive.SourceArchive(spec, targetDir) assert srcarch.is_cached()
def testFetch(self): spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') targetDir = '/tmp/tests' srcarch = pisi.sourcearchive.SourceArchive(spec, targetDir) self.assert_(not srcarch.fetch())
def setUp(self): testcase.TestCase.setUp(self) self.spec = SpecFile() self.spec.read('tests/popt/pspec.xml') self.spec.check()
def testMakeUri(self): self.spec = SpecFile() self.url = uri.URI(self.spec.source.archive.uri) f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read) self.assert_(f.make_uri('uri'))
def testIscached(self): spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') srcarch = pisi.sourcearchive.SourceArchive(spec.source.archive[0]) assert srcarch.is_cached()
def testUnpack(self): spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') targetDir = '/tmp/tests' srcarch = pisi.sourcearchive.SourceArchive(spec.source.archive[0]) srcarch.unpack(targetDir)
def bump(options, path): if path.endswith("/"): path = path[:-1] if not path.endswith("/pspec.xml"): path += "/pspec.xml" if not os.path.isfile(path): print "%s not found!" % path sys.exit(1) if not os.access(path, os.W_OK): print "Cannot write to %s." % path sys.exit(1) info = get_and_save_user_info() pspec = open(path, "r").read().strip() specfile = SpecFile(path) old_archive = specfile.source.archive if len(old_archive) == 0: print("No <Archive> tag found in %s." % path) return elif len( old_archive ) > 1 and not options.many and not options.release and not options.rrelease: print("Multiarchive pspec.xml not supported yet.") sys.exit(1) old_archive = old_archive[0].uri old_type = re.sub(ver_ext_pattern, "\\2", old_archive).replace(".", "").replace("src", "") new_type = old_type last = specfile.history[0] old_version = last.version if options.many: verfrom = options.many.split("-")[0] new_version = options.many.split("-")[1] if not old_version == verfrom: print "skipping %s, different versions" % specfile.source.name return new_archive = old_archive.replace(old_version, new_version) elif options.uri: if not options.uri.split(":")[0] in [ "ftp", "file", "http", "https", "mirrors" ]: print "Wrong uri: %s" % options.uri sys.exit(1) new_archive = options.uri new_version = re.sub(ver_ext_pattern, "\\1", new_archive) new_type = re.sub(ver_ext_pattern, "\\2", new_archive).replace( ".", "").replace("tgz", "targz").replace("src", "") elif options.ver: if not re.search("[\d\.]", options.ver): print "Wrong version number: %s" % options.ver sys.exit(1) new_version = options.ver new_archive = old_archive.replace(old_version, new_version) if "." in old_version: mver = ".".join(old_version.split(".")[:-1]) if "/%s/" % mver in new_archive: new_archive = new_archive.replace( "/%s/" % mver, "/%s/" % ".".join(new_version.split(".")[:-1])) elif options.release or options.rrelease: new_type = old_type new_archive = old_archive new_version = old_version else: print old_archive sys.exit(0) info["RELEASE"] = int(last.release) + 1 info["DATE"] = time.strftime("%Y-%m-%d") info["VERSION"] = new_version if options.release or options.rrelease: info["COMMENT"] = "Release bump." else: info["COMMENT"] = "Version bump." new_release = RELEASE % info new_pspec = '' if new_type == "tgz": new_type = "targz" elif not new_type in types: new_type = "binary" for line in pspec.split("\n"): if "<Archive" in line and old_archive in line: new_line = line.split('>') new_line = new_line[0] + '>' + new_archive + '<' + new_line[ 1].split('<')[1] + '>' new_pspec = "\n".join((new_pspec, new_line)) elif "<History>" in line: new_pspec = "\n".join( (new_pspec, " <History>\n%s" % new_release)) elif options.vfrom and "<Dependency versionFrom" in line: new_pspec = "\n".join( (new_pspec, line.replace(old_version, new_version))) else: if not new_pspec: new_pspec = line else: new_pspec = "\n".join((new_pspec, line)) open(path, "w").write(new_pspec) open(path, "a").write("\n") if options.release or options.rrelease: return specfile.source.name if os.getenv("USER") != "root": os.system("sudo pisi build %s --fetch" % path) else: os.system("pisi build %s --fetch" % path) pspec = open(path, "r").read().strip() new_pspec = '' for line in pspec.split("\n"): if "<Archive" in line and os.path.basename(new_archive) in line: sha1sum = os.popen("sha1sum /var/cache/pisi/archives/%s" % os.path.basename(new_archive)).read().split()[0] new_line = re.sub("(.*sha1sum=)[\"\'][^\"^\']+[\"\'](.*)", r'\1"%s"\2' % sha1sum, line) new_line = re.sub("(.*type=)[\"\'][^\"^\']+[\"\'](.*)", r'\1"%s"\2' % new_type, new_line) new_pspec = "\n".join((new_pspec, new_line)) else: if not new_pspec: new_pspec = line else: new_pspec = "\n".join((new_pspec, line)) open(path, "w").write(new_pspec) open(path, "a").write("\n") return specfile.source.name
def testFetch(self): spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') srcarch = pisi.sourcearchive.SourceArchive(spec.source.archive[0]) self.assertTrue(not srcarch.fetch())
def testMakeUri(self): spec = SpecFile("repos/pardus-2007/system/base/curl/pspec.xml") url = uri.URI(spec.source.archive[0].uri) self.assert_(File.make_uri(url))
def testTarUnpack(self): spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') targetDir = '/tmp/tests' archiv = sourcearchive.SourceArchive(spec, targetDir) archiv.unpack() assert spec.source.archive.type == 'targz'