Commit ca181cef authored by David McFarland's avatar David McFarland
Browse files

nuget-to-nix: skip local sources

parent 482e352b
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -23,9 +23,16 @@ export DOTNET_CLI_TELEMETRY_OPTOUT=1

mapfile -t sources < <(dotnet nuget list source --format short | awk '/^E / { print $2 }')

declare -a remote_sources
declare -A base_addresses

for index in "${sources[@]}"; do
    if [[ -d "$index" ]]; then
        continue
    fi

    remote_sources+=($index)

    base_addresses[$index]=$(
    curl --compressed --netrc -fsL "$index" | \
      jq -r '.resources[] | select(."@type" == "PackageBaseAddress/3.0.0")."@id"')
@@ -35,6 +42,7 @@ echo "{ fetchNuGet }: ["

cd "$pkgs"
for package in *; do
  [[ -d "$package" ]] || continue
  cd "$package"
  for version in *; do
    id=$(xq -r .package.metadata.id "$version"/*.nuspec)
@@ -44,7 +52,12 @@ for package in *; do
    fi

    used_source="$(jq -r '.source' "$version"/.nupkg.metadata)"
    for source in "${sources[@]}"; do

    if [[ -d "$used_source" ]]; then
        continue
    fi

    for source in "${remote_sources[@]}"; do
      url="${base_addresses[$source]}$package/$version/$package.$version.nupkg"
      if [[ "$source" == "$used_source" ]]; then
        sha256="$(nix-hash --type sha256 --flat --base32 "$version/$package.$version".nupkg)"