Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / compilers / roslyn / create-deps.sh
blob5bdc37956b52353dd550189c88f4b402007d2780
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p dotnet-sdk_5 -p jq -p xmlstarlet -p curl
3 set -euo pipefail
5 cat << EOL
6 { fetchurl }: [
7 EOL
9 tmpdir="$(mktemp -d -p "$(pwd)")" # must be under source root
10 trap 'rm -rf "$tmpdir"' EXIT
12 HOME="$tmpdir" dotnet msbuild -t:restore -p:Configuration=Release -p:RestorePackagesPath="$tmpdir"/.nuget/packages \
13 -p:RestoreNoCache=true -p:RestoreForce=true \
14 src/NuGet/Microsoft.Net.Compilers.Toolset/Microsoft.Net.Compilers.Toolset.Package.csproj >&2
16 mapfile -t repos < <(
17 xmlstarlet sel -t -v 'configuration/packageSources/add/@value' -n NuGet.config "$tmpdir"/.nuget/NuGet/NuGet.Config |
18 while IFS= read index
20 curl --compressed -fsL "$index" | \
21 jq -r '.resources[] | select(."@type" == "PackageBaseAddress/3.0.0")."@id"'
22 done
25 cd "$tmpdir/.nuget/packages"
26 for package in *
28 cd "$package"
29 for version in *
31 found=false
32 for repo in "${repos[@]}"
34 url="$repo$package/$version/$package.$version.nupkg"
35 if curl -fsL "$url" -o /dev/null
36 then
37 found=true
38 break
40 done
42 if ! $found
43 then
44 echo "couldn't find $package $version" >&2
45 exit 1
48 sha256=$(nix-prefetch-url "$url" 2>/dev/null)
49 cat << EOL
51 name = "$package";
52 version = "$version";
53 src = fetchurl {
54 url = "$url";
55 sha256 = "$sha256";
58 EOL
59 done
60 cd ..
61 done
63 cat << EOL
65 EOL