Skip to content

Commit

Permalink
Merge pull request NixOS#141658 from superherointj/package-updateScri…
Browse files Browse the repository at this point in the history
…pt-fix3

update script fix #3 for fluxcd, k3s, linode-cli, linkerd
  • Loading branch information
ryantm authored Oct 14, 2021
2 parents 486c7c2 + 875bb31 commit 13b2a8a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
15 changes: 11 additions & 4 deletions pkgs/applications/networking/cluster/fluxcd/update.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnugrep gnused jq

set -eu -o pipefail
set -x -eu -o pipefail

cd $(dirname "${BASH_SOURCE[0]}")

Expand All @@ -14,7 +14,7 @@ SHA256=$(nix-prefetch-url --quiet --unpack https://github.com/fluxcd/flux2/archi
SPEC_SHA256=$(nix-prefetch-url --quiet --unpack https://github.com/fluxcd/flux2/releases/download/${TAG}/manifests.tar.gz)

setKV () {
sed -i "s|$1 = \".*\"|$1 = \"$2\"|" ./default.nix
sed -i "s|$1 = \".*\"|$1 = \"${2:-}\"|" ./default.nix
}

setKV version ${VERSION}
Expand All @@ -24,8 +24,15 @@ setKV vendorSha256 ""

cd ../../../../../
set +e
VENDOR_SHA256=$(nix-build --no-out-link -A fluxcd 2>&1 | grep "got:" | cut -d':' -f2 | sed 's/ //g')
VENDOR_SHA256=$(nix-build --no-out-link -A fluxcd 2>&1 | grep "got:" | cut -d':' -f2 | sed 's| ||g')
set -e

cd - > /dev/null
setKV vendorSha256 ${VENDOR_SHA256}

if [ -n "${VENDOR_SHA256:-}" ]; then
setKV vendorSha256 ${VENDOR_SHA256}
else
echo "Update failed. VENDOR_SHA256 is empty."
exit 1
fi

4 changes: 2 additions & 2 deletions pkgs/applications/networking/cluster/k3s/update.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnugrep gnused jq

set -eu -o pipefail
set -x -eu -o pipefail

WORKDIR=$(mktemp -d)
trap "rm -rf ${WORKDIR}" EXIT
Expand Down Expand Up @@ -45,7 +45,7 @@ CNIPLUGINS_SHA256=$(nix-prefetch-url --quiet --unpack \
"https://github.com/rancher/plugins/archive/refs/tags/v${CNIPLUGINS_VERSION}.tar.gz")

setKV () {
sed -i "s|$1 = \".*\"|$1 = \"$2\"|" ./default.nix
sed -i "s|$1 = \".*\"|$1 = \"${2:-}\"|" ./default.nix
}

setKV k3sVersion ${K3S_VERSION}
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/networking/cluster/linkerd/update-edge.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnugrep gnused jq

set -eu -o pipefail
set -x -eu -o pipefail

cd $(dirname "$0")

Expand All @@ -14,7 +14,7 @@ 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
sed -i "s|$1 = \".*\"|$1 = \"${2:-}\"|" ./edge.nix
}

setKV version ${VERSION}
Expand All @@ -25,9 +25,9 @@ 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
cd - > /dev/null

if [ -n "${VENDOR_SHA256:-}" ]; then
cd - > /dev/null
setKV vendorSha256 ${VENDOR_SHA256}
else
echo "Update failed. VENDOR_SHA256 is empty."
Expand Down
12 changes: 6 additions & 6 deletions pkgs/applications/networking/cluster/linkerd/update-stable.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnugrep gnused jq

set -eu -o pipefail
set -x -eu -o pipefail

cd $(dirname "$0")

Expand All @@ -14,7 +14,7 @@ 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
sed -i "s|$1 = \".*\"|$1 = \"${2:-}\"|" ./default.nix
}

setKV version ${VERSION}
Expand All @@ -25,11 +25,11 @@ cd ../../../../../
set +e
VENDOR_SHA256=$(nix-build --no-out-link -A linkerd 2>&1 | grep "got:" | cut -d':' -f2 | sed 's| ||g')
set -e
cd - > /dev/null

if [ -n "${VENDOR_SHA256:-}" ]; then
cd - > /dev/null
setKV vendorSha256 ${VENDOR_SHA256}
setKV vendorSha256 ${VENDOR_SHA256}
else
echo "Update failed. VENDOR_SHA256 is empty."
exit 1
echo "Update failed. VENDOR_SHA256 is empty."
exit 1
fi
4 changes: 2 additions & 2 deletions pkgs/tools/virtualization/linode-cli/update.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnugrep gnused jq yq-go

set -eu -o pipefail
set -x -eu -o pipefail

cd $(dirname "${BASH_SOURCE[0]}")

Expand All @@ -21,7 +21,7 @@ VERSION=$(curl -s ${GITHUB_TOKEN:+"-u \":$GITHUB_TOKEN\""} \
SHA256=$(nix-prefetch-url --quiet --unpack https://github.com/linode/linode-cli/archive/refs/tags/${VERSION}.tar.gz)

setKV () {
sed -i "s|$1 = \".*\"|$1 = \"$2\"|" ./default.nix
sed -i "s|$1 = \".*\"|$1 = \"${2:-}\"|" ./default.nix
}

setKV specVersion ${SPEC_VERSION}
Expand Down

0 comments on commit 13b2a8a

Please sign in to comment.