11#! /bin/sh
22
3- # getNonPortableDistroRid
4- #
5- # Input:
6- # targetOs: (str)
7- # targetArch: (str)
8- # rootfsDir: (str)
9- #
10- # Return:
11- # non-portable rid
12- getNonPortableDistroRid ()
13- {
14- targetOs=" $1 "
15- targetArch=" $2 "
16- rootfsDir=" $3 "
17- nonPortableRid=" "
18-
19- if [ " $targetOs " = " linux" ]; then
20- # shellcheck disable=SC1091
21- if [ -e " ${rootfsDir} /etc/os-release" ]; then
22- . " ${rootfsDir} /etc/os-release"
23- if [ " ${ID} " = " rhel" ] || [ " ${ID} " = " rocky" ] || [ " ${ID} " = " alpine" ] || [ " ${ID} " = " ol" ]; then
24- VERSION_ID=" ${VERSION_ID% .* } " # Remove the last version digit for these distros
25- fi
26-
27- if echo " ${VERSION_ID:- } " | grep -qE ' ^([[:digit:]]|\.)+$' ; then
28- nonPortableRid=" ${ID} .${VERSION_ID} -${targetArch} "
29- else
30- # Rolling release distros either do not set VERSION_ID, set it as blank or
31- # set it to non-version looking string (such as TEMPLATE_VERSION_ID on ArchLinux);
32- # so omit it here to be consistent with everything else.
33- nonPortableRid=" ${ID} -${targetArch} "
34- fi
35- elif [ -e " ${rootfsDir} /android_platform" ]; then
36- # shellcheck disable=SC1091
37- . " ${rootfsDir} /android_platform"
38- nonPortableRid=" $RID "
39- fi
40- fi
41-
42- if [ " $targetOs " = " freebsd" ]; then
43- # $rootfsDir can be empty. freebsd-version is a shell script and should always work.
44- __freebsd_major_version=$( " $rootfsDir " /bin/freebsd-version | cut -d' .' -f1)
45- nonPortableRid=" freebsd.$__freebsd_major_version -${targetArch} "
46- elif command -v getprop > /dev/null && getprop ro.product.system.model | grep -qi android; then
47- __android_sdk_version=$( getprop ro.build.version.sdk)
48- nonPortableRid=" android.$__android_sdk_version -${targetArch} "
49- elif [ " $targetOs " = " illumos" ]; then
50- __uname_version=$( uname -v)
51- case " $__uname_version " in
52- omnios-* )
53- __omnios_major_version=$( echo " $__uname_version " | cut -c9-10)
54- nonPortableRid=" omnios.$__omnios_major_version -${targetArch} "
55- ;;
56- joyent_* )
57- __smartos_major_version=$( echo " $__uname_version " | cut -c9-10)
58- nonPortableRid=" smartos.$__smartos_major_version -${targetArch} "
59- ;;
60- * )
61- nonPortableRid=" illumos-${targetArch} "
62- ;;
63- esac
64- elif [ " $targetOs " = " solaris" ]; then
65- __uname_version=$( uname -v)
66- __solaris_major_version=$( echo " $__uname_version " | cut -d' .' -f1)
67- nonPortableRid=" solaris.$__solaris_major_version -${targetArch} "
68- elif [ " $targetOs " = " haiku" ]; then
69- __uname_release=" $( uname -r) "
70- nonPortableRid=haiku.r" $__uname_release " -" $targetArch "
71- fi
72-
73- echo " $nonPortableRid " | tr ' [:upper:]' ' [:lower:]'
74- }
75-
763# initDistroRidGlobal
774#
785# Input:
@@ -86,7 +13,6 @@ getNonPortableDistroRid()
8613# Notes:
8714# It is important to note that the function does not return anything, but it
8815# exports the following variables on success:
89- # __DistroRid : Non-portable rid of the target platform.
9016# __PortableTargetOS : OS-part of the portable rid that corresponds to the target platform.
9117initDistroRidGlobal ()
9218{
@@ -105,8 +31,6 @@ initDistroRidGlobal()
10531 fi
10632 fi
10733
108- __DistroRid=$( getNonPortableDistroRid " ${targetOs} " " ${targetArch} " " ${rootfsDir} " )
109-
11034 if [ -z " ${__PortableTargetOS:- } " ]; then
11135 __PortableTargetOS=" $targetOs "
11236
@@ -122,5 +46,5 @@ initDistroRidGlobal()
12246 fi
12347 fi
12448
125- export __DistroRid __PortableTargetOS
49+ export __PortableTargetOS
12650}
0 commit comments