74 lines
2.2 KiB
Bash
74 lines
2.2 KiB
Bash
|
#!/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
|