diff --git a/build_scripts/debian/README.md b/build_scripts/debian/README.md deleted file mode 100644 index f1c92138bdb..00000000000 --- a/build_scripts/debian/README.md +++ /dev/null @@ -1,30 +0,0 @@ -Debian Packaging -================ - -Updating the Debian package ---------------------------- - -On a build machine (e.g. new Ubuntu 14.04 VM), run the build script. - -For example: -``` -git clone https://github.com/azure/azure-cli -cd azure-cli -export CLI_VERSION=2.0.9 \ - && export BUILD_ARTIFACT_DIR=$(mktemp -d)\ - && build_scripts/debian/build.sh $(pwd) -``` - -Note: The paths above have to be full paths, not relative otherwise the build will fail. - -Now you have built the package, upload the package to the apt repository. - - -Verification ------------- - -``` -sudo dpkg -i azure-cli_${CLI_VERSION}-1_all.deb -az -az --version -``` diff --git a/build_scripts/debian/build.sh b/build_scripts/debian/build.sh deleted file mode 100644 index 9e7ea6200e2..00000000000 --- a/build_scripts/debian/build.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env bash -#--------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -#--------------------------------------------------------------------------------------------- - -set -ex - -: "${CLI_VERSION:?CLI_VERSION environment variable not set.}" -: "${BUILD_ARTIFACT_DIR:?BUILD_ARTIFACT_DIR environment variable not set.}" - -if [ -z "$1" ] - then - echo "Argument should be path to local repo." - exit 1 -fi - -local_repo=$1 - -sudo apt-get update - -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 -source_dir=$local_repo -deb_file=$local_repo/../azure-cli_${CLI_VERSION}-${CLI_VERSION_REVISION:=1}_all.deb -az_completion_file=$source_dir/az.completion -# clean up old build output -if [ -d "$source_dir/debian" ] - then - 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) -python_archive=$(mktemp) -wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz -qO $python_archive -tar -xvzf $python_archive -C $python_dir -echo "Python dir is $python_dir" -# clean any previous make files -make clean || echo "Nothing to clean" -$python_dir/*/configure --srcdir $python_dir/* --prefix $source_dir/python_env -make -# required to run the 'make install' -sudo apt-get install -y zlib1g-dev -make install - -# note: This installation step could happen in debian/rules but was unable to escape $ char. -# 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; -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 -# Add the debian files -mkdir $source_dir/debian -# Create temp dir for the debian/ directory used for CLI build. -cli_debian_dir_tmp=$(mktemp -d) - -$debian_directory_creator $cli_debian_dir_tmp $az_completion_file $source_dir -cp -r $cli_debian_dir_tmp/* $source_dir/debian -cd $source_dir -dpkg-buildpackage -us -uc -echo "The archive is available at $working_dir/azure-cli_${CLI_VERSION}-${CLI_VERSION_REVISION:=1}_all.deb" -cp $deb_file ${BUILD_ARTIFACT_DIR} -echo "The archive has also been copied to ${BUILD_ARTIFACT_DIR}" -echo "Done." diff --git a/build_scripts/debian/dir_creator.sh b/build_scripts/debian/dir_creator.sh deleted file mode 100644 index f14331b6cb7..00000000000 --- a/build_scripts/debian/dir_creator.sh +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env bash -#--------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -#--------------------------------------------------------------------------------------------- - -set -ex - -# Create the debian/ directory for building the azure-cli Debian package - -# This script takes an argument of the empty directory where the files will be placed. - -if [ -z "$1" ] - then - echo "No argument supplied for debian directory." - exit 1 -fi - -if [ -z "$2" ] - then - echo "No argument supplied for completion script." - exit 1 -fi - -if [ -z "$3" ] - then - echo "No argument supplied for source directory." - exit 1 -fi - -TAB=$'\t' - -debian_dir=$1 -completion_script=$2 -source_dir=$3 -mkdir $debian_dir/source - -echo '1.0' > $debian_dir/source/format -echo '9' > $debian_dir/compat - -cat > $debian_dir/changelog <<- EOM -azure-cli (${CLI_VERSION}-${CLI_VERSION_REVISION:=1}) unstable; urgency=low - - * Debian package release. - - -- Azure Python CLI Team $(date -R) - -EOM - -cat > $debian_dir/control <<- EOM -Source: azure-cli -Section: python -Priority: extra -Maintainer: Azure Python CLI Team -Build-Depends: debhelper (>= 9), libssl-dev, libffi-dev, python3-dev -Standards-Version: 3.9.5 -Homepage: https://github.com/azure/azure-cli - -Package: azure-cli -Architecture: all -Depends: \${shlibs:Depends}, \${misc:Depends} -Description: Azure CLI - A great cloud needs great tools; we're excited to introduce Azure CLI, - our next generation multi-platform command line experience for Azure. - -EOM - -cat > $debian_dir/copyright <<- EOM -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: azure-cli -Upstream-Contact: Azure Python CLI Team -Source: https://github.com/azure/azure-cli - -Files: * -Copyright: Copyright (c) Microsoft Corporation -License: MIT -Azure CLI - -Copyright (c) Microsoft Corporation - -All rights reserved. - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -EOM - -# TODO: Instead of "_ssl.cpython-36m-x86_64-linux-gnu.so" only, find all .so files with "find debian/azure-cli/opt/az -type f -name '*.so'" - -cat > $debian_dir/rules << EOM -#!/usr/bin/make -f - -# Uncomment this to turn on verbose mode. -export DH_VERBOSE=1 -export DH_OPTIONS=-v - -%: -${TAB}dh \$@ --sourcedirectory $source_dir - -override_dh_install: -${TAB}mkdir -p debian/azure-cli/opt/az -${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\n/opt/az/bin/python3 -Im azure.cli \"\044\100\"" > debian/azure-cli/usr/bin/az -${TAB}chmod 0755 debian/azure-cli/usr/bin/az -${TAB}mkdir -p debian/azure-cli/etc/bash_completion.d/ -${TAB}cat ${completion_script} > debian/azure-cli/etc/bash_completion.d/azure-cli -${TAB}dpkg-shlibdeps -v --warnings=7 -Tdebian/azure-cli.substvars -dDepends -edebian/azure-cli/opt/az/bin/python3 debian/azure-cli/opt/az/lib/python3.6/lib-dynload/_ssl.cpython-36m-x86_64-linux-gnu.so - - -override_dh_strip: -${TAB}dh_strip --exclude=_cffi_backend - -EOM - -cat $debian_dir/rules - -# debian/rules should be executable -chmod 0755 $debian_dir/rules diff --git a/build_scripts/docker/README.md b/build_scripts/docker/README.md deleted file mode 100644 index b1740a090fc..00000000000 --- a/build_scripts/docker/README.md +++ /dev/null @@ -1,35 +0,0 @@ -Docker Packaging -================ - -The Docker image is available at https://hub.docker.com/r/microsoft/azure-cli/tags/. - -Updating the Docker image -------------------------- -1. Run `docker build` with the Dockerfile. - When tagging this Docker image, choose an appropriate version number. - e.g.: ``sudo docker build --no-cache --build-arg BUILD_DATE="`date -u +"%Y-%m-%dT%H:%M:%SZ"`" --build-arg CLI_VERSION=${CLI_VERSION} -f Dockerfile -t microsoft/azure-cli:${CLI_VERSION} .`` -2. Push the image to the registry, - e.g.: `sudo docker push microsoft/azure-cli:${CLI_VERSION}` -3. Create a PR to commit the Dockerfile changes back to the repository. - - -Verification ------------- - -Run the image. - -``` -$ docker run -it microsoft/azure-cli:${CLI_VERSION} -$ az -$ az --version -``` - -Save the image -``` -docker save -o docker-microsoft-azure-cli-VERSION.tar microsoft/azure-cli:${CLI_VERSION} -``` - -Load the saved image -``` -docker load -i docker-microsoft-azure-cli-VERSION.tar -``` diff --git a/build_scripts/homebrew/README.md b/build_scripts/homebrew/README.md deleted file mode 100644 index a14e5a373d0..00000000000 --- a/build_scripts/homebrew/README.md +++ /dev/null @@ -1,35 +0,0 @@ -Homebrew Packaging -================== - - -Updating the formula --------------------- -1. Change the `url` in the formula to point to the new release and change the `sha256` value also. -2. Update the resources list in the formula (see below). -3. Run the formula verification commands (see below). -4. Submit a PR to https://github.com/Homebrew/homebrew-core. - - -Updating the resources list ---------------------------- -``` -# Create a new virtual environment first -pip install azure-cli homebrew-pypi-poet; poet -r azure-cli -``` - -Verification ------------- - -``` -brew install --build-from-source azure-cli.rb -brew test azure-cli.rb -brew audit --strict --online azure-cli.rb -``` - -More Information ----------------- -https://github.com/Homebrew/homebrew-core/blob/master/CONTRIBUTING.md - -https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md - -https://github.com/Homebrew/brew/blob/master/docs/Acceptable-Formulae.md diff --git a/build_scripts/homebrew/formula-generate.py b/build_scripts/homebrew/formula-generate.py deleted file mode 100644 index 5080943b83d..00000000000 --- a/build_scripts/homebrew/formula-generate.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env python -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- -import os -import sys -import tempfile -import hashlib -import shutil -from collections import OrderedDict -from sh import pip, git - -try: - # Attempt to load python 3 module - from urllib.request import urlopen -except ImportError: - # Import python 2 version - from urllib2 import urlopen - -HOMEBREW_REPO_URL = 'https://github.com/Homebrew/homebrew-core' -AZURE_CLI_FORMULA_PATH = os.path.join('Formula', 'azure-cli.rb') - -CLI_VERSION = os.environ['CLI_VERSION'] -UPSTREAM_URL = os.environ['UPSTREAM_URL'] -BUILD_ARTIFACTS_DIR = os.environ.get('BUILD_ARTIFACT_DIR') - -def get_homebrew_formula(): - tmp_dir = tempfile.mkdtemp() - git(['clone', '--depth', '1', HOMEBREW_REPO_URL, tmp_dir], _out=sys.stdout, _err=sys.stdout) - formula_path = os.path.join(tmp_dir, AZURE_CLI_FORMULA_PATH) - formula_content = [] - with open(formula_path) as f: - formula_content = f.readlines() - formula_content = [x.rstrip() for x in formula_content] - return formula_path, formula_content - -def modify_url(formula_content): - for line_no, line_contents in enumerate(formula_content): - # Find/replace first url - if 'url' in line_contents: - formula_content[line_no] = ' url "' + UPSTREAM_URL + '"' - break - -def modify_sha256(formula_content): - tmp_file = tempfile.mkstemp()[1] - response = urlopen(UPSTREAM_URL) - with open(tmp_file, 'wb') as f: - f.write(response.read()) - sha256 = hashlib.sha256() - with open(tmp_file, 'rb') as f: - sha256.update(f.read()) - computed_hash = sha256.hexdigest() - for line_no, line_contents in enumerate(formula_content): - # Find/replace first sha256 - if 'sha256' in line_contents: - formula_content[line_no] = ' sha256 "' + computed_hash + '"' - break - -def _should_include_resource(r): - return not r.startswith('azure-cli') and r not in ['futures'] - -def modify_resources(formula_content): - start_resources_line_no = None - end_resources_line_no = None - for line_no, line_contents in enumerate(formula_content): - if 'resource' in line_contents and start_resources_line_no is None: - start_resources_line_no = line_no - if 'def install' in line_contents and end_resources_line_no is None: - end_resources_line_no = line_no - 1 - break - # Delete resources block - del formula_content[start_resources_line_no : end_resources_line_no] - # The script will have installed homebrew-pypi-poet by this point so we can import - from poet.poet import make_graph, RESOURCE_TEMPLATE - nodes = make_graph('azure-cli') - filtered_nodes = OrderedDict([(n, nodes[n]) for n in nodes if _should_include_resource(n)]) - resources_stanza = '\n\n'.join([RESOURCE_TEMPLATE.render(resource=node) for node in filtered_nodes.values()]) - formula_content[start_resources_line_no:start_resources_line_no] = resources_stanza.split('\n') - - -def write_file(formula_path, formula_content): - with open(formula_path, 'w') as f: - for line in formula_content: - f.write("%s\n" % line) - -def setup_pip_deps(): - pip(['install', '--ignore-installed', 'azure-cli', 'homebrew-pypi-poet'], _out=sys.stdout, _err=sys.stdout) - -def main(): - formula_path, formula_content = get_homebrew_formula() - setup_pip_deps() - modify_url(formula_content) - modify_sha256(formula_content) - modify_resources(formula_content) - write_file(formula_path, formula_content) - print('Done') - new_formula_path = formula_path - if BUILD_ARTIFACTS_DIR: - new_formula_path = os.path.join(BUILD_ARTIFACTS_DIR, 'azure-cli.rb') - shutil.copyfile(formula_path, new_formula_path) - print('The new Homebrew formula is available at {}'.format(new_formula_path)) - print('Create a PR to {} for {}'.format(HOMEBREW_REPO_URL, AZURE_CLI_FORMULA_PATH)) - - -if __name__ == '__main__': - main() diff --git a/build_scripts/pypi/README.md b/build_scripts/pypi/README.md deleted file mode 100644 index e41a2fbe69b..00000000000 --- a/build_scripts/pypi/README.md +++ /dev/null @@ -1,9 +0,0 @@ -Python Package Builds (.whl & .tar.gz) -====================================== - -For example: -``` -artifacts_dir=$(mktemp -d) -python build_scripts/pypi/build.py $artifacts_dir . -ls -la $artifacts_dir -``` diff --git a/build_scripts/pypi/build.py b/build_scripts/pypi/build.py deleted file mode 100644 index 39800b2172b..00000000000 --- a/build_scripts/pypi/build.py +++ /dev/null @@ -1,67 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -""" -Script to build all command modules that can be used to install a fully self-contained instance of the CLI. -""" - -from __future__ import print_function - -import glob -import os -import sys -import tempfile -import subprocess - -def _error_exit(msg): - print('ERROR: '+msg, file=sys.stderr) - sys.exit(1) - -def _print_status(msg=''): - print('-- '+msg) - -def _get_tmp_dir(): - return tempfile.mkdtemp() - -def _get_tmp_file(): - return tempfile.mkstemp()[1] - -def _exec_command(command_list, cwd=None, stdout=None): - """Returns True in the command was executed successfully""" - try: - _print_status('Executing {}'.format(command_list)) - subprocess.check_call(command_list, stdout=stdout, cwd=cwd) - return True - except subprocess.CalledProcessError as err: - print(err, file=sys.stderr) - return False - -def _build_package(path_to_package, dist_dir): - cmd_success = _exec_command(['python', 'setup.py', 'bdist_wheel', '-d', dist_dir], cwd=path_to_package) - cmd_success = _exec_command(['python', 'setup.py', 'sdist', '-d', dist_dir], cwd=path_to_package) - if not cmd_success: - _error_exit('Error building {}.'.format(path_to_package)) - -def build_packages(clone_root, dist_dir): - packages_to_build = [ - os.path.join(clone_root, 'src', 'azure-cli'), - os.path.join(clone_root, 'src', 'azure-cli-core'), - os.path.join(clone_root, 'src', 'azure-cli-nspkg'), - os.path.join(clone_root, 'src', 'azure-cli-command_modules-nspkg'), - ] - - packages_to_build.extend(glob.glob(os.path.join(clone_root, 'src', 'command_modules', 'azure-cli-*'))) - for p in packages_to_build: - if os.path.isfile(os.path.join(p, 'setup.py')): - _build_package(p, dist_dir) - -if __name__ == '__main__': - if len(sys.argv) == 1: - raise ValueError('Please provide temporary path for local built packages') - dist_dir = sys.argv[1] - clone_root = sys.argv[2] - build_packages(clone_root, dist_dir) - print("package were built to {}".format(dist_dir)) - print("Done.") diff --git a/build_scripts/rpm/README.md b/build_scripts/rpm/README.md deleted file mode 100644 index a64dfe7c681..00000000000 --- a/build_scripts/rpm/README.md +++ /dev/null @@ -1,53 +0,0 @@ -RPM Packaging -================ - -Building the RPM package ------------------------- - -On a build machine (e.g. new CentOS 7 VM) run the following. - -Install dependencies required to build: -Required for rpm build tools & required to build the CLI. -``` -sudo yum install -y gcc git rpm-build rpm-devel rpmlint make bash coreutils diffutils patch rpmdevtools python libffi-devel python-devel openssl-devel -``` - -Build example: -Note: use the full path to the repo path, not a relative path. -``` -git clone https://github.com/azure/azure-cli -cd azure-cli -export CLI_VERSION=2.0.16 -export REPO_PATH=$(pwd) -rpmbuild -v -bb --clean build_scripts/rpm/azure-cli.spec -``` - -Verification ------------- - -``` -sudo rpm -i RPMS/*/azure-cli-2.0.16-1.noarch.rpm -az --version -``` - -Check the file permissions of the package: -``` -rpmlint RPMS/*/azure-cli-2.0.16-1.x86_64.rpm -``` - -Check the file permissions of the package: -``` -rpm -qlvp RPMS/*/azure-cli-2.0.16-1.x86_64.rpm -``` - -To remove: -``` -sudo rpm -e azure-cli -``` - -Links ------ - -https://fedoraproject.org/wiki/How_to_create_an_RPM_package - -https://fedoraproject.org/wiki/Packaging:RPMMacros?rd=Packaging/RPMMacros diff --git a/build_scripts/rpm/azure-cli.spec b/build_scripts/rpm/azure-cli.spec deleted file mode 100644 index 4f034e11fa6..00000000000 --- a/build_scripts/rpm/azure-cli.spec +++ /dev/null @@ -1,78 +0,0 @@ -# RPM spec file for Azure CLI -# Definition of macros used - https://fedoraproject.org/wiki/Packaging:RPMMacros?rd=Packaging/RPMMacros - -# .el7.centos -> .el7 -%if 0%{?rhel} == 7 - %define dist .el7 -%endif - -%define name azure-cli -%define release 1%{?dist} -%define version %{getenv:CLI_VERSION} -%define repo_path %{getenv:REPO_PATH} -%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 - -Summary: Azure CLI -License: MIT -Name: %{name} -Version: %{version} -Release: %{release} -Url: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli -BuildArch: x86_64 -Requires: python - -BuildRequires: gcc -BuildRequires: python -BuildRequires: libffi-devel -BuildRequires: python-devel -BuildRequires: openssl-devel - -%global _python_bytecompile_errors_terminate_build 0 - -%description -A great cloud needs great tools; we're excited to introduce Azure CLI, - our next generation multi-platform command line experience for Azure. - -%prep -# Create some tmp files -tmp_venv_archive=$(mktemp) - -# Download, Extract Virtualenv -wget %{venv_url} -qO $tmp_venv_archive -echo "%{venv_sha256} $tmp_venv_archive" | sha256sum -c - -tar -xvzf $tmp_venv_archive -C %{_builddir} - -%install -# Create the venv -python %{_builddir}/virtualenv-15.0.0/virtualenv.py --python python %{buildroot}%{cli_lib_dir} - -# Build the wheels from the source -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 -all_modules=`find $dist_dir -name "*.whl"` -%{buildroot}%{cli_lib_dir}/bin/pip install --no-compile $all_modules -%{buildroot}%{cli_lib_dir}/bin/pip install --no-compile --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg - -# Fix up %{buildroot} appearing in some files... -for d in %{buildroot}%{cli_lib_dir}/bin/*; do perl -p -i -e "s#%{buildroot}##g" $d; done; - -# Create executable -mkdir -p %{buildroot}%{_bindir} -printf '#!/usr/bin/env bash\n%{cli_lib_dir}/bin/python -Esm azure.cli "$@"' > %{buildroot}%{_bindir}/az - -# Set up tab completion -mkdir -p %{buildroot}%{_sysconfdir}/bash_completion.d/ -cat $source_dir/az.completion > %{buildroot}%{_sysconfdir}/bash_completion.d/azure-cli - -%files -%attr(-,root,root) %{cli_lib_dir} -%config(noreplace) %{_sysconfdir}/bash_completion.d/azure-cli -%attr(0755,root,root) %{_bindir}/az diff --git a/scripts/dependency/requirements.Darwin.external.txt b/scripts/dependency/requirements.Darwin.external.txt deleted file mode 100644 index a174ecb8ec2..00000000000 --- a/scripts/dependency/requirements.Darwin.external.txt +++ /dev/null @@ -1,107 +0,0 @@ -adal==1.1.0 -antlr4-python3-runtime==4.7.1 -applicationinsights==0.11.6 -argcomplete==1.9.4 -asn1crypto==0.24.0 -azure-batch==5.0.0 -azure-common==1.1.15 -azure-datalake-store==0.0.31 -azure-graphrbac==0.40.0 -azure-keyvault==1.1.0 -azure-mgmt-advisor==1.0.1 -azure-mgmt-authorization==0.50.0 -azure-mgmt-batch==5.0.1 -azure-mgmt-batchai==2.0.0 -azure-mgmt-billing==0.2.0 -azure-mgmt-botservice==0.1.0 -azure-mgmt-cdn==3.0.0 -azure-mgmt-cognitiveservices==3.0.0 -azure-mgmt-compute==4.1.0 -azure-mgmt-consumption==2.0.0 -azure-mgmt-containerinstance==1.1.0 -azure-mgmt-containerregistry==2.2.0 -azure-mgmt-containerservice==4.2.2 -azure-mgmt-cosmosdb==0.4.0 -azure-mgmt-datalake-analytics==0.2.0 -azure-mgmt-datalake-nspkg==2.0.0 -azure-mgmt-datalake-store==0.5.0 -azure-mgmt-datamigration==0.1.0 -azure-mgmt-devtestlabs==2.2.0 -azure-mgmt-dns==2.1.0 -azure-mgmt-iotcentral==0.2.0 -azure-mgmt-iothub==0.6.0 -azure-mgmt-iothubprovisioningservices==0.2.0 -azure-mgmt-keyvault==1.1.0 -azure-mgmt-loganalytics==0.2.0 -azure-mgmt-managementgroups==0.1.0 -azure-mgmt-maps==0.1.0 -azure-mgmt-marketplaceordering==0.1.0 -azure-mgmt-media==1.0.0rc1 -azure-mgmt-monitor==0.5.2 -azure-mgmt-msi==0.2.0 -azure-mgmt-network==2.3.0 -azure-mgmt-nspkg==2.0.0 -azure-mgmt-policyinsights==0.1.0 -azure-mgmt-rdbms==1.3.0 -azure-mgmt-recoveryservices==0.1.0 -azure-mgmt-recoveryservicesbackup==0.1.1 -azure-mgmt-redis==5.0.0 -azure-mgmt-relay==0.1.0 -azure-mgmt-reservations==0.3.0 -azure-mgmt-resource==2.0.0 -azure-mgmt-search==2.0.0 -azure-mgmt-servicebus==0.5.1 -azure-mgmt-servicefabric==0.2.0 -azure-mgmt-signalr==0.1.1 -azure-mgmt-sql==0.9.1 -azure-mgmt-storage==2.0.0rc4 -azure-mgmt-trafficmanager==0.50.0 -azure-mgmt-web==0.40.0 -azure-multiapi-storage==0.2.2 -azure-nspkg==2.0.0 -azure-storage-blob==1.1.0 -azure-storage-common==1.1.0 -azure-storage-nspkg==3.0.0 -bcrypt==3.1.4 -certifi==2018.8.24 -cffi==1.11.5 -chardet==3.0.4 -colorama==0.3.9 -cryptography==2.3.1 -entrypoints==0.2.3 -humanfriendly==4.16.1 -idna==2.7 -isodate==0.6.0 -jmespath==0.9.3 -keyring==15.1.0 -knack==0.4.4 -mock==2.0.0 -msrest==0.5.5 -msrestazure==0.4.34 -oauthlib==2.1.0 -paramiko==2.4.1 -pbr==4.2.0 -portalocker==1.2.1 -prompt-toolkit==1.0.15 -pyasn1==0.4.4 -pycparser==2.18 -pydocumentdb==2.3.3 -Pygments==2.2.0 -PyJWT==1.6.4 -PyNaCl==1.2.1 -pyOpenSSL==18.0.0 -python-dateutil==2.7.3 -pytz==2018.5 -PyYAML==3.13 -requests==2.19.1 -requests-oauthlib==1.0.0 -scp==0.11.0 -six==1.11.0 -sshtunnel==0.1.4 -tabulate==0.8.2 -urllib3==1.23 -vsts-cd-manager==1.0.2 -wcwidth==0.1.7 -websocket-client==0.53.0 -Whoosh==2.7.4 -xmltodict==0.11.0 diff --git a/scripts/dependency/requirements.Linux.external.txt b/scripts/dependency/requirements.Linux.external.txt deleted file mode 100644 index 2eb588261c3..00000000000 --- a/scripts/dependency/requirements.Linux.external.txt +++ /dev/null @@ -1,109 +0,0 @@ -adal==1.1.0 -antlr4-python3-runtime==4.7.1 -applicationinsights==0.11.6 -argcomplete==1.9.4 -asn1crypto==0.24.0 -azure-batch==5.0.0 -azure-common==1.1.15 -azure-datalake-store==0.0.31 -azure-graphrbac==0.40.0 -azure-keyvault==1.1.0 -azure-mgmt-advisor==1.0.1 -azure-mgmt-authorization==0.50.0 -azure-mgmt-batch==5.0.1 -azure-mgmt-batchai==2.0.0 -azure-mgmt-billing==0.2.0 -azure-mgmt-botservice==0.1.0 -azure-mgmt-cdn==3.0.0 -azure-mgmt-cognitiveservices==3.0.0 -azure-mgmt-compute==4.1.0 -azure-mgmt-consumption==2.0.0 -azure-mgmt-containerinstance==1.1.0 -azure-mgmt-containerregistry==2.2.0 -azure-mgmt-containerservice==4.2.2 -azure-mgmt-cosmosdb==0.4.0 -azure-mgmt-datalake-analytics==0.2.0 -azure-mgmt-datalake-nspkg==2.0.0 -azure-mgmt-datalake-store==0.5.0 -azure-mgmt-datamigration==0.1.0 -azure-mgmt-devtestlabs==2.2.0 -azure-mgmt-dns==2.1.0 -azure-mgmt-iotcentral==0.2.0 -azure-mgmt-iothub==0.6.0 -azure-mgmt-iothubprovisioningservices==0.2.0 -azure-mgmt-keyvault==1.1.0 -azure-mgmt-loganalytics==0.2.0 -azure-mgmt-managementgroups==0.1.0 -azure-mgmt-maps==0.1.0 -azure-mgmt-marketplaceordering==0.1.0 -azure-mgmt-media==1.0.0rc1 -azure-mgmt-monitor==0.5.2 -azure-mgmt-msi==0.2.0 -azure-mgmt-network==2.3.0 -azure-mgmt-nspkg==2.0.0 -azure-mgmt-policyinsights==0.1.0 -azure-mgmt-rdbms==1.3.0 -azure-mgmt-recoveryservices==0.1.0 -azure-mgmt-recoveryservicesbackup==0.1.1 -azure-mgmt-redis==5.0.0 -azure-mgmt-relay==0.1.0 -azure-mgmt-reservations==0.3.0 -azure-mgmt-resource==2.0.0 -azure-mgmt-search==2.0.0 -azure-mgmt-servicebus==0.5.1 -azure-mgmt-servicefabric==0.2.0 -azure-mgmt-signalr==0.1.1 -azure-mgmt-sql==0.9.1 -azure-mgmt-storage==2.0.0rc4 -azure-mgmt-trafficmanager==0.50.0 -azure-mgmt-web==0.40.0 -azure-multiapi-storage==0.2.2 -azure-nspkg==2.0.0 -azure-storage-blob==1.1.0 -azure-storage-common==1.1.0 -azure-storage-nspkg==3.0.0 -bcrypt==3.1.4 -certifi==2018.8.24 -cffi==1.11.5 -chardet==3.0.4 -colorama==0.3.9 -cryptography==2.3.1 -entrypoints==0.2.3 -humanfriendly==4.16.1 -idna==2.7 -isodate==0.6.0 -jeepney==0.3.1 -jmespath==0.9.3 -keyring==15.1.0 -knack==0.4.4 -mock==2.0.0 -msrest==0.5.5 -msrestazure==0.4.34 -oauthlib==2.1.0 -paramiko==2.4.1 -pbr==4.2.0 -portalocker==1.2.1 -prompt-toolkit==1.0.15 -pyasn1==0.4.4 -pycparser==2.18 -pydocumentdb==2.3.3 -Pygments==2.2.0 -PyJWT==1.6.4 -PyNaCl==1.2.1 -pyOpenSSL==18.0.0 -python-dateutil==2.7.3 -pytz==2018.5 -PyYAML==3.13 -requests==2.19.1 -requests-oauthlib==1.0.0 -scp==0.11.0 -SecretStorage==3.1.0 -six==1.11.0 -sshtunnel==0.1.4 -tabulate==0.8.2 -urllib3==1.23 -vsts-cd-manager==1.0.2 -wcwidth==0.1.7 -websocket-client==0.53.0 -Whoosh==2.7.4 -xmltodict==0.11.0 diff --git a/scripts/move-tests.sh b/scripts/move-tests.sh deleted file mode 100755 index 88a46bb1b1a..00000000000 --- a/scripts/move-tests.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -for test_folder in `find src/command_modules -name tests`; do - p=`dirname $test_folder` - t=$p/test_temp - mv $test_folder $t - - if [ -d $t/recordings/2017-03-09-profile ]; then - mkdir -p $test_folder/profile_2017_03_09 - cp -r $t/* $test_folder/profile_2017_03_09 - rm -r $test_folder/profile_2017_03_09/recordings - mkdir -p $test_folder/profile_2017_03_09/recordings - cp -r $t/recordings/2017-03-09-profile/* $test_folder/profile_2017_03_09/recordings/ - fi - - if [ -d $t/recordings/2018-03-01-hybrid ]; then - mkdir -p $test_folder/hybrid_2018_03_01 - cp -r $t/* $test_folder/hybrid_2018_03_01 - rm -r $test_folder/hybrid_2018_03_01/recordings - mkdir -p $test_folder/hybrid_2018_03_01/recordings - cp -r $t/recordings/2018-03-01-hybrid/* $test_folder/hybrid_2018_03_01/recordings/ - fi - - mkdir -p $test_folder/latest - cp -r $t/* $test_folder/latest/ - - if [ -d $t/recordings/latest ]; then - rm -r $test_folder/latest/recordings - mkdir -p $test_folder/latest/recordings - cp -r $t/recordings/latest/* $test_folder/latest/recordings/ - fi - - rm -r $t - -done diff --git a/scripts/remove_bom.py b/scripts/remove_bom.py deleted file mode 100644 index fefae17218d..00000000000 --- a/scripts/remove_bom.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python - -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -# Remove the UTF-8 BOM from all python files - -from __future__ import print_function - -import os -import codecs -from _common import get_repo_root - -def remove_bom(file_path): - file_size = os.path.getsize(file_path) - if file_size < 32: - return False - - content = None - with open(file_path, 'rb') as f: - first_32 = f.read(32) - if not first_32.startswith(codecs.BOM_UTF8): - return - - content = bytearray(first_32 + f.read(file_size)) - - with open(file_path, 'wb') as f: - f.write(content[len(codecs.BOM_UTF8):]) - - -if __name__ == '__main__': - repo_root = get_repo_root() - for root, dirs, files in os.walk(repo_root): - if root[len(repo_root):len(repo_root) + 5] == '/.git': - continue - - for f in (os.path.join(root, f) for f in files if f[-3:] == '.py'): - remove_bom(f) - diff --git a/scripts/scrub_test_log.py b/scripts/scrub_test_log.py deleted file mode 100644 index ced07eb510b..00000000000 --- a/scripts/scrub_test_log.py +++ /dev/null @@ -1,41 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -from __future__ import print_function -import os -import sys - -try: - filename = sys.argv[1] -except IndexError: - filename = 'log.txt' - -try: - dest_file = sys.argv[2] -except IndexError: - dest_file = 'log_scrub.txt' - -with open(filename) as f: - lines = f.readlines() - count = 0 - final_lines = [] - for line in lines: - if '... ERROR' in line or '... FAIL' in line: - line = line.replace('(', '') - line = line.replace(')', '') - try: - test_name, test_path, _, _ = line.split(' ') - path_comps = test_path.split('.') - path_file = path_comps[-2] - path_class = path_comps[-1] - module_name = path_comps[-4] - line = 'run_tests --module {} --test {}.{}.{}\n'.format(module_name, path_file, path_class, test_name) - except: - pass - final_lines.append(line) - -with open(dest_file, 'w') as f: - for line in final_lines: - f.write(line + os.linesep) diff --git a/scripts/scrub_vcr_auth.py b/scripts/scrub_vcr_auth.py deleted file mode 100644 index 6b8cfa05d24..00000000000 --- a/scripts/scrub_vcr_auth.py +++ /dev/null @@ -1,51 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -# pylint: disable=line-too-long -import os -import tempfile - -COMMAND_MODULE_PREFIX = 'azure-cli-' -PATH_TO_COMMAND_MODULES = os.path.abspath(os.path.join(os.path.abspath(__file__), - '..', '..', 'src',#'..', '..', '..', '..', - 'command_modules')) -command_modules = [] -insecure_cassettes = [] -for name in os.listdir(PATH_TO_COMMAND_MODULES): - full_module_path = os.path.join(PATH_TO_COMMAND_MODULES, name) - if name.startswith(COMMAND_MODULE_PREFIX) and os.path.isdir(full_module_path): - command_modules += [(name, full_module_path)] - - for name, fullpath in command_modules: - path_to_recordings = os.path.join(fullpath, 'azure', 'cli', 'command_modules', - name.replace(COMMAND_MODULE_PREFIX, ''), - 'tests', 'recordings') - if not os.path.isdir(path_to_recordings): - continue - - for name in os.listdir(path_to_recordings): - if not str.endswith(name, '.yaml'): - continue - src_path = os.path.join(path_to_recordings, name) - t = tempfile.NamedTemporaryFile('r+') - with open(src_path, 'r') as f: - for line in f: - if 'authorization: [bearer' in line.lower(): - insecure_cassettes.append(name) - else: - t.write(line) - t.seek(0) - with open(src_path, 'w') as f: - for line in t: - f.write(line) - t.close() - -insecure_cassettes = list(set(insecure_cassettes)) -if insecure_cassettes: - print('Bearer tokens removed from the following cassettes:') - for cassette in insecure_cassettes: - print('\t{}'.format(cassette)) -else: - print('All cassettes free from Bearer tokens!') diff --git a/tools/automation/__main__.py b/tools/automation/__main__.py index 95ccb7baee2..44e6463cb48 100644 --- a/tools/automation/__main__.py +++ b/tools/automation/__main__.py @@ -6,8 +6,6 @@ import argparse import sys import automation.verify -import automation.clibuild -import automation.clipublish import automation.style import automation.tests import automation.cli_linter @@ -18,8 +16,6 @@ def main(): sub_parser = parser.add_subparsers(title='sub commands') automation.verify.init_args(sub_parser) - automation.clibuild.init_args(sub_parser) - automation.clipublish.init_args(sub_parser) automation.style.init_args(sub_parser) automation.tests.init_args(sub_parser) automation.cli_linter.init_args(sub_parser) diff --git a/tools/automation/clibuild/__init__.py b/tools/automation/clibuild/__init__.py deleted file mode 100644 index fe588adccd5..00000000000 --- a/tools/automation/clibuild/__init__.py +++ /dev/null @@ -1,172 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- -import os -import tempfile -import datetime -from subprocess import check_output, CalledProcessError -from concurrent.futures import ThreadPoolExecutor, as_completed - -try: - import xmlrpclib -except ImportError: - import xmlrpc.client as xmlrpclib # pylint: disable=import-error - -from ..utilities.display import print_heading -from ..utilities.path import get_repo_root -from ..utilities.pypi import is_available_on_pypi - -# TODO Add 'msi' once we support it -BUILD_TYPES = ['debian', 'docker', 'rpm', 'pypi', 'homebrew'] - -def build_all_debian(git_url, git_branch, cli_version, artifact_dir, arg_ns=None): - # To only build a certain debian package, comment out the ones you don't want from the list below - dists = [ - ('wheezy', 'debian:wheezy'), - ('jessie', 'debian:jessie'), - ('stretch', 'debian:stretch'), - ('artful', 'ubuntu:artful'), - ('xenial', 'ubuntu:xenial'), - ('trusty', 'ubuntu:trusty'), - ('bionic', 'ubuntu:bionic'), - ] - with ThreadPoolExecutor(max_workers=len(dists)) as executor: - tasks = {executor.submit(build_debian, dist_info, git_url, git_branch, cli_version, artifact_dir, arg_ns=arg_ns) for dist_info - in dists} - for t in as_completed(tasks): - t.result() - print('Finished debian builds for {}. Check each build message above for completion status.'.format(', '.join([d[0] for d in dists]))) - -def build_debian(dist_info, git_url, git_branch, cli_version, artifact_dir, arg_ns=None): - # If you need to release a revision to the package, change this number then reset back to 1 for the next release - revision = 1 - dist_codename = dist_info[0] - docker_image = dist_info[1] - cmd = ['docker', 'run', '-d', '-e', 'CLI_VERSION=' + cli_version, - '-e', 'CLI_VERSION_REVISION={}~{}'.format(revision, dist_codename), '-e', 'BUILD_ARTIFACT_DIR=/artifacts', - '-v', artifact_dir + ':/artifacts', docker_image, '/bin/bash', '-cx', - 'apt-get update && apt-get install -y git wget sudo && git clone --progress --verbose {} --branch {} /repo_clone ' - '&& cd /repo_clone && build_scripts/debian/build.sh /repo_clone'.format(git_url, git_branch)] - container_id = check_output(cmd, universal_newlines=True).strip() - print('Debian {} build running. Use `docker logs -f {}`'.format(dist_info[0], container_id)) - exit_code = check_output(['docker', 'wait', container_id], universal_newlines=True).strip() - print('FINISHED Debian {} build. Exit code {} (0 for success)'.format(dist_info[0], exit_code)) - - -def build_docker(git_url, git_branch, cli_version, artifact_dir, arg_ns=None): - cmd = ['docker', 'build', '--no-cache', '--quiet', '--build-arg', 'BUILD_DATE="`date -u +"%Y-%m-%dT%H:%M:%SZ"`"', - '--build-arg', 'CLI_VERSION=' + cli_version, get_repo_root()] - print('Docker build started. The git url and branch parameters are ignored. We use the current repository.') - image_id = check_output(cmd, universal_newlines=True).strip() - image_id = image_id.split(':')[1] - image_file_location = os.path.join(artifact_dir, 'docker-azure-cli-{}.tar'.format(cli_version)) - cmd = ['docker', 'save', '-o', image_file_location, image_id] - image_id = check_output(cmd, universal_newlines=True).strip() - print('COMPLETED Docker build. image id: {}, saved to {}'.format(image_id, image_file_location)) - - -def build_rpm(git_url, git_branch, cli_version, artifact_dir, arg_ns=None): - cmd = ['docker', 'run', '-d', '-e', 'CLI_VERSION=' + cli_version, '-e', 'REPO_PATH=/repo_clone', - '-v', artifact_dir + ':/artifacts', 'centos:7', '/bin/bash', '-cx', - 'yum check-update; yum install -y gcc git rpm-build rpm-devel rpmlint make bash coreutils diffutils patch ' - 'rpmdevtools python libffi-devel python-devel openssl-devel wget && git clone --progress --verbose {} ' - '--branch {} /repo_clone && cd /repo_clone && rpmbuild -v -bb --clean build_scripts/rpm/azure-cli.spec && ' - 'cp /root/rpmbuild/RPMS/x86_64/* /artifacts/'.format(git_url, git_branch)] - container_id = check_output(cmd, universal_newlines=True).strip() - print('RPM build running. Use `docker logs -f {}` to view logs'.format(container_id)) - exit_code = check_output(['docker', 'wait', container_id], universal_newlines=True).strip() - print('FINISHED RPM build. Exit code {} (0 for success)'.format(exit_code)) - - -def build_pypi(git_url, git_branch, _, artifact_dir, arg_ns=None): - cmd = ['docker', 'run', '-d', '-v', artifact_dir + ':/artifacts', 'python:3.6', '/bin/bash', '-cx', - 'mkdir /artifacts/pypi && git clone --progress --verbose {} --branch {} /repo_clone && cd /repo_clone && ' - 'python build_scripts/pypi/build.py /artifacts/pypi /repo_clone'.format(git_url, git_branch)] - container_id = check_output(cmd, universal_newlines=True).strip() - print('Python pypi build message: The version numbers of packages will be as defined in source code.') - print('Python pypi build running. Use `docker logs -f {}`'.format(container_id)) - exit_code = check_output(['docker', 'wait', container_id], universal_newlines=True).strip() - print('COMPLETED Python pypi build. Exit code {}'.format(exit_code)) - - -def build_msi(git_url, git_branch, cli_version, artifact_dir, arg_ns=None): - # TODO - print('SKIPPED MSI build. Not Yet Implemented. Please build manually.') - - -def build_homebrew(git_url, git_branch, cli_version, artifact_dir, arg_ns=None): - if not is_available_on_pypi('azure-cli', cli_version): - print('Homebrew message : The Homebrew formula requires CLI packages to be available on public PyPI. ' - 'Version {} of the CLI does not appear to be on PyPI. ' - 'If it was just updated, this message can be safely ignored.'.format(cli_version)) - - upstream_url = arg_ns.homebrew_upstream_url or 'https://github.com/Azure/azure-cli/archive/azure-cli-{cli_version}.tar.gz'.format( - cli_version=cli_version) - print('Homebrew message: The generated formula uses the latest public packages that are available on PyPI, ' - 'not the code in your Git repo.') - cmd = ['docker', 'run', '-d', '-e', 'CLI_VERSION=' + cli_version, '-e', 'BUILD_ARTIFACT_DIR=/artifacts', - '-e', 'UPSTREAM_URL=' + upstream_url, - '-v', artifact_dir + ':/artifacts', 'python:3.6', '/bin/bash', '-cx', - 'pip install sh && git clone --progress --verbose {} --branch {} /repo_clone && cd /repo_clone && ' - 'python build_scripts/homebrew/formula-generate.py'.format(git_url, git_branch)] - container_id = check_output(cmd, universal_newlines=True).strip() - print('Homebrew formula generation running. Use `docker logs -f {}`'.format(container_id)) - exit_code = check_output(['docker', 'wait', container_id], universal_newlines=True).strip() - print('COMPLETED Homebrew formula generation. Exit code {}'.format(exit_code)) - - -def build_dispatch(build_type, git_url, git_branch, cli_version, artifact_dir, arg_ns=None): - if build_type == 'debian': - build_all_debian(git_url, git_branch, cli_version, artifact_dir, arg_ns=arg_ns) - elif build_type == 'docker': - build_docker(git_url, git_branch, cli_version, artifact_dir, arg_ns=arg_ns) - elif build_type == 'rpm': - build_rpm(git_url, git_branch, cli_version, artifact_dir, arg_ns=arg_ns) - elif build_type == 'pypi': - build_pypi(git_url, git_branch, cli_version, artifact_dir, arg_ns=arg_ns) - elif build_type == 'msi': - build_msi(git_url, git_branch, cli_version, artifact_dir, arg_ns=arg_ns) - elif build_type == 'homebrew': - build_homebrew(git_url, git_branch, cli_version, artifact_dir, arg_ns=arg_ns) - - -def cli_build(args): - assert check_output(['docker', 'ps']), "Docker required." - build_types = args.build_types - git_url = args.git_clone_url - git_branch = args.git_clone_branch - cli_version = args.cli_version - artifact_dir = tempfile.mkdtemp( - prefix='cli-build-{}-'.format(datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')), dir=os.getcwd()) - if len(build_types) == 1 and build_types[0] == '*': - build_types = BUILD_TYPES - print_heading('Building for {} from branch {} of {} ' - 'and version number will be {}\n' - 'Build artifacts will be in {}'.format(', '.join(build_types), git_branch, git_url, cli_version, - artifact_dir)) - with ThreadPoolExecutor(max_workers=len(build_types)) as executor: - tasks = {executor.submit(build_dispatch, bt, git_url, git_branch, cli_version, artifact_dir, arg_ns=args) for bt - in build_types} - for t in as_completed(tasks): - t.result() - print('Done.') - - -def init_args(root): - cli_build_parser = root.add_parser('build', help='Build the CLI. Docker is required.') - cli_build_parser.set_defaults(func=cli_build) - git_args = cli_build_parser.add_argument_group('Git Clone Arguments') - git_args.add_argument('-b', '--git-clone-branch', dest='git_clone_branch', - help='Branch name that should be checked out. (default: %(default)s)', default='master') - git_args.add_argument('-u', '--git-clone-url', dest='git_clone_url', - help='The url to clone. This will be passed to `git clone`. (default: %(default)s)', - default='https://github.com/Azure/azure-cli.git') - cli_build_parser.add_argument('-t', '--type', dest='build_types', required=True, nargs='+', - choices=BUILD_TYPES + ['*'], - help="Space-separated list of the artifacts to build. Use '*' for all.") - cli_build_parser.add_argument('-c', '--cli-version', dest='cli_version', required=True, - help="The version of the build. (ignored for 'pypi' type)") - homebrew_args = cli_build_parser.add_argument_group('Homebrew Specific Arguments') - homebrew_args.add_argument('--homebrew-upstream-url', dest='homebrew_upstream_url', - help='The upstream URL to specify in the formula.') diff --git a/tools/automation/clipublish/__init__.py b/tools/automation/clipublish/__init__.py deleted file mode 100644 index 320381f6efd..00000000000 --- a/tools/automation/clipublish/__init__.py +++ /dev/null @@ -1,83 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -import os -import sys -import requests - -PUBLISH_TYPES = ['debian', 'rpm'] - - -def get_debian_payload(cli_version, repo_id, distro, source_url): - return {'name': 'azure-cli', 'version': cli_version + '-1~' + distro, 'repositoryId': repo_id, 'sourceUrl': source_url} - - -def get_yum_payload(cli_version, repo_id, source_url): - return {'name': 'azure-cli', 'version': cli_version, 'repositoryId': repo_id, 'sourceUrl': source_url} - - -def publish_payload(endpoint, payload): - assert 'REPO_PASSWORD' in os.environ, "Set REPO_PASSWORD environment variable" - repo_password = os.environ['REPO_PASSWORD'] - repo_username = 'azure-cli' - print('Publishing - {}'.format(payload)) - r = requests.post(endpoint + '/v1/packages', verify=False, auth=(repo_username, repo_password), json=payload) - print('Status Code {}'.format(r.status_code)) - # Query with a GET to the following (creds. required) - if r.status_code == 202: - print(endpoint + r.headers['Location']) - else: - print('Possible error. Server didn\'t return 202 Accepted.') - - -def cli_publish(args): - publish_type = args.publish_type - cli_version = args.cli_version - endpoint = args.endpoint - if publish_type == 'debian': - debs = args.debs - assert debs, "No debs provided. Nothing to do." - payloads = [get_debian_payload(cli_version, repo_id, distro, source_url) for repo_id, distro, source_url in debs] - print('Payloads') - print('\n'.join(str(p) for p in payloads)) - input('Please enter to confirm the payloads to make requests to publish the DEBIAN packages: ') - for p in payloads: - publish_payload(endpoint, p) - elif publish_type == 'rpm': - repo_id = args.rpm_repo_id - source_url = args.rpm_source_url - assert repo_id, "Missing --repo-id" - assert source_url, "Missing --source-url" - payload = get_yum_payload(cli_version, repo_id, source_url) - print('Payload') - print(payload) - input('Please enter to confirm the payload to make requests to publish the RPM package: ') - publish_payload(endpoint, payload) - else: - raise ValueError("Unknown publish type {}".format(publish_type)) - - -def type_debs(val): - repo_id, distro, source_url = val.split('/', 2) - return repo_id, distro, source_url - - -def init_args(root): - parser = root.add_parser('publish', help='Publish the CLI.') - parser.set_defaults(func=cli_publish) - git_args = parser.add_argument_group('Git Clone Arguments') - parser.add_argument('-t', '--type', dest='publish_type', required=True, - choices=PUBLISH_TYPES, - help="Space separated list of the artifacts to build. Use '*' for all.") - parser.add_argument('-c', '--cli-version', dest='cli_version', required=True, - help="The version of the publish.") - parser.add_argument('-e', '--repo-endpoint', dest='endpoint', required=True, - help="The endpoint to publish the debian or yum package.") - deb_args = parser.add_argument_group('Debian Publish Arguments') - deb_args.add_argument('--debs', dest='debs', nargs='+', type=type_debs, default=[], - help='A space separated list of repoid/distro/source_url for each package to publish.') - rpm_args = parser.add_argument_group('RPM Publish Arguments') - rpm_args.add_argument('-r', '--rpm-repo-id', dest='rpm_repo_id', help='Repo ID for RPM Repo') - rpm_args.add_argument('-s', '--rpm-source-url', dest='rpm_source_url', help='URL to the RPM package')