From cf3a19b38f90b99092cc47ed7fbf91c38b86216a Mon Sep 17 00:00:00 2001 From: Hang Lei Date: Wed, 17 Aug 2022 14:33:09 +0800 Subject: [PATCH 1/7] Init --- azure-pipelines.yml | 11 +++++++++++ scripts/release/rpm/pipeline.sh | 4 ++-- scripts/release/rpm/ubi9.dockerfile | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 scripts/release/rpm/ubi9.dockerfile diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 12e64961b96..747274f7c9e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -640,6 +640,10 @@ jobs: image: ubi8 tag: 8.4 artifact: rpm-ubi8 + Red Hat Universal Base Image 9: + image: ubi9 + tag: 9.0.0-1604 + artifact: rpm-ubi9 Fedora35: image: fedora tag: 35 @@ -684,6 +688,13 @@ jobs: python_package: python39 python_cmd: python3.9 pip_cmd: pip3.9 + Red Hat Universal Base Image 9: + artifact: rpm-ubi9 + distro: el9 + image: registry.access.redhat.com/ubi9/ubi:9.0.0-1604 + python_package: python3 + python_cmd: python3 + pip_cmd: pip3 Fedora35: artifact: rpm-fedora35 distro: fc35 diff --git a/scripts/release/rpm/pipeline.sh b/scripts/release/rpm/pipeline.sh index d1d6ec84331..43147ecea97 100755 --- a/scripts/release/rpm/pipeline.sh +++ b/scripts/release/rpm/pipeline.sh @@ -6,9 +6,9 @@ set -exv : "${BUILD_STAGINGDIRECTORY:?BUILD_STAGINGDIRECTORY environment variable not set.}" -# IMAGE should be one of 'centos7', 'ubi8' or 'fedora' +# IMAGE should be one of 'centos7', 'ubi8', 'ubi9' or 'fedora' : "${IMAGE:?IMAGE environment variable not set.}" -# TAG should be 'centos7', '8.4' or Fedora version number +# TAG should be RHEL image tag or Fedora version number : "${TAG:?TAG 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` diff --git a/scripts/release/rpm/ubi9.dockerfile b/scripts/release/rpm/ubi9.dockerfile new file mode 100644 index 00000000000..0aeeb1ecef8 --- /dev/null +++ b/scripts/release/rpm/ubi9.dockerfile @@ -0,0 +1,26 @@ +# Red Hat Universal Base Image 9: https://catalog.redhat.com/software/containers/ubi9/ubi/615bcf606feffc5384e8452e + +ARG tag=9.0.0-1604 + +FROM registry.access.redhat.com/ubi9/ubi:${tag} AS build-env +ARG cli_version=dev + +RUN yum update -y +RUN yum install -y wget rpm-build gcc libffi-devel python3-devel openssl-devel make bash diffutils patch dos2unix perl + +WORKDIR /azure-cli + +COPY . . + +# RHEL 9's 'python3' is Python 3.9. +# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html-single/9.0_release_notes/index#enhancement_dynamic-programming-languages-web-and-database-servers +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 /root/rpmbuild/RPMS/x86_64/azure-cli-${cli_version}-1.*.x86_64.rpm /azure-cli-dev.rpm + +FROM registry.access.redhat.com/ubi9/ubi:${tag} AS execution-env + +COPY --from=build-env /azure-cli-dev.rpm ./ +RUN rpm -i ./azure-cli-dev.rpm && \ + az --version From 83fe59bc7ba178569f716f7eafe443ae7a82081a Mon Sep 17 00:00:00 2001 From: Hang Lei Date: Thu, 18 Aug 2022 11:43:59 +0800 Subject: [PATCH 2/7] Add devel_package arg, use same ubi.dockerfile --- azure-pipelines.yml | 12 ++++++--- scripts/release/rpm/fedora.dockerfile | 3 ++- scripts/release/rpm/pipeline.sh | 6 ++++- .../rpm/{ubi8.dockerfile => ubi.dockerfile} | 7 +++-- scripts/release/rpm/ubi9.dockerfile | 26 ------------------- 5 files changed, 20 insertions(+), 34 deletions(-) rename scripts/release/rpm/{ubi8.dockerfile => ubi.dockerfile} (65%) delete mode 100644 scripts/release/rpm/ubi9.dockerfile diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 747274f7c9e..2b07b5b121d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -637,21 +637,25 @@ jobs: strategy: matrix: Red Hat Universal Base Image 8: - image: ubi8 + image: ubi tag: 8.4 artifact: rpm-ubi8 + devel_package: python39-devel Red Hat Universal Base Image 9: - image: ubi9 - tag: 9.0.0-1604 + image: ubi + tag: 9.0.0 artifact: rpm-ubi9 + devel_package: python3-devel Fedora35: image: fedora tag: 35 artifact: rpm-fedora35 + devel_package: python3-devel Fedora36: image: fedora tag: 36 artifact: rpm-fedora36 + devel_package: python3-devel steps: - task: Bash@3 displayName: 'Build Rpm Package' @@ -691,7 +695,7 @@ jobs: Red Hat Universal Base Image 9: artifact: rpm-ubi9 distro: el9 - image: registry.access.redhat.com/ubi9/ubi:9.0.0-1604 + image: registry.access.redhat.com/ubi9/ubi:9.0.0 python_package: python3 python_cmd: python3 pip_cmd: pip3 diff --git a/scripts/release/rpm/fedora.dockerfile b/scripts/release/rpm/fedora.dockerfile index 531216f0d2e..6de813a7253 100644 --- a/scripts/release/rpm/fedora.dockerfile +++ b/scripts/release/rpm/fedora.dockerfile @@ -2,9 +2,10 @@ ARG tag=35 FROM fedora:${tag} AS build-env ARG cli_version=dev +ARG devel_package=python3-devel RUN dnf update -y -RUN dnf install -y wget rpm-build gcc libffi-devel python3-devel openssl-devel make bash coreutils diffutils patch dos2unix perl +RUN dnf install -y wget rpm-build gcc libffi-devel $devel_package openssl-devel make bash coreutils diffutils patch dos2unix perl WORKDIR /azure-cli diff --git a/scripts/release/rpm/pipeline.sh b/scripts/release/rpm/pipeline.sh index 43147ecea97..9a6bfe83a73 100755 --- a/scripts/release/rpm/pipeline.sh +++ b/scripts/release/rpm/pipeline.sh @@ -6,10 +6,12 @@ set -exv : "${BUILD_STAGINGDIRECTORY:?BUILD_STAGINGDIRECTORY environment variable not set.}" -# IMAGE should be one of 'centos7', 'ubi8', 'ubi9' or 'fedora' +# IMAGE should be one of 'centos7', 'ubi' or 'fedora' : "${IMAGE:?IMAGE environment variable not set.}" # TAG should be RHEL image tag or Fedora version number : "${TAG:?TAG environment variable not set.}" +# DEVEL_PACKAGE should be python-devel package name +: "${DEVEL_PACKAGE:?DEVEL_PACKAGE 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` @@ -18,6 +20,7 @@ docker build \ --target build-env \ --build-arg cli_version=${CLI_VERSION} \ --build-arg tag=${TAG} \ + --build-arg devel_package=${DEVEL_PACKAGE} \ -f ./scripts/release/rpm/${IMAGE}.dockerfile \ -t azure/azure-cli:${IMAGE}-builder \ . @@ -26,6 +29,7 @@ docker build \ docker build \ --build-arg cli_version=${CLI_VERSION} \ --build-arg tag=${TAG} \ + --build-arg devel_package=${DEVEL_PACKAGE} \ -f ./scripts/release/rpm/${IMAGE}.dockerfile \ -t azure/azure-cli:${IMAGE} \ . diff --git a/scripts/release/rpm/ubi8.dockerfile b/scripts/release/rpm/ubi.dockerfile similarity index 65% rename from scripts/release/rpm/ubi8.dockerfile rename to scripts/release/rpm/ubi.dockerfile index e53fec41d49..452ba8a95e6 100644 --- a/scripts/release/rpm/ubi8.dockerfile +++ b/scripts/release/rpm/ubi.dockerfile @@ -1,18 +1,21 @@ # Red Hat Universal Base Image 8: https://catalog.redhat.com/software/containers/ubi8/ubi/5c359854d70cc534b3a3784e +# Red Hat Universal Base Image 9: https://catalog.redhat.com/software/containers/ubi9/ubi/615bcf606feffc5384e8452e ARG tag=8.4 +ARG devel_package=python39-devel FROM registry.access.redhat.com/ubi8/ubi:${tag} AS build-env ARG cli_version=dev RUN yum update -y -RUN yum install -y wget rpm-build gcc libffi-devel python39-devel openssl-devel make bash diffutils patch dos2unix perl +RUN yum install -y wget rpm-build gcc libffi-devel $devel_package openssl-devel make bash diffutils patch dos2unix perl WORKDIR /azure-cli COPY . . -# RHEL's 'python3' is Python 3.6. We have to explicitly specify 'python39' to install Python 3.9. +# RHEL 8's 'python3' is Python 3.6. RHEL 9's 'python3' is Python 3.9. +# We have to explicitly specify 'python39' to install Python 3.9. RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=python39 PYTHON_CMD=python3.9 \ rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \ diff --git a/scripts/release/rpm/ubi9.dockerfile b/scripts/release/rpm/ubi9.dockerfile deleted file mode 100644 index 0aeeb1ecef8..00000000000 --- a/scripts/release/rpm/ubi9.dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -# Red Hat Universal Base Image 9: https://catalog.redhat.com/software/containers/ubi9/ubi/615bcf606feffc5384e8452e - -ARG tag=9.0.0-1604 - -FROM registry.access.redhat.com/ubi9/ubi:${tag} AS build-env -ARG cli_version=dev - -RUN yum update -y -RUN yum install -y wget rpm-build gcc libffi-devel python3-devel openssl-devel make bash diffutils patch dos2unix perl - -WORKDIR /azure-cli - -COPY . . - -# RHEL 9's 'python3' is Python 3.9. -# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html-single/9.0_release_notes/index#enhancement_dynamic-programming-languages-web-and-database-servers -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 /root/rpmbuild/RPMS/x86_64/azure-cli-${cli_version}-1.*.x86_64.rpm /azure-cli-dev.rpm - -FROM registry.access.redhat.com/ubi9/ubi:${tag} AS execution-env - -COPY --from=build-env /azure-cli-dev.rpm ./ -RUN rpm -i ./azure-cli-dev.rpm && \ - az --version From 85f8919ee1e5974f9bcbe1ea6defbc705308f690 Mon Sep 17 00:00:00 2001 From: Hang Lei Date: Thu, 18 Aug 2022 11:58:45 +0800 Subject: [PATCH 3/7] Add version number --- azure-pipelines.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2b07b5b121d..1d50668f926 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -645,7 +645,7 @@ jobs: image: ubi tag: 9.0.0 artifact: rpm-ubi9 - devel_package: python3-devel + devel_package: python3.9-devel Fedora35: image: fedora tag: 35 @@ -696,9 +696,9 @@ jobs: artifact: rpm-ubi9 distro: el9 image: registry.access.redhat.com/ubi9/ubi:9.0.0 - python_package: python3 - python_cmd: python3 - pip_cmd: pip3 + python_package: python3.9 + python_cmd: python3.9 + pip_cmd: pip3.9 Fedora35: artifact: rpm-fedora35 distro: fc35 From c8da6b9c70562539e8f30b64f5088e1cd0611627 Mon Sep 17 00:00:00 2001 From: Hang Lei Date: Fri, 19 Aug 2022 10:45:06 +0800 Subject: [PATCH 4/7] Fix ubi9 image url --- azure-pipelines.yml | 16 ++++++++-------- scripts/release/rpm/fedora.dockerfile | 6 +++--- scripts/release/rpm/pipeline.sh | 18 +++++++++--------- scripts/release/rpm/ubi.dockerfile | 6 +++--- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1d50668f926..95a465f2af8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -637,23 +637,23 @@ jobs: strategy: matrix: Red Hat Universal Base Image 8: - image: ubi - tag: 8.4 + docker_file: ubi + image: registry.access.redhat.com/ubi8/ubi:8.4 artifact: rpm-ubi8 devel_package: python39-devel Red Hat Universal Base Image 9: - image: ubi - tag: 9.0.0 + docker_file: ubi + image: registry.access.redhat.com/ubi9/ubi:9.0.0 artifact: rpm-ubi9 devel_package: python3.9-devel Fedora35: - image: fedora - tag: 35 + docker_file: ubi + image: fedora:35 artifact: rpm-fedora35 devel_package: python3-devel Fedora36: - image: fedora - tag: 36 + docker_file: ubi + image: fedora:36 artifact: rpm-fedora36 devel_package: python3-devel steps: diff --git a/scripts/release/rpm/fedora.dockerfile b/scripts/release/rpm/fedora.dockerfile index 6de813a7253..07cc8652043 100644 --- a/scripts/release/rpm/fedora.dockerfile +++ b/scripts/release/rpm/fedora.dockerfile @@ -1,6 +1,6 @@ -ARG tag=35 +ARG image=fedora:35 -FROM fedora:${tag} AS build-env +FROM ${image} AS build-env ARG cli_version=dev ARG devel_package=python3-devel @@ -16,7 +16,7 @@ RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \ cp /root/rpmbuild/RPMS/x86_64/azure-cli-${cli_version}-1.*.x86_64.rpm /azure-cli-dev.rpm -FROM fedora:${tag} AS execution-env +FROM ${image} AS execution-env COPY --from=build-env /azure-cli-dev.rpm ./ RUN rpm -i ./azure-cli-dev.rpm && \ diff --git a/scripts/release/rpm/pipeline.sh b/scripts/release/rpm/pipeline.sh index 9a6bfe83a73..135a95124d1 100755 --- a/scripts/release/rpm/pipeline.sh +++ b/scripts/release/rpm/pipeline.sh @@ -6,10 +6,10 @@ set -exv : "${BUILD_STAGINGDIRECTORY:?BUILD_STAGINGDIRECTORY environment variable not set.}" -# IMAGE should be one of 'centos7', 'ubi' or 'fedora' +# DOCKER_FILE should be one of 'ubi' or 'fedora' +: "${DOCKER_FILE:?DOCKER_FILE environment variable not set.}" +# IMAGE should be RHEL or Fedora image url : "${IMAGE:?IMAGE environment variable not set.}" -# TAG should be RHEL image tag or Fedora version number -: "${TAG:?TAG environment variable not set.}" # DEVEL_PACKAGE should be python-devel package name : "${DEVEL_PACKAGE:?DEVEL_PACKAGE environment variable not set.}" @@ -19,19 +19,19 @@ CLI_VERSION=`cat src/azure-cli/azure/cli/__main__.py | grep __version__ | sed s/ docker build \ --target build-env \ --build-arg cli_version=${CLI_VERSION} \ - --build-arg tag=${TAG} \ + --build-arg image=${IMAGE} \ --build-arg devel_package=${DEVEL_PACKAGE} \ - -f ./scripts/release/rpm/${IMAGE}.dockerfile \ - -t azure/azure-cli:${IMAGE}-builder \ + -f ./scripts/release/rpm/${DOCKER_FILE}.dockerfile \ + -t azure/azure-cli:${DOCKER_FILE}-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 tag=${TAG} \ + --build-arg image=${IMAGE} \ --build-arg devel_package=${DEVEL_PACKAGE} \ - -f ./scripts/release/rpm/${IMAGE}.dockerfile \ - -t azure/azure-cli:${IMAGE} \ + -f ./scripts/release/rpm/${DOCKER_FILE}.dockerfile \ + -t azure/azure-cli:${DOCKER_FILE} \ . # Extract the built RPM so that it can be distributed independently. diff --git a/scripts/release/rpm/ubi.dockerfile b/scripts/release/rpm/ubi.dockerfile index 452ba8a95e6..cc561097dcc 100644 --- a/scripts/release/rpm/ubi.dockerfile +++ b/scripts/release/rpm/ubi.dockerfile @@ -1,10 +1,10 @@ # Red Hat Universal Base Image 8: https://catalog.redhat.com/software/containers/ubi8/ubi/5c359854d70cc534b3a3784e # Red Hat Universal Base Image 9: https://catalog.redhat.com/software/containers/ubi9/ubi/615bcf606feffc5384e8452e -ARG tag=8.4 +ARG image=registry.access.redhat.com/ubi8/ubi:8.4 ARG devel_package=python39-devel -FROM registry.access.redhat.com/ubi8/ubi:${tag} AS build-env +FROM ${image} AS build-env ARG cli_version=dev RUN yum update -y @@ -21,7 +21,7 @@ RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \ cp /root/rpmbuild/RPMS/x86_64/azure-cli-${cli_version}-1.*.x86_64.rpm /azure-cli-dev.rpm -FROM registry.access.redhat.com/ubi8/ubi:${tag} AS execution-env +FROM ${image} AS execution-env RUN yum update -y RUN yum install -y python39 From e03cc496342023453580c1572a9aad0b22086f21 Mon Sep 17 00:00:00 2001 From: Hang Lei Date: Fri, 19 Aug 2022 11:57:03 +0800 Subject: [PATCH 5/7] Add python_devel in azure-cli.spec --- scripts/release/rpm/azure-cli.spec | 4 +++- scripts/release/rpm/fedora.dockerfile | 2 +- scripts/release/rpm/ubi.dockerfile | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/release/rpm/azure-cli.spec b/scripts/release/rpm/azure-cli.spec index 040618f1cf2..daa7840d3b2 100644 --- a/scripts/release/rpm/azure-cli.spec +++ b/scripts/release/rpm/azure-cli.spec @@ -14,6 +14,8 @@ %define python_package %{getenv:PYTHON_PACKAGE} # The Python executable name, such as python3.9, python3 %define python_cmd %{getenv:PYTHON_CMD} +# The Python devel package name, such as python3.9-devel, python3-devel +%define python_devel %{getenv:DEVEL-PACKAGE} %define name azure-cli %define release 1%{?dist} @@ -33,7 +35,7 @@ Prefix: /usr Prefix: /etc BuildRequires: gcc, libffi-devel, openssl-devel, perl -BuildRequires: %{python_package}-devel +BuildRequires: %{python_devel} %global _python_bytecompile_errors_terminate_build 0 diff --git a/scripts/release/rpm/fedora.dockerfile b/scripts/release/rpm/fedora.dockerfile index 07cc8652043..0cc4c0831de 100644 --- a/scripts/release/rpm/fedora.dockerfile +++ b/scripts/release/rpm/fedora.dockerfile @@ -12,7 +12,7 @@ WORKDIR /azure-cli COPY . . RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ - REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=python3 PYTHON_CMD=python3 \ + REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=python3 PYTHON_CMD=python3 DEVEL_PACKAGE=$devel_package \ rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \ cp /root/rpmbuild/RPMS/x86_64/azure-cli-${cli_version}-1.*.x86_64.rpm /azure-cli-dev.rpm diff --git a/scripts/release/rpm/ubi.dockerfile b/scripts/release/rpm/ubi.dockerfile index cc561097dcc..fab849cb68a 100644 --- a/scripts/release/rpm/ubi.dockerfile +++ b/scripts/release/rpm/ubi.dockerfile @@ -17,7 +17,7 @@ COPY . . # RHEL 8's 'python3' is Python 3.6. RHEL 9's 'python3' is Python 3.9. # We have to explicitly specify 'python39' to install Python 3.9. RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ - REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=python39 PYTHON_CMD=python3.9 \ + REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=python39 PYTHON_CMD=python3.9 DEVEL_PACKAGE=$devel_package \ rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \ cp /root/rpmbuild/RPMS/x86_64/azure-cli-${cli_version}-1.*.x86_64.rpm /azure-cli-dev.rpm From f7f317b0dccf126b2a95892cbbca09391e1e87a9 Mon Sep 17 00:00:00 2001 From: Hang Lei Date: Fri, 19 Aug 2022 14:44:51 +0800 Subject: [PATCH 6/7] Add python_package arg --- azure-pipelines.yml | 12 ++++++------ scripts/release/rpm/azure-cli.spec | 4 +--- scripts/release/rpm/fedora.dockerfile | 6 +++--- scripts/release/rpm/pipeline.sh | 10 +++++----- scripts/release/rpm/ubi.dockerfile | 6 +++--- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 95a465f2af8..d79ff207f9c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -640,22 +640,22 @@ jobs: docker_file: ubi image: registry.access.redhat.com/ubi8/ubi:8.4 artifact: rpm-ubi8 - devel_package: python39-devel + python_package: python39 Red Hat Universal Base Image 9: docker_file: ubi image: registry.access.redhat.com/ubi9/ubi:9.0.0 artifact: rpm-ubi9 - devel_package: python3.9-devel + python_package: python3.9 Fedora35: - docker_file: ubi + docker_file: fedora image: fedora:35 artifact: rpm-fedora35 - devel_package: python3-devel + python_package: python3 Fedora36: - docker_file: ubi + docker_file: fedora image: fedora:36 artifact: rpm-fedora36 - devel_package: python3-devel + python_package: python3 steps: - task: Bash@3 displayName: 'Build Rpm Package' diff --git a/scripts/release/rpm/azure-cli.spec b/scripts/release/rpm/azure-cli.spec index daa7840d3b2..040618f1cf2 100644 --- a/scripts/release/rpm/azure-cli.spec +++ b/scripts/release/rpm/azure-cli.spec @@ -14,8 +14,6 @@ %define python_package %{getenv:PYTHON_PACKAGE} # The Python executable name, such as python3.9, python3 %define python_cmd %{getenv:PYTHON_CMD} -# The Python devel package name, such as python3.9-devel, python3-devel -%define python_devel %{getenv:DEVEL-PACKAGE} %define name azure-cli %define release 1%{?dist} @@ -35,7 +33,7 @@ Prefix: /usr Prefix: /etc BuildRequires: gcc, libffi-devel, openssl-devel, perl -BuildRequires: %{python_devel} +BuildRequires: %{python_package}-devel %global _python_bytecompile_errors_terminate_build 0 diff --git a/scripts/release/rpm/fedora.dockerfile b/scripts/release/rpm/fedora.dockerfile index 0cc4c0831de..ea8b6c45cae 100644 --- a/scripts/release/rpm/fedora.dockerfile +++ b/scripts/release/rpm/fedora.dockerfile @@ -2,17 +2,17 @@ ARG image=fedora:35 FROM ${image} AS build-env ARG cli_version=dev -ARG devel_package=python3-devel +ARG python_package=python3 RUN dnf update -y -RUN dnf install -y wget rpm-build gcc libffi-devel $devel_package openssl-devel make bash coreutils diffutils patch dos2unix perl +RUN dnf install -y wget rpm-build gcc libffi-devel ${python_package}-devel openssl-devel make bash coreutils diffutils patch dos2unix perl WORKDIR /azure-cli COPY . . RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ - REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=python3 PYTHON_CMD=python3 DEVEL_PACKAGE=$devel_package \ + REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=$python_package PYTHON_CMD=python3 \ rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \ cp /root/rpmbuild/RPMS/x86_64/azure-cli-${cli_version}-1.*.x86_64.rpm /azure-cli-dev.rpm diff --git a/scripts/release/rpm/pipeline.sh b/scripts/release/rpm/pipeline.sh index 135a95124d1..2cc5810e418 100755 --- a/scripts/release/rpm/pipeline.sh +++ b/scripts/release/rpm/pipeline.sh @@ -10,8 +10,8 @@ set -exv : "${DOCKER_FILE:?DOCKER_FILE environment variable not set.}" # IMAGE should be RHEL or Fedora image url : "${IMAGE:?IMAGE environment variable not set.}" -# DEVEL_PACKAGE should be python-devel package name -: "${DEVEL_PACKAGE:?DEVEL_PACKAGE environment variable not set.}" +# PYTHON_PACKAGE should be python package name +: "${PYTHON_PACKAGE:?PYTHON_PACKAGE 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` @@ -20,7 +20,7 @@ docker build \ --target build-env \ --build-arg cli_version=${CLI_VERSION} \ --build-arg image=${IMAGE} \ - --build-arg devel_package=${DEVEL_PACKAGE} \ + --build-arg python_package=${PYTHON_PACKAGE} \ -f ./scripts/release/rpm/${DOCKER_FILE}.dockerfile \ -t azure/azure-cli:${DOCKER_FILE}-builder \ . @@ -29,14 +29,14 @@ docker build \ docker build \ --build-arg cli_version=${CLI_VERSION} \ --build-arg image=${IMAGE} \ - --build-arg devel_package=${DEVEL_PACKAGE} \ + --build-arg python_package=${PYTHON_PACKAGE} \ -f ./scripts/release/rpm/${DOCKER_FILE}.dockerfile \ -t azure/azure-cli:${DOCKER_FILE} \ . # Extract the built RPM so that it can be distributed independently. # The RPM file looks like azure-cli-2.32.0-1.el7.x86_64.rpm -id=$(docker create azure/azure-cli:${IMAGE}-builder) +id=$(docker create azure/azure-cli:${DOCKER_FILE}-builder) # 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:/root/rpmbuild/RPMS/x86_64/. ${BUILD_STAGINGDIRECTORY} diff --git a/scripts/release/rpm/ubi.dockerfile b/scripts/release/rpm/ubi.dockerfile index fab849cb68a..b1ecef72fad 100644 --- a/scripts/release/rpm/ubi.dockerfile +++ b/scripts/release/rpm/ubi.dockerfile @@ -2,13 +2,13 @@ # Red Hat Universal Base Image 9: https://catalog.redhat.com/software/containers/ubi9/ubi/615bcf606feffc5384e8452e ARG image=registry.access.redhat.com/ubi8/ubi:8.4 -ARG devel_package=python39-devel FROM ${image} AS build-env ARG cli_version=dev +ARG python_package=python39 RUN yum update -y -RUN yum install -y wget rpm-build gcc libffi-devel $devel_package openssl-devel make bash diffutils patch dos2unix perl +RUN yum install -y wget rpm-build gcc libffi-devel ${python_package}-devel openssl-devel make bash diffutils patch dos2unix perl WORKDIR /azure-cli @@ -17,7 +17,7 @@ COPY . . # RHEL 8's 'python3' is Python 3.6. RHEL 9's 'python3' is Python 3.9. # We have to explicitly specify 'python39' to install Python 3.9. RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \ - REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=python39 PYTHON_CMD=python3.9 DEVEL_PACKAGE=$devel_package \ + REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=$python_package PYTHON_CMD=python3.9 \ rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \ cp /root/rpmbuild/RPMS/x86_64/azure-cli-${cli_version}-1.*.x86_64.rpm /azure-cli-dev.rpm From f16eaa1a929c8b7a7c8167b01f5ba38d4ccebc3e Mon Sep 17 00:00:00 2001 From: Hang Lei Date: Mon, 22 Aug 2022 12:00:16 +0800 Subject: [PATCH 7/7] Rename docker_file to dockerfile --- azure-pipelines.yml | 8 ++++---- scripts/release/rpm/pipeline.sh | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d79ff207f9c..6ca010e74a7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -637,22 +637,22 @@ jobs: strategy: matrix: Red Hat Universal Base Image 8: - docker_file: ubi + dockerfile: ubi image: registry.access.redhat.com/ubi8/ubi:8.4 artifact: rpm-ubi8 python_package: python39 Red Hat Universal Base Image 9: - docker_file: ubi + dockerfile: ubi image: registry.access.redhat.com/ubi9/ubi:9.0.0 artifact: rpm-ubi9 python_package: python3.9 Fedora35: - docker_file: fedora + dockerfile: fedora image: fedora:35 artifact: rpm-fedora35 python_package: python3 Fedora36: - docker_file: fedora + dockerfile: fedora image: fedora:36 artifact: rpm-fedora36 python_package: python3 diff --git a/scripts/release/rpm/pipeline.sh b/scripts/release/rpm/pipeline.sh index 2cc5810e418..106af0ad627 100755 --- a/scripts/release/rpm/pipeline.sh +++ b/scripts/release/rpm/pipeline.sh @@ -6,8 +6,8 @@ set -exv : "${BUILD_STAGINGDIRECTORY:?BUILD_STAGINGDIRECTORY environment variable not set.}" -# DOCKER_FILE should be one of 'ubi' or 'fedora' -: "${DOCKER_FILE:?DOCKER_FILE environment variable not set.}" +# DOCKERFILE should be one of 'ubi' or 'fedora' +: "${DOCKERFILE:?DOCKERFILE environment variable not set.}" # IMAGE should be RHEL or Fedora image url : "${IMAGE:?IMAGE environment variable not set.}" # PYTHON_PACKAGE should be python package name @@ -21,8 +21,8 @@ docker build \ --build-arg cli_version=${CLI_VERSION} \ --build-arg image=${IMAGE} \ --build-arg python_package=${PYTHON_PACKAGE} \ - -f ./scripts/release/rpm/${DOCKER_FILE}.dockerfile \ - -t azure/azure-cli:${DOCKER_FILE}-builder \ + -f ./scripts/release/rpm/${DOCKERFILE}.dockerfile \ + -t azure/azure-cli:${DOCKERFILE}-builder \ . # Continue the previous build, and create a container that has the current azure-cli build but not the source code. @@ -30,13 +30,13 @@ docker build \ --build-arg cli_version=${CLI_VERSION} \ --build-arg image=${IMAGE} \ --build-arg python_package=${PYTHON_PACKAGE} \ - -f ./scripts/release/rpm/${DOCKER_FILE}.dockerfile \ - -t azure/azure-cli:${DOCKER_FILE} \ + -f ./scripts/release/rpm/${DOCKERFILE}.dockerfile \ + -t azure/azure-cli:${DOCKERFILE} \ . # Extract the built RPM so that it can be distributed independently. # The RPM file looks like azure-cli-2.32.0-1.el7.x86_64.rpm -id=$(docker create azure/azure-cli:${DOCKER_FILE}-builder) +id=$(docker create azure/azure-cli:${DOCKERFILE}-builder) # 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:/root/rpmbuild/RPMS/x86_64/. ${BUILD_STAGINGDIRECTORY}