Skip to content

[Packaging] Add Dockerfile.mariner to support Mariner build#20061

Merged
jiasli merged 11 commits intoAzure:devfrom
mfrw:mfrw/build-mariner
Dec 2, 2021
Merged

[Packaging] Add Dockerfile.mariner to support Mariner build#20061
jiasli merged 11 commits intoAzure:devfrom
mfrw:mfrw/build-mariner

Conversation

@mfrw
Copy link
Copy Markdown
Member

@mfrw mfrw commented Oct 27, 2021

  • [Packaging] Add Dockerfile for mariner
  • [Packaging] Update Readme to reflect mariner build steps
  • [Packaging] Fix test for fedora Dockerfile

Description

  • Add docker build support for creating azure-cli.rpm for CBL-Mariner.
  • Update the Readme to document mariner specific build.
  • Update Dockerfile.fedora to include the az --version.

Testing Guide

Created a dev rpm and tested it with installation & uninstallation.

Step 14/14 : RUN rpm -i ./azure-cli-*-1*.rpm &&     az --version
 ---> Running in 0d18c0d9c386
WARNING: You have 2 updates available. Consider updating your CLI installation with 'az upgrade'
azure-cli                         2.29.0 *

core                              2.29.0 *
telemetry                          1.0.6

Python location '/usr/bin/python3.7'
Extensions directory '/root/.azure/cliextensions'

Python (Linux) 3.7.10 (default, Sep 28 2021, 20:29:11)
[GCC 9.1.0]

Legal docs and information: aka.ms/AzureCliLegal



Please let us know how we are doing: https://aka.ms/azureclihats
and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy
Removing intermediate container 0d18c0d9c386
 ---> 5b549ca69286
Successfully built 5b549ca69286
Successfully tagged azure/azure-cli:mariner-builder

History Notes

NA


This checklist is used to make sure that common guidelines for a pull request are followed.

mfrw added 3 commits October 27, 2021 11:01
Modify the `azure-cli.spec` with a %if conditional macro to handle
mariner specific installation path.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
@mfrw mfrw requested review from jiasli and kairu-ms as code owners October 27, 2021 05:38
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
python_cmd=%{python_cmd}
if command -v ${python_version} &>/dev/null; then python_cmd=${python_version}; fi
%if 0%{?cblmariner}
AZ_INSTALLER=RPM PYTHONPATH=\"%{_libdir}/az/lib/${python_version}/site-packages\" \$python_cmd -sm azure.cli \"\$@\"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There seems to be no difference between %{_libdir} and "$bin_dir"/../%{_lib}:

# command -v az
/usr/bin/az

# cat /usr/bin/az
#!/usr/bin/env bash
bin_dir=`cd "$(dirname "$BASH_SOURCE[0]")"; pwd`
python_cmd=python3
if command -v python3.6 &>/dev/null; then python_cmd=python3.6; fi
AZ_INSTALLER=RPM PYTHONPATH="$bin_dir"/../lib64/az/lib/python3.6/site-packages $python_cmd -sm azure.cli "$@"

# rpm --eval %{_lib}
lib64

# rpm --eval %{_libdir}
/usr/lib64

The if-else seems redundant.

See https://rpm-packaging-guide.github.io/#rpm-macros

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I tried that earlier, but that seemed to fail to find module specification (below):

root [ / ]# ls /usr/bin/az
/usr/bin/az
root [ / ]# cat /usr/bin/az
#!/usr/bin/env bash
bin_dir=`cd "$(dirname "$BASH_SOURCE[0]")"; pwd`
python_cmd=python3
if command -v python3.7 &>/dev/null; then python_cmd=python3.7; fi
AZ_INSTALLER=RPM PYTHONPATH="$bin_dir"/..//usr/lib/az/lib/python3.7/site-packages $python_cmd -sm azure.cli "$@"
root [ / ]# az
/usr/bin/python3.7: Error while finding module specification for 'azure.cli' (ModuleNotFoundError: No module named 'azure')
root [ / ]# 

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like %{_lib} doesn't expand correctly. Is this a bug on the image?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The macro %{_lib} & %{_libdir} both point to /usr/lib.
When we do the "$bin_dir"/../%{_lib}/az/lib/......... it points to a location which is not present, i.e
/usr/usr/lib/az/lib,

Mariner's %{_bindir} is /usr/bin and not /bin. This is the reason to have an %if else clause in the spec.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I will do some research in next sprint. We may possibly find one line that works everywhere.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think %{_lib} is used here for a reason. Without it being available, we can't figure out the PYTHONPATH if the RPM is installed to some other place. See #17491 (comment)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's move the entry script work to #20574.

Copy link
Copy Markdown
Member Author

@mfrw mfrw Dec 1, 2021

Choose a reason for hiding this comment

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

Do you want me to rebase this PR with the one you created or should I modify this PR with the change:

s/%{_lib}/lib64/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please just don't change this file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@jiasli As discussed offline, copying the az-cli.spec changes from PR #20574.

@yonzhan yonzhan added this to the Nov 2021 (2021-12-07) milestone Oct 27, 2021
@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Oct 27, 2021

Support Mariner

@yonzhan yonzhan self-requested a review October 27, 2021 13:39
@mfrw mfrw requested a review from jiasli October 28, 2021 06:05
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
@mfrw
Copy link
Copy Markdown
Member Author

mfrw commented Nov 17, 2021

@yonzhan, @kairu-ms, @jiasli -- Team, a gentle reminder on this.
Do we have an update for this PR.

@jiasli jiasli requested a review from wangzelin007 as a code owner December 1, 2021 09:43
mfrw and others added 4 commits December 1, 2021 19:28
Co-authored-by: Jiashuo Li <4003950+jiasli@users.noreply.github.com>
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>

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 && \
cp /usr/src/mariner/RPMS/x86_64/azure-cli-${cli_version}-1.x86_64.rpm /azure-cli-dev.rpm
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For CentOS, it is /root/rpmbuild/RPMS/x86_64/azure-cli-${cli_version}-1.*.x86_64.rpm. Interesting difference.

@jiasli jiasli merged commit 23a4a35 into Azure:dev Dec 2, 2021
@mfrw mfrw deleted the mfrw/build-mariner branch December 2, 2021 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants