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}";
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.

View file

@ -12,6 +12,7 @@ finalImageTag=
hashType=$NIX_HASH_ALGO
hashFormat=$hashFormat
format=nix
skopeoCmd="skopeo --insecure-policy --tmpdir=$TMPDIR"
usage(){
echo >&2 "syntax: nix-prefetch-docker [options] [IMAGE_NAME [IMAGE_TAG|IMAGE_DIGEST]]
@ -38,7 +39,7 @@ get_image_digest(){
imageTag="latest"
fi
skopeo inspect "docker://$imageName:$imageTag" | jq '.Digest' -r
"$skopeoCmd" inspect "docker://$imageName:$imageTag" | jq '.Digest' -r
}
get_name() {
@ -127,9 +128,9 @@ trap "rm -rf \"$tmpPath\"" EXIT
tmpFile="$tmpPath/$(get_name $finalImageName $finalImageTag)"
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
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
# Compute the hash.

View file

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