Merge pull request #87821 from zowoq/skopeo

skopeo: 0.2.0 -> 1.0.0, don't set policy and tmpdir during build
This commit is contained in:
adisbladis 2020-05-19 03:25:37 +02:00 committed by GitHub
commit c57a98affe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 24 deletions

View File

@ -95,7 +95,7 @@ rec {
sourceURL = "docker://${imageName}@${imageDigest}"; sourceURL = "docker://${imageName}@${imageDigest}";
destNameTag = "${finalImageName}:${finalImageTag}"; destNameTag = "${finalImageName}:${finalImageTag}";
} '' } ''
skopeo --override-os ${os} --override-arch ${arch} copy "$sourceURL" "docker-archive://$out:$destNameTag" skopeo --insecure-policy --tmpdir=$TMPDIR --override-os ${os} --override-arch ${arch} copy "$sourceURL" "docker-archive://$out:$destNameTag"
''; '';
# We need to sum layer.tar, not a directory, hence tarsum instead of nix-hash. # We need to sum layer.tar, not a directory, hence tarsum instead of nix-hash.

View File

@ -12,6 +12,7 @@ finalImageTag=
hashType=$NIX_HASH_ALGO hashType=$NIX_HASH_ALGO
hashFormat=$hashFormat hashFormat=$hashFormat
format=nix format=nix
skopeoCmd="skopeo --insecure-policy --tmpdir=$TMPDIR"
usage(){ usage(){
echo >&2 "syntax: nix-prefetch-docker [options] [IMAGE_NAME [IMAGE_TAG|IMAGE_DIGEST]] echo >&2 "syntax: nix-prefetch-docker [options] [IMAGE_NAME [IMAGE_TAG|IMAGE_DIGEST]]
@ -38,7 +39,7 @@ get_image_digest(){
imageTag="latest" imageTag="latest"
fi fi
skopeo inspect "docker://$imageName:$imageTag" | jq '.Digest' -r "$skopeoCmd" inspect "docker://$imageName:$imageTag" | jq '.Digest' -r
} }
get_name() { get_name() {
@ -127,9 +128,9 @@ trap "rm -rf \"$tmpPath\"" EXIT
tmpFile="$tmpPath/$(get_name $finalImageName $finalImageTag)" tmpFile="$tmpPath/$(get_name $finalImageName $finalImageTag)"
if test -z "$QUIET"; then if test -z "$QUIET"; then
skopeo --override-os ${os} --override-arch ${arch} copy "$sourceUrl" "docker-archive://$tmpFile:$finalImageName:$finalImageTag" "$skopeoCmd" --override-os ${os} --override-arch ${arch} copy "$sourceUrl" "docker-archive://$tmpFile:$finalImageName:$finalImageTag"
else else
skopeo --override-os ${os} --override-arch ${arch} copy "$sourceUrl" "docker-archive://$tmpFile:$finalImageName:$finalImageTag" > /dev/null "$skopeoCmd" --override-os ${os} --override-arch ${arch} copy "$sourceUrl" "docker-archive://$tmpFile:$finalImageName:$finalImageTag" > /dev/null
fi fi
# Compute the hash. # Compute the hash.

View File

@ -10,46 +10,36 @@
, installShellFiles , installShellFiles
, makeWrapper , makeWrapper
, fuse-overlayfs , fuse-overlayfs
, nixosTests
}: }:
let buildGoModule rec {
version = "0.2.0"; pname = "skopeo";
version = "1.0.0";
src = fetchFromGitHub { src = fetchFromGitHub {
rev = "v${version}"; rev = "v${version}";
owner = "containers"; owner = "containers";
repo = "skopeo"; repo = "skopeo";
sha256 = "09zqzrw6f1s6kaknnj3hra3xz4nq6y86vmw5vk8p4f6g7cwakg1x"; sha256 = "1zg0agf8x7fa8zdzfzgncm64j363lmxrqjhdzsx6mlig87k17p05";
}; };
defaultPolicyFile = runCommand "skopeo-default-policy.json" {} "cp ${src}/default-policy.json $out";
vendorPath = "github.com/containers/skopeo/vendor/github.com/containers/image/v5";
in
buildGoModule {
pname = "skopeo";
inherit version;
inherit src;
outputs = [ "out" "man" ]; outputs = [ "out" "man" ];
vendorSha256 = null; vendorSha256 = null;
excludedPackages = [ "integration" ];
nativeBuildInputs = [ pkg-config go-md2man installShellFiles makeWrapper ]; nativeBuildInputs = [ pkg-config go-md2man installShellFiles makeWrapper ];
buildInputs = [ gpgme ] buildInputs = [ gpgme ]
++ stdenv.lib.optionals stdenv.isLinux [ lvm2 btrfs-progs ]; ++ stdenv.lib.optionals stdenv.isLinux [ lvm2 btrfs-progs ];
buildFlagsArray = '' buildPhase = ''
-ldflags= patchShebangs .
-X ${vendorPath}/signature.systemDefaultPolicyPath=${defaultPolicyFile} make binary-local
-X ${vendorPath}/internal/tmpdir.unixTempDirForBigFiles=/tmp
''; '';
postBuild = '' installPhase = ''
make install-binary PREFIX=$out
make install-docs MANINSTALLDIR="$man/share/man" make install-docs MANINSTALLDIR="$man/share/man"
installShellCompletion --bash completions/bash/skopeo installShellCompletion --bash completions/bash/skopeo
''; '';
@ -59,6 +49,8 @@ buildGoModule {
--prefix PATH : ${stdenv.lib.makeBinPath [ fuse-overlayfs ]} --prefix PATH : ${stdenv.lib.makeBinPath [ fuse-overlayfs ]}
''; '';
passthru.tests.docker-tools = nixosTests.docker-tools;
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "A command line utility for various operations on container images and image repositories"; description = "A command line utility for various operations on container images and image repositories";
homepage = "https://github.com/containers/skopeo"; homepage = "https://github.com/containers/skopeo";