Skip to content

Commit

Permalink
--update[-master]: New optional argument 'diff' #460
Browse files Browse the repository at this point in the history
  • Loading branch information
mviereck committed Jul 29, 2022
1 parent 6e42cf7 commit c73c8db
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 51 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

Project website: https://github.com/mviereck/x11docker

## [Unreleased]
### Changed
- `--update`, `--update-master`: New optional argument `diff` to show
the difference between installed and new version without installing it.
[(460)](https://github.com/mviereck/x11docker/issues/460)

## [7.4.0](https://github.com/mviereck/x11docker/releases/tag/v7.4.0) - 2022-07-28
### Added
- `--xauth [=yes|trusted|untrusted|no]`: New option to configure X cookie.
Expand Down
138 changes: 87 additions & 51 deletions x11docker
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Run 'x11docker --help' or scroll down to read usage information.
# More documentation at: https://github.com/mviereck/x11docker

Version="7.4.0"
Version="7.4.1-beta-1"

# --enforce-i: Enforce running in interactive mode to allow commands tty and weston-launch in special setups. (deprecated)
grep -q -- "--enforce-i" <<< "$*" && case $- in
Expand Down Expand Up @@ -376,8 +376,10 @@ Verbosity options:
Installation options and cleanup (need root permissions):
--install Install x11docker from current folder.
Useful to install from an extracted zip file.
--update Download and install latest release from github.
--update-master Download and install latest master version from github.
--update [=diff] Download and install latest release from github.
--update-master [=diff] Download and install latest master version.
Optional argument 'diff' shows the difference between
installed and new version without installing it.
--remove Remove x11docker from your system. Includes --cleanup.
Preserves ~/.local/share/x11docker from option --home.
--cleanup Clean up orphaned containers and cache files. Those
Expand Down Expand Up @@ -1639,13 +1641,18 @@ installer() { # --install, --update, --update-master, --remove
case "$Winsubsystem" in
CYGWIN|MSYS2) ;;
*)
case "$Binowner" in
root)
error "Must run as root to install, update or remove x11docker system wide."
return 1
;;
*) warning "Option ${1:-}: Not running as root.
case "$Installerarg" in
diff) ;;
*)
case "$Binowner" in
root)
error "Must run as root to install, update or remove x11docker system wide."
return 1
;;
*) warning "Option ${1:-}: Not running as root.
Installing or updating non-essential files in system wide folders might fail." ;;
esac
;;
esac
;;
esac
Expand All @@ -1660,7 +1667,8 @@ installer() { # --install, --update, --update-master, --remove
return 1
}
command -v x11docker > /dev/null && {
warning "x11docker seems to be installed already.
warning "x11docker seems to be installed already
at $Binpath/x11docker.
Will overwrite existing installation.
Consider to use option '--update' or '--update-master' instead."
}
Expand Down Expand Up @@ -1728,8 +1736,63 @@ installer() { # --install, --update, --update-master, --remove
;;
esac

# Doing
# New version number
case "${1:-}" in
--install|--update|--update-master)
Newversion="$(bash $(pwd)/x11docker --version)"
;;
esac

# Changelog excerpt
case "${1:-}" in
--update)
echo "$Oldversion" | grep -q beta && {
warning "You are switching from master branch to stable releases.
To get latest master beta version, use option --update-master instead"
Key1="\[${Newversion}\]"
Key2="https:\/\/github.com\/mviereck\/x11docker\/releases"
} || {
Key1="\[${Newversion}\]"
Key2="\[${Oldversion}\]"
[ "$Newversion" = "$Oldversion" ] && {
Key2="https:\/\/github.com\/mviereck\/x11docker\/releases"
note "Version $Newversion was already installed before this update.
If you want the latest beta version from master branch, use --update-master."
}
[ -z "$Oldversion" ] && Key2="https:\/\/github.com\/mviereck\/x11docker\/releases"
}
;;
--update-master)
echo "$Oldversion" | grep -q beta && {
Key1="\[Unreleased\]"
Key2="https:\/\/github.com\/mviereck\/x11docker\/releases"
} || {
Key1="\[Unreleased\]"
Key2="\[${Oldversion}\]"
[ -z "$Oldversion" ] && Key2="https:\/\/github.com\/mviereck\/x11docker\/releases"
}
;;
esac
case "${1:-}" in
--update|--update-master)
note "Excerpt of x11docker changelog:
$(sed -n "/${Key1}/,/${Key2}/p" CHANGELOG.md | head -n-1)"
;;
esac

# show diff
[ "$Installerarg" = "diff" ] && {
case "${1:-}" in
--update|--update-master)
note "Difference of installed version to new version:
$ diff $Binpath/x11docker $(pwd)/x11docker
$(diff $Binpath/x11docker $(pwd)/x11docker 2>&1)"
;;
esac
}

# Doing
[ -z "$Installerarg" ] && case "${1:-}" in
--install|--update|--update-master)
note "Installing x11docker in $Binpath"
cp x11docker "$Binpath/" || {
Expand All @@ -1755,7 +1818,6 @@ installer() { # --install, --update, --update-master, --remove
cp LICENSE.txt /usr/share/doc/x11docker/
} || note "Error while creating /usr/share/doc/x11docker"

Newversion="$("$Binpath/x11docker" --version)"
note "Installed x11docker version $Newversion"
;;
--remove)
Expand Down Expand Up @@ -1783,43 +1845,6 @@ installer() { # --install, --update, --update-master, --remove
rm -R /tmp/x11docker-install
;;
esac

# Changelog excerpt
case "${1:-}" in
--update)
echo "$Oldversion" | grep -q beta && {
warning "You are switching from master branch to stable releases.
To get latest master beta version, use option --update-master instead"
Key1="\[${Newversion}\]"
Key2="https:\/\/github.com\/mviereck\/x11docker\/releases"
} || {
Key1="\[${Newversion}\]"
Key2="\[${Oldversion}\]"
[ "$Newversion" = "$Oldversion" ] && {
Key2="https:\/\/github.com\/mviereck\/x11docker\/releases"
note "Version $Newversion was already installed before this update.
If you want the latest beta version from master branch, use --update-master."
}
[ -z "$Oldversion" ] && Key2="https:\/\/github.com\/mviereck\/x11docker\/releases"
}
;;
--update-master)
echo "$Oldversion" | grep -q beta && {
Key1="\[Unreleased\]"
Key2="https:\/\/github.com\/mviereck\/x11docker\/releases"
} || {
Key1="\[Unreleased\]"
Key2="\[${Oldversion}\]"
[ -z "$Oldversion" ] && Key2="https:\/\/github.com\/mviereck\/x11docker\/releases"
}
;;
esac
case "${1:-}" in
--update|--update-master)
note "Excerpt of x11docker changelog:
$(sed -n "/${Key1}/,/${Key2}/p" /usr/share/doc/x11docker/CHANGELOG.md | head -n-1)"
;;
esac
note "Ready."
}
mkpasswd() {
Expand Down Expand Up @@ -9017,7 +9042,7 @@ parse_options() { # parse cli options
Longoptions="$Longoptions,printenv::,printid::,printinfofile::,printpid1::" # Output of vars on stdout
Longoptions="$Longoptions,debug,printcheck,quiet,verbose::" # Verbose options
Longoptions="$Longoptions,build,cleanup,help,launcher,licence,license,version" # Special options without starting X or container
Longoptions="$Longoptions,install,remove,update,update-master" # Installation
Longoptions="$Longoptions,install,remove,update::,update-master::" # Installation
#
Longoptions="$Longoptions,keepcache,remountcgroup,xopt:,xorgconf:" # Experimental
Longoptions="$Longoptions,dbus-system,enforce-i,exe,homedir:,hostipc,hostnet,iglx,kwin-xwayland" # Deprecated
Expand Down Expand Up @@ -9215,7 +9240,8 @@ ${2:-}" ; shift ;; # Add custo
#### Special options not starting X or docker
--build) Buildimage="yes" ;; # Build an image from x11docker repository
--cleanup) Cleanup="yes" ;; # Remove orphaned containers and cache files
--install|--update|--update-master|--remove) Installermode="${1:-}" ;; # Installer
--install|--remove) Installermode="${1:-}" ;; # Installer
--update|--update-master) Installermode="${1:-}" ; Installerarg="${2:-}" ; shift ;; # Installer
--launcher) Createlauncher="yes" ;; # Create application launcher on desktop and exit

#### Experimental options
Expand Down Expand Up @@ -9598,6 +9624,15 @@ check_options_arguments() { # check for [likely] valid arguments
;;
esac

# --update, --update-master
case "$Installerarg" in
"") ;;
diff) ;;
*)
error "Option --update/--update-master: Unknown argument '$Installerarg'."
;;
esac

# --vt
[ -n "$Newxvt" ] && {
[ "$Newxvt" = "auto" ] || isint "$Newxvt" || {
Expand Down Expand Up @@ -10968,6 +11003,7 @@ declare_variables() { # declare global variables
Cleanup="" # --cleanup: Remove orphaned containers and cache files
Createlauncher="" # --launcher: Create application launcher on desktop and exit yes/no
Installermode="" # --install/--update/--update-master/--remove
Installerarg="" # --update/--update-master: show diff only, do not install

# Lists of window managers
# - these window managers are known to work well with x11docker (alphabetical order)(excluding $Wm_not_recommended and $Wm_ugly):
Expand Down

0 comments on commit c73c8db

Please sign in to comment.