Ejemplo n.º 1
0
def _run(archives=sys.argv[1:]):

    for archive in archives:

        archive = os.path.abspath(archive)

        try:
            print("Opening archive, this may take a while")
            archive_parser = get_archive_parser(archive,
                                                tempdir=options.TEMPDIR)

            # patch set
            if _is_patch_set_archive(archive_parser):
                # create the top-level patch set mpm
                set_mpm = create_patch_set_mpm(archive_parser, archive)
                write_mpm(set_mpm)
                # create the individual patch mpms
                patches, _dummy = archive_parser.list()
                if patches == ['patches']:
                    patches, _dummy = archive_parser.list('patches/')
                for dirname in patches:
                    patch_mpm = create_patch_mpm(archive_parser,
                                                 prefix=dirname)
                    write_mpm(patch_mpm)
                    _close_mpm(patch_mpm)

            # single patch
            elif _is_patch_archive(archive_parser):
                patch_mpm = create_patch_mpm(archive_parser, archive=archive)
                write_mpm(patch_mpm)
                _close_mpm(patch_mpm)

            # package
            elif _is_package_archive(archive_parser):
                pkgs, _dummy = archive_parser.list()
                for dirname in pkgs:
                    pkg_mpm = create_pkg_mpm(archive_parser, prefix=dirname)
                    write_mpm(pkg_mpm)
                    _close_mpm(pkg_mpm)

            # don't know what the hell the customer is trying to run this on
            else:
                raise MPMInputError(
                    "'%s' does not appear to contain Solaris content")

        # pylint: disable=W0703
        except Exception:
            e = sys.exc_info()[1]
            print("Error creating mpm for %s: %s" % (archive, repr(e)))

        # cleanup as we go
        if options.CLEANUP:
            for filename in _temp_files:
                if os.path.isfile(filename):
                    os.unlink(filename)
Ejemplo n.º 2
0
def _run(archives=sys.argv[1:]):

    for archive in archives:

        archive = os.path.abspath(archive)

        try:
            print "Opening archive, this may take a while"
            archive_parser = get_archive_parser(archive, tempdir=options.TEMPDIR)

            # patch set
            if _is_patch_set_archive(archive_parser):
                # create the top-level patch set mpm
                set_mpm = create_patch_set_mpm(archive_parser, archive)
                write_mpm(set_mpm)
                # create the individual patch mpms
                patches, x = archive_parser.list()
                if patches == ['patches']:
                    patches, x = archive_parser.list('patches/')
                for dir in patches:
                    patch_mpm = create_patch_mpm(archive_parser, prefix=dir)
                    write_mpm(patch_mpm)
                    _close_mpm(patch_mpm)

            # single patch
            elif _is_patch_archive(archive_parser):
                patch_mpm = create_patch_mpm(archive_parser, archive=archive)
                write_mpm(patch_mpm)
                _close_mpm(patch_mpm)

            # package
            elif _is_package_archive(archive_parser):
                pkgs, x = archive_parser.list()
                for dir in pkgs:
                    pkg_mpm = create_pkg_mpm(archive_parser, prefix=dir)
                    write_mpm(pkg_mpm)
                    _close_mpm(pkg_mpm)
                        

            # don't know what the hell the customer is trying to run this on
            else:
                raise MPMInputError("'%s' does not appear to contain Solaris content")

        except Exception, e:
            print "Error creating mpm for %s:" % archive
            # print str(e)

        # cleanup as we go
        if options.CLEANUP:
            for file in _temp_files:
                if os.path.isfile(file):
                    os.unlink(file)
Ejemplo n.º 3
0
 def testRead():
     "test the ability of the parser to read a file in the archive"
     p = archive.get_archive_parser(TEST_ARCHIVE)
     contents = p.read(TEST_FILE)
     assert contents == TEST_CONTENTS
Ejemplo n.º 4
0
 def testFind():
     "test the ability of the parser to find a file in the archive"
     p = archive.get_archive_parser(TEST_ARCHIVE)
     assert p.contains(TEST_FILE)
Ejemplo n.º 5
0
 def testFindPath():
     "test the ability of the parser to find a subpath in the archive"
     p = archive.get_archive_parser(TEST_ARCHIVE)
     assert p.contains("foo/bar/" + TEST_FILE)
Ejemplo n.º 6
0
 def testInstantiation():
     "test the instantiation of an archive parser object"
     p = archive.get_archive_parser(TEST_ARCHIVE)
     assert isinstance(p, archive.ArchiveParser)
 def testRead():
     "test the ability of the parser to read a file in the archive"
     p = archive.get_archive_parser(TEST_ARCHIVE)
     contents = p.read(TEST_FILE)
     assert contents == TEST_CONTENTS
 def testFindPath():
     "test the ability of the parser to find a subpath in the archive"
     p = archive.get_archive_parser(TEST_ARCHIVE)
     assert p.contains("foo/bar/" + TEST_FILE)
 def testFind():
     "test the ability of the parser to find a file in the archive"
     p = archive.get_archive_parser(TEST_ARCHIVE)
     assert p.contains(TEST_FILE)
Ejemplo n.º 10
0
 def testInstantiation():
     "test the instantiation of an archive parser object"
     p = archive.get_archive_parser(TEST_ARCHIVE)
     assert isinstance(p, archive.ArchiveParser)