2023-09-24 13:16:22 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
version=
|
|
|
|
gitArgs=
|
|
|
|
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
|
|
i="$1"
|
|
|
|
shift 1
|
|
|
|
case "$i" in
|
2023-11-20 17:24:12 +01:00
|
|
|
--version | -v)
|
2023-09-24 13:16:22 +02:00
|
|
|
version="$1"
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
--git-args)
|
2023-11-20 17:24:12 +01:00
|
|
|
gitArgs="$gitArgs $1"
|
|
|
|
shift 1
|
|
|
|
;;
|
2023-09-24 13:16:22 +02:00
|
|
|
*)
|
|
|
|
echo "$0: unknown option \`$i'"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# Create a working environment
|
|
|
|
CWD=$(pwd)
|
|
|
|
|
|
|
|
TMP=$(mktemp -d)
|
|
|
|
cd "$TMP"
|
|
|
|
|
|
|
|
# Fetch the latest source or the required version
|
|
|
|
gitUrl="https://github.com/demarches-simplifiees/demarches-simplifiees.fr.git"
|
|
|
|
|
|
|
|
if [ -n "$version" ]; then
|
|
|
|
git clone --depth 1 --branch $version $gitUrl .
|
|
|
|
else
|
|
|
|
git clone --depth 1 $gitUrl .
|
2023-11-10 11:18:34 +01:00
|
|
|
|
2023-11-20 17:24:12 +01:00
|
|
|
version="$(git rev-parse HEAD)"
|
2023-09-24 13:16:22 +02:00
|
|
|
fi
|
|
|
|
|
2023-11-20 17:24:12 +01:00
|
|
|
echo "[+] ds-fr version:"
|
|
|
|
echo "- $version"
|
|
|
|
|
2023-09-24 13:16:22 +02:00
|
|
|
# Generate gemset.nix
|
2023-11-10 11:18:34 +01:00
|
|
|
echo "[+] Updating gem files"
|
2023-11-20 17:24:12 +01:00
|
|
|
nix-shell -p bundix --run "bundix -l" >/dev/null
|
2023-09-24 13:16:22 +02:00
|
|
|
|
|
|
|
# Copy the new files
|
|
|
|
cp gemset.nix Gemfile Gemfile.lock "$CWD/rubyEnv/"
|
|
|
|
|
|
|
|
# Print the new source details
|
2023-11-10 11:18:34 +01:00
|
|
|
echo "[+] New hash:"
|
2023-11-16 09:21:34 +01:00
|
|
|
SRC_HASH=$(nix-shell -p nurl --run "nurl --hash $gitUrl $version")
|
2023-11-10 11:18:34 +01:00
|
|
|
|
|
|
|
# Print Yarn deps hash
|
|
|
|
echo "[+] New dependencies hash:"
|
|
|
|
hash=$(nix-shell -p prefetch-yarn-deps --run "prefetch-yarn-deps yarn.lock")
|
|
|
|
|
2023-11-16 09:21:34 +01:00
|
|
|
DEPS_HASH=$(nix-hash --to-sri --type sha256 "$hash")
|
|
|
|
|
2023-11-20 17:24:12 +01:00
|
|
|
cat <<EOF >"$CWD/meta.nix"
|
2023-11-16 09:21:34 +01:00
|
|
|
{
|
|
|
|
version = "$version";
|
|
|
|
src-hash = "$SRC_HASH";
|
|
|
|
deps-hash = "$DEPS_HASH";
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
rm -rf "$TMP"
|