Merge pull request #140286 from superherointj/package-linkerd-updateScript

This commit is contained in:
Sandro 2021-10-03 16:46:04 +02:00 committed by GitHub
commit fcadfea45c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 147 additions and 73 deletions

View File

@ -1,71 +1,8 @@
{ lib, fetchFromGitHub, buildGoModule, installShellFiles }:
{ callPackage }:
let generic = { channel, version, sha256, vendorSha256 }:
buildGoModule rec {
pname = "linkerd-${channel}";
inherit version vendorSha256;
src = fetchFromGitHub {
owner = "linkerd";
repo = "linkerd2";
rev = "${channel}-${version}";
inherit sha256;
};
subPackages = [ "cli" ];
runVend = true;
preBuild = ''
env GOFLAGS="" go generate ./pkg/charts/static
env GOFLAGS="" go generate ./jaeger/static
env GOFLAGS="" go generate ./multicluster/static
env GOFLAGS="" go generate ./viz/static
'';
tags = [
"prod"
];
ldflags = [
"-s" "-w"
"-X github.com/linkerd/linkerd2/pkg/version.Version=${src.rev}"
];
nativeBuildInputs = [ installShellFiles ];
postInstall = ''
mv $out/bin/cli $out/bin/linkerd
installShellCompletion --cmd linkerd \
--bash <($out/bin/linkerd completion bash) \
--zsh <($out/bin/linkerd completion zsh) \
--fish <($out/bin/linkerd completion fish)
'';
doInstallCheck = true;
installCheckPhase = ''
$out/bin/linkerd version --client | grep ${src.rev} > /dev/null
'';
meta = with lib; {
description = "A simple Kubernetes service mesh that improves security, observability and reliability";
downloadPage = "https://github.com/linkerd/linkerd2/";
homepage = "https://linkerd.io/";
license = licenses.asl20;
maintainers = with maintainers; [ Gonzih bryanasdev000 superherointj ];
};
};
in
{
stable = generic {
channel = "stable";
version = "2.10.2";
sha256 = "sha256-dOD0S4FJ2lXE+1VZooi8tKvC8ndGEHAxmAvSqoWI/m0=";
vendorSha256 = "sha256-Qb0FZOvKL9GgncfUl538PynkYbm3V8Q6lUpApUoIp5s=";
};
edge = generic {
channel = "edge";
version = "21.9.3";
sha256 = "0swqx4myvr24visj39icg8g90kj325pvf22bq447rnm0whq3cnyz";
vendorSha256 = "sha256-fMtAR66TwMNR/HCVQ9Jg3sJ0XBx2jUKDG7/ts0lEZM4=";
};
}
(callPackage ./generic.nix { }) {
channel = "stable";
version = "2.10.2";
sha256 = "sha256-dOD0S4FJ2lXE+1VZooi8tKvC8ndGEHAxmAvSqoWI/m0=";
vendorSha256 = "sha256-Qb0FZOvKL9GgncfUl538PynkYbm3V8Q6lUpApUoIp5s=";
}

View File

@ -0,0 +1,8 @@
{ callPackage }:
(callPackage ./generic.nix { }) {
channel = "edge";
version = "21.9.3";
sha256 = "0swqx4myvr24visj39icg8g90kj325pvf22bq447rnm0whq3cnyz";
vendorSha256 = "sha256-fMtAR66TwMNR/HCVQ9Jg3sJ0XBx2jUKDG7/ts0lEZM4=";
}

View File

@ -0,0 +1,59 @@
{ lib, fetchFromGitHub, buildGoModule, installShellFiles }:
{ channel, version, sha256, vendorSha256 }:
buildGoModule rec {
pname = "linkerd-${channel}";
inherit version vendorSha256;
src = fetchFromGitHub {
owner = "linkerd";
repo = "linkerd2";
rev = "${channel}-${version}";
inherit sha256;
};
subPackages = [ "cli" ];
runVend = true;
preBuild = ''
env GOFLAGS="" go generate ./pkg/charts/static
env GOFLAGS="" go generate ./jaeger/static
env GOFLAGS="" go generate ./multicluster/static
env GOFLAGS="" go generate ./viz/static
'';
tags = [
"prod"
];
ldflags = [
"-s" "-w"
"-X github.com/linkerd/linkerd2/pkg/version.Version=${src.rev}"
];
nativeBuildInputs = [ installShellFiles ];
postInstall = ''
mv $out/bin/cli $out/bin/linkerd
installShellCompletion --cmd linkerd \
--bash <($out/bin/linkerd completion bash) \
--zsh <($out/bin/linkerd completion zsh) \
--fish <($out/bin/linkerd completion fish)
'';
doInstallCheck = true;
installCheckPhase = ''
$out/bin/linkerd version --client | grep ${src.rev} > /dev/null
'';
passthru.updateScript = (./. + "/update-${channel}.sh");
meta = with lib; {
description = "A simple Kubernetes service mesh that improves security, observability and reliability";
downloadPage = "https://github.com/linkerd/linkerd2/";
homepage = "https://linkerd.io/";
license = licenses.asl20;
maintainers = with maintainers; [ Gonzih bryanasdev000 superherointj ];
};
}

View File

@ -0,0 +1,35 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnugrep gnused jq
set -eu -o pipefail
cd $(dirname "$0")
TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} \
--silent https://api.github.com/repos/linkerd/linkerd2/releases | \
jq 'map(.tag_name)' | grep edge | sed 's/["|,| ]//g' | sort -r | head -n1)
VERSION=$(echo ${TAG} | sed 's/^edge-//')
SHA256=$(nix-prefetch-url --quiet --unpack https://github.com/linkerd/linkerd2/archive/refs/tags/${TAG}.tar.gz)
setKV () {
sed -i "s|$1 = \".*\"|$1 = \"$2\"|" ./edge.nix
}
setKV version ${VERSION}
setKV sha256 ${SHA256}
setKV vendorSha256 "" # Necessary to force clean build.
cd ../../../../../
set +e
VENDOR_SHA256=$(nix-build --no-out-link -A linkerd_edge 2>&1 | grep "got:" | cut -d':' -f2 | sed 's| ||g')
set -e
if [ -n "${VENDOR_SHA256:-}" ]; then
cd - > /dev/null
setKV vendorSha256 ${VENDOR_SHA256}
else
echo "Update failed. VENDOR_SHA256 is empty."
exit 1
fi

View File

@ -0,0 +1,35 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnugrep gnused jq
set -eu -o pipefail
cd $(dirname "$0")
TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} \
--silent https://api.github.com/repos/linkerd/linkerd2/releases/latest | \
jq -r '.tag_name')
VERSION=$(echo ${TAG} | sed 's/^stable-//')
SHA256=$(nix-prefetch-url --quiet --unpack https://github.com/linkerd/linkerd2/archive/refs/tags/${TAG}.tar.gz)
setKV () {
sed -i "s|$1 = \".*\"|$1 = \"$2\"|" ./default.nix
}
setKV version ${VERSION}
setKV sha256 ${SHA256}
setKV vendorSha256 "" # Necessary to force clean build.
cd ../../../../../
set +e
VENDOR_SHA256=$(nix-build --no-out-link -A linkerd 2>&1 | grep "got:" | cut -d':' -f2 | sed 's| ||g')
set -e
if [ -n "${VENDOR_SHA256:-}" ]; then
cd - > /dev/null
setKV vendorSha256 ${VENDOR_SHA256}
else
echo "Update failed. VENDOR_SHA256 is empty."
exit 1
fi

View File

@ -25651,9 +25651,9 @@ with pkgs;
fluxcd = callPackage ../applications/networking/cluster/fluxcd { };
linkerd_edge = (callPackage ../applications/networking/cluster/linkerd { }).edge;
linkerd_stable = (callPackage ../applications/networking/cluster/linkerd { }).stable;
linkerd = linkerd_stable;
linkerd = callPackage ../applications/networking/cluster/linkerd { };
linkerd_edge = callPackage ../applications/networking/cluster/linkerd/edge.nix { };
linkerd_stable = linkerd;
kile-wl = callPackage ../applications/misc/kile-wl { };