def download_image(self): # create image dir if not exist os.makedirs(self._container_imagedir, exist_ok=True) image_name = self._container_config.get_image() output_filename = self._container_imagedir + self._container_imagename docker_image = DockerImage(image_name) docker_image.export_image(output_filename)
def __init__(self, os_and_version): (os, version) = os_and_version.split('.', 1) if os.startswith('osx'): build_image = TaskEnvironment.by_name('osx10_10.build') else: build_image = DockerImage.by_name('build') if os == 'linux' or os.startswith('osx'): h = hashlib.sha1(build_image.hexdigest) h.update('v2') if os == 'linux': description = 'git v{}'.format(version) else: env = build_image description = 'git v{} {} {}'.format(version, env.os, env.cpu) Task.__init__( self, task_env=build_image, description=description, index='{}.git.v{}'.format(h.hexdigest(), version), expireIn='26 weeks', command=Task.checkout( 'git://git.kernel.org/pub/scm/git/git.git', 'v{}'.format(version)) + [ 'make -C repo -j$(nproc) install prefix=/' ' NO_GETTEXT=1 NO_OPENSSL=1 NO_TCLTK=1' ' DESTDIR=$PWD/git', 'tar -Jcf $ARTIFACTS/git-{}.tar.xz git'.format(version), ], artifact='git-{}.tar.xz'.format(version), ) else: env = TaskEnvironment.by_name('{}.build'.format(os)) raw_version = version if 'windows' not in version: version = { version: version + '.windows.1', '2.17.1': '2.17.1.windows.2', }.get(version) if version.endswith('.windows.1'): min_ver = version[:-len('.windows.1')] else: min_ver = version.replace('windows.', '') Task.__init__( self, task_env=build_image, description='git v{} {} {}'.format(version, env.os, env.cpu), index='{}.git.v{}'.format(os, raw_version), expireIn='26 weeks', command=[ 'curl -L https://github.com/git-for-windows/git/releases/' 'download/v{}/MinGit-{}-{}-bit.zip' ' -o git.zip'.format(version, min_ver, msys.bits(env.cpu)), 'unzip -d git git.zip', 'tar -jcf $ARTIFACTS/git-{}.tar.bz2 git'.format( raw_version), ], artifact='git-{}.tar.bz2'.format(raw_version), )
def download_docker_image(repo, image): print("downloading file!") docker_image = DockerImage(repo=repo, image=image) tar_path = docker_image.tar_path for layer_index, total, current_bytes, total_bytes in docker_image.pull(): emit('pull_progress', { "index": layer_index, "total": total, "current_bytes": current_bytes, "total_bytes": int(total_bytes) }, namespace="/", room=room_id) emit("start_compress", {}, namespace="/", room=room_id) for line in docker_image.compress(): emit("compress_progress", { "line": str(line) }, namespace="/", room=room_id) print("pull done!") emit('pull_done', {"data": "pull_done!", "tar_path": tar_path}, namespace="/", room=room_id)
def image_exists(path): match = re.match(IMAGE_TAG_REGEX, path) if not match: return json.dumps({ "exists": False }) groups = match.groupdict() image = groups["image"] tag = groups["tag"] \ if groups["tag"] is not None else "latest" repository = groups["repository"] \ if groups["repository"] is not None else "library" return json.dumps({"exists": DockerImage(image=f"{image}:{tag}", repo=repository).exists()})
def __init__(self, cpu): assert cpu in CPUS _create_command = ( 'curl -L http://repo.msys2.org/distrib/{cpu}' '/msys2-base-{cpu}-{version}.tar.xz | xz -cd | bzip2 -c' ' > $ARTIFACTS/msys2.tar.bz2'.format(cpu=cpu, version=MSYS_VERSION)) h = hashlib.sha1(_create_command) self.hexdigest = h.hexdigest() self.cpu = cpu Task.__init__( self, task_env=DockerImage.by_name('base'), description='msys2 image: base {}'.format(cpu), index=self.index, expireIn='26 weeks', command=[_create_command], artifact='msys2.tar.bz2', )
def __init__(self, cpu): assert cpu in CPUS _create_command = ( 'curl -L http://repo.msys2.org/distrib/{cpu}' '/msys2-base-{cpu}-{version}.tar.xz | xz -cd | bzip2 -c' ' > $ARTIFACTS/msys2.tar.bz2'.format( cpu=msys_cpu(cpu), version=MSYS_VERSION) ) h = hashlib.sha1(_create_command.encode()) self.hexdigest = h.hexdigest() self.cpu = cpu Task.__init__( self, task_env=DockerImage.by_name('base'), description='msys2 image: base {}'.format(cpu), index=self.index, expireIn='26 weeks', command=[_create_command], artifact='msys2.tar.bz2', )
def __init__(self, os_and_version): (os, version) = os_and_version.split('.', 1) if os.startswith('osx'): build_image = TaskEnvironment.by_name('osx10_10.build') else: build_image = DockerImage.by_name('build') if os == 'linux' or os.startswith('osx'): h = hashlib.sha1(build_image.hexdigest.encode()) h.update(b'v2') if os == 'linux': description = 'git v{}'.format(version) else: env = build_image description = 'git v{} {} {}'.format(version, env.os, env.cpu) Task.__init__( self, task_env=build_image, description=description, index='{}.git.v{}'.format(h.hexdigest(), version), expireIn='26 weeks', command=Task.checkout( 'git://git.kernel.org/pub/scm/git/git.git', 'v{}'.format(version) ) + [ 'make -C repo -j$({}) install prefix=/ NO_GETTEXT=1' ' NO_OPENSSL=1 NO_TCLTK=1 DESTDIR=$PWD/git'.format( nproc(build_image)), 'tar -Jcf $ARTIFACTS/git-{}.tar.xz git' .format(version), ], artifact='git-{}.tar.xz'.format(version), ) else: env = TaskEnvironment.by_name('{}.build'.format(os)) raw_version = version if 'windows' not in version: version = { version: version + '.windows.1', '2.17.1': '2.17.1.windows.2', }.get(version) if version.endswith('.windows.1'): min_ver = version[:-len('.windows.1')] else: min_ver = version.replace('windows.', '') Task.__init__( self, task_env=build_image, description='git v{} {} {}'.format(version, env.os, env.cpu), index='{}.git.v{}'.format(os, raw_version), expireIn='26 weeks', command=[ 'curl -L https://github.com/git-for-windows/git/releases/' 'download/v{}/MinGit-{}-{}-bit.zip' ' -o git.zip'.format(version, min_ver, msys.bits(env.cpu)), 'unzip -d git git.zip', 'curl -L https://github.com/git-for-windows/git/releases/' 'download/v{}/Git-{}-{}-bit.tar.bz2 | ' 'tar -C git -jx {}/libexec/git-core/git-http-backend.exe' .format(version, min_ver, msys.bits(env.cpu), msys.mingw(env.cpu).lower()), 'tar -jcf $ARTIFACTS/git-{}.tar.bz2 git'.format( raw_version), ], artifact='git-{}.tar.bz2'.format(raw_version), )