Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Packaging] Release Azure Linux 3 RPM package #29348

Merged
merged 9 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 29 additions & 27 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ jobs:

- job: BuildDockerImageAzureLinux
displayName: Build Docker Image Azure Linux
dependsOn: BuildRpmPackageMariner
dependsOn: BuildRpmPackagesAzureLinux
strategy:
matrix:
${{ each arch in parameters.architectures }}:
Expand Down Expand Up @@ -766,30 +766,31 @@ jobs:
displayName: 'Test Homebrew Package'


- job: BuildRpmPackageMariner
displayName: Build Rpm Package Mariner
- job: BuildRpmPackagesAzureLinux
displayName: Build Rpm Package
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual', 'Schedule'))
strategy:
matrix:
2.0 AMD64:
image: mcr.microsoft.com/cbl-mariner/base/core:2.0
artifact: rpm-mariner2.0-amd64
pool: ${{ variables.ubuntu_pool }}
2.0 ARM64:
image: mcr.microsoft.com/cbl-mariner/base/core:2.0
artifact: rpm-mariner2.0-arm64
pool: ${{ variables.ubuntu_arm64_pool }}
${{ each arch in parameters.architectures }}:
Mariner 2.0 ${{ arch.name }}:
image: mcr.microsoft.com/cbl-mariner/base/core:2.0
artifact: rpm-mariner2.0-${{ arch.value }}
pool: ${{ arch.pool }}
Azure Linux 3.0 ${{ arch.name }}:
image: azurelinuxpreview.azurecr.io/public/azurelinux/base/core:3.0
artifact: rpm-azurelinux3.0-${{ arch.value }}
pool: ${{ arch.pool }}
pool:
name: $(pool)
steps:
- bash: ./scripts/ci/install_docker.sh
displayName: Install Docker

- task: Bash@3
displayName: 'Build Rpm Package: Mariner'
displayName: 'Build Rpm Package: Azure Linux'
inputs:
targetType: 'filePath'
filePath: scripts/release/rpm/pipeline_mariner.sh
filePath: scripts/release/rpm/pipeline_azurelinux.sh

- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
displayName: 'SBOM'
Expand All @@ -802,25 +803,26 @@ jobs:
TargetPath: $(Build.ArtifactStagingDirectory)
ArtifactName: $(artifact)

- job: TestRpmPackageMariner
displayName: Test Rpm Package Mariner
- job: TestRpmPackagesAzureLinux
displayName: Test Rpm Package
timeoutInMinutes: 120
dependsOn:
- BuildRpmPackageMariner
- BuildRpmPackagesAzureLinux
- ExtractMetadata
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual', 'Schedule'))
pool:
name: $(pool)
strategy:
matrix:
2.0 AMD64:
image: mcr.microsoft.com/cbl-mariner/base/core:2.0
artifact: rpm-mariner2.0-amd64
pool: ${{ variables.ubuntu_pool }}
2.0 ARM64:
image: mcr.microsoft.com/cbl-mariner/base/core:2.0
artifact: rpm-mariner2.0-arm64
pool: ${{ variables.ubuntu_arm64_pool }}
${{ each arch in parameters.architectures }}:
Mariner 2.0 ${{ arch.name }}:
image: mcr.microsoft.com/cbl-mariner/base/core:2.0
artifact: rpm-mariner2.0-${{ arch.value }}
pool: ${{ arch.pool }}
Azure Linux 3.0 ${{ arch.name }}:
image: azurelinuxpreview.azurecr.io/public/azurelinux/base/core:3.0
artifact: rpm-azurelinux3.0-${{ arch.value }}
pool: ${{ arch.pool }}
steps:
- task: DownloadPipelineArtifact@1
displayName: 'Download Metadata'
Expand All @@ -841,11 +843,11 @@ jobs:
set -ex

CLI_VERSION=`cat $SYSTEM_ARTIFACTSDIRECTORY/metadata/version`
RPM_NAME=$(find $SYSTEM_ARTIFACTSDIRECTORY/rpm/ -type f -name "azure-cli-$CLI_VERSION-1.cm2.*.rpm" -printf '%f\n')
RPM_NAME=$(find $SYSTEM_ARTIFACTSDIRECTORY/rpm/ -type f -name "azure-cli-$CLI_VERSION-1.*.rpm" -printf '%f\n')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will be the new package name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

azure-cli-2.62.0-1.azl3.x86_64.rpm

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some example names to the comment, including both Mariner 2 and Azure Linux 3? This will increase the readability.


echo "== Test rpm package on ${IMAGE} =="
docker pull $IMAGE
docker run --rm -e RPM_NAME=$RPM_NAME -v $SYSTEM_ARTIFACTSDIRECTORY/rpm:/mnt/rpm -v $(pwd):/azure-cli $IMAGE /bin/bash "/azure-cli/scripts/release/rpm/test_mariner_in_docker.sh"
docker run --rm -e RPM_NAME=$RPM_NAME -v $SYSTEM_ARTIFACTSDIRECTORY/rpm:/mnt/rpm -v $(pwd):/azure-cli $IMAGE /bin/bash "/azure-cli/scripts/release/rpm/test_azurelinux_in_docker.sh"

displayName: 'Test Rpm Package Mariner'

Expand Down Expand Up @@ -1253,7 +1255,7 @@ jobs:
- BuildHomebrewFormula
- TestHomebrewFormula
- TestHomebrewPackage
- BuildRpmPackageMariner
- BuildRpmPackagesAzureLinux
- BuildRpmPackages
- TestRpmPackage
- BuildDebPackages
Expand Down
1 change: 1 addition & 0 deletions scripts/ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ CLASSIFIERS = [
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'License :: OSI Approved :: MIT License',
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ WORKDIR /azure-cli

COPY . .

# Mariner 2.0 only has 'python3' package, which is currently (2022-12-09) Python 3.9.
# It has no version-specific packages like 'python39'.
# Mariner 2.0's python3 is 3.9, the rpm paths are
# /usr/src/mariner/RPMS/x86_64/azure-cli-2.63.0-1.cm2.x86_64.rpm
# /usr/src/mariner/RPMS/aarch64/azure-cli-2.63.0-1.cm2.aarch64.rpm
# Azure Linux 3's python3 is 3.12, the rpm paths are
# /usr/src/azl/RPMS/x86_64/azure-cli-2.63.0-1.azl3.x86_64.rpm
# /usr/src/azl/RPMS/aarch64/azure-cli-2.63.0-1.azl3.aarch64.rpm
RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \
REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=python3 PYTHON_CMD=python3 \
rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \
cp /usr/src/mariner/RPMS/*/azure-cli-${cli_version}-1.*.rpm /azure-cli-dev.rpm && \
mkdir /out && cp /usr/src/mariner/RPMS/*/azure-cli-${cli_version}-1.*.rpm /out/
cp /usr/src/*/RPMS/*/azure-cli-${cli_version}-1.*.rpm /azure-cli-dev.rpm && \
mkdir /out && cp /usr/src/*/RPMS/*/azure-cli-${cli_version}-1.*.rpm /out/

FROM ${image} AS execution-env

Expand Down
13 changes: 0 additions & 13 deletions scripts/release/rpm/build.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env bash

# Build assets related to Linux Distributions that use RPM/yum for installation specific for CBL-Mariner.
# Build assets related to Linux Distributions that use RPM/yum for installation specific for Azure Linux

set -exv

: "${BUILD_STAGINGDIRECTORY:?BUILD_STAGINGDIRECTORY environment variable not set.}"

# IMAGE should be Mariner docker image url, such as mcr.microsoft.com/cbl-mariner/base/core:2.0
# IMAGE should be Azure Linux docker image url, such as mcr.microsoft.com/cbl-mariner/base/core:2.0
: "${IMAGE:?IMAGE environment variable not set.}"

CLI_VERSION=`cat src/azure-cli/azure/cli/__main__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g`
Expand All @@ -16,21 +16,21 @@ docker build \
--target build-env \
--build-arg cli_version=${CLI_VERSION} \
--build-arg image=${IMAGE} \
-f ./scripts/release/rpm/mariner.dockerfile \
-t azure/azure-cli:mariner-builder \
-f ./scripts/release/rpm/azurelinux.dockerfile \
-t azure/azure-cli:azurelinux-builder \
.

# Continue the previous build, and create a container that has the current azure-cli build but not the source code.
docker build \
--build-arg cli_version=${CLI_VERSION} \
--build-arg image=${IMAGE} \
-f ./scripts/release/rpm/mariner.dockerfile \
-t azure/azure-cli:mariner \
-f ./scripts/release/rpm/azurelinux.dockerfile \
-t azure/azure-cli:azurelinux \
.

# Extract the built RPM so that it can be distributed independently.
# The RPM file looks like azure-cli-2.32.0-1.x86_64.rpm
id=$(docker create azure/azure-cli:mariner-builder bash)
id=$(docker create azure/azure-cli:azurelinux-builder bash)
# https://docs.docker.com/engine/reference/commandline/cp/
# Append /. so that the x86_64 folder's content is copied, instead of x86_64 folder itself.
docker cp $id:/out/. ${BUILD_STAGINGDIRECTORY}
Expand All @@ -40,6 +40,6 @@ docker cp $id:/out/. ${BUILD_STAGINGDIRECTORY}
#
# The products of `docker save` can be rehydrated using `docker load`.
# mkdir -p ${BUILD_STAGINGDIRECTORY}/docker
# docker save azure/azure-cli:mariner-builder | gzip > ${BUILD_STAGINGDIRECTORY}/docker/azure_azure-cli_mariner-builder.tar.gz &
# docker save azure/azure-cli:mariner | gzip > ${BUILD_STAGINGDIRECTORY}/docker/azure_azure-cli_mariner.tar.gz &
# docker save azure/azure-cli:azurelinux-builder | gzip > ${BUILD_STAGINGDIRECTORY}/docker/azure_azure-cli_azurelinux-builder.tar.gz &
# docker save azure/azure-cli:azurelinux | gzip > ${BUILD_STAGINGDIRECTORY}/docker/azure_azure-cli_azurelinux.tar.gz &
# wait
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# This script should be run in a Mariner 2.0 docker container.
# This script should be run in a Azure Linux docker container.
set -exv

export USERNAME=azureuser
Expand All @@ -14,7 +14,7 @@ time az self-test
time az --version

cd /azure-cli/
pip install wheel
python -m pip install --upgrade pip setuptools
./scripts/ci/build.sh

# From Fedora36, when using `pip install --prefix` with root privileges, the package is installed into `{prefix}/local/lib`.
Expand Down
4 changes: 2 additions & 2 deletions scripts/release/rpm/test_rpm_in_docker.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# This script should be run in a centos7 docker.
# This script should be run in a ubi8, ubi9 docker.
set -exv

export USERNAME=azureuser
Expand All @@ -15,7 +15,7 @@ time az self-test
time az --version

cd /azure-cli/
pip install wheel
python -m pip install --upgrade pip setuptools
./scripts/ci/build.sh

# From Fedora36, when using `pip install --prefix` with root privileges, the package is installed into `{prefix}/local/lib`.
Expand Down