@@ -132,71 +132,76 @@ initDistroRidGlobal()
132132 local targetOs=" $1 "
133133 local buildArch=" $2 "
134134 local isPortable=" $3 "
135+ local packageRid=" $4 "
135136 local rootfsDir=" "
136- if [ " $# " -ge 4 ]; then
137- rootfsDir=" $4 "
137+ if [ " $# " -ge 5 ]; then
138+ rootfsDir=" $5 "
138139 fi
139140
140- if [ -n " ${rootfsDir} " ]; then
141- # We may have a cross build. Check for the existence of the rootfsDir
142- if [ ! -e " ${rootfsDir} " ]; then
143- echo " Error rootfsDir has been passed, but the location is not valid."
144- exit 1
141+ if [ -n " $packageRid " ]; then
142+ export __DistroRid=$packageRid
143+ else
144+ if [ -n " ${rootfsDir} " ]; then
145+ # We may have a cross build. Check for the existence of the rootfsDir
146+ if [ ! -e " ${rootfsDir} " ]; then
147+ echo " Error rootfsDir has been passed, but the location is not valid."
148+ exit 1
149+ fi
145150 fi
146- fi
147151
148- initNonPortableDistroRid " ${targetOs} " " ${buildArch} " " ${isPortable} " " ${rootfsDir} "
152+ initNonPortableDistroRid " ${targetOs} " " ${buildArch} " " ${isPortable} " " ${rootfsDir} "
149153
150- if [ " $buildArch " = " wasm" ]; then
151- __DistroRid=browser-wasm
152- export __DistroRid
153- fi
154+ if [ " $buildArch " = " wasm" ]; then
155+ __DistroRid=browser-wasm
156+ export __DistroRid
157+ fi
154158
155- if [ -z " ${__DistroRid} " ]; then
156- # The non-portable build rid was not set. Set the portable rid.
159+ if [ -z " ${__DistroRid} " ]; then
160+ # The non-portable build rid was not set. Set the portable rid.
157161
158- __PortableBuild=1
159- export __PortableBuild
160- local distroRid=" "
162+ __PortableBuild=1
163+ export __PortableBuild
164+ local distroRid=" "
161165
162- # Check for musl-based distros (e.g Alpine Linux, Void Linux).
163- if " ${rootfsDir} /usr/bin/ldd" --version 2>&1 | grep -q musl ||
164- strings " ${rootfsDir} /usr/bin/ldd" 2>&1 | grep -q musl; then
165- distroRid=" linux-musl-${buildArch} "
166- fi
166+ # Check for musl-based distros (e.g Alpine Linux, Void Linux).
167+ if " ${rootfsDir} /usr/bin/ldd" --version 2>&1 | grep -q musl ||
168+ strings " ${rootfsDir} /usr/bin/ldd" 2>&1 | grep -q musl; then
169+ distroRid=" linux-musl-${buildArch} "
170+ fi
167171
168- if [ -z " ${distroRid} " ]; then
169- if [ " $targetOs " = " Linux" ]; then
170- distroRid=" linux-$buildArch "
171- elif [ " $targetOs " = " linux-bionic" ]; then
172- distroRid=" linux-bionic-$buildArch "
173- elif [ " $targetOs " = " OSX" ]; then
174- distroRid=" osx-$buildArch "
175- elif [ " $targetOs " = " MacCatalyst" ]; then
176- distroRid=" maccatalyst-$buildArch "
177- elif [ " $targetOs " = " tvOS" ]; then
178- distroRid=" tvos-$buildArch "
179- elif [ " $targetOs " = " tvOSSimulator" ]; then
180- distroRid=" tvossimulator-$buildArch "
181- elif [ " $targetOs " = " iOS" ]; then
182- distroRid=" ios-$buildArch "
183- elif [ " $targetOs " = " iOSSimulator" ]; then
184- distroRid=" iossimulator-$buildArch "
185- elif [ " $targetOs " = " Android" ]; then
186- distroRid=" android-$buildArch "
187- elif [ " $targetOs " = " Browser" ]; then
188- distroRid=" browser-$buildArch "
189- elif [ " $targetOs " = " FreeBSD" ]; then
190- distroRid=" freebsd-$buildArch "
191- elif [ " $targetOs " = " illumos" ]; then
192- distroRid=" illumos-$buildArch "
193- elif [ " $targetOs " = " Solaris" ]; then
194- distroRid=" solaris-$buildArch "
172+ if [ -z " ${distroRid} " ]; then
173+ if [ " $targetOs " = " Linux" ]; then
174+ distroRid=" linux-$buildArch "
175+ elif [ " $targetOs " = " linux-bionic" ]; then
176+ distroRid=" linux-bionic-$buildArch "
177+ elif [ " $targetOs " = " OSX" ]; then
178+ distroRid=" osx-$buildArch "
179+ elif [ " $targetOs " = " MacCatalyst" ]; then
180+ distroRid=" maccatalyst-$buildArch "
181+ elif [ " $targetOs " = " tvOS" ]; then
182+ distroRid=" tvos-$buildArch "
183+ elif [ " $targetOs " = " tvOSSimulator" ]; then
184+ distroRid=" tvossimulator-$buildArch "
185+ elif [ " $targetOs " = " iOS" ]; then
186+ distroRid=" ios-$buildArch "
187+ elif [ " $targetOs " = " iOSSimulator" ]; then
188+ distroRid=" iossimulator-$buildArch "
189+ elif [ " $targetOs " = " Android" ]; then
190+ distroRid=" android-$buildArch "
191+ elif [ " $targetOs " = " Browser" ]; then
192+ distroRid=" browser-$buildArch "
193+ elif [ " $targetOs " = " FreeBSD" ]; then
194+ distroRid=" freebsd-$buildArch "
195+ elif [ " $targetOs " = " illumos" ]; then
196+ distroRid=" illumos-$buildArch "
197+ elif [ " $targetOs " = " Solaris" ]; then
198+ distroRid=" solaris-$buildArch "
199+ fi
195200 fi
196- fi
197201
198- __DistroRid=" ${distroRid} "
199- export __DistroRid
202+ __DistroRid=" ${distroRid} "
203+ export __DistroRid
204+ fi
200205 fi
201206
202207 if [ -z " $__DistroRid " ]; then
0 commit comments