at master 2.6 kB view raw
1# shellcheck shell=bash disable=SC2154 2 3unpackNupkg() { 4 local -r nupkg="$1" unpacked="$2" 5 local nuspec nuspec_l 6 7 mkdir -p "$unpacked" 8 @unzip@/bin/unzip -nqd "$unpacked" "$nupkg" 9 cd "$unpacked" 10 chmod -R +rw . 11 nuspec=(*.nuspec) 12 nuspec_l="${nuspec,,}" 13 if [[ $nuspec != "$nuspec_l" ]]; then 14 mv "$nuspec" "$nuspec".tmp 15 mv "$nuspec".tmp "$nuspec_l" 16 fi 17 echo {} > .nupkg.metadata 18 cd - >/dev/null 19} 20 21_unpackNugetPackagesInOutput() { 22 local -r unpacked="$prefix"/share/nuget/packages/.unpacked 23 local nuspec nuspec_l 24 ( 25 shopt -s nullglob globstar 26 for nupkg in "$prefix"/share/nuget/source/**/*.nupkg; do 27 unpackNupkg "$nupkg" "$unpacked" 28 @xmlstarlet@/bin/xmlstarlet \ 29 sel -t \ 30 -m /_:package/_:metadata \ 31 -v _:id -nl \ 32 -v _:version -nl \ 33 "$unpacked"/*.nuspec | ( 34 read id 35 read version 36 id=''${id,,} 37 version=''${version,,} 38 mkdir -p "$prefix"/share/nuget/packages/"$id" 39 mv "$unpacked" "$prefix"/share/nuget/packages/"$id"/"$version" 40 ) 41 done 42 rm -rf "$prefix"/share/nuget/source 43 ) 44} 45 46unpackNugetPackages() { 47 local output 48 for output in $(getAllOutputNames); do 49 prefix="${!output}" _unpackNugetPackagesInOutput 50 done 51} 52 53if [[ -z ${dontUnpackNugetPackages-} ]]; then 54 preFixupHooks+=(unpackNugetPackages) 55fi 56 57_createNugetSourceInOutput() { 58 local package version id dir nupkg content 59 local -a nuspec 60 ( 61 shopt -s nullglob 62 63 for package in "$prefix"/share/nuget/packages/*/*; do 64 version=$(basename "$package") 65 id=$(basename "$(dirname "$package")") 66 dir="$prefix/share/nuget/source/$id/$version" 67 nupkg=$dir/$id.$version.nupkg 68 nuspec=("$package"/*.nuspec) 69 70 if [[ -n ${createInstallableNugetSource-} ]]; then 71 content=. 72 else 73 content=$(basename "${nuspec[0]}") 74 fi 75 76 mkdir -p "$dir" 77 cp "${nuspec[0]}" "$dir/$id.nuspec" 78 (cd "$package" && @zip@/bin/zip -rq0 "$nupkg" "$content") 79 @stripNondeterminism@/bin/strip-nondeterminism --type zip "$nupkg" 80 touch "$nupkg".sha512 81 done 82 ) 83} 84 85createNugetSource() { 86 local output 87 for output in $(getAllOutputNames); do 88 prefix="${!output}" _createNugetSourceInOutput 89 done 90} 91 92if [[ -z ${dontCreateNugetSource-} ]]; then 93 postFixupHooks+=(createNugetSource) 94fi