-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Support local builds for all installers (Docker, MSI, Pip, Debian, RPM) #4696
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,50 +11,32 @@ set -ex | |
|
||
if [ -z "$1" ] | ||
then | ||
echo "First argument should be path to executable debian directory creator." | ||
echo "Argument should be path to local repo." | ||
exit 1 | ||
fi | ||
|
||
local_repo=$2 | ||
if [ -z "$local_repo" ] | ||
then | ||
: "${CLI_DOWNLOAD_SHA256:?CLI_DOWNLOAD_SHA256 environment variable not set.}" | ||
fi | ||
local_repo=$1 | ||
|
||
sudo apt-get update | ||
|
||
debian_directory_creator=$1 | ||
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
debian_directory_creator=$script_dir/dir_creator.sh | ||
|
||
# Install dependencies for the build | ||
sudo apt-get install -y libssl-dev libffi-dev python3-dev debhelper | ||
# Download, Extract, Patch, Build CLI | ||
tmp_pkg_dir=$(mktemp -d) | ||
working_dir=$(mktemp -d) | ||
cd $working_dir | ||
if [ -z "$local_repo" ] | ||
source_dir=$local_repo | ||
deb_file=$local_repo/../azure-cli_${CLI_VERSION}-1_all.deb | ||
az_completion_file=$source_dir/az.completion | ||
# clean up old build output | ||
if [ -d "$source_dir/debian" ] | ||
then | ||
source_archive=$working_dir/azure-cli-${CLI_VERSION}.tar.gz | ||
source_dir=$working_dir/azure-cli-${CLI_VERSION} | ||
deb_file=$working_dir/azure-cli_${CLI_VERSION}-1_all.deb | ||
az_completion_file=$source_dir/az.completion | ||
wget https://azurecliprod.blob.core.windows.net/releases/azure-cli_packaged_${CLI_VERSION}.tar.gz -qO $source_archive | ||
echo "$CLI_DOWNLOAD_SHA256 $source_archive" | sha256sum -c - | ||
mkdir $source_dir | ||
# Extract archive | ||
archive_extract_dir=$(mktemp -d) | ||
tar -xvzf $source_archive -C $archive_extract_dir | ||
cp -r $archive_extract_dir/azure-cli_packaged_${CLI_VERSION}/* $source_dir | ||
else | ||
source_dir=$local_repo | ||
deb_file=$local_repo/../azure-cli_${CLI_VERSION}-1_all.deb | ||
az_completion_file=$source_dir/packaged_releases/az.completion | ||
# clean up old build output | ||
if [ -d "$source_dir/debian" ] | ||
then | ||
rm -rf $source_dir/debian | ||
fi | ||
cp $local_repo/privates/*.whl $tmp_pkg_dir | ||
rm -rf $source_dir/debian | ||
fi | ||
[ -d $local_repo/privates ] && cp $local_repo/privates/*.whl $tmp_pkg_dir | ||
|
||
# Build Python from source and include | ||
python_dir=$(mktemp -d) | ||
|
@@ -74,7 +56,8 @@ make install | |
# It does not affect the built .deb file though. | ||
$source_dir/python_env/bin/pip3 install wheel | ||
for d in $source_dir/src/azure-cli $source_dir/src/azure-cli-core $source_dir/src/azure-cli-nspkg $source_dir/src/azure-cli-command_modules-nspkg $source_dir/src/command_modules/azure-cli-*/; do cd $d; $source_dir/python_env/bin/python3 setup.py bdist_wheel -d $tmp_pkg_dir; cd -; done; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if easy, please move the loop body to new lines. The current line is too long. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do in next PR. |
||
$source_dir/python_env/bin/pip3 install azure-cli --find-links $tmp_pkg_dir | ||
all_modules=`find $tmp_pkg_dir -name "*.whl"` | ||
$source_dir/python_env/bin/pip3 install $all_modules | ||
$source_dir/python_env/bin/pip3 install --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg | ||
# WORKAROUND: Newer versions of cryptography do not work on Bash on Windows / WSL - see https://github.com/Azure/azure-cli/issues/4154 | ||
# If you *have* to use a newer version of cryptography in the future, verify that it works on WSL also. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,7 @@ | |
%define name azure-cli | ||
%define release 1%{?dist} | ||
%define version %{getenv:CLI_VERSION} | ||
%define source_sha256 %{getenv:CLI_DOWNLOAD_SHA256} | ||
%define source_url https://azurecliprod.blob.core.windows.net/releases/azure-cli_packaged_%{version}.tar.gz | ||
%define repo_path %{getenv:REPO_PATH} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too bad that relative paths are not supported, which otherwise would save an environment variable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added it so user doesn't have to run script from root of repo. |
||
%define venv_url https://pypi.python.org/packages/source/v/virtualenv/virtualenv-15.0.0.tar.gz | ||
%define venv_sha256 70d63fb7e949d07aeb37f6ecc94e8b60671edb15b890aa86dba5dfaf2225dc19 | ||
%define cli_lib_dir %{_libdir}/az | ||
|
@@ -20,7 +19,6 @@ License: MIT | |
Name: %{name} | ||
Version: %{version} | ||
Release: %{release} | ||
Source0: %{source_url} | ||
Url: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli | ||
BuildArch: x86_64 | ||
Requires: python | ||
|
@@ -40,11 +38,6 @@ A great cloud needs great tools; we're excited to introduce Azure CLI 2.0, | |
tmp_venv_archive=$(mktemp) | ||
tmp_source_archive=$(mktemp) | ||
|
||
# Download, Extract Source | ||
wget %{source_url} -qO $tmp_source_archive | ||
echo "%{source_sha256} $tmp_source_archive" | sha256sum -c - | ||
tar -xvzf $tmp_source_archive -C %{_builddir} | ||
|
||
# Download, Extract Virtualenv | ||
wget %{venv_url} -qO $tmp_venv_archive | ||
echo "%{venv_sha256} $tmp_venv_archive" | sha256sum -c - | ||
|
@@ -55,13 +48,16 @@ tar -xvzf $tmp_venv_archive -C %{_builddir} | |
python %{_builddir}/virtualenv-15.0.0/virtualenv.py --python python %{buildroot}%{cli_lib_dir} | ||
|
||
# Build the wheels from the source | ||
source_dir=%{_builddir}/azure-cli_packaged_%{version} | ||
source_dir=%{repo_path} | ||
dist_dir=$(mktemp -d) | ||
for d in $source_dir/src/azure-cli $source_dir/src/azure-cli-core $source_dir/src/azure-cli-nspkg $source_dir/src/azure-cli-command_modules-nspkg $source_dir/src/command_modules/azure-cli-*/; \ | ||
do cd $d; %{buildroot}%{cli_lib_dir}/bin/python setup.py bdist_wheel -d $dist_dir; cd -; done; | ||
|
||
[ -d $source_dir/privates ] && cp $source_dir/privates/*.whl $dist_dir | ||
|
||
# Install the CLI | ||
%{buildroot}%{cli_lib_dir}/bin/pip install azure-cli --find-links $dist_dir | ||
all_modules=`find $dist_dir -name "*.whl"` | ||
%{buildroot}%{cli_lib_dir}/bin/pip install $all_modules | ||
%{buildroot}%{cli_lib_dir}/bin/pip install --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg | ||
|
||
# Fix up %{buildroot} appearing in some files... | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Wheel Builds | ||
============ | ||
|
||
For example: | ||
``` | ||
whl_dir=$(mktemp -d) | ||
python build_scripts/wheels/build.py $whl_dir . | ||
ls -la $whl_dir | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove this folder from the image after build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The folder would only contain the source code due to the .dockerignore file we have.
Don't see harm in including it.