2023-07-17 19:10:27 +00:00
|
|
|
#!/usr/bin/env nix-shell
|
2024-01-06 12:05:51 +00:00
|
|
|
#!nix-shell -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github jq
|
2023-07-17 19:10:27 +00:00
|
|
|
|
|
|
|
if [ "$#" -gt 3 ] || [[ "$1" == -* ]]; then
|
|
|
|
echo "Regenerates packaging data for the ERPNext packages."
|
|
|
|
echo "Usage: $0 [git bench release tag] [git erpnext release tag] [git frappe release tag]"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
bench_version="$1"
|
|
|
|
erpnext_version="$2"
|
|
|
|
frappe_version="$3"
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
if [ -z "$bench_version" ]; then
|
2024-01-06 12:05:51 +00:00
|
|
|
bench_version="$(wget --quiet --output-document=- "https://api.github.com/repos/frappe/bench/releases?per_page=1" | jq --raw-output '.[0].tag_name')"
|
2023-07-17 19:10:27 +00:00
|
|
|
fi
|
|
|
|
if [ -z "$erpnext_version" ]; then
|
2024-01-06 12:05:51 +00:00
|
|
|
erpnext_version="$(wget --quiet --output-document=- "https://api.github.com/repos/frappe/erpnext/releases?per_page=1" | jq --raw-output '.[0].tag_name')"
|
2023-07-17 19:10:27 +00:00
|
|
|
fi
|
|
|
|
if [ -z "$frappe_version" ]; then
|
2024-01-06 12:05:51 +00:00
|
|
|
frappe_version="$(wget --quiet --output-document=- "https://api.github.com/repos/frappe/frappe/releases?per_page=1" | jq --raw-output '.[0].tag_name')"
|
2023-07-17 19:10:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# strip leading "v"
|
|
|
|
bench_version="${bench_version#v}"
|
|
|
|
erpnext_version="${erpnext_version#v}"
|
|
|
|
frappe_version="${frappe_version#v}"
|
|
|
|
|
|
|
|
# Bench
|
2024-01-06 12:05:51 +00:00
|
|
|
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)
|
2023-07-17 19:10:27 +00:00
|
|
|
|
|
|
|
# Erpnext
|
2024-01-06 12:05:51 +00:00
|
|
|
echo "Prefetching erpnext source version $erpnext_version from GitHub ..."
|
2023-07-17 19:10:27 +00:00
|
|
|
erpnext_src="https://raw.githubusercontent.com/frappe/erpnext/v$erpnext_version"
|
2024-01-06 12:05:51 +00:00
|
|
|
erpnext_src_hash="$(nix-prefetch-github frappe erpnext --rev "v${erpnext_version}" | jq --raw-output .hash)"
|
2023-07-17 19:10:27 +00:00
|
|
|
|
2024-01-06 12:05:51 +00:00
|
|
|
erpnext_tmpdir=$(mktemp --directory)
|
2023-07-17 19:10:27 +00:00
|
|
|
trap 'rm -rf "$erpnext_tmpdir"' EXIT
|
|
|
|
|
2024-01-06 12:05:51 +00:00
|
|
|
pushd "$erpnext_tmpdir" &> /dev/null
|
|
|
|
wget --quiet "$erpnext_src/yarn.lock"
|
|
|
|
echo "Prefetching erpnext yarn dependencies ..."
|
2023-07-17 19:10:27 +00:00
|
|
|
erpnext_yarn_hash=$(prefetch-yarn-deps yarn.lock)
|
2024-01-06 12:05:51 +00:00
|
|
|
popd &> /dev/null
|
2023-07-17 19:10:27 +00:00
|
|
|
|
|
|
|
# Frappe
|
2024-01-06 12:05:51 +00:00
|
|
|
echo "Prefetching frappe source version $frappe_version from GitHub ..."
|
2023-07-17 19:10:27 +00:00
|
|
|
frappe_src="https://raw.githubusercontent.com/frappe/frappe/v$frappe_version"
|
2024-01-06 12:05:51 +00:00
|
|
|
frappe_src_hash="$(nix-prefetch-github frappe frappe --rev "v${frappe_version}" | jq --raw-output .hash)"
|
2023-07-17 19:10:27 +00:00
|
|
|
|
2024-01-06 12:05:51 +00:00
|
|
|
frappe_tmpdir=$(mktemp --directory)
|
2023-07-17 19:10:27 +00:00
|
|
|
trap 'rm -rf "$frappe_tmpdir"' EXIT
|
|
|
|
|
2024-01-06 12:05:51 +00:00
|
|
|
pushd "$frappe_tmpdir" &> /dev/null
|
|
|
|
wget --quiet "$frappe_src/yarn.lock"
|
|
|
|
echo "Prefetching frappe yarn dependencies ..."
|
2023-07-17 19:10:27 +00:00
|
|
|
frappe_yarn_hash=$(prefetch-yarn-deps yarn.lock)
|
2024-01-06 12:05:51 +00:00
|
|
|
popd &> /dev/null
|
2023-07-17 19:10:27 +00:00
|
|
|
|
2024-01-06 12:05:51 +00:00
|
|
|
echo "Saving updated versions and hashes to pin.nix file ..."
|
2023-07-17 19:10:27 +00:00
|
|
|
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
|