3 # initNonPortableDistroRid
16 # initNonPortableDistroRid will attempt to initialize a non portable rid. These
17 # rids are specific to distros need to build the product/package and consume
18 # them on the same platform.
20 # If -portablebuild=false is passed a non-portable rid will be created for any
23 # Below is the list of current non-portable platforms.
25 # Builds from the following *must* be non-portable:
27 # | OS | Expected RID |
28 # -------------------------------------------------
29 # | rhel6 | rhel.6-x64 |
30 # | alpine* | linux-musl-(arch) |
31 # | freeBSD | freebsd.(version)-x64 |
33 # It is important to note that the function does not return anything, but it
34 # will set __DistroRid if there is a non-portable distro rid to be used.
36 initNonPortableDistroRid()
38 # Make sure out parameter is cleared.
46 if [ "$buildOs" = "Linux" ]; then
47 # RHEL 6 is the only distro we will check redHat release for.
48 if [ -e "${rootfsDir}/etc/os-release" ]; then
49 source "${rootfsDir}/etc/os-release"
51 # We have forced __PortableBuild=0. This is because -portablebuld
52 # has been passed as false.
53 if (( ${isPortable} == 0 )); then
54 if [ "${ID}" == "rhel" ]; then
55 # remove the last version digit
56 VERSION_ID=${VERSION_ID%.*}
59 if [ -z ${VERSION_ID+x} ]; then
60 # Rolling release distros do not set VERSION_ID, so omit
61 # it here to be consistent with everything else.
62 nonPortableBuildID="${ID}-${buildArch}"
64 nonPortableBuildID="${ID}.${VERSION_ID}-${buildArch}"
68 elif [ -e "${rootfsDir}/etc/redhat-release" ]; then
69 local redhatRelease=$(<${rootfsDir}/etc/redhat-release)
71 if [[ "${redhatRelease}" == "CentOS release 6."* || "$redhatRelease" == "Red Hat Enterprise Linux Server release 6."* ]]; then
72 nonPortableBuildID="rhel.6-${buildArch}"
74 elif [ -e "${rootfsDir}/android_platform" ]; then
75 source $rootfsDir/android_platform
76 nonPortableBuildID="$RID"
80 if [ "$buildOs" = "FreeBSD" ]; then
81 __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
82 nonPortableBuildID="freebsd.$__freebsd_version-${buildArch}"
85 if [ "${nonPortableBuildID}" != "" ]; then
86 export __DistroRid=${nonPortableBuildID}
88 # We are using a non-portable build rid. Force __PortableBuild to false.
89 export __PortableBuild=0
100 # rootfsDir?: (nullable:string)
107 # The following out parameters are returned
112 initDistroRidGlobal()
114 # __DistroRid must be set at the end of the function.
115 # Previously we would create a variable __HostDistroRid and/or __DistroRid.
117 # __HostDistroRid was used in the case of a non-portable build, it has been
118 # deprecated. Now only __DistroRid is supported. It will be used for both
119 # portable and non-portable rids and will be used in build-packages.sh
126 # Setup whether this is a crossbuild. We can find this out if rootfsDir
130 if [ -z "${rootfsDir}" ]; then
133 # We may have a cross build. Check for the existance of the rootfsDir
134 if [ -e ${rootfsDir} ]; then
137 echo "Error rootfsDir has been passed, but the location is not valid."
142 if [ "$buildArch" = "armel" ]; then
143 # Armel cross build is Tizen specific and does not support Portable RID build
144 export __PortableBuild=0
148 initNonPortableDistroRid ${buildOs} ${buildArch} ${isPortable} ${rootfsDir}
150 if [ -z "${__DistroRid}" ]; then
151 # The non-portable build rid was not set. Set the portable rid.
153 export __PortableBuild=1
156 # Check for alpine. It is the only portable build that will will have
157 # its name in the portable build rid.
158 if [ -e "${rootfsDir}/etc/os-release" ]; then
159 source "${rootfsDir}/etc/os-release"
160 if [ "${ID}" = "alpine" ]; then
161 distroRid="linux-musl-${buildArch}"
165 if [ "${distroRid}" == "" ]; then
166 if [ "$buildOs" = "Linux" ]; then
167 distroRid="linux-$buildArch"
168 elif [ "$buildOs" = "OSX" ]; then
169 distroRid="osx-$buildArch"
170 elif [ "$buildOs" = "FreeBSD" ]; then
171 distroRid="freebsd-$buildArch"
175 export __DistroRid=${distroRid}
178 if [ -z "$__DistroRid" ]; then
179 echo "DistroRid is not set. This is almost certainly an error"
183 echo "__DistroRid: ${__DistroRid}"
184 echo "__RuntimeId: ${__DistroRid}"
186 export __RuntimeId=${__DistroRid}