2020-12-30 15:21:44 +01:00
|
|
|
#!/usr/bin/env nix-shell
|
2022-04-13 16:38:09 +02:00
|
|
|
#!nix-shell -I nixpkgs=../../../.. -i bash -p dotnet-sdk_6 jq xmlstarlet curl
|
2020-12-30 15:21:44 +01:00
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
cat << EOL
|
|
|
|
{ fetchurl }: [
|
|
|
|
EOL
|
|
|
|
|
2022-04-13 16:38:09 +02:00
|
|
|
# enter a temporary directory containing the source code, copied from the derivation
|
|
|
|
srcdir="$(mktemp -d)"
|
|
|
|
cp -r "$(nix-build -A omnisharp-roslyn.src ../../../..)"/. "$srcdir"
|
|
|
|
rm -f "$srcdir"/global.json
|
|
|
|
|
|
|
|
pushd $srcdir >&2
|
|
|
|
|
2020-12-30 15:21:44 +01:00
|
|
|
tmpdir="$(mktemp -d -p "$(pwd)")" # must be under source root
|
|
|
|
|
|
|
|
mapfile -t repos < <(
|
|
|
|
xmlstarlet sel -t -v 'configuration/packageSources/add/@value' -n NuGet.Config |
|
|
|
|
while IFS= read index
|
|
|
|
do
|
|
|
|
curl --compressed -fsL "$index" | \
|
|
|
|
jq -r '.resources[] | select(."@type" == "PackageBaseAddress/3.0.0")."@id"'
|
|
|
|
done
|
|
|
|
)
|
|
|
|
|
2022-02-08 18:14:31 +01:00
|
|
|
dotnet msbuild -t:restore -p:Configuration=Release -p:RestorePackagesPath="$tmpdir" \
|
2020-12-30 15:21:44 +01:00
|
|
|
-p:RestoreNoCache=true -p:RestoreForce=true \
|
2022-04-13 16:38:09 +02:00
|
|
|
"$srcdir/src/OmniSharp.Stdio.Driver/OmniSharp.Stdio.Driver.csproj" >&2
|
2020-12-30 15:21:44 +01:00
|
|
|
|
|
|
|
cd "$tmpdir"
|
|
|
|
for package in *
|
|
|
|
do
|
|
|
|
cd "$package"
|
|
|
|
for version in *
|
|
|
|
do
|
|
|
|
found=false
|
|
|
|
for repo in "${repos[@]}"
|
|
|
|
do
|
|
|
|
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)
|
|
|
|
cat << EOL
|
|
|
|
{
|
2022-01-23 13:39:52 +01:00
|
|
|
pname = "$package";
|
2020-12-30 15:21:44 +01:00
|
|
|
version = "$version";
|
|
|
|
src = fetchurl {
|
|
|
|
url = "$url";
|
|
|
|
sha256 = "$sha256";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
EOL
|
|
|
|
done
|
|
|
|
cd ..
|
|
|
|
done
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
cat << EOL
|
|
|
|
]
|
|
|
|
EOL
|
2022-04-13 16:38:09 +02:00
|
|
|
|
|
|
|
popd >&2
|