From 7d72e386042fe6d72b7724a9caba2f05693e92c5 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 25 Jun 2018 14:51:30 -0700 Subject: [PATCH] Updates to build for Alpine (#7139) setdate.cpp was incorrectly assigning an int to a struct, fixed to initialize struct zero'd update the typegen project in the bash script added some help text at top of script for someone trying to build it updated runtime to linux-musl-x64 instead of linux-x64 as Alpine distro uses the musl libc libraries instead of glibc which is used by most distros. --- src/libpsl-native/src/setdate.cpp | 2 +- .../build-and-run-pwsh.sh | 38 +++++++++++++------ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/libpsl-native/src/setdate.cpp b/src/libpsl-native/src/setdate.cpp index b5d7b70dde..334d70ba06 100644 --- a/src/libpsl-native/src/setdate.cpp +++ b/src/libpsl-native/src/setdate.cpp @@ -41,7 +41,7 @@ int32_t SetDate(struct private_tm* time) static int32_t GetTimeVal(struct private_tm& time, struct timeval& tv) { - struct tm nativeTime = 0; + struct tm nativeTime = {0}; nativeTime.tm_hour = static_cast(time.Hour); nativeTime.tm_isdst = static_cast(time.IsDst); nativeTime.tm_mday = static_cast(time.DayOfMonth); diff --git a/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh b/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh index 2624f2b6d9..e7144c9c50 100755 --- a/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh +++ b/tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh @@ -1,5 +1,17 @@ #!/bin/sh +set -e + +# this script needs to be run from within Alpine with dotnet 2.1 SDK installed, example: +# docker run -it -v ~/repos/PowerShell:/PowerShell microsoft/dotnet:2.1-sdk-alpine + +# build tools required: +# apk update +# apk add build-base gcc abuild binutils git python bash cmake + +# run from root of PowerShell repo: +# tools/releaseBuild/Images/microsoft_powershell_alpine3/build-and-run-pwsh.sh /PowerShell /PowerShell 6.1.0 + repoRoot=$1 destination=$2 releaseTag=$3 @@ -37,10 +49,10 @@ esac # remove v from release tag (v3.5 => 3.5) if [ "${releaseTag:0:1}" = "v" ]; then releaseTag=${releaseTag:1} - tarName=$destination/powershell-$releaseTag-alpine.3-$arch.tar.gz + tarName=$destination/powershell-$releaseTag-linux-musl-$arch.tar.gz dotnetArguments=/p:ReleaseTag=$releaseTag; else - tarName=$destination/powershell-alpine.3-$arch.tar.gz + tarName=$destination/powershell-linux-musl-$arch.tar.gz fi # Build libpsl-native @@ -62,13 +74,13 @@ cd .. targetFile="Microsoft.PowerShell.SDK/obj/Microsoft.PowerShell.SDK.csproj.TypeCatalog.targets" cat > $targetFile <<-"EOF" - - - <_RefAssemblyPath Include="%(_ReferencesFromRAR.ResolvedPath)%3B" Condition=" '%(_ReferencesFromRAR.Type)' == 'assembly' And '%(_ReferencesFromRAR.PackageName)' != 'Microsoft.Management.Infrastructure' " /> - - - + + + <_RefAssemblyPath Include="%(_ReferencesFromRAR.HintPath)%3B" Condition=" '%(_ReferencesFromRAR.NuGetPackageId)' != 'Microsoft.Management.Infrastructure' "/> + + + EOF @@ -79,12 +91,14 @@ dotnet run ../System.Management.Automation/CoreCLR/CorePsTypeCatalog.cs powershe # build PowerShell cd ../powershell-unix -dotnet publish --configuration Linux --runtime linux-x64 $dotnetArguments +dotnet publish --configuration Release --runtime linux-musl-x64 $dotnetArguments # add libpsl-native to build -mv libpsl-native.so bin/Linux/netcoreapp2.0/linux-x64 +mv libpsl-native.so bin/Release/netcoreapp2.1/linux-musl-x64/publish # tar build for output -cd bin/Linux/netcoreapp2.0/linux-x64 +cd bin/Release/netcoreapp2.1/linux-musl-x64/publish tar -czvf $tarName . + +echo "Created $tarName"