-
-
Notifications
You must be signed in to change notification settings - Fork 15k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnetCorePackages.*_5*: 5.0.0 -> 5.0.10 #138296
Changes from all commits
4a9f1c7
0da3293
89d319c
9740573
e594fe6
5acdea7
57301b8
146dc44
7d13a68
1c67f3e
3f980e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,26 @@ | ||
#! /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 | ||
# ./create_deps.sh /path/to/package/source/checkout > deps.nix | ||
|
||
# TODO: consolidate with other dotnet deps generation scripts by which | ||
# this script is inspired: | ||
# - pkgs/servers/nosql/eventstore/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" | ||
|
||
|
@@ -30,69 +43,56 @@ DEPS_TEMPLATE=" | |
sha256 = \"%s\"; | ||
})" | ||
|
||
tmpdir="$(mktemp -d -p "$(pwd)")" # must be under source root | ||
trap 'rm -rf "$tmpdir"' EXIT | ||
|
||
HOME="$tmpdir" dotnet restore --packages "$tmpdir"/.nuget/packages \ | ||
--no-cache --force --runtime linux-x64 \ | ||
WalletWasabi.Backend/WalletWasabi.Backend.csproj >&2 | ||
|
||
mapfile -t repos < <( | ||
xmlstarlet sel -t -v 'configuration/packageSources/add/@value' -n NuGet.config "$tmpdir"/.nuget/NuGet/NuGet.Config | | ||
while IFS= read index | ||
do | ||
curl --compressed -fsL "$index" | \ | ||
jq -r '.resources[] | select(."@type" == "PackageBaseAddress/3.0.0")."@id"' | ||
done | ||
) | ||
|
||
echo $DEPS_HEADER >&6 | ||
|
||
cd "$tmpdir/.nuget/packages" | ||
for package in * | ||
do | ||
cd "$package" | ||
for version in * | ||
do | ||
found=false | ||
for repo in "${repos[@]}" | ||
do | ||
Comment on lines
+65
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally google style bash is preferred.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I prefer that too; just copied that from somewhere else... Hope to fix all these things and use nuget-to-nix instead of all the different things done in those scripts. |
||
url="$repo$package/$version/$package.$version.nupkg" | ||
if curl -fsL "$url" -o /dev/null | ||
then | ||
found=true | ||
break | ||
fi | ||
done | ||
|
||
if ! $found | ||
then | ||
echo "couldn't find $package $version" >&2 | ||
exit 1 | ||
fi | ||
|
||
sha256=$(nix-prefetch-url "$url" 2>/dev/null) | ||
|
||
printf "$DEPS_TEMPLATE" $package $version $sha256 >&6 | ||
done | ||
cd .. | ||
done | ||
|
||
echo $DEPS_FOOTER >&6 | ||
|
||
exec 6>&- | ||
|
||
function generate_restore_log() { | ||
checkout_path=$1 | ||
>&2 echo "generating restore log for $checkout_path..." | ||
cd $checkout_path | ||
dotnet nuget locals all --clear | ||
dotnet restore -v normal --no-cache WalletWasabi.Backend -r linux-x64 | ||
cd - | ||
} | ||
|
||
function process_restore_log() { | ||
restore_log=$1 | ||
>&2 echo "processing restore log..." | ||
while read line; do | ||
if echo $line | grep -q "^[[:space:]]*Installing"; then | ||
l=$(echo $line | xargs) | ||
l=${l#Installing } | ||
l=${l%.} | ||
echo $l | ||
fi | ||
done < $restore_log | ||
} | ||
|
||
function prefetch_deps() { | ||
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() { | ||
packages=$1 | ||
>&2 echo "generating deps nix-expression..." | ||
echo $DEPS_HEADER | ||
while read line; do | ||
name=$(echo $line | cut -d' ' -f1) | ||
version=$(echo $line | cut -d' ' -f2) | ||
hash=$(echo $line | cut -d' ' -f3) | ||
printf "$DEPS_TEMPLATE" $name $version $hash | ||
done < $packages | ||
echo $DEPS_FOOTER | ||
} | ||
|
||
function main() { | ||
checkout_path=$1 | ||
tmpdir=$(mktemp -d) | ||
generate_restore_log $checkout_path > $tmpdir/restore.log | ||
process_restore_log $tmpdir/restore.log > $tmpdir/processed.log | ||
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 | ||
>&2 echo "First argument must be a directory, the path to the package source checkout" | ||
exit 1 | ||
fi | ||
|
||
main $@ | ||
nixfmt "$deps_file" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use nixpkgs-fmt. nixfmt enforces stupidly short lines.