Ejemplo n.º 1
0
 def testDecompress(self):
     localfile = File('repos/pardus-2007/system/base/curl/pspec.xml',
                      File.read)
     compress = File('repos/contrib-2007/eopkg-index.xml', File.read)
     self.assert_(File.decompress(localfile, compress))
Ejemplo n.º 2
0
 def testDecompress(self):
     localfile = open('repos/pardus-2007/system/base/curl/pspec.xml',
                      File.read)
     compress = open('repos/contrib-2007/pisi-index.xml', File.read)
     self.assertTrue(File.decompress(localfile, compress))
Ejemplo n.º 3
0
 def testDecompress(self):
     localfile = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
     compress = File('repos/contrib-2007/pisi-index.xml', File.read)
     self.assert_(File.decompress(localfile,compress))
Ejemplo n.º 4
0
def main():
    global options

    # Parse options
    parser = OptionParser(usage="%prog [options]", version="%prog 1.0")

    parser.add_option("-N", "--no-color",
                      action="store_false", dest="color", default=True,
                      help=_("don't use colors"))
    parser.add_option("-p", "--packages",
                      action="store_true", dest="packages", default=False,
                      help=_("show package names"))
    parser.add_option("-l", "--long",
                      action="store_true", dest="long", default=False,
                      help=_("show details of advisories"))
    parser.add_option("-a", "--all",
                      action="store_false", dest="affected", default=True,
                      help=_("show all advisories"))
    parser.add_option("-F", "--no-fetch",
                      action="store_false", dest="fetch", default=True,
                      help=_("don't download PLSA index"))

    (options, args) = parser.parse_args()
    
    # Get locale
    lang = os.environ["LC_ALL"].split("_")[0]

    # Show package details in --long
    if options.long:
        options.packages = True

    # Create work directory
    if not os.access("/tmp/plsa", os.F_OK):
        os.mkdir("/tmp/plsa")

    # Init PISI API
    pisi.api.init(database=True, comar=False, write=False)

    # Get installed packages
    installed_packages = {}
    for package in ctx.installdb.list_installed():
        # Release comparison seems enough
        installed_packages[package] = int(ctx.installdb.get_version(package)[1])

    # List of orphaned packages
    orphaned = []

    # Get list of reporsitories
    plsas = {}
    for repo in ctx.repodb.list():
        uri = ctx.repodb.get_repo(repo).indexuri.get_uri()
        plsafile = "%s/plsa-index.xml.bz2" % uri[0:uri.rfind("/")]
        tmpfile = "/tmp/plsa/%s.xml" % repo

        if options.fetch:
            print _("Downloading PLSA database of %s") % repo
            try:
                fetch_url(plsafile, "/tmp/plsa", progress=ctx.ui.Progress)
            except FetchError, e:
                print _("Unable to download %s: %s") % (plsafile, e)
                continue

            print _("Checking file integrity of %s") % repo
            try:
                fetch_url("%s.sha1sum" % plsafile, "/tmp/plsa")
            except FetchError, e:
                print _("Unable to download checksum of %s") % repo
                continue

            orig_sha1sum = file("%s.sha1sum" % plsafile).readlines()[0].split()[0]
            if sha1_file(plsafile) != orig_sha1sum:
                print _("File integrity of %s compromised.") % plsafile
                continue

            print _("Unpacking PLSA database of %s") % repo
            try:
                File.decompress("/tmp/plsa/plsa-index.xml.bz2", File.bz2)
            except:
                print _("Unable to decompress %s") % plsafile
                continue
            
            os.rename("/tmp/plsa/plsa-index.xml", tmpfile)
            os.unlink("/tmp/plsa/plsa-index.xml.bz2")
            plsas[repo] = tmpfile