예제 #1
0
def makeArchive(srcrepo, archive, pkgs):
    # pull is the pkgrecv(1) command
    import pull

    print "source directory:", srcrepo
    print "package list:", pkgs

    urlprefix = ['http://', 'https://', 'file://']
    if not True in [srcrepo.startswith(i) for i in urlprefix]:
        # We need the replace statement because the urllib.url2pathname
        # command used in pull.py will work correctly with '/' slash in
        # windows.
        srcrepo = urlunparse(("file", os.path.abspath(srcrepo).replace('\\', '/'), '','','',''))

    destrepo = tempfile.mkdtemp()
    if not True in [destrepo.startswith(i) for i in urlprefix]:
        destrepo_url = urlunparse(("file", os.path.abspath(destrepo).replace('\\', '/'), '','','',''))

    sys.argv = [sys.argv[0], '-m', 'all-timestamps', '-s', srcrepo, '-d', destrepo_url]
    sys.argv.extend(pkgs)
    rv = pull.main_func()

    #copy the cfg_cache to the archive
    if isinstance(archive, zipfile.ZipFile):
        for root, dirs, files in os.walk(destrepo, topdown=False):
            reldir = root[len(destrepo)+1:]
            for name in files:
                archive.write(os.path.join(root, name), os.path.join(reldir, name))
    elif isinstance(archive, tarfile.TarFile):
        archive.add(destrepo, destrepo[len(destrepo):])

    #close the archive
    archive.close()
    return rv
예제 #2
0
def makeArchive(srcrepo, archive, pkgs):
    # pull is the pkgrecv(1) command
    import pull

    print "source directory:", srcrepo
    print "package list:", pkgs

    urlprefix = ['http://', 'https://', 'file://']
    if not True in [srcrepo.startswith(i) for i in urlprefix]:
        # We need the replace statement because the urllib.url2pathname
        # command used in pull.py will work correctly with '/' slash in
        # windows.
        srcrepo = urlunparse(
            ("file", os.path.abspath(srcrepo).replace('\\',
                                                      '/'), '', '', '', ''))

    destrepo = tempfile.mkdtemp()
    if not True in [destrepo.startswith(i) for i in urlprefix]:
        destrepo_url = urlunparse(
            ("file", os.path.abspath(destrepo).replace('\\',
                                                       '/'), '', '', '', ''))

    sys.argv = [
        sys.argv[0], '-m', 'all-timestamps', '-s', srcrepo, '-d', destrepo_url
    ]
    sys.argv.extend(pkgs)
    rv = pull.main_func()

    #copy the cfg_cache to the archive
    if isinstance(archive, zipfile.ZipFile):
        for root, dirs, files in os.walk(destrepo, topdown=False):
            reldir = root[len(destrepo) + 1:]
            for name in files:
                archive.write(os.path.join(root, name),
                              os.path.join(reldir, name))
    elif isinstance(archive, tarfile.TarFile):
        archive.add(destrepo, destrepo[len(destrepo):])

    #close the archive
    archive.close()
    return rv
예제 #3
0
    pkgs = pargs

    print "source repository:", srcrepo
    print "destination repository:", destrepo
    print "package list:", pkgs

    urlprefix = ["http://", "https://", "file://"]
    if not True in [srcrepo.startswith(i) for i in urlprefix]:
        srcrepo = urljoin("file://", os.path.abspath(srcrepo))

    if not True in [destrepo.startswith(i) for i in urlprefix]:
        destrepo = urljoin("file://", os.path.abspath(destrepo))

    sys.argv = [sys.argv[0], "-m", "all-timestamps", "-s", srcrepo, "-d", destrepo]
    sys.argv.extend(pkgs)
    rv = pull.main_func()
    return rv


if __name__ == "__main__":
    try:
        ret = main_func()
    except SystemExit, e:
        raise e
    except KeyboardInterrupt:
        print "Interrupted"
        sys.exit(1)
    except:
        traceback.print_exc()
        sys.exit(99)
    sys.exit(ret)
예제 #4
0
    print "source repository:", srcrepo
    print "destination repository:", destrepo
    print "package list:", pkgs

    urlprefix = ['http://', 'https://', 'file://']
    if not True in [srcrepo.startswith(i) for i in urlprefix]:
        srcrepo = urljoin("file://", os.path.abspath(srcrepo))

    if not True in [destrepo.startswith(i) for i in urlprefix]:
        destrepo = urljoin("file://", os.path.abspath(destrepo))

    sys.argv = [
        sys.argv[0], '-m', 'all-timestamps', '-s', srcrepo, '-d', destrepo
    ]
    sys.argv.extend(pkgs)
    rv = pull.main_func()
    return rv


if __name__ == "__main__":
    try:
        ret = main_func()
    except SystemExit, e:
        raise e
    except KeyboardInterrupt:
        print "Interrupted"
        sys.exit(1)
    except:
        traceback.print_exc()
        sys.exit(99)
    sys.exit(ret)