commit tumbleweed-cli for openSUSE:Factory
Hello community, here is the log from the commit of package tumbleweed-cli for openSUSE:Factory checked in at 2018-09-19 14:31:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/tumbleweed-cli (Old) and /work/SRC/openSUSE:Factory/.tumbleweed-cli.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "tumbleweed-cli" Wed Sep 19 14:31:06 2018 rev:4 rq:636472 version:0.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/tumbleweed-cli/tumbleweed-cli.changes 2018-04-04 11:10:08.933753846 +0200 +++ /work/SRC/openSUSE:Factory/.tumbleweed-cli.new/tumbleweed-cli.changes 2018-09-19 14:33:16.295307259 +0200 @@ -1,0 +2,10 @@ +Wed Sep 12 03:25:27 UTC 2018 - jimmy@boombatower.com + +- Update to version 0.3.0: + * Provide bash completion script. + * Provide migrate and unmigrate commands. + * Provide pre and post migrate URLs and check to pick which to use. + * Utilize prompt() in uninit(). + * README: drop bash highlighter from command examples. + +------------------------------------------------------------------- Old: ---- tumbleweed-cli-0.2.1.tar.xz New: ---- tumbleweed-cli-0.3.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ tumbleweed-cli.spec ++++++ --- /var/tmp/diff_new_pack.iOm76K/_old 2018-09-19 14:33:16.883306862 +0200 +++ /var/tmp/diff_new_pack.iOm76K/_new 2018-09-19 14:33:16.883306862 +0200 @@ -17,7 +17,7 @@ Name: tumbleweed-cli -Version: 0.2.1 +Version: 0.3.0 Release: 0 Summary: Command line interface for interacting with tumbleweed snapshots License: GPL-2.0-only @@ -48,5 +48,6 @@ %files %defattr(-,root,root,-) %{_bindir}/tumbleweed +%{_sysconfdir}/bash_completion.d/tumbleweed-completion.bash %changelog ++++++ _service ++++++ --- /var/tmp/diff_new_pack.iOm76K/_old 2018-09-19 14:33:16.919306838 +0200 +++ /var/tmp/diff_new_pack.iOm76K/_new 2018-09-19 14:33:16.919306838 +0200 @@ -1,7 +1,7 @@ <services> <service name="tar_scm" mode="disabled"> <param name="versionformat">@PARENT_TAG@</param> - <param name="revision">refs/tags/0.2.1</param> + <param name="revision">refs/tags/0.3.0</param> <param name="url">https://github.com/boombatower/tumbleweed-cli.git</param> <param name="scm">git</param> <param name="changesgenerate">enable</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.iOm76K/_old 2018-09-19 14:33:16.947306819 +0200 +++ /var/tmp/diff_new_pack.iOm76K/_new 2018-09-19 14:33:16.947306819 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/boombatower/tumbleweed-cli.git</param> - <param name="changesrevision">3f187416a3f057fcfea3d53f067c9ca8f177652a</param> + <param name="changesrevision">9fc01ee664fa20bf4712e702afa872760d2433f1</param> </service> </servicedata> ++++++ tumbleweed-cli-0.2.1.tar.xz -> tumbleweed-cli-0.3.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tumbleweed-cli-0.2.1/Makefile new/tumbleweed-cli-0.3.0/Makefile --- old/tumbleweed-cli-0.2.1/Makefile 2018-04-04 04:42:48.000000000 +0200 +++ new/tumbleweed-cli-0.3.0/Makefile 2018-09-12 05:23:12.000000000 +0200 @@ -4,6 +4,7 @@ INSTALL_PROGRAM = $(INSTALL) PREFIX = /usr +SYSCONFIG = /etc VERSION="build-$(shell date +%F)" all: @@ -15,3 +16,6 @@ $(INSTALL_PROGRAM) tumbleweed $(DESTDIR)$(PREFIX)/bin/ sed -i 's/VERSION=".*"/VERSION=$(VERSION)/' \ $(DESTDIR)$(PREFIX)/bin/tumbleweed + + $(INSTALL) -d $(DESTDIR)$(SYSCONFIG)/bash_completion.d + $(INSTALL) tumbleweed-completion.bash $(DESTDIR)$(SYSCONFIG)/bash_completion.d diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tumbleweed-cli-0.2.1/README.md new/tumbleweed-cli-0.3.0/README.md --- old/tumbleweed-cli-0.2.1/README.md 2018-04-04 04:42:48.000000000 +0200 +++ new/tumbleweed-cli-0.3.0/README.md 2018-09-12 05:23:12.000000000 +0200 @@ -6,7 +6,7 @@ The latest stable version can be installed from the main OSS repository. -```bash +``` zypper in tumbleweed-cli ``` @@ -14,13 +14,13 @@ See `tumbleweed --help` for reference. To get started utilizing snapshots: -```bash +``` tumbleweed init ``` The repos can be verified by ensuring that the URLs contain a snapshot version. -```bash +``` zypper lr -EUP ``` @@ -31,7 +31,7 @@ Some common examples are as follows. -```bash +``` # present latest, target, and installed snapshot versions tumbleweed status @@ -53,7 +53,7 @@ To operate more manually, the following is equivalent to `tumbleweed update`. -```bash +``` # switch to latest tumbleweed switch diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tumbleweed-cli-0.2.1/tumbleweed new/tumbleweed-cli-0.3.0/tumbleweed --- old/tumbleweed-cli-0.2.1/tumbleweed 2018-04-04 04:42:48.000000000 +0200 +++ new/tumbleweed-cli-0.3.0/tumbleweed 2018-09-12 05:23:12.000000000 +0200 @@ -1,7 +1,8 @@ #!/usr/bin/env bash VERSION="development" -URL="http://download.tumbleweed.boombatower.com" +URL_PRE_MIGRATE="http://download.tumbleweed.boombatower.com" +URL_POST_MIGRATE="http://download.opensuse.org/history" CONFIG_DIR="/etc/zypp" VARS_DIR="$CONFIG_DIR/vars.d" VAR_NAME="snapshotVersion" @@ -70,7 +71,7 @@ echo "backup $file" sudo cp --backup=numbered "$file" "$REPOS_DIR/.previous/$(basename "$file")" sudo sed -i -r 's|(name=.*)|\1 ($snapshotVersion)|' "$file" - sudo sed -i -r 's|(baseurl=).*tumbleweed/(.*)|\1'$URL'/$snapshotVersion/\2|' "$file" + sudo sed -i -r 's|(baseurl=).*tumbleweed/(.*)|\1'$URL'/$snapshotVersion/tumbleweed/\2|' "$file" done } @@ -193,12 +194,7 @@ # Prompt for confirmation. local repos=($(ls "$REPOS_DIR/.previous")) - echo -n "revert ${#repos[@]} repos? [y/n] (y): " - read response - if [ "$response" != "" ] && [ "$response" != "y" ] ; then - echo "exiting" - exit 1 - fi + tumbleweed_prompt "revert ${#repos[@]} repos?" tumbleweed_sudo sudo mv "$REPOS_DIR/.previous"/* $REPOS_DIR/ @@ -212,6 +208,77 @@ sudo zypper dup } +tumbleweed_migrate_check() +{ + if grep -l "$URL_PRE_MIGRATE" "$REPOS_DIR"/* > /dev/null ; then + MIGRATED=0 + URL="$URL_PRE_MIGRATE" + else + MIGRATED=1 + URL="$URL_POST_MIGRATE" + fi +} + +tumbleweed_migrate() +{ + if [ $MIGRATED -eq 1 ] ; then + echo "already migrated, exiting" + exit 1 + fi + + echo "A backup of repos to be migrated will be kept in $REPOS_DIR/.migrated" + echo "which may be restored by invoking the unmigrate command." + echo + + echo "Be aware that the official hosting snapshot count differs from the" + echo "unofficial hosting that you are currently using." + echo + + local count_pre=$(curl --silent "$URL_PRE_MIGRATE/list" | wc -l) + local count_post=$(curl --silent "$URL_POST_MIGRATE/list" | wc -l) + echo "- unofficial, $URL_PRE_MIGRATE: $count_pre snapshots" + echo "- official, $URL_POST_MIGRATE: $count_post snapshots" + echo + + echo "Eventually the unofficial hosting will be phased out." + echo + + tumbleweed_prompt "Do you wish to continue?" + tumbleweed_sudo + tumbleweed_repo_migrate +} + +tumbleweed_repo_migrate() +{ + if [ ! -d "$REPOS_DIR/.migrated" ] ; then + sudo mkdir "$REPOS_DIR/.migrated" + fi + + local IFS=$'\n' # Handle repo files with space in name. :( + local files=($(grep -l "\$snapshotVersion" "$REPOS_DIR"/*)) + for file in ${files[@]} ; do + sudo cp "$file" "$REPOS_DIR/.migrated" + sudo sed -i -r 's|(baseurl=).*(\$snapshotVersion)/(.*)|\1'$URL_POST_MIGRATE'/\2/tumbleweed/\3|' "$file" + echo "migrated $file" + done +} + +tumbleweed_unmigrate() +{ + if [ ! -d "$REPOS_DIR/.migrated" ] ; then + echo "nothing to unmigrate" + exit 1 + fi + + # Prompt for confirmation. + local repos=($(ls "$REPOS_DIR/.migrated")) + tumbleweed_prompt "unmigrate ${#repos[@]} repos?" + + tumbleweed_sudo + sudo mv "$REPOS_DIR/.migrated"/* $REPOS_DIR/ + sudo rm -r "$REPOS_DIR/.migrated" +} + tumbleweed_usage() { cat <<_EOF_ @@ -235,6 +302,8 @@ switch %version Switch to a new snapshot (none for latest). revert Revert to the previous snapshot or repo state. uninit Revert back to a snapshotless repository setup. +migrate Migrate from boombatower hosting to download.opensuse.org. +unmigrate Revert migration to official hosting. _EOF_ } @@ -245,7 +314,7 @@ --force) force=1 ; ;; --install) install=1 ; ;; -h|--help) command="usage" ; ;; - history|init|installed|latest|list|revert|status|target|uninit|update) + history|init|installed|latest|list|revert|status|target|uninit|update|migrate|unmigrate) command="$1" ; ;; version) command="installed" ; ;; @@ -279,6 +348,7 @@ exit 1 fi +tumbleweed_migrate_check tumbleweed_$command ${args[@]} if [ "$install" == "1" ] ; then diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tumbleweed-cli-0.2.1/tumbleweed-completion.bash new/tumbleweed-cli-0.3.0/tumbleweed-completion.bash --- old/tumbleweed-cli-0.2.1/tumbleweed-completion.bash 1970-01-01 01:00:00.000000000 +0100 +++ new/tumbleweed-cli-0.3.0/tumbleweed-completion.bash 2018-09-12 05:23:12.000000000 +0200 @@ -0,0 +1,43 @@ +#/usr/bin/env bash + +_tumbleweed_completion() +{ + if [ ${#COMP_WORDS[@]} -eq 2 ] ; then + COMPREPLY=($(compgen -W "history init installed latest list migrate revert status switch target uninit unmigrate update upgrade version --version --help" -- "${COMP_WORDS[-1]}")) + elif [[ ${#COMP_WORDS[@]} -gt 2 && ( + "${COMP_WORDS[1]}" == "init" || + "${COMP_WORDS[1]}" == "switch" || + "${COMP_WORDS[1]}" == "update" || + "${COMP_WORDS[1]}" == "upgrade" ) ]] ; then + + local flags=("--force" "--install") + for word in ${COMP_WORDS[@]:2} ; do + for i in ${!flags[@]} ; do + if [ "${flags[$i]}" == "$word" ] ; then + unset flags[$i] + fi + done + done + COMPREPLY=($(compgen -W "$(echo ${flags[@]})" -- "${COMP_WORDS[-1]}")) + + if [ "${COMP_WORDS[1]}" == "switch" ] ; then + # Cache the list to avoid remote call each completion. + if [ -z "$_TUMBLEWEED_LIST" ] ; then + _TUMBLEWEED_LIST="$(tumbleweed list)" + fi + + # Skip list if a snapshot is already an argument. + for word in ${COMP_WORDS[@]:2} ; do + for snapshot in $_TUMBLEWEED_LIST ; do + if [ "$snapshot" == "$word" ] ; then + return + fi + done + done + + COMPREPLY+=($(compgen -W "$_TUMBLEWEED_LIST" -- "${COMP_WORDS[-1]}")) + fi + fi +} + +complete -F _tumbleweed_completion tumbleweed
participants (1)
-
root