nixpkgs/pkgs/applications/blockchains/nbxplorer/util/create-deps.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.3 KiB
Bash
Raw Normal View History

2020-08-10 19:49:20 +02:00
#!/usr/bin/env nix-shell
2022-05-26 23:13:55 +02:00
#!nix-shell -i bash -p dotnet-sdk_6
2020-08-10 19:49:20 +02:00
set -euo pipefail
# Writes deps for dotnet package in $pkgSrc to $depsFile.
# Expects $pkgSrc to contain a single .sln file.
pkgSrc=$1
depsFile=$(realpath "$2")
2021-07-13 11:19:21 +02:00
customFlags=$3
2020-08-10 19:49:20 +02:00
sln=$(cd "$pkgSrc"; find * -maxdepth 0 -name '*.sln' | head -1)
[[ $sln ]] || { echo "No .sln file in $pkgSrc" ; exit 1; }
tmpdir=$(mktemp -d /tmp/$pkgName-src.XXX)
echo "Using tmp dir: $tmpdir"
cp -rT "$pkgSrc" "$tmpdir"
chmod -R +w "$tmpdir"
pushd "$tmpdir" > /dev/null
mkdir home
echo "Running dotnet restore for $sln"
HOME=home DOTNET_CLI_TELEMETRY_OPTOUT=1 \
2021-07-13 11:19:21 +02:00
dotnet restore $customFlags -v normal --no-cache "$sln" > restore_log
2020-08-10 19:49:20 +02:00
echo "{ fetchNuGet }: [" > "$depsFile"
while read pkgSpec; do
{ read pname; read version; } < <(
2020-08-10 19:49:20 +02:00
# Ignore build version part: 1.0.0-beta2+77df2220 -> 1.0.0-beta2
sed -nE 's/.*<id>([^<]*).*/\1/p; s/.*<version>([^<+]*).*/\1/p' "$pkgSpec"
)
sha256=$(nix-hash --type sha256 --flat --base32 "$(dirname "$pkgSpec")"/*.nupkg)
cat >> "$depsFile" <<EOF
(fetchNuGet {
pname = "$pname";
2020-08-10 19:49:20 +02:00
version = "$version";
sha256 = "$sha256";
})
EOF
done < <(find home/.nuget/packages -name '*.nuspec' | LC_ALL=C sort)
echo "]" >> "$depsFile"
echo "Created $depsFile"
popd > /dev/null
rm -r $tmpdir