From 5ddfad099e6d1837f1a1fa5f9652fbc3ebf7c85b Mon Sep 17 00:00:00 2001 From: Derek Bekoe Date: Mon, 26 Mar 2018 09:49:19 -0700 Subject: [PATCH] Snapcraft yaml for Azure CLI (#5904) * snapcraft.yaml * add version --- .snapcraft.yaml | 42 +++++++++++++++++++++++++++ build_scripts/snap/az.snap.completion | 21 ++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .snapcraft.yaml create mode 100644 build_scripts/snap/az.snap.completion diff --git a/.snapcraft.yaml b/.snapcraft.yaml new file mode 100644 index 000000000..c97c52adb --- /dev/null +++ b/.snapcraft.yaml @@ -0,0 +1,42 @@ +name: azure-cli +summary: Microsoft Azure CLI 2.0 +description: | + A great cloud needs great tools; we're excited to introduce Azure CLI 2.0, our + next generation multi-platform command line experience for Azure. +version: "release" +version-script: | + grep VERSION src/azure-cli/setup.py | head -n 1 | cut -d'"' -f2 +confinement: classic +grade: stable +apps: + az: + command: usr/bin/python -m azure.cli + completer: az.completion +parts: + azure-cli: + plugin: python + source: . + python-version: python3 + build-packages: + - build-essential + - python3-dev + - python3-wheel + - libffi-dev + - libssl-dev + stage-packages: + - libffi6 + - libssl1.0.0 + requirements: requirements.txt + install: | + python_packages="src/azure-cli-core src/azure-cli-nspkg src/azure-cli-command_modules-nspkg src/command_modules/azure-cli*" + export PYTHONUSERBASE=$SNAPCRAFT_PART_INSTALL + export PYTHONHOME=$SNAPCRAFT_PART_INSTALL/usr + echo $SNAPCRAFT_PART_INSTALL/usr/bin/python3 + $SNAPCRAFT_PART_INSTALL/usr/bin/python3 -c 'import site; print("PYTHONUSERBASE set to {!r}".format(site.getuserbase()))' + $SNAPCRAFT_PART_INSTALL/usr/bin/python3 -m pip install --user $python_packages + $SNAPCRAFT_PART_INSTALL/usr/bin/python3 -m pip install --no-index --user src/azure-cli + install build_scripts/snap/az.snap.completion $SNAPCRAFT_PART_INSTALL/az.completion + # PEP 394 says you should use python3, but the client uses python. + ln -s python3 $SNAPCRAFT_PART_INSTALL/usr/bin/python + prime: + - -lib/python3.5/site-packages/tabulate-0.7.7.dist-info/.PKG-INFO.swp \ No newline at end of file diff --git a/build_scripts/snap/az.snap.completion b/build_scripts/snap/az.snap.completion new file mode 100644 index 000000000..5ffa5f03a --- /dev/null +++ b/build_scripts/snap/az.snap.completion @@ -0,0 +1,21 @@ +_python_argcomplete() { + local IFS=$'\013' + local SUPPRESS_SPACE=0 + if compopt +o nospace 2> /dev/null; then + SUPPRESS_SPACE=1 + fi + COMPREPLY=( $(IFS="$IFS" \ + COMP_LINE="$COMP_LINE" \ + COMP_POINT="$COMP_POINT" \ + COMP_TYPE="$COMP_TYPE" \ + _ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" \ + _ARGCOMPLETE=1 \ + _ARGCOMPLETE_SUPPRESS_SPACE=$SUPPRESS_SPACE \ + "$SNAP/usr/bin/python" -m azure.cli 8>&1 9>&2 1>/dev/null 2>/dev/null) ) + if [[ $? != 0 ]]; then + unset COMPREPLY + elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "$COMPREPLY" =~ [=/:]$ ]]; then + compopt -o nospace + fi +} +complete -o nospace -F _python_argcomplete azure-cli.az \ No newline at end of file