From 7ca7ba680b5359b0809bb84e94ce959ad2e8b6be Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 9 Jun 2020 10:55:38 +0100 Subject: [PATCH 01/18] snap: drop sudo Fixes #3989 --- scripts/build_snap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build_snap.sh b/scripts/build_snap.sh index 93e7d51cc5..9f6600d280 100755 --- a/scripts/build_snap.sh +++ b/scripts/build_snap.sh @@ -7,7 +7,7 @@ if [ ! -d "dvc" ]; then exit 1 fi -sudo snapcraft --use-lxd +snapcraft --use-lxd pip uninstall -y dvc if which dvc; then From 52ce8496e40d5e1768d96f309c8735e3cf0ef39e Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 9 Jun 2020 16:03:38 +0100 Subject: [PATCH 02/18] snap: ci: fix builds --- .travis.yml | 2 ++ scripts/build_snap.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 616a30d8ed..6bafe52949 100644 --- a/.travis.yml +++ b/.travis.yml @@ -102,7 +102,9 @@ jobs: channel: stable env: - SNAPCRAFT_IMAGE_INFO: '{"build_url": "$TRAVIS_BUILD_URL"}' + - SNAPCRAFT_BUILD_ENVIRONMENT: lxd install: + - sudo usermod --append --groups lxd $USER - sudo /snap/bin/lxd.migrate -yes - sudo /snap/bin/lxd waitready - sudo /snap/bin/lxd init --auto diff --git a/scripts/build_snap.sh b/scripts/build_snap.sh index 9f6600d280..3d1ea85472 100755 --- a/scripts/build_snap.sh +++ b/scripts/build_snap.sh @@ -7,7 +7,7 @@ if [ ! -d "dvc" ]; then exit 1 fi -snapcraft --use-lxd +sg lxd -c snapcraft pip uninstall -y dvc if which dvc; then From c2cd34b9ea82bf66a3f2b5592cff7bfc598092d1 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 9 Jun 2020 16:04:12 +0100 Subject: [PATCH 03/18] snap: ci: developer notifications --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6bafe52949..281ab28878 100644 --- a/.travis.yml +++ b/.travis.yml @@ -101,8 +101,9 @@ jobs: - name: lxd channel: stable env: - - SNAPCRAFT_IMAGE_INFO: '{"build_url": "$TRAVIS_BUILD_URL"}' + - SNAPCRAFT_IMAGE_INFO: '{"build_url": "$TRAVIS_BUILD_WEB_URL"}' - SNAPCRAFT_BUILD_ENVIRONMENT: lxd + - SNAPCRAFT_BUILD_INFO: 1 # https://snapcraft.io/blog/introducing-developer-notifications-for-snap-security-updates install: - sudo usermod --append --groups lxd $USER - sudo /snap/bin/lxd.migrate -yes From f7dfa670a54fd908bbecb77d2c752fa22d7d10fe Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 9 Jun 2020 16:04:31 +0100 Subject: [PATCH 04/18] snap: minimise size --- snap/snapcraft.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 75d0f7daaa..6d07927e6a 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -42,6 +42,17 @@ parts: # https://github.com/snapcore/snapcraft/blob/19393ef36cd773a28131cec10cc0bfb3bf9c7e77/tools/snapcraft-override-build.sh#L18 sed -ri 's/^(ENABLE_USER_SITE = )None$/\1False/' $SNAPCRAFT_PART_INSTALL/usr/lib/python*/site.py cp $SNAPCRAFT_PART_BUILD/scripts/completion/dvc.bash $SNAPCRAFT_PART_INSTALL/completion.sh + # remove files already available at runtime from the base snap - reference: + # https://forum.snapcraft.io/t/reducing-the-size-of-desktop-snaps/17280 + cleanup: + after: + - dvc + plugin: nil + build-snaps: + - core18 + override-prime: | + set -eux + cd "/snap/core18/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \; apps: dvc: command: bin/dvc From dc0e44629724e2ece066bae24ea56936f91ffa58 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 9 Jun 2020 16:04:54 +0100 Subject: [PATCH 05/18] debug commit --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 281ab28878..26afde8814 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,10 @@ env: - PATH="$PYENV_ROOT/bin:$PATH" - PIP_CACHE_DIR="$HOME/.cache/pip" # unify pip cache location for all platforms stages: - - check - - test + - name: check + if: false + - name: test + if: false - build # Travis doesn't support testing python on Mac yet, so we need # to workaround it by installing it directly with brew. From 26eec9cda03fcdfdf2d4a3274548f42213d70049 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 9 Jun 2020 17:21:33 +0100 Subject: [PATCH 06/18] Revert "snap: minimise size" This reverts commit 77b41a96f68b2c8df833803d0a644172b7db4779. --- snap/snapcraft.yaml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 6d07927e6a..75d0f7daaa 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -42,17 +42,6 @@ parts: # https://github.com/snapcore/snapcraft/blob/19393ef36cd773a28131cec10cc0bfb3bf9c7e77/tools/snapcraft-override-build.sh#L18 sed -ri 's/^(ENABLE_USER_SITE = )None$/\1False/' $SNAPCRAFT_PART_INSTALL/usr/lib/python*/site.py cp $SNAPCRAFT_PART_BUILD/scripts/completion/dvc.bash $SNAPCRAFT_PART_INSTALL/completion.sh - # remove files already available at runtime from the base snap - reference: - # https://forum.snapcraft.io/t/reducing-the-size-of-desktop-snaps/17280 - cleanup: - after: - - dvc - plugin: nil - build-snaps: - - core18 - override-prime: | - set -eux - cd "/snap/core18/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \; apps: dvc: command: bin/dvc From e87587bfbeca802a15ae1e605d6ccd0af00823cb Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 9 Jun 2020 17:37:27 +0100 Subject: [PATCH 07/18] fix image info --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 26afde8814..d8a9f32241 100644 --- a/.travis.yml +++ b/.travis.yml @@ -103,7 +103,8 @@ jobs: - name: lxd channel: stable env: - - SNAPCRAFT_IMAGE_INFO: '{"build_url": "$TRAVIS_BUILD_WEB_URL"}' + - SNAPCRAFT_IMAGE_INFO: | + '{"build_url": "$TRAVIS_JOB_WEB_URL"}' - SNAPCRAFT_BUILD_ENVIRONMENT: lxd - SNAPCRAFT_BUILD_INFO: 1 # https://snapcraft.io/blog/introducing-developer-notifications-for-snap-security-updates install: From d7a614587409ea9472de6a262a73539c0ad4188e Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 9 Jun 2020 21:43:43 +0100 Subject: [PATCH 08/18] Revert "debug commit" This reverts commit 232baf0ad78335b0f3806456a3f20b82cdf0f24c. --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d8a9f32241..07071bd3d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,10 +10,8 @@ env: - PATH="$PYENV_ROOT/bin:$PATH" - PIP_CACHE_DIR="$HOME/.cache/pip" # unify pip cache location for all platforms stages: - - name: check - if: false - - name: test - if: false + - check + - test - build # Travis doesn't support testing python on Mac yet, so we need # to workaround it by installing it directly with brew. From 4a8f8fbe2a2de282f5a97394780ed50a91ac41d0 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 9 Jun 2020 21:49:39 +0100 Subject: [PATCH 09/18] snap: v1 channels Related: #3872 --- scripts/ci/before_install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ci/before_install.sh b/scripts/ci/before_install.sh index 1a02b33871..b16a581052 100644 --- a/scripts/ci/before_install.sh +++ b/scripts/ci/before_install.sh @@ -53,10 +53,10 @@ fi if [[ -n "$TRAVIS_TAG" ]]; then if [[ $(echo "$TRAVIS_TAG" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$') ]]; then - echo "export SNAP_CHANNEL=stable" >>env.sh + echo "export SNAP_CHANNEL=stable,v1/stable" >>env.sh else - echo "export SNAP_CHANNEL=beta" >>env.sh + echo "export SNAP_CHANNEL=beta,v1/beta" >>env.sh fi else - echo "export SNAP_CHANNEL=edge" >>env.sh + echo "export SNAP_CHANNEL=edge,v1/edge" >>env.sh fi From b613a42860d1d86c18dc5dd3d2ce8c5a6d601b52 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 9 Jun 2020 22:00:19 +0100 Subject: [PATCH 10/18] snap: v0 channels Related #3990 Related #3989 --- scripts/ci/before_install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ci/before_install.sh b/scripts/ci/before_install.sh index b16a581052..28a34ca2d2 100644 --- a/scripts/ci/before_install.sh +++ b/scripts/ci/before_install.sh @@ -53,10 +53,10 @@ fi if [[ -n "$TRAVIS_TAG" ]]; then if [[ $(echo "$TRAVIS_TAG" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$') ]]; then - echo "export SNAP_CHANNEL=stable,v1/stable" >>env.sh + echo "export SNAP_CHANNEL=stable,v0/stable" >>env.sh else - echo "export SNAP_CHANNEL=beta,v1/beta" >>env.sh + echo "export SNAP_CHANNEL=beta,v0/beta" >>env.sh fi else - echo "export SNAP_CHANNEL=edge,v1/edge" >>env.sh + echo "export SNAP_CHANNEL=edge,v0/edge" >>env.sh fi From 699572ddda3776d76baf016a776967f3fd537071 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 9 Jun 2020 22:57:05 +0100 Subject: [PATCH 11/18] snap: auto-version (major) detect --- .travis.yml | 1 - scripts/ci/before_install.sh | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 07071bd3d6..cdedbe290a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -110,7 +110,6 @@ jobs: - sudo /snap/bin/lxd.migrate -yes - sudo /snap/bin/lxd waitready - sudo /snap/bin/lxd init --auto - - git fetch --tags script: - ./scripts/build_snap.sh after_failure: diff --git a/scripts/ci/before_install.sh b/scripts/ci/before_install.sh index 28a34ca2d2..758e75416a 100644 --- a/scripts/ci/before_install.sh +++ b/scripts/ci/before_install.sh @@ -51,12 +51,15 @@ elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip fi +# can't rely on $TRAVIS_TAG for `edge` releases so fetch tags for git-describe +git fetch --tags +TAG_MAJOR="$(git describe --tags | sed -r 's/^v?([0-9]+)\.[0-9]+\.[0-9]+.*/\1/')" if [[ -n "$TRAVIS_TAG" ]]; then if [[ $(echo "$TRAVIS_TAG" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$') ]]; then - echo "export SNAP_CHANNEL=stable,v0/stable" >>env.sh + echo "export SNAP_CHANNEL=stable,v$TAG_MAJOR/stable" >>env.sh else - echo "export SNAP_CHANNEL=beta,v0/beta" >>env.sh + echo "export SNAP_CHANNEL=beta,v$TAG_MAJOR/beta" >>env.sh fi else - echo "export SNAP_CHANNEL=edge,v0/edge" >>env.sh + echo "export SNAP_CHANNEL=edge,v$TAG_MAJOR/edge" >>env.sh fi From 439ae84d3ece903dd04bd1f477d846640ba9a9a6 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 9 Jun 2020 23:03:37 +0100 Subject: [PATCH 12/18] ci: fetch --tags explanation & error checking --- scripts/ci/before_install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/ci/before_install.sh b/scripts/ci/before_install.sh index 758e75416a..287c159228 100644 --- a/scripts/ci/before_install.sh +++ b/scripts/ci/before_install.sh @@ -51,9 +51,12 @@ elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip fi -# can't rely on $TRAVIS_TAG for `edge` releases so fetch tags for git-describe +# fetch tags for `git-describe`, since +# - can't rely on $TRAVIS_TAG for `edge` (master) releases, and +# - `snapcraft` also uses `git-describe` for version detection git fetch --tags TAG_MAJOR="$(git describe --tags | sed -r 's/^v?([0-9]+)\.[0-9]+\.[0-9]+.*/\1/')" +[[ -n "$TAG_MAJOR" ]] || exit 1 # failed to detect major version if [[ -n "$TRAVIS_TAG" ]]; then if [[ $(echo "$TRAVIS_TAG" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$') ]]; then echo "export SNAP_CHANNEL=stable,v$TAG_MAJOR/stable" >>env.sh From a5636e1f9af393bc03c4b3fcc73c43d36891bdda Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Wed, 10 Jun 2020 00:55:18 +0100 Subject: [PATCH 13/18] snap: update warning framework --- dvc/updater.py | 43 ++++++++++++++++++++++++++++++++++++++++++- snap/hooks/configure | 2 ++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100755 snap/hooks/configure diff --git a/dvc/updater.py b/dvc/updater.py index cfa416ffa8..50a6226cca 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -48,7 +48,35 @@ def _with_lock(self, func, action): logger.debug(msg.format(self.lock.lockfile, action)) def check(self): - if os.getenv("CI") or env2bool("DVC_TEST") or PKG == "snap": + if os.getenv("CI") or env2bool("DVC_TEST"): + return + + if PKG == "snap": + # Ideally need to check if SNAP_CHANNEL.startswith(self.current), + # where SNAP_CHANNEL is: + # snap info dvc | grep -E '^tracking:' | awk '{print $2}' + # However a quicker way is to skip if a user-configurable variable + # `skip_update_check` is set + import subprocess + + kwargs = {"close_fds": True} + if os.name == "nt": + kwargs["shell"] = True + cmd = [] + else: + kwargs["shell"] = False + cmd = ["/bin/sh", "-c"] + p = subprocess.Popen( + cmd + ["snapctl", "get", "skip_update_check"], **kwargs + ) + skip_update_check = p.communicate()[0] + if skip_update_check not in ("", "0", "false", "False"): + # frozen on current version so suppress notification + return + + self.current = f"v{version.parse(self.current).major}" + self.latest = f"v{version.parse(self.current).major + 1}" + self._notify() return self._with_lock(self._check, "checking") @@ -138,6 +166,19 @@ def _get_update_instructions(self): ), "conda": "Run `{yellow}conda{reset} update dvc`", "choco": "Run `{yellow}choco{reset} upgrade dvc`", + "snap": ( + "To upgrade to the latest major release,\n" + "run `{yellow}snap{reset} refresh --channel=latest/beta`, or\n" + "to stay on the current major release track,\n" + "run `{yellow}snap{reset} refresh" + " --channel={current}/stable`\n" + "and `{yellow}snap{reset} set dvc skip_update_check=1`.\n" + "\n" + "{red}WARNING{reset}: ignoring this message will result in\n" + "snap automatically performing an upgrade soon.\n" + "More information can be found at\n" + "{blue}https://github.com/iterative/dvc/issues/3872{reset}" + ), None: ( "Find the latest release at\n" "{blue}https://github.com/iterative/dvc/releases/latest{reset}" diff --git a/snap/hooks/configure b/snap/hooks/configure new file mode 100755 index 0000000000..dc29d965d6 --- /dev/null +++ b/snap/hooks/configure @@ -0,0 +1,2 @@ +#!/bin/sh -e +snapctl get skip_update_check || snapctl set skip_update_check=false From a50871be7108a2a6835d456e2da8dc7a0266cf9d Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 12 Jun 2020 11:32:01 +0100 Subject: [PATCH 14/18] hardocde warning --- dvc/updater.py | 30 +++++------------------------- snap/hooks/configure | 2 -- 2 files changed, 5 insertions(+), 27 deletions(-) delete mode 100755 snap/hooks/configure diff --git a/dvc/updater.py b/dvc/updater.py index 50a6226cca..3a4cfd9f54 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -52,28 +52,10 @@ def check(self): return if PKG == "snap": - # Ideally need to check if SNAP_CHANNEL.startswith(self.current), - # where SNAP_CHANNEL is: + # Ideally `if SNAP_CHANNEL.startswith(self.current): return` + # where `SNAP_CHANNEL` is: # snap info dvc | grep -E '^tracking:' | awk '{print $2}' - # However a quicker way is to skip if a user-configurable variable - # `skip_update_check` is set - import subprocess - - kwargs = {"close_fds": True} - if os.name == "nt": - kwargs["shell"] = True - cmd = [] - else: - kwargs["shell"] = False - cmd = ["/bin/sh", "-c"] - p = subprocess.Popen( - cmd + ["snapctl", "get", "skip_update_check"], **kwargs - ) - skip_update_check = p.communicate()[0] - if skip_update_check not in ("", "0", "false", "False"): - # frozen on current version so suppress notification - return - + # However that's too slow to check self.current = f"v{version.parse(self.current).major}" self.latest = f"v{version.parse(self.current).major + 1}" self._notify() @@ -170,10 +152,8 @@ def _get_update_instructions(self): "To upgrade to the latest major release,\n" "run `{yellow}snap{reset} refresh --channel=latest/beta`, or\n" "to stay on the current major release track,\n" - "run `{yellow}snap{reset} refresh" - " --channel={current}/stable`\n" - "and `{yellow}snap{reset} set dvc skip_update_check=1`.\n" - "\n" + "run `{yellow}snap{reset} refresh --channel={current}/stable`" + "\n\n" "{red}WARNING{reset}: ignoring this message will result in\n" "snap automatically performing an upgrade soon.\n" "More information can be found at\n" diff --git a/snap/hooks/configure b/snap/hooks/configure deleted file mode 100755 index dc29d965d6..0000000000 --- a/snap/hooks/configure +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -e -snapctl get skip_update_check || snapctl set skip_update_check=false From c7f1bce96905872ed778c98aba56317ee7d6c61c Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 12 Jun 2020 11:55:01 +0100 Subject: [PATCH 15/18] add deprecation dev comment --- scripts/ci/before_install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/ci/before_install.sh b/scripts/ci/before_install.sh index 287c159228..92c57983fe 100644 --- a/scripts/ci/before_install.sh +++ b/scripts/ci/before_install.sh @@ -57,6 +57,8 @@ fi git fetch --tags TAG_MAJOR="$(git describe --tags | sed -r 's/^v?([0-9]+)\.[0-9]+\.[0-9]+.*/\1/')" [[ -n "$TAG_MAJOR" ]] || exit 1 # failed to detect major version +# NOTE: after deprecating major releses, remove `CHANNEL,` prefixes +# (e.g. `stable,v$TAG_MAJOR/stable` => `v$TAG_MAJOR/stable`) if [[ -n "$TRAVIS_TAG" ]]; then if [[ $(echo "$TRAVIS_TAG" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$') ]]; then echo "export SNAP_CHANNEL=stable,v$TAG_MAJOR/stable" >>env.sh From 2a74d6c5e23f8b550cc3ae79fef9e5535aef5ad3 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 12 Jun 2020 12:15:30 +0100 Subject: [PATCH 16/18] remove warning on explicit v0 channel --- .travis.yml | 10 +++++- scripts/build_snap.sh | 7 ++++ scripts/ci/before_install.sh | 15 +++++--- scripts/remove_update_warning.patch | 53 +++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 scripts/remove_update_warning.patch diff --git a/.travis.yml b/.travis.yml index cdedbe290a..4b8ad13af5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -160,6 +160,14 @@ deploy: script: "(echo $SNAP_TOKEN | snapcraft login --with -) && timeout 600 snapcraft push dvc_*.snap --release $SNAP_CHANNEL || echo timed out" on: all_branches: true - condition: "$(./scripts/ci/deploy_condition.sh dvc_*.snap) && ($TRAVIS_BRANCH = master || -n $TRAVIS_TAG)" + condition: "$(./scripts/ci/deploy_condition.sh dvc_*.snap) && ($TRAVIS_BRANCH = master || -n $TRAVIS_TAG) && -n $SNAP_CHANNEL" + repo: iterative/dvc + stage: build + - provider: script + skip_cleanup: true + script: "(echo $SNAP_TOKEN | snapcraft login --with -) && timeout 600 snapcraft push nowarn_update_dvc_*.snap --release $SNAP_CHANNEL_MAJOR || echo timed out" + on: + all_branches: true + condition: "$(./scripts/ci/deploy_condition.sh nowarn_update_dvc_*.snap) && ($TRAVIS_BRANCH = master || -n $TRAVIS_TAG) && -n $SNAP_CHANNEL_MAJOR" repo: iterative/dvc stage: build diff --git a/scripts/build_snap.sh b/scripts/build_snap.sh index 3d1ea85472..a97847a2db 100755 --- a/scripts/build_snap.sh +++ b/scripts/build_snap.sh @@ -8,6 +8,13 @@ if [ ! -d "dvc" ]; then fi sg lxd -c snapcraft +original_snap_name="$(ls dvc_*.snap)" +mv "$original_snap_name" original.snap + +git apply scripts/remove_update_warning.patch +sg lxd -c snapcraft +mv dvc_*.snap nowarn_update_"$original_snap_name".snap +mv original.snap "$original_snap_name" pip uninstall -y dvc if which dvc; then diff --git a/scripts/ci/before_install.sh b/scripts/ci/before_install.sh index 92c57983fe..df4407ca9b 100644 --- a/scripts/ci/before_install.sh +++ b/scripts/ci/before_install.sh @@ -57,14 +57,19 @@ fi git fetch --tags TAG_MAJOR="$(git describe --tags | sed -r 's/^v?([0-9]+)\.[0-9]+\.[0-9]+.*/\1/')" [[ -n "$TAG_MAJOR" ]] || exit 1 # failed to detect major version -# NOTE: after deprecating major releses, remove `CHANNEL,` prefixes -# (e.g. `stable,v$TAG_MAJOR/stable` => `v$TAG_MAJOR/stable`) + if [[ -n "$TRAVIS_TAG" ]]; then if [[ $(echo "$TRAVIS_TAG" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$') ]]; then - echo "export SNAP_CHANNEL=stable,v$TAG_MAJOR/stable" >>env.sh + echo "export SNAP_CHANNEL=stable" >>env.sh + echo "export SNAP_CHANNEL_MAJOR=v$TAG_MAJOR/stable" >>env.sh else - echo "export SNAP_CHANNEL=beta,v$TAG_MAJOR/beta" >>env.sh + echo "export SNAP_CHANNEL=beta" >>env.sh + echo "export SNAP_CHANNEL_MAJOR=v$TAG_MAJOR/beta" >>env.sh fi else - echo "export SNAP_CHANNEL=edge,v$TAG_MAJOR/edge" >>env.sh + echo "export SNAP_CHANNEL=edge" >>env.sh + echo "export SNAP_CHANNEL_MAJOR=v$TAG_MAJOR/edge" >>env.sh fi + +# NOTE: after deprecating this branch, uncomment this line +# echo "unset SNAP_CHANNEL" >>env.sh diff --git a/scripts/remove_update_warning.patch b/scripts/remove_update_warning.patch new file mode 100644 index 0000000000..bcd5ba73f3 --- /dev/null +++ b/scripts/remove_update_warning.patch @@ -0,0 +1,53 @@ +diff --git a/dvc/updater.py b/dvc/updater.py +index 3a4cfd9..cfa416f 100644 +--- a/dvc/updater.py ++++ b/dvc/updater.py +@@ -48,17 +48,7 @@ class Updater(object): # pragma: no cover + logger.debug(msg.format(self.lock.lockfile, action)) + + def check(self): +- if os.getenv("CI") or env2bool("DVC_TEST"): +- return +- +- if PKG == "snap": +- # Ideally `if SNAP_CHANNEL.startswith(self.current): return` +- # where `SNAP_CHANNEL` is: +- # snap info dvc | grep -E '^tracking:' | awk '{print $2}' +- # However that's too slow to check +- self.current = f"v{version.parse(self.current).major}" +- self.latest = f"v{version.parse(self.current).major + 1}" +- self._notify() ++ if os.getenv("CI") or env2bool("DVC_TEST") or PKG == "snap": + return + + self._with_lock(self._check, "checking") +@@ -148,17 +138,6 @@ class Updater(object): # pragma: no cover + ), + "conda": "Run `{yellow}conda{reset} update dvc`", + "choco": "Run `{yellow}choco{reset} upgrade dvc`", +- "snap": ( +- "To upgrade to the latest major release,\n" +- "run `{yellow}snap{reset} refresh --channel=latest/beta`, or\n" +- "to stay on the current major release track,\n" +- "run `{yellow}snap{reset} refresh --channel={current}/stable`" +- "\n\n" +- "{red}WARNING{reset}: ignoring this message will result in\n" +- "snap automatically performing an upgrade soon.\n" +- "More information can be found at\n" +- "{blue}https://github.com/iterative/dvc/issues/3872{reset}" +- ), + None: ( + "Find the latest release at\n" + "{blue}https://github.com/iterative/dvc/releases/latest{reset}" +diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml +index 75d0f7d..996db8c 100644 +--- a/snap/snapcraft.yaml ++++ b/snap/snapcraft.yaml +@@ -30,7 +30,6 @@ parts: + override-pull: | + snapcraftctl pull + snapcraftctl set-version $(cd $SNAPCRAFT_PART_SRC && git describe --tags) +- git diff --quiet || error_dirty_build + echo 'PKG = "snap"' > $SNAPCRAFT_PART_SRC/dvc/utils/build.py + # install all optional extras + sed -ri 's/(=install_requires)/\1+all_remotes+hdfs/' $SNAPCRAFT_PART_SRC/setup.py From 761c0c6f2c47e9e934e0281698f5b5c9a3198ac9 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 12 Jun 2020 12:24:08 +0100 Subject: [PATCH 17/18] tidy comment --- dvc/updater.py | 5 +---- scripts/remove_update_warning.patch | 11 ++++------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/dvc/updater.py b/dvc/updater.py index 3a4cfd9f54..3ecb3caa72 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -52,10 +52,7 @@ def check(self): return if PKG == "snap": - # Ideally `if SNAP_CHANNEL.startswith(self.current): return` - # where `SNAP_CHANNEL` is: - # snap info dvc | grep -E '^tracking:' | awk '{print $2}' - # However that's too slow to check + # hardcoded transition message self.current = f"v{version.parse(self.current).major}" self.latest = f"v{version.parse(self.current).major + 1}" self._notify() diff --git a/scripts/remove_update_warning.patch b/scripts/remove_update_warning.patch index bcd5ba73f3..0a9161c891 100644 --- a/scripts/remove_update_warning.patch +++ b/scripts/remove_update_warning.patch @@ -1,8 +1,8 @@ diff --git a/dvc/updater.py b/dvc/updater.py -index 3a4cfd9..cfa416f 100644 +index 3ecb3ca..cfa416f 100644 --- a/dvc/updater.py +++ b/dvc/updater.py -@@ -48,17 +48,7 @@ class Updater(object): # pragma: no cover +@@ -48,14 +48,7 @@ class Updater(object): # pragma: no cover logger.debug(msg.format(self.lock.lockfile, action)) def check(self): @@ -10,10 +10,7 @@ index 3a4cfd9..cfa416f 100644 - return - - if PKG == "snap": -- # Ideally `if SNAP_CHANNEL.startswith(self.current): return` -- # where `SNAP_CHANNEL` is: -- # snap info dvc | grep -E '^tracking:' | awk '{print $2}' -- # However that's too slow to check +- # hardcoded transition message - self.current = f"v{version.parse(self.current).major}" - self.latest = f"v{version.parse(self.current).major + 1}" - self._notify() @@ -21,7 +18,7 @@ index 3a4cfd9..cfa416f 100644 return self._with_lock(self._check, "checking") -@@ -148,17 +138,6 @@ class Updater(object): # pragma: no cover +@@ -145,17 +138,6 @@ class Updater(object): # pragma: no cover ), "conda": "Run `{yellow}conda{reset} update dvc`", "choco": "Run `{yellow}choco{reset} upgrade dvc`", From 3da3319a3bdda4c67c3bdb97ac9159de85378c38 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 12 Jun 2020 13:14:57 +0100 Subject: [PATCH 18/18] fix py2 --- dvc/updater.py | 5 +++-- scripts/remove_update_warning.patch | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dvc/updater.py b/dvc/updater.py index 3ecb3caa72..d6dc3727bd 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -53,8 +53,9 @@ def check(self): if PKG == "snap": # hardcoded transition message - self.current = f"v{version.parse(self.current).major}" - self.latest = f"v{version.parse(self.current).major + 1}" + version_major = version.parse(self.current).major + self.current = "v{}".format(version_major) + self.latest = "v{}".format(version_major + 1) self._notify() return diff --git a/scripts/remove_update_warning.patch b/scripts/remove_update_warning.patch index 0a9161c891..567864d196 100644 --- a/scripts/remove_update_warning.patch +++ b/scripts/remove_update_warning.patch @@ -1,8 +1,8 @@ diff --git a/dvc/updater.py b/dvc/updater.py -index 3ecb3ca..cfa416f 100644 +index d6dc372..cfa416f 100644 --- a/dvc/updater.py +++ b/dvc/updater.py -@@ -48,14 +48,7 @@ class Updater(object): # pragma: no cover +@@ -48,15 +48,7 @@ class Updater(object): # pragma: no cover logger.debug(msg.format(self.lock.lockfile, action)) def check(self): @@ -11,14 +11,15 @@ index 3ecb3ca..cfa416f 100644 - - if PKG == "snap": - # hardcoded transition message -- self.current = f"v{version.parse(self.current).major}" -- self.latest = f"v{version.parse(self.current).major + 1}" +- version_major = version.parse(self.current).major +- self.current = "v{}".format(version_major) +- self.latest = "v{}".format(version_major + 1) - self._notify() + if os.getenv("CI") or env2bool("DVC_TEST") or PKG == "snap": return self._with_lock(self._check, "checking") -@@ -145,17 +138,6 @@ class Updater(object): # pragma: no cover +@@ -146,17 +138,6 @@ class Updater(object): # pragma: no cover ), "conda": "Run `{yellow}conda{reset} update dvc`", "choco": "Run `{yellow}choco{reset} upgrade dvc`",