wasabibackend: Fix create_deps.sh script and update dependencies
The old version of the script tried to parse the output of the dotnet tool, but apparently, that output changed and thus the list of dependencies was empty.
This commit is contained in:
parent
1b97f5d00b
commit
791cb92cf0
2 changed files with 946 additions and 946 deletions
122
pkgs/applications/blockchains/wasabibackend/create_deps.sh
Normal file → Executable file
122
pkgs/applications/blockchains/wasabibackend/create_deps.sh
Normal file → Executable file
|
@ -1,13 +1,26 @@
|
||||||
#! /usr/bin/env nix-shell
|
#! /usr/bin/env nix-shell
|
||||||
#! nix-shell -i bash -p dotnet-sdk_3 nixfmt
|
#! nix-shell -i bash -p dotnet-sdk_3 jq xmlstarlet curl nixfmt
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
# Run this script to generate deps.nix
|
# Run this script to generate deps.nix
|
||||||
# ./create_deps.sh /path/to/package/source/checkout > deps.nix
|
|
||||||
|
|
||||||
# TODO: consolidate with other dotnet deps generation scripts by which
|
# TODO: consolidate with other dotnet deps generation scripts by which
|
||||||
# this script is inspired:
|
# this script is inspired:
|
||||||
# - pkgs/servers/nosql/eventstore/create-deps.sh
|
# - pkgs/servers/nosql/eventstore/create-deps.sh
|
||||||
# - pkgs/development/dotnet-modules/python-language-server/create_deps.sh
|
# - pkgs/development/dotnet-modules/python-language-server/create_deps.sh
|
||||||
|
# - pkgs/misc/emulators/ryujinx/updater.sh
|
||||||
|
|
||||||
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
|
deps_file="$(realpath "./deps.nix")"
|
||||||
|
|
||||||
|
exec 2>&1 6> "$deps_file"
|
||||||
|
|
||||||
|
store_src="$( nix-build ../../../.. -A wasabibackend.src --no-out-link )"
|
||||||
|
src="$(mktemp -d)"
|
||||||
|
cp -rT "$store_src" "$src"
|
||||||
|
chmod -R +w "$src"
|
||||||
|
pushd "$src"
|
||||||
|
|
||||||
URLBASE="https://www.nuget.org/api/v2/package"
|
URLBASE="https://www.nuget.org/api/v2/package"
|
||||||
|
|
||||||
|
@ -30,69 +43,56 @@ DEPS_TEMPLATE="
|
||||||
sha256 = \"%s\";
|
sha256 = \"%s\";
|
||||||
})"
|
})"
|
||||||
|
|
||||||
|
tmpdir="$(mktemp -d -p "$(pwd)")" # must be under source root
|
||||||
|
trap 'rm -rf "$tmpdir"' EXIT
|
||||||
|
|
||||||
function generate_restore_log() {
|
HOME="$tmpdir" dotnet restore --packages "$tmpdir"/.nuget/packages \
|
||||||
checkout_path=$1
|
--no-cache --force --runtime linux-x64 \
|
||||||
>&2 echo "generating restore log for $checkout_path..."
|
WalletWasabi.Backend/WalletWasabi.Backend.csproj >&2
|
||||||
cd $checkout_path
|
|
||||||
dotnet nuget locals all --clear
|
|
||||||
dotnet restore -v normal --no-cache WalletWasabi.Backend -r linux-x64
|
|
||||||
cd -
|
|
||||||
}
|
|
||||||
|
|
||||||
function process_restore_log() {
|
mapfile -t repos < <(
|
||||||
restore_log=$1
|
xmlstarlet sel -t -v 'configuration/packageSources/add/@value' -n NuGet.config "$tmpdir"/.nuget/NuGet/NuGet.Config |
|
||||||
>&2 echo "processing restore log..."
|
while IFS= read index
|
||||||
while read line; do
|
do
|
||||||
if echo $line | grep -q "^[[:space:]]*Installing"; then
|
curl --compressed -fsL "$index" | \
|
||||||
l=$(echo $line | xargs)
|
jq -r '.resources[] | select(."@type" == "PackageBaseAddress/3.0.0")."@id"'
|
||||||
l=${l#Installing }
|
done
|
||||||
l=${l%.}
|
)
|
||||||
echo $l
|
|
||||||
fi
|
|
||||||
done < $restore_log
|
|
||||||
}
|
|
||||||
|
|
||||||
function prefetch_deps() {
|
echo $DEPS_HEADER >&6
|
||||||
processed_log=$1
|
|
||||||
>&2 echo "prefetching deps..."
|
|
||||||
while read line; do
|
|
||||||
name=$(echo $line | cut -d' ' -f1)
|
|
||||||
>&2 echo "prefetching '$name' version: $version"
|
|
||||||
version=$(echo $line | cut -d' ' -f2)
|
|
||||||
hash=$(nix-prefetch-url "$URLBASE/$name/$version" 2>/dev/null)
|
|
||||||
echo "$name $version $hash"
|
|
||||||
done < $processed_log
|
|
||||||
}
|
|
||||||
|
|
||||||
function generate_deps_expression() {
|
cd "$tmpdir/.nuget/packages"
|
||||||
packages=$1
|
for package in *
|
||||||
>&2 echo "generating deps nix-expression..."
|
do
|
||||||
echo $DEPS_HEADER
|
cd "$package"
|
||||||
while read line; do
|
for version in *
|
||||||
name=$(echo $line | cut -d' ' -f1)
|
do
|
||||||
version=$(echo $line | cut -d' ' -f2)
|
found=false
|
||||||
hash=$(echo $line | cut -d' ' -f3)
|
for repo in "${repos[@]}"
|
||||||
printf "$DEPS_TEMPLATE" $name $version $hash
|
do
|
||||||
done < $packages
|
url="$repo$package/$version/$package.$version.nupkg"
|
||||||
echo $DEPS_FOOTER
|
if curl -fsL "$url" -o /dev/null
|
||||||
}
|
then
|
||||||
|
found=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
function main() {
|
if ! $found
|
||||||
checkout_path=$1
|
then
|
||||||
tmpdir=$(mktemp -d)
|
echo "couldn't find $package $version" >&2
|
||||||
generate_restore_log $checkout_path > $tmpdir/restore.log
|
exit 1
|
||||||
process_restore_log $tmpdir/restore.log > $tmpdir/processed.log
|
fi
|
||||||
prefetch_deps $tmpdir/processed.log > $tmpdir/prefetched.log
|
|
||||||
generate_deps_expression $tmpdir/prefetched.log > $tmpdir/deps.nix
|
|
||||||
nixfmt $tmpdir/deps.nix
|
|
||||||
cat $tmpdir/deps.nix
|
|
||||||
rm -rf $tmpdir
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -d "$1" ]; then
|
sha256=$(nix-prefetch-url "$url" 2>/dev/null)
|
||||||
>&2 echo "First argument must be a directory, the path to the package source checkout"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
main $@
|
printf "$DEPS_TEMPLATE" $package $version $sha256 >&6
|
||||||
|
done
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
|
||||||
|
echo $DEPS_FOOTER >&6
|
||||||
|
|
||||||
|
exec 6>&-
|
||||||
|
|
||||||
|
nixfmt "$deps_file"
|
||||||
|
|
1770
pkgs/applications/blockchains/wasabibackend/deps.nix
generated
1770
pkgs/applications/blockchains/wasabibackend/deps.nix
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue