From 1c5dc536278102fa628150127c31ed743d090f17 Mon Sep 17 00:00:00 2001 From: Gaurav Khanna Date: Mon, 19 Dec 2016 11:54:51 -0800 Subject: [PATCH] Update build-packages.sh to support portableLinux --- build-packages.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/build-packages.sh b/build-packages.sh index 6ac0ab2..0dd1035 100755 --- a/build-packages.sh +++ b/build-packages.sh @@ -3,14 +3,56 @@ usage() { echo "Builds the NuGet packages from the binaries that were built in the Build product binaries step." - echo "Usage: build-packages -BuildArch -BuildType" - echo "arch can be x64, x86, arm, arm64 (default is x64)" - echo "configuration can be release, checked, debug (default is debug)" + echo "Usage: build-packages -BuildArch -BuildType [portableLinux]" + echo "BuildArch can be x64, x86, arm, arm64 (default is x64)" + echo "BuildType can be release, checked, debug (default is debug)" + echo "portableLinux - build for Portable Linux Distribution" echo exit 1 } __ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +__PortableLinux=0 + +# Use uname to determine what the OS is. +OSName=$(uname -s) +case $OSName in + Linux) + __BuildOS=Linux + __HostOS=Linux + ;; + + Darwin) + __BuildOS=OSX + __HostOS=OSX + ;; + + FreeBSD) + __BuildOS=FreeBSD + __HostOS=FreeBSD + ;; + + OpenBSD) + __BuildOS=OpenBSD + __HostOS=OpenBSD + ;; + + NetBSD) + __BuildOS=NetBSD + __HostOS=NetBSD + ;; + + SunOS) + __BuildOS=SunOS + __HostOS=SunOS + ;; + + *) + echo "Unsupported OS $OSName detected, configuring as if for Linux" + __BuildOS=Linux + __HostOS=Linux + ;; +esac unprocessedBuildArgs= @@ -28,13 +70,29 @@ while :; do unprocessedBuildArgs="$unprocessedBuildArgs $1" __Arch=$(echo $1| cut -d'=' -f 2) ;; + + portableLinux) + if [ "$__BuildOS" == "Linux" ]; then + __PortableLinux=1 + else + echo "ERROR: portableLinux not supported for non-Linux platforms." + exit 1 + fi + ;; *) unprocessedBuildArgs="$unprocessedBuildArgs $1" esac shift done -$__ProjectRoot/run.sh build-packages -Project=$__ProjectRoot/src/.nuget/packages.builds -DistroRid=\${OSRid}-$__Arch -UseSharedCompilation=false -BuildNugetPackage=false $unprocessedBuildArgs +# Portable builds target the base RID only for Linux based platforms +if [ $__PortableLinux == 1 ]; then + export __DistroRid="linux-$__Arch" +else + export __DistroRid="\${OSRid}-$__Arch" +fi + +$__ProjectRoot/run.sh build-packages -Project=$__ProjectRoot/src/.nuget/packages.builds -DistroRid=$__DistroRid -UseSharedCompilation=false -BuildNugetPackage=false $unprocessedBuildArgs if [ $? -ne 0 ] then echo "ERROR: An error occurred while building packages; See build-packages.log for more details." -- 2.7.4