Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 7 additions & 3 deletions scripts/release/rpm/azure-cli.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
%define dist .el%{?rhel}
%endif

%define python_cmd python3
# The Python package name for dnf/yum/tdnf, such as python39, python3
%define python_package %{getenv:PYTHON_PACKAGE}
# The Python executable name, such as python3.9, python3
%define python_cmd %{getenv:PYTHON_CMD}

%define name azure-cli
%define release 1%{?dist}
Expand All @@ -25,12 +28,12 @@ Version: %{version}
Release: %{release}
Url: https://docs.microsoft.com/cli/azure/install-azure-cli
BuildArch: x86_64
Requires: %{python_cmd}
Requires: %{python_package}
Prefix: /usr
Prefix: /etc

BuildRequires: gcc, libffi-devel, openssl-devel, perl
BuildRequires: %{python_cmd}-devel
BuildRequires: %{python_package}-devel

%global _python_bytecompile_errors_terminate_build 0

Expand Down Expand Up @@ -66,6 +69,7 @@ for d in %{buildroot}%{cli_lib_dir}/bin/*; do perl -p -i -e "s#%{buildroot}##g"
# The only solution left is to hard-code 'lib64' as we only release 64-bit RPM packages.
mkdir -p %{buildroot}%{_bindir}
python_version=$(ls %{buildroot}%{cli_lib_dir}/lib/ | head -n 1)
# We make %{python_cmd} the default executable, but if there is a more precise match, such as python3.9, we prefer that.
printf "#!/usr/bin/env bash
bin_dir=\`cd \"\$(dirname \"\$BASH_SOURCE[0]\")\"; pwd\`
python_cmd=%{python_cmd}
Expand Down
4 changes: 3 additions & 1 deletion scripts/release/rpm/centos7.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ WORKDIR /azure-cli

COPY . .

# CentOS 7 only has 'python3' package, which is Python 3.6.
RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \
REPO_PATH=$(pwd) CLI_VERSION=$cli_version rpmbuild -v -bb --clean 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 centos:${tag} AS execution-env
Expand Down
6 changes: 5 additions & 1 deletion scripts/release/rpm/mariner.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ WORKDIR /azure-cli

COPY . .

# Mariner only has 'python3' package. It has no version-specific packages, like 'python39'.
# - On Mariner 1.0, 'python3' is Python 3.7
# - On Mariner 2.0, 'python3' is Python 3.9
Comment on lines +15 to +16

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think this is good. Mariner should have specific versions of Python packages (microsoft/azurelinux#3058):

Explicit is better than implicit.
-- PEP 20 – The Zen of Python

RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \
REPO_PATH=$(pwd) CLI_VERSION=$cli_version rpmbuild -v -bb --clean 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/x86_64/azure-cli-${cli_version}-1.x86_64.rpm /azure-cli-dev.rpm

FROM ${image}:${tag} AS execution-env
Expand Down
8 changes: 5 additions & 3 deletions scripts/release/rpm/ubi8.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ 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 python3-devel openssl-devel make bash diffutils patch dos2unix python3-virtualenv perl

@jiasli Jiashuo Li (jiasli) May 25, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We use venv built-in module now. No need to install python3-virtualenv.

RHEL 8's python3-virtualenv actually requires Python 3.6.

# yum install python3-virtualenv
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 2:24:15 ago on Wed May 25 04:37:38 2022.
Dependencies resolved.
===========================================================================================================================
 Package                       Architecture  Version                                          Repository              Size
===========================================================================================================================
Installing:
 python3-virtualenv            noarch        15.1.0-21.module+el8.5.0+12207+5c5719bc          ubi-8-appstream        101 k
Upgrading:
 chkconfig                     x86_64        1.19.1-1.el8                                     ubi-8-baseos           198 k
 platform-python               x86_64        3.6.8-45.el8                                     ubi-8-baseos            85 k
 python3-libs                  x86_64        3.6.8-45.el8                                     ubi-8-baseos           7.8 M
Installing dependencies:
 libpkgconf                    x86_64        1.4.2-1.el8                                      ubi-8-baseos            35 k
 pkgconf                       x86_64        1.4.2-1.el8                                      ubi-8-baseos            38 k
 pkgconf-m4                    noarch        1.4.2-1.el8                                      ubi-8-baseos            17 k
 pkgconf-pkg-config            x86_64        1.4.2-1.el8                                      ubi-8-baseos            15 k
 platform-python-devel         x86_64        3.6.8-45.el8                                     ubi-8-appstream        250 k
 platform-python-pip           noarch        9.0.3-22.el8                                     ubi-8-baseos           1.6 M
 python-rpm-macros             noarch        3-41.el8                                         ubi-8-appstream         15 k
 python-srpm-macros            noarch        3-41.el8                                         ubi-8-appstream         15 k
 python3-pip                   noarch        9.0.3-22.el8                                     ubi-8-appstream         20 k
 python3-rpm-generators        noarch        5-7.el8                                          ubi-8-appstream         25 k
 python3-rpm-macros            noarch        3-41.el8                                         ubi-8-appstream         14 k
 python3-setuptools            noarch        39.2.0-6.el8                                     ubi-8-baseos           163 k
 python3-wheel-wheel           noarch        1:0.31.1-3.module+el8.5.0+12207+5c5719bc         ubi-8-appstream         45 k
 python36                      x86_64        3.6.8-38.module+el8.5.0+12207+5c5719bc           ubi-8-appstream         19 k
 python36-devel                x86_64        3.6.8-38.module+el8.5.0+12207+5c5719bc           ubi-8-appstream         17 k
Enabling module streams:
 python36                                    3.6

Transaction Summary
===========================================================================================================================
Install  16 Packages
Upgrade   3 Packages

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we also remove python3-virtualenv in centos7.dockerfile?

RUN yum install -y wget rpm-build gcc libffi-devel python39-devel 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.
RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \
REPO_PATH=$(pwd) CLI_VERSION=$cli_version rpmbuild -v -bb --clean 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 && \
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

RUN yum update -y
RUN yum install -y python3 python3-virtualenv
RUN yum install -y python39

COPY --from=build-env /azure-cli-dev.rpm ./
RUN rpm -i ./azure-cli-dev.rpm && \
Expand Down