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 nonPortableBuildID="${ID}.${VERSION_ID}-${buildArch}"
62 elif [ -e "${rootfsDir}/etc/redhat-release" ]; then
63 local redhatRelease=$(<${rootfsDir}/etc/redhat-release)
65 if [[ "${redhatRelease}" == "CentOS release 6."* || "$redhatRelease" == "Red Hat Enterprise Linux Server release 6."* ]]; then
66 nonPortableBuildID="rhel.6-${buildArch}"
68 elif [ -e "${rootfsDir}/android_platform" ]; then
69 source $rootfsDir/android_platform
70 nonPortableBuildID="$RID"
74 if [ "$buildOs" = "FreeBSD" ]; then
75 __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
76 nonPortableBuildID="freebsd.$__freebsd_version-${buildArch}"
79 if [ "${nonPortableBuildID}" != "" ]; then
80 export __DistroRid=${nonPortableBuildID}
82 # We are using a non-portable build rid. Force __PortableBuild to false.
83 export __PortableBuild=0
94 # rootfsDir?: (nullable:string)
101 # The following out parameters are returned
106 initDistroRidGlobal()
108 # __DistroRid must be set at the end of the function.
109 # Previously we would create a variable __HostDistroRid and/or __DistroRid.
111 # __HostDistroRid was used in the case of a non-portable build, it has been
112 # deprecated. Now only __DistroRid is supported. It will be used for both
113 # portable and non-portable rids and will be used in build-packages.sh
120 # Setup whether this is a crossbuild. We can find this out if rootfsDir
124 if [ -z "${rootfsDir}" ]; then
127 # We may have a cross build. Check for the existance of the rootfsDir
128 if [ -e ${rootfsDir} ]; then
131 echo "Error rootfsDir has been passed, but the location is not valid."
136 if [ "$buildArch" = "armel" ]; then
137 # Armel cross build is Tizen specific and does not support Portable RID build
138 export __PortableBuild=0
142 initNonPortableDistroRid ${buildOs} ${buildArch} ${isPortable} ${rootfsDir}
144 if [ -z "${__DistroRid}" ]; then
145 # The non-portable build rid was not set. Set the portable rid.
147 export __PortableBuild=1
150 # Check for alpine. It is the only portable build that will will have
151 # its name in the portable build rid.
152 if [ -e "${rootfsDir}/etc/os-release" ]; then
153 source "${rootfsDir}/etc/os-release"
154 if [ "${ID}" = "alpine" ]; then
155 distroRid="linux-musl-${buildArch}"
159 if [ "${distroRid}" == "" ]; then
160 if [ "$buildOs" = "Linux" ]; then
161 distroRid="linux-$buildArch"
162 elif [ "$buildOs" = "OSX" ]; then
163 distroRid="osx-$buildArch"
164 elif [ "$buildOs" = "FreeBSD" ]; then
165 distroRid="freebsd-$buildArch"
169 export __DistroRid=${distroRid}
172 if [ -z "$__DistroRid" ]; then
173 echo "DistroRid is not set. This is almost certainly an error"
177 echo "__DistroRid: ${__DistroRid}"
178 echo "__RuntimeId: ${__DistroRid}"
180 export __RuntimeId=${__DistroRid}