forked from axeman/erpnext-nix
fix: update script, use long options for commands
This commit is contained in:
parent
19559562b2
commit
6c293138fd
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github
|
||||
#!nix-shell -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github jq
|
||||
|
||||
if [ "$#" -gt 3 ] || [[ "$1" == -* ]]; then
|
||||
echo "Regenerates packaging data for the ERPNext packages."
|
||||
|
@ -14,13 +14,13 @@ frappe_version="$3"
|
|||
set -euo pipefail
|
||||
|
||||
if [ -z "$bench_version" ]; then
|
||||
bench_version="$(wget -q -O- "https://api.github.com/repos/frappe/bench/releases?per_page=1" | jq -r '.[0].tag_name')"
|
||||
bench_version="$(wget --quiet --output-document=- "https://api.github.com/repos/frappe/bench/releases?per_page=1" | jq --raw-output '.[0].tag_name')"
|
||||
fi
|
||||
if [ -z "$erpnext_version" ]; then
|
||||
erpnext_version="$(wget -q -O- "https://api.github.com/repos/frappe/erpnext/releases?per_page=1" | jq -r '.[0].tag_name')"
|
||||
erpnext_version="$(wget --quiet --output-document=- "https://api.github.com/repos/frappe/erpnext/releases?per_page=1" | jq --raw-output '.[0].tag_name')"
|
||||
fi
|
||||
if [ -z "$frappe_version" ]; then
|
||||
frappe_version="$(wget -q -O- "https://api.github.com/repos/frappe/frappe/releases?per_page=1" | jq -r '.[0].tag_name')"
|
||||
frappe_version="$(wget --quiet --output-document=- "https://api.github.com/repos/frappe/frappe/releases?per_page=1" | jq --raw-output '.[0].tag_name')"
|
||||
fi
|
||||
|
||||
# strip leading "v"
|
||||
|
@ -29,32 +29,38 @@ erpnext_version="${erpnext_version#v}"
|
|||
frappe_version="${frappe_version#v}"
|
||||
|
||||
# Bench
|
||||
bench_src_hash=$(nix-prefetch-github frappe bench --rev "v${bench_version}" | jq -r .sha256)
|
||||
echo "Prefetching bench source version $bench_version from GitHub ..."
|
||||
bench_src_hash=$(nix-prefetch-github frappe bench --rev "v${bench_version}" | jq --raw-output .hash)
|
||||
|
||||
# Erpnext
|
||||
echo "Prefetching erpnext source version $erpnext_version from GitHub ..."
|
||||
erpnext_src="https://raw.githubusercontent.com/frappe/erpnext/v$erpnext_version"
|
||||
erpnext_src_hash="$(nix-prefetch-github frappe erpnext --rev "v${erpnext_version}" | jq -r .sha256)"
|
||||
erpnext_src_hash="$(nix-prefetch-github frappe erpnext --rev "v${erpnext_version}" | jq --raw-output .hash)"
|
||||
|
||||
erpnext_tmpdir=$(mktemp -d)
|
||||
erpnext_tmpdir=$(mktemp --directory)
|
||||
trap 'rm -rf "$erpnext_tmpdir"' EXIT
|
||||
|
||||
pushd "$erpnext_tmpdir"
|
||||
wget -q "$erpnext_src/yarn.lock"
|
||||
pushd "$erpnext_tmpdir" &> /dev/null
|
||||
wget --quiet "$erpnext_src/yarn.lock"
|
||||
echo "Prefetching erpnext yarn dependencies ..."
|
||||
erpnext_yarn_hash=$(prefetch-yarn-deps yarn.lock)
|
||||
popd
|
||||
popd &> /dev/null
|
||||
|
||||
# Frappe
|
||||
echo "Prefetching frappe source version $frappe_version from GitHub ..."
|
||||
frappe_src="https://raw.githubusercontent.com/frappe/frappe/v$frappe_version"
|
||||
frappe_src_hash="$(nix-prefetch-github frappe frappe --rev "v${frappe_version}" | jq -r .sha256)"
|
||||
frappe_src_hash="$(nix-prefetch-github frappe frappe --rev "v${frappe_version}" | jq --raw-output .hash)"
|
||||
|
||||
frappe_tmpdir=$(mktemp -d)
|
||||
frappe_tmpdir=$(mktemp --directory)
|
||||
trap 'rm -rf "$frappe_tmpdir"' EXIT
|
||||
|
||||
pushd "$frappe_tmpdir"
|
||||
wget -q "$frappe_src/yarn.lock"
|
||||
pushd "$frappe_tmpdir" &> /dev/null
|
||||
wget --quiet "$frappe_src/yarn.lock"
|
||||
echo "Prefetching frappe yarn dependencies ..."
|
||||
frappe_yarn_hash=$(prefetch-yarn-deps yarn.lock)
|
||||
popd
|
||||
popd &> /dev/null
|
||||
|
||||
echo "Saving updated versions and hashes to pin.nix file ..."
|
||||
cat > pin.nix << EOF
|
||||
{
|
||||
benchVersion = "$bench_version";
|
||||
|
|
73
update.sh
73
update.sh
|
@ -1,73 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -I nixpkgs=../../../../../ -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github
|
||||
|
||||
if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
|
||||
echo "Regenerates packaging data for the ERPNext packages."
|
||||
echo "Usage: $0 [git bench release tag] $1 [git erpnext release tag] $2 [git frappe release tag]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bench_version="$1"
|
||||
erpnext_version="$3"
|
||||
frappe_version="$2"
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ -z "$bench_version" ]; then
|
||||
bench_version="$(wget -q -O- "https://api.github.com/repos/frappe/bench/releases?per_page=1" | jq -r '.[0].tag_name')"
|
||||
fi
|
||||
if [ -z "$erpnext_version" ]; then
|
||||
erpnext_version="$(wget -q -O- "https://api.github.com/repos/frappe/erpnext/releases?per_page=1" | jq -r '.[0].tag_name')"
|
||||
fi
|
||||
if [ -z "$frappe_version" ]; then
|
||||
frappe_version="$(wget -q -O- "https://api.github.com/repos/frappe/frappe/releases?per_page=1" | jq -r '.[0].tag_name')"
|
||||
fi
|
||||
|
||||
# strip leading "v"
|
||||
bench_version="${bench_version#v}"
|
||||
erpnext_version="${erpnext_version#v}"
|
||||
frappe_version="${frappe_version#v}"
|
||||
|
||||
# Bench
|
||||
bench_src_hash=$(nix-prefetch-github frappe bench --rev "v${bench_version}" | jq -r .sha256)
|
||||
|
||||
popd
|
||||
|
||||
# Erpnext
|
||||
erpnext_src="https://raw.githubusercontent.com/frappe/erpnext/v$erpnext_version"
|
||||
erpnext_src_hash="$(nix-prefetch-github frappe erpnext --rev "v${erpnext_version}" | jq -r .sha256)"
|
||||
|
||||
erpnext_tmpdir=$(mktemp -d)
|
||||
trap 'rm -rf "$erpnext_tmpdir"' EXIT
|
||||
|
||||
pushd "$erpnext_tmpdir"
|
||||
wget -q "$erpnext_src/yarn.lock"
|
||||
erpnext_yarn_hash=$(prefetch-yarn-deps yarn.lock)
|
||||
popd
|
||||
|
||||
# Frappe
|
||||
frappe_src="https://raw.githubusercontent.com/frappe/frappe/v$frappe_version"
|
||||
frappe_src_hash="$(nix-prefetch-github frappe frappe --rev "v${frappe_version}" | jq -r .sha256)"
|
||||
|
||||
frappe_tmpdir=$(mktemp -d)
|
||||
trap 'rm -rf "$frappe_tmpdir"' EXIT
|
||||
|
||||
pushd "$frappe_tmpdir"
|
||||
wget -q "$frappe_src/yarn.lock"
|
||||
frappe_yarn_hash=$(prefetch-yarn-deps yarn.lock)
|
||||
popd
|
||||
|
||||
cat > pin.nix << EOF
|
||||
{
|
||||
benchVersion = "$bench_version";
|
||||
erpnextVersion = "$erpnext_version";
|
||||
frappeVersion = "$frappe_version";
|
||||
hashes = {
|
||||
"benchSrcHash" = "$bench_src_hash";
|
||||
"erpnextSrcHash" = "$erpnext_src_hash";
|
||||
"erpnextYarnHash" = "$erpnext_yarn_hash";
|
||||
"frappeSrcHash" = "$frappe_src_hash";
|
||||
"frappeYarnHash" = "$frappe_yarn_hash";
|
||||
};
|
||||
}
|
||||
EOF
|
Loading…
Reference in a new issue