{Packaging} Unblock installation in customized location for deb and RPM #17491
Merged
fengzhou-msft merged 7 commits intoAzure:devfrom Apr 7, 2021
Merged
{Packaging} Unblock installation in customized location for deb and RPM #17491fengzhou-msft merged 7 commits intoAzure:devfrom
fengzhou-msft merged 7 commits intoAzure:devfrom
Conversation
…ux_custom_install
fengzhou-msft
commented
Mar 29, 2021
| mkdir -p %{buildroot}%{_bindir} | ||
| python_version=$(ls %{buildroot}%{cli_lib_dir}/lib/ | head -n 1) | ||
| printf "#!/usr/bin/env bash\nAZ_INSTALLER=RPM PYTHONPATH=%{cli_lib_dir}/lib/${python_version}/site-packages /usr/bin/%{python_cmd} -sm azure.cli \"\$@\"" > %{buildroot}%{_bindir}/az | ||
| printf "#!/usr/bin/env bash\nbin_dir=\`cd \"\$(dirname \"\$BASH_SOURCE[0]\")\"; pwd\`\nAZ_INSTALLER=RPM PYTHONPATH=\"\$bin_dir\"/../%{_lib}/az/lib/${python_version}/site-packages %{python_cmd} -sm azure.cli \"\$@\"" > %{buildroot}%{_bindir}/az |
Member
Author
There was a problem hiding this comment.
The script becomes:
#!/usr/bin/env bash
bin_dir=`cd "$(dirname "$BASH_SOURCE[0]")"; pwd`
AZ_INSTALLER=RPM PYTHONPATH="$bin_dir"/../lib64/az/lib/python3.6/site-packages python3 -sm azure.cli "$@"
Member
Author
There was a problem hiding this comment.
Use python3 instead of hard-coded /usr/bin/python3. This gives users flexibility to use any installed python3 by manipulating the PATH environment variable.
Member
There was a problem hiding this comment.
%{_lib} causes problem on Mariner as it is different from that on Fedora/CentOS/RedHat:
> docker run -it --rm fedora rpm --eval '%{_lib}'
lib64
> docker run -it --rm centos rpm --eval '%{_lib}'
lib64
> docker run -it --rm redhat/ubi8-minimal rpm --eval '%{_lib}'
lib64
> docker run -it --rm cblmariner.azurecr.io/base/core:1.0 rpm --eval '%{_lib}'
/usr/lib
| ${TAB}cp -a python_env/* debian/azure-cli/opt/az | ||
| ${TAB}mkdir -p debian/azure-cli/usr/bin/ | ||
| ${TAB}echo "\043!/usr/bin/env bash\nAZ_INSTALLER=DEB /opt/az/bin/python3 -Im azure.cli \"\044\100\"" > debian/azure-cli/usr/bin/az | ||
| ${TAB}echo "\043!/usr/bin/env bash\nbin_dir=\140cd \"\044(dirname \"\044BASH_SOURCE[0]\")\"; pwd\140\nAZ_INSTALLER=DEB \"\044bin_dir\"/../../opt/az/bin/python3 -Im azure.cli \"\044\100\"" > debian/azure-cli/usr/bin/az |
Member
Author
There was a problem hiding this comment.
The script becomes:
#!/usr/bin/env bash
bin_dir=`cd "$(dirname "$BASH_SOURCE[0]")"; pwd`
AZ_INSTALLER=DEB "$bin_dir"/../../opt/az/bin/python3 -Im azure.cli "$@"
| _print("Python location '{}'".format(sys.executable)) | ||
| _print("Extensions directory '{}'".format(EXTENSIONS_DIR)) | ||
| import os | ||
| _print("Python location '{}'".format(os.path.abspath(sys.executable))) |
Member
Author
There was a problem hiding this comment.
Use abspath so on Ubuntu the bundle python won't show path like /usr/bin/../../opt/az/bin/python3, instead it will just show /opt/az/bin/python3.
fengzhou-msft
commented
Mar 31, 2021
Comment on lines
+29
to
+30
| Prefix: /usr | ||
| Prefix: /etc |
houk-ms
approved these changes
Apr 6, 2021
jiasli
approved these changes
Apr 6, 2021
This was referenced Dec 1, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Resolve #17221
This PR provides a more general
azscript to unblock customized location install, but it is not aimed to fully support custom install for deb and RPM as custom install is not fully tested and may cause some unknown issues. It is not a recommended way ofazure-cliinstallation.Testing Guide
build_testbranch build has the packages for the same code).History Notes
[Packaging] BREAKING CHANGE: RPM installed az now uses
python3instead of hard-coded/usr/bin/python3.This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.