From 90596ecdf4fd724c2d136f7031371773fefce8e0 Mon Sep 17 00:00:00 2001 From: Dennis Ameling Date: Thu, 26 Nov 2020 16:21:16 +0100 Subject: [PATCH 1/3] Add first support for Linux arm64 --- .azure-pipelines/templates/linux/compile.yml | 11 ++++- .github/workflows/build-installers.yml | 4 +- .github/workflows/build-signed-deb.yml | 6 ++- .github/workflows/continuous-integration.yml | 4 +- docs/development.md | 6 +++ .../Packaging.Linux/Packaging.Linux.csproj | 4 +- src/linux/Packaging.Linux/build.sh | 40 ++++++++++++++++--- .../Git-Credential-Manager.csproj | 2 +- 8 files changed, 62 insertions(+), 15 deletions(-) diff --git a/.azure-pipelines/templates/linux/compile.yml b/.azure-pipelines/templates/linux/compile.yml index 032ef5ca4..7b4eaf719 100644 --- a/.azure-pipelines/templates/linux/compile.yml +++ b/.azure-pipelines/templates/linux/compile.yml @@ -6,11 +6,18 @@ steps: version: 3.1.x - task: DotNetCoreCLI@2 - displayName: Compile common code + displayName: Compile common code (amd64) inputs: command: build projects: 'Git-Credential-Manager.sln' - arguments: '--configuration=Linux$(configuration)' + arguments: '--configuration=Linux$(configuration) -r linux-amd64' + + - task: DotNetCoreCLI@2 + displayName: Compile common code (arm64) + inputs: + command: build + projects: 'Git-Credential-Manager.sln' + arguments: '--configuration=Linux$(configuration) -r linux-arm64' - task: DotNetCoreCLI@2 displayName: Run common unit tests diff --git a/.github/workflows/build-installers.yml b/.github/workflows/build-installers.yml index 71336f45a..0d040fee3 100644 --- a/.github/workflows/build-installers.yml +++ b/.github/workflows/build-installers.yml @@ -26,7 +26,9 @@ jobs: run: dotnet restore --force - name: Build Linux Payloads - run: dotnet build -c Release src/linux/Packaging.Linux/Packaging.Linux.csproj + run: | + dotnet build -c Release -r linux-amd64 src/linux/Packaging.Linux/Packaging.Linux.csproj + dotnet build -c Release -r linux-arm64 src/linux/Packaging.Linux/Packaging.Linux.csproj - name: Upload Installers uses: actions/upload-artifact@v2 diff --git a/.github/workflows/build-signed-deb.yml b/.github/workflows/build-signed-deb.yml index b3dba6a28..fc66fc07f 100644 --- a/.github/workflows/build-signed-deb.yml +++ b/.github/workflows/build-signed-deb.yml @@ -23,7 +23,9 @@ jobs: run: dotnet restore --force - name: Build Linux Payloads - run: dotnet build -c Release src/linux/Packaging.Linux/Packaging.Linux.csproj + run: | + dotnet build -c Release -r linux-amd64 src/linux/Packaging.Linux/Packaging.Linux.csproj + dotnet build -c Release -r linux-arm64 src/linux/Packaging.Linux/Packaging.Linux.csproj - name: Upload Installers uses: actions/upload-artifact@v2 @@ -90,4 +92,4 @@ jobs: with: name: DebianInstallerSigned path: | - Signed/*.deb \ No newline at end of file + Signed/*.deb diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index bffee0884..0a4388dfc 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -35,7 +35,9 @@ jobs: - name: Build Linux if: contains(matrix.os, 'ubuntu') - run: dotnet build --configuration LinuxRelease + run: | + dotnet build --configuration LinuxRelease -r linux-amd64 + dotnet build --configuration LinuxRelease -r linux-arm64 - name: Build macOS if: contains(matrix.os, 'macos') diff --git a/docs/development.md b/docs/development.md index 6db8a219a..cebee5d98 100644 --- a/docs/development.md +++ b/docs/development.md @@ -49,6 +49,12 @@ To build from the command line, run: dotnet build -c LinuxDebug ``` +If you want to build for a specific architecture, you can provide `linux-amd64` or `linux-arm64` as the runtime: + +```shell +dotnet build -c LinuxDebug -r linux-arm64 +``` + You can find a copy of the Debian package (.deb) file in `out/linux/Packaging.Linux/deb/Debug`. The flat binaries can also be found in `out/linux/Packaging.Linux/payload/Debug`. diff --git a/src/linux/Packaging.Linux/Packaging.Linux.csproj b/src/linux/Packaging.Linux/Packaging.Linux.csproj index 3eeb3f45f..6a6e0d779 100644 --- a/src/linux/Packaging.Linux/Packaging.Linux.csproj +++ b/src/linux/Packaging.Linux/Packaging.Linux.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/src/linux/Packaging.Linux/build.sh b/src/linux/Packaging.Linux/build.sh index 05a2b9d76..4899a5c24 100755 --- a/src/linux/Packaging.Linux/build.sh +++ b/src/linux/Packaging.Linux/build.sh @@ -32,12 +32,33 @@ case "$i" in VERSION="${i#*=}" shift # past argument=value ;; + --runtime=*) + RUNTIME="${i#*=}" + shift # past argument=value + ;; *) # unknown option ;; esac done +# Fall back to host architecture if no explicit runtime is given. +if test -z "$RUNTIME"; then + HOST_ARCH="`dpkg-architecture -q DEB_HOST_ARCH`" + + case $HOST_ARCH in + amd64) + RUNTIME="linux-x64" + ;; + arm64) + RUNTIME="linux-arm64" + ;; + *) + die "Could not determine host architecture!" + ;; + esac +fi + # Directories THISDIR="$( cd "$(dirname "$0")" ; pwd -P )" ROOT="$( cd "$THISDIR"/../../.. ; pwd -P )" @@ -48,7 +69,19 @@ PROJ_OUT="$OUT/linux/Packaging.Linux" # Build parameters FRAMEWORK=netcoreapp3.1 -RUNTIME=linux-x64 +case $RUNTIME in + linux-x64) + ARCH="x64" + ;; + linux-arm64) + ARCH="arm64" + ;; + *) + die "Incompatible runtime architecture given for build.sh" + ;; +esac + +echo "Building for runtime ${RUNTIME} and arch ${ARCH}" # Perform pre-execution checks CONFIGURATION="${CONFIGURATION:=Debug}" @@ -56,11 +89,6 @@ if [ -z "$VERSION" ]; then die "--version was not set" fi -ARCH="`dpkg-architecture -q DEB_HOST_ARCH`" -if test -z "$ARCH"; then - die "Could not determine host architecture!" -fi - # Outputs PAYLOAD="$PROJ_OUT/payload/$CONFIGURATION" SYMBOLOUT="$PROJ_OUT/payload.sym/$CONFIGURATION" diff --git a/src/shared/Git-Credential-Manager/Git-Credential-Manager.csproj b/src/shared/Git-Credential-Manager/Git-Credential-Manager.csproj index 5d3df4e8e..bb43a87b7 100644 --- a/src/shared/Git-Credential-Manager/Git-Credential-Manager.csproj +++ b/src/shared/Git-Credential-Manager/Git-Credential-Manager.csproj @@ -4,7 +4,7 @@ Exe netcoreapp3.1 net461;netcoreapp3.1 - win-x86;osx-x64;linux-x64 + win-x86;osx-x64;linux-x64;linux-arm64 x86 git-credential-manager-core Microsoft.Git.CredentialManager From 1992800bab4ae51f22ccda9d2910f9c10397fcbb Mon Sep 17 00:00:00 2001 From: Dennis Ameling Date: Thu, 26 Nov 2020 16:33:26 +0100 Subject: [PATCH 2/3] Fix wrong runtime for x64 --- .azure-pipelines/templates/linux/compile.yml | 2 +- .github/workflows/build-installers.yml | 2 +- .github/workflows/build-signed-deb.yml | 2 +- .github/workflows/continuous-integration.yml | 2 +- docs/development.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.azure-pipelines/templates/linux/compile.yml b/.azure-pipelines/templates/linux/compile.yml index 7b4eaf719..bd56e9810 100644 --- a/.azure-pipelines/templates/linux/compile.yml +++ b/.azure-pipelines/templates/linux/compile.yml @@ -10,7 +10,7 @@ steps: inputs: command: build projects: 'Git-Credential-Manager.sln' - arguments: '--configuration=Linux$(configuration) -r linux-amd64' + arguments: '--configuration=Linux$(configuration) -r linux-x64' - task: DotNetCoreCLI@2 displayName: Compile common code (arm64) diff --git a/.github/workflows/build-installers.yml b/.github/workflows/build-installers.yml index 0d040fee3..cdf160351 100644 --- a/.github/workflows/build-installers.yml +++ b/.github/workflows/build-installers.yml @@ -27,7 +27,7 @@ jobs: - name: Build Linux Payloads run: | - dotnet build -c Release -r linux-amd64 src/linux/Packaging.Linux/Packaging.Linux.csproj + dotnet build -c Release -r linux-x64 src/linux/Packaging.Linux/Packaging.Linux.csproj dotnet build -c Release -r linux-arm64 src/linux/Packaging.Linux/Packaging.Linux.csproj - name: Upload Installers diff --git a/.github/workflows/build-signed-deb.yml b/.github/workflows/build-signed-deb.yml index fc66fc07f..3e61266d2 100644 --- a/.github/workflows/build-signed-deb.yml +++ b/.github/workflows/build-signed-deb.yml @@ -24,7 +24,7 @@ jobs: - name: Build Linux Payloads run: | - dotnet build -c Release -r linux-amd64 src/linux/Packaging.Linux/Packaging.Linux.csproj + dotnet build -c Release -r linux-x64 src/linux/Packaging.Linux/Packaging.Linux.csproj dotnet build -c Release -r linux-arm64 src/linux/Packaging.Linux/Packaging.Linux.csproj - name: Upload Installers diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 0a4388dfc..b13ae9732 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -36,7 +36,7 @@ jobs: - name: Build Linux if: contains(matrix.os, 'ubuntu') run: | - dotnet build --configuration LinuxRelease -r linux-amd64 + dotnet build --configuration LinuxRelease -r linux-x64 dotnet build --configuration LinuxRelease -r linux-arm64 - name: Build macOS diff --git a/docs/development.md b/docs/development.md index cebee5d98..0aedc1753 100644 --- a/docs/development.md +++ b/docs/development.md @@ -49,7 +49,7 @@ To build from the command line, run: dotnet build -c LinuxDebug ``` -If you want to build for a specific architecture, you can provide `linux-amd64` or `linux-arm64` as the runtime: +If you want to build for a specific architecture, you can provide `linux-x64` or `linux-arm64` as the runtime: ```shell dotnet build -c LinuxDebug -r linux-arm64 From ec8f2c638dd214e985248c8f2e14253614557cf0 Mon Sep 17 00:00:00 2001 From: Dennis Ameling Date: Thu, 26 Nov 2020 16:39:09 +0100 Subject: [PATCH 3/3] Fix deb package name on Linux --- src/linux/Packaging.Linux/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/linux/Packaging.Linux/build.sh b/src/linux/Packaging.Linux/build.sh index 4899a5c24..77270630d 100755 --- a/src/linux/Packaging.Linux/build.sh +++ b/src/linux/Packaging.Linux/build.sh @@ -71,7 +71,7 @@ PROJ_OUT="$OUT/linux/Packaging.Linux" FRAMEWORK=netcoreapp3.1 case $RUNTIME in linux-x64) - ARCH="x64" + ARCH="amd64" ;; linux-arm64) ARCH="arm64"