Exemple #1
0
 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'
Exemple #2
0
 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')
Exemple #3
0
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
Exemple #5
0
 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()
Exemple #6
0
 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
Exemple #7
0
    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)
Exemple #8
0
 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)
Exemple #9
0
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
Exemple #10
0
    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')))
Exemple #11
0
 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'
Exemple #12
0
    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()
Exemple #13
0
    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)
Exemple #14
0
    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)
Exemple #15
0
    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")
Exemple #16
0
    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")
Exemple #17
0
    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
Exemple #18
0
 def __init__(self, pkgname, filepath):
     self.pspec = SpecFile()
     self.package = Package()
     self.update = Update()
     self.filepath = filepath
     self.name = pkgname
Exemple #19
0
 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()
Exemple #20
0
 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()
Exemple #22
0
 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'))
Exemple #23
0
 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()
Exemple #24
0
 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)
Exemple #25
0
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
Exemple #26
0
 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())
Exemple #27
0
 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))
Exemple #28
0
 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'