exit 1
}
-initHostDistroRid()
+initDistroRid()
{
- __HostDistroRid=""
- if [ "$__HostOS" == "Linux" ]; then
- if [ -e /etc/os-release ]; then
- source /etc/os-release
- if [[ $ID == "rhel" ]]; then
- # remove the last version digit
- VERSION_ID=${VERSION_ID%.*}
- fi
- __HostDistroRid="$ID.$VERSION_ID-$__Arch"
- if [[ $ID == "alpine" ]]; then
- __HostDistroRid="linux-musl-$__Arch"
- fi
- elif [ -e /etc/redhat-release ]; then
- local redhatRelease=$(</etc/redhat-release)
- if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
- __HostDistroRid="rhel.6-$__Arch"
- fi
- if [[ $redhatRelease == "CentOS Linux release 7."* ]]; then
- __HostDistroRid="rhel.7-$__Arch"
- fi
- fi
- fi
- if [ "$__HostOS" == "FreeBSD" ]; then
- __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
- __HostDistroRid="freebsd.$__freebsd_version-$__Arch"
- fi
+ source init-distro-rid.sh
+
+ local passedRootfsDir=""
- if [ "$__HostDistroRid" == "" ]; then
- echo "WARNING: Cannot determine runtime id for current distro."
+ # Only pass ROOTFS_DIR if __DoCrossArchBuild is specified.
+ if [ -z "${__CrossBuild}" ]; then
+ passedRootfsDir=${ROOTFS_DIR}
fi
+
+ initDistroRidGlobal ${__BuildOS} ${__BuildArch} ${__IsPortableBuild} ${passedRootfsDir}
}
__ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
exit 1
;;
-BuildArch=*)
- __Arch=$(echo $1| cut -d'=' -f 2)
- buildArgs="$buildArgs /p:__BuildArch=$__Arch"
+ __BuildArch=$(echo $1| cut -d'=' -f 2)
+ buildArgs="$buildArgs /p:__BuildArch=$__BuildArch"
;;
-BuildType=*)
__Type=$(echo $1| cut -d'=' -f 2)
shift
done
-# Portable builds target the base RID
-if [ $__IsPortableBuild == 1 ]; then
- if [ "$__BuildOS" == "Linux" ]; then
- export __DistroRid="linux-$__Arch"
- elif [ "$__BuildOS" == "OSX" ]; then
- export __DistroRid="osx-$__Arch"
- elif [ "$__BuildOS" == "FreeBSD" ]; then
- export __DistroRid="freebsd-$__Arch"
- fi
-else
- # init the host distro name
- initHostDistroRid
- export __DistroRid="$__HostDistroRid"
-fi
+initDistroRid
$__ProjectRoot/dotnet.sh msbuild /nologo /verbosity:minimal /clp:Summary \
/p:__BuildOS=$__BuildOS /flp:v=detailed\;Append\;LogFile=build-packages.log \
#!/usr/bin/env bash
-initHostDistroRid()
-{
- __HostDistroRid=""
-
- # Some OS groups should default to use the portable packages
- if [ "$__BuildOS" == "OSX" ]; then
- __PortableBuild=1
- fi
-
- if [ "$__HostOS" == "Linux" ]; then
- if [ -e /etc/redhat-release ]; then
- __PortableBuild=1
- elif [ -e /etc/os-release ]; then
- source /etc/os-release
- if [[ $ID == "alpine" ]]; then
- __HostDistroRid="linux-musl-$__HostArch"
- else
- __PortableBuild=1
- __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
- fi
- fi
- elif [ "$__HostOS" == "FreeBSD" ]; then
- __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
- __HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
- fi
-
- # Portable builds target the base RID
- if [ "$__PortableBuild" == 1 ]; then
- if [ "$__BuildOS" == "OSX" ]; then
- export __HostDistroRid="osx-$__BuildArch"
- elif [ "$__BuildOS" == "Linux" ]; then
- export __HostDistroRid="linux-$__BuildArch"
- fi
- fi
-
- if [ "$__HostDistroRid" == "" ]; then
- echo "WARNING: Cannot determine runtime id for current distro."
- fi
-
- echo "Setting __HostDistroRid to $__HostDistroRid"
-}
+__PortableBuild=1
initTargetDistroRid()
{
- if [ $__CrossBuild == 1 ]; then
- if [ "$__BuildOS" == "Linux" ]; then
- if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
- if [ -e $ROOTFS_DIR/android_platform ]; then
- source $ROOTFS_DIR/android_platform
- export __DistroRid="$RID"
- else
- echo "WARNING: Cannot determine runtime id for current distro."
- export __DistroRid=""
- fi
- else
- source $ROOTFS_DIR/etc/os-release
- export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
- fi
- fi
- else
- export __DistroRid="$__HostDistroRid"
- export __RuntimeId="$__HostDistroRid"
- fi
-
- if [ "$ID.$VERSION_ID" == "ubuntu.16.04" ]; then
- export __DistroRid="ubuntu.14.04-$__BuildArch"
- fi
+ source init-distro-rid.sh
- # Portable builds target the base RID
- if [ "$__PortableBuild" == 1 ]; then
- if [ "$__BuildOS" == "Linux" ]; then
- export __DistroRid="linux-$__BuildArch"
- export __RuntimeId="linux-$__BuildArch"
- elif [ "$__BuildOS" == "OSX" ]; then
- export __DistroRid="osx-$__BuildArch"
- export __RuntimeId="osx-$__BuildArch"
- fi
+ # Only pass ROOTFS_DIR if cross is specified.
+ if (( ${__CrossBuild} == 1 )); then
+ passedRootfsDir=${ROOTFS_DIR}
fi
- echo "__DistroRid: " $__DistroRid
+ initDistroRidGlobal ${__BuildOS} ${__BuildArch} ${__PortableBuild} ${passedRootfsDir}
}
isMSBuildOnNETCoreSupported()
UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
do
- if [ "$__HostDistroRid" == "$UNSUPPORTED_RID" ]; then
+ if [ "${__DistroRid}" == "$UNSUPPORTED_RID" ]; then
__isMSBuildOnNETCoreSupported=0
break
fi
__ClangMajorVersion=0
__ClangMinorVersion=0
__NuGetPath="$__PackagesDir/NuGet.exe"
-__HostDistroRid=""
__SkipRestorePackages=0
__DistroRid=""
__cmakeargs=""
__CrossBuild=1
;;
- portableBuild)
- __PortableBuild=1
+ portablebuild=false)
+ __PortableBuild=0
;;
portablelinux)
__LogsDir="$__RootBinDir/Logs"
__MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs"
-# init the host distro name
-initHostDistroRid
-
# Set the remaining variables based upon the determined build configuration
__BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
__PackagesBinDir="$__BinDir/.nuget"
echo "-bindir - output directory (defaults to $__ProjectRoot/bin)"
echo "-msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
echo "-numproc - set the number of build processes."
+ echo "-portablebuild - pass -portablebuild=false to force a non-portable build."
exit 1
}
-initHostDistroRid()
-{
- __HostDistroRid=""
- if [ "$__HostOS" == "Linux" ]; then
- if [ -e /etc/os-release ]; then
- source /etc/os-release
- if [[ $ID == "rhel" ]]; then
- # remove the last version digit
- VERSION_ID=${VERSION_ID%.*}
- fi
- __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
- if [[ $ID == "alpine" ]]; then
- __HostDistroRid="linux-musl-$__HostArch"
- fi
- elif [ -e /etc/redhat-release ]; then
- local redhatRelease=$(</etc/redhat-release)
- if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
- __HostDistroRid="rhel.6-$__HostArch"
- fi
- if [[ $redhatRelease == "CentOS Linux release 7."* ]]; then
- __HostDistroRid="rhel.7-$__Arch"
- fi
- fi
- fi
- if [ "$__HostOS" == "FreeBSD" ]; then
- __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
- __HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
- fi
-
- if [ "$__HostDistroRid" == "" ]; then
- echo "WARNING: Can not determine runtime id for current distro."
- fi
-}
-
initTargetDistroRid()
{
- if [ $__CrossBuild == 1 ]; then
- if [ "$__BuildOS" == "Linux" ]; then
- if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
- if [ -e $ROOTFS_DIR/android_platform ]; then
- source $ROOTFS_DIR/android_platform
- export __DistroRid="$RID"
- else
- echo "WARNING: Can not determine runtime id for current distro."
- export __DistroRid=""
- fi
- else
- source $ROOTFS_DIR/etc/os-release
- export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
- fi
- fi
- else
- export __DistroRid="$__HostDistroRid"
- fi
+ source init-distro-rid.sh
- if [ "$__BuildOS" == "OSX" ]; then
- __PortableBuild=1
- fi
+ local passedRootfsDir=""
- # Portable builds target the base RID
- if [ $__PortableBuild == 1 ]; then
- if [ "$__BuildOS" == "Linux" ]; then
- export __DistroRid="linux-$__BuildArch"
- elif [ "$__BuildOS" == "OSX" ]; then
- export __DistroRid="osx-$__BuildArch"
- elif [ "$__BuildOS" == "FreeBSD" ]; then
- export __DistroRid="freebsd-$__BuildArch"
- fi
+ # Only pass ROOTFS_DIR if cross is specified.
+ if (( ${__CrossBuild} == 1 )); then
+ passedRootfsDir=${ROOTFS_DIR}
+ elif [ "${__BuildArch}" != "${__HostArch}" ]; then
+ echo "Error, you are building a cross scenario without passing -cross."
+ exit 1
fi
+
+ initDistroRidGlobal ${__BuildOS} ${__BuildArch} ${__PortableBuild} ${passedRootfsDir}
}
setup_dirs()
if [ "$__HostOS" == "Linux" ]; then
__isMSBuildOnNETCoreSupported=1
# note: the RIDs below can use globbing patterns
- UNSUPPORTED_RIDS=("debian.9-x64" "ubuntu.17.04-x64")
+ UNSUPPORTED_RIDS=("ubuntu.17.04-x64")
for UNSUPPORTED_RID in "${UNSUPPORTED_RIDS[@]}"
do
- if [[ $__HostDistroRid == $UNSUPPORTED_RID ]]; then
+ if [[ ${__DistroRid} == $UNSUPPORTED_RID ]]; then
__isMSBuildOnNETCoreSupported=0
break
fi
__GccMajorVersion=0
__GccMinorVersion=0
__NuGetPath="$__PackagesDir/NuGet.exe"
-__HostDistroRid=""
__DistroRid=""
__cmakeargs=""
__SkipGenerateVersion=0
__LogsDir="$__RootBinDir/Logs"
__MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs"
-# init the host distro name
-initHostDistroRid
-
# Set the remaining variables based upon the determined build configuration
__BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
__PackagesBinDir="$__BinDir/.nuget"
fi
__CrossGenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$__BuildArch.$__BuildType.log"
+# init the target distro name
+initTargetDistroRid
+
# Init if MSBuild for .NET Core is supported for this platform
isMSBuildOnNETCoreSupported
fi
fi
-# init the target distro name
-initTargetDistroRid
-
# Make the directories necessary for build if they don't exist
setup_dirs
--- /dev/null
+#!/usr/bin/env bash
+
+# initNonPortableDistroRid
+#
+# Input:
+# buildOs: (str)
+# buildArch: (str)
+# isPortable: (int)
+# rootfsDir: (str)
+#
+# Return:
+# None
+#
+# Notes:
+#
+# initNonPortableDistroRid will attempt to initialize a non portable rid. These
+# rids are specific to distros need to build the product/package and consume
+# them on the same platform.
+#
+# If -portablebuild=false is passed a non-portable rid will be created for any
+# distro.
+#
+# Below is the list of current non-portable platforms.
+#
+# Builds from the following *must* be non-portable:
+#
+# | OS | Expected RID |
+# -------------------------------------------------
+# | rhel6 | rhel.6-x64 |
+# | alpine* | linux-musl-(arch) |
+# | freeBSD | freebsd.(version)-x64 |
+#
+# It is important to note that the function does not return anything, but it
+# will set __DistroRid if there is a non-portable distro rid to be used.
+#
+initNonPortableDistroRid()
+{
+ # Make sure out parameter is cleared.
+ __DistroRid=
+
+ local buildOs=$1
+ local buildArch=$2
+ local isPortable=$3
+ local rootfsDir=$4
+
+ if [ "$buildOs" = "Linux" ]; then
+ # RHEL 6 is the only distro we will check redHat release for.
+ if [ -e "${rootfsDir}/etc/os-release" ]; then
+ source "${rootfsDir}/etc/os-release"
+
+ # We have forced __PortableBuild=0. This is because -portablebuld
+ # has been passed as false.
+ if (( ${isPortable} == 0 )); then
+ if [ "${ID}" == "rhel" ]; then
+ # remove the last version digit
+ VERSION_ID=${VERSION_ID%.*}
+ fi
+
+ nonPortableBuildID="${ID}.${VERSION_ID}-${buildArch}"
+ fi
+
+ elif [ -e "${rootfsDir}/etc/redhat-release" ]; then
+ local redhatRelease=$(<${rootfsDir}/etc/redhat-release)
+
+ if [[ "${redhatRelease}" == "CentOS release 6."* || "$redhatRelease" == "Red Hat Enterprise Linux Server release 6."* ]]; then
+ nonPortableBuildID="rhel.6-${buildArch}"
+ fi
+ elif [ -e "${rootfsDir}/android_platform" ]; then
+ source $rootfsDir/android_platform
+ nonPortableBuildID="$RID"
+ fi
+ fi
+
+ if [ "$buildOs" = "FreeBSD" ]; then
+ __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
+ nonPortableBuildID="freebsd.$__freebsd_version-${buildArch}"
+ fi
+
+ if [ "${nonPortableBuildID}" != "" ]; then
+ export __DistroRid=${nonPortableBuildID}
+
+ # We are using a non-portable build rid. Force __PortableBuild to false.
+ export __PortableBuild=0
+ fi
+}
+
+
+# initDistroRidGlobal
+#
+# Input:
+# os: (str)
+# arch: (str)
+# isPortable: (int)
+# rootfsDir?: (nullable:string)
+#
+# Return:
+# None
+#
+# Notes:
+#
+# The following out parameters are returned
+#
+# __DistroRid
+# __PortableBuild
+#
+initDistroRidGlobal()
+{
+ # __DistroRid must be set at the end of the function.
+ # Previously we would create a variable __HostDistroRid and/or __DistroRid.
+ #
+ # __HostDistroRid was used in the case of a non-portable build, it has been
+ # deprecated. Now only __DistroRid is supported. It will be used for both
+ # portable and non-portable rids and will be used in build-packages.sh
+
+ local buildOs=$1
+ local buildArch=$2
+ local isPortable=$3
+ local rootfsDir=$4
+
+ # Setup whether this is a crossbuild. We can find this out if rootfsDir
+ # is set.
+ local isCrossBuild=0
+
+ if [ -z "${rootfsDir}" ]; then
+ isCrossBuild=0
+ else
+ # We may have a cross build. Check for the existance of the rootfsDir
+ if [ -e ${rootfsDir} ]; then
+ isCrossBuild=1
+ else
+ echo "Error rootfsDir has been passed, but the location is not valid."
+ exit 1
+ fi
+ fi
+
+ initNonPortableDistroRid ${buildOs} ${buildArch} ${isPortable} ${rootfsDir}
+
+ if [ -z "${__DistroRid}" ]; then
+ # The non-portable build rid was not set. Set the portable rid.
+
+ export __PortableBuild=1
+ local distroRid=""
+
+ # Check for alpine. It is the only portable build that will will have
+ # its name in the portable build rid.
+ if [ -e "${rootfsDir}/etc/os-release" ]; then
+ source "${rootfsDir}/etc/os-release"
+ if [ "${ID}" = "alpine" ]; then
+ distroRid="linux-musl-${buildArch}"
+ fi
+ fi
+
+ if [ "${distroRid}" == "" ]; then
+ if [ "$buildOs" = "Linux" ]; then
+ distroRid="linux-$buildArch"
+ elif [ "$buildOs" = "OSX" ]; then
+ distroRid="osx-$buildArch"
+ elif [ "$buildOs" = "FreeBSD" ]; then
+ distroRid="freebsd-$buildArch"
+ fi
+ fi
+
+ export __DistroRid=${distroRid}
+ fi
+
+ if [ -z "$__DistroRid" ]; then
+ echo "DistroRid is not set. This is almost certainly an error"
+
+ exit 1
+ else
+ echo "__DistroRid: ${__DistroRid}"
+ echo "__RuntimeId: ${__DistroRid}"
+
+ export __RuntimeId=${__DistroRid}
+ fi
+}
\ No newline at end of file