diff --git a/CHANGELOG.md b/CHANGELOG.md index 81dcb31..d14ee45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Project website: https://github.com/mviereck/x11docker +## [7.6.0](https://github.com/mviereck/x11docker/releases/tag/v7.6.0) - 2023-01-18 +### Changed + - Up to version 7.5.0 x11docker installed itself with prefix `/usr`, + now it uses `/usr/local`. This serves to follow the + [Linux Foundation specifications of `/usr/local`.](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s09.html). + To help with the transition, a new option `--remove-oldprefix` + was introduced. Recommended procedure: + - First run: `x11docker --update` + - Afterwards run: `x11docker --remove-oldprefix` +### Added + - `--remove-oldprefix`: Remove installation in old prefix `/usr`. + [(479)](https://github.com/mviereck/x11docker/issues/479) + ## [7.5.0](https://github.com/mviereck/x11docker/releases/tag/v7.5.0) - 2023-01-16 ### Added - `man` page for x11docker. (Run update from 7.4.2 twice to install it.) @@ -21,7 +34,7 @@ Project website: https://github.com/mviereck/x11docker [(478)](https://github.com/mviereck/x11docker/issues/478) - Replace `getent` with custom `grep` command. [(477)](https://github.com/mviereck/x11docker/issues/477) - - `--install|--update*`: Do not dpend on backend. + - `--install|--update*`: Do not depend on backend. [(470)](https://github.com/mviereck/x11docker/issues/470) ### Deprecated - `--backend=proot`: Deprecated because likely no one uses it, diff --git a/README.md b/README.md index d0f2195..6a5ddba 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,8 @@ Files to work on can be shared between host and container. Since a while Docker distributes a version called "Docker Desktop" that runs Docker in a QEMU VM. x11docker is not designed to support this VM based version. Instead, use x11docker with the native ["Docker Engine Server version"](https://docs.docker.com/engine/install/#server) that uses your host kernel to run containers. - If you install Docker from your distribution's repository, you'll likely get this native version. - - If you prefer podman over Docker, you'll don't need to care about this difference. + - The supported native Docker Engine package name is mostly `docker.io` or `docker-ce`, in opposite to the non-supported VM based `docker-desktop` package. + - If you prefer podman over Docker, you don't need to care about this difference. ### TL;DR For a quick start: @@ -452,16 +453,18 @@ As root you can install, update and remove x11docker in system directories to be - `x11docker --update-master` : download and install latest master version from github. - `x11docker --remove` : remove all files installed by x11docker. - Note: This does not remove `~/.local/share/x11docker` where it stores persistent files of option `--home`. + - `x11docker --remove-oldprefix` : Before version 7.6.0 x11docker installed itself into `/usr/bin`. + Now it installs into `/usr/local/bin`. Use `--remove-oldprefix` to remove `/usr/bin` installations. To see the difference between current and coming updated version, you can use optional argument `diff` for `--update` and `--update-master`. Example: `x11docker --update-master=diff` will show you the code changes from your current installation to latest master/beta version without installing it. #### Installed files What the installation does (just for information): - - Copies script `x11docker` to `/usr/bin`. - - Installs icon `x11docker.png` in `/usr/share/icons` using `xdg-icon-resource`. - - Copies documentation `README.md`, `CHANGELOG.md` and `LICENSE.txt` to `/usr/share/doc/x11docker`. - - Stores `man` page for x11docker in `/usr/share/man/man1/x11docker.1.gz`. + - Copies script `x11docker` to `/usr/local/bin`. + - Installs icon `x11docker.png` below `/usr/share/icons` using `xdg-icon-resource`. + - Copies documentation `README.md`, `CHANGELOG.md` and `LICENSE.txt` to `/usr/local/share/doc/x11docker`. + - Stores `man` page for x11docker in `/usr/local/share/man/man1/x11docker.1.gz`. #### Shortest way for first installation: - For systems using `sudo`: diff --git a/x11docker b/x11docker index f263c06..f6f1e2c 100755 --- a/x11docker +++ b/x11docker @@ -11,7 +11,7 @@ # Run 'x11docker --help' or scroll down to read usage information. # More documentation at: https://github.com/mviereck/x11docker -Version="7.5.0" +Version="7.6.0" Packagedversion="no" # Set to "yes" if you want to package x11docker. This disables installation options. # --enforce-i: Enforce running in interactive mode to allow commands tty and weston-launch in special setups. (deprecated) @@ -382,9 +382,9 @@ Installation options (need root permissions): installed and new version without installing it. --remove Remove x11docker from your system. Includes --cleanup. Preserves ~/.local/share/x11docker from option --home. ---update, --update-master and --remove regard a possible custom installation -path different from default /usr/bin directory. -Additional options are disregarded." + --remove-oldprefix Before version 7.6.0 x11docker installed itself + into /usr/bin. Now it installs into /usr/local/bin. + Use --remove-oldprefix to remove /usr/bin installations." ;; esac @@ -1451,7 +1451,7 @@ writeaccess() { # check if useruid $1 has write access to folder [ "w" = "$(getfacl -pn "${2:-}" | grep "user:${1:-}:" | rev | cut -c2)" ] && return 0 || return 1 } -#### special jobs of x11docker (not running X or docker) +#### special jobs of x11docker buildimage() { # --build: build image from x11docker repository Dockerfile # Build image $1 from x11docker repository @@ -1642,30 +1642,25 @@ installer() { # --install, --update, --update-master, --remove ### FIXME: (--update) ### maybe not install additional files if x11docker is owned by user - local Key1= Key2= Oldversion= Newversion= Format= - local Binpath Binowner Bingroup Binpathdefault + local Key1= Key2= Oldversion= Newversion= Format= Prefix + + Prefix="/usr/local" - Binpathdefault="/usr/bin" - # Detect existing installation location case "${1:-}" in - --install) - Binpath="$Binpathdefault" - ;; - --update|--update-master|--remove) - grep -q x11docker <<< "$0" && { - Binpath="$(dirname "$0")" - [ -d "$Binpath/.git" ] && Binpath="/usr/bin" - Binpath="$(myrealpath "$Binpath")" - Binowner="$(stat -c '%U' "$Binpath/x11docker")" - Bingroup="$(stat -c '%G' "$Binpath/x11docker")" - } + --remove-oldprefix) + Prefix="/usr" + ;; + *) + [ -x "/usr/bin/x11docker" ] && warning "Option ${1:-}: Detected x11docker installation in /usr/bin + Since version 7.6.0 x11docker defaults to ${Prefix}/bin instead. + If this was a custom installation without your package manager, + you can remove the old installation as root with: +rm /usr/bin/x11docker +rm -R /usr/share/doc/x11docker +rm /usr/share/man/man1/x11docker.1.gz + or with x11docker option --remove-oldprefix" ;; esac - Binpath="${Binpath:-$Binpathdefault}" - Binowner="${Binowner:-root}" - Bingroup="${Bingroup:-root}" - [ "$Binpath" != "$Binpathdefault" ] && note "Option ${1:-}: Detected custom installation path: - $Binpath" [ "$Startuser" != "root" ] && { case "$Winsubsystem" in @@ -1674,14 +1669,8 @@ installer() { # --install, --update, --update-master, --remove 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 + error "Must run as root to install, update or remove x11docker system wide." + return 1 ;; esac ;; @@ -1696,24 +1685,24 @@ installer() { # --install, --update, --update-master, --remove Try 'x11docker --update' instead." return 1 } - command -v x11docker > /dev/null && { + [ -x "${Prefix}/bin/x11docker" ] && { warning "x11docker seems to be installed already - at $Binpath/x11docker. + at ${Prefix}/bin/x11docker. Will overwrite existing installation. Consider to use option '--update' or '--update-master' instead." } ;; --update|--update-master) - [ -x "$Binpath/x11docker" ] && { - Oldversion="$($Binpath/x11docker --version)" + [ -x "${Prefix}/bin/x11docker" ] && { + Oldversion="$(${Prefix}/bin/x11docker --version)" note "Current installed version: x11docker $Oldversion - at $Binpath/x11docker" + at ${Prefix}/bin/x11docker" } || { Oldversion="" } - [ -d /tmp/x11docker-install ] && rm -R /tmp/x11docker-install - mkdir -p /tmp/x11docker-install && cd /tmp/x11docker-install || { + [ -d "/tmp/x11docker-install" ] && rm -R "/tmp/x11docker-install" + mkdir -p "/tmp/x11docker-install" && cd "/tmp/x11docker-install" || { error "Could not create or cd to /tmp/x11docker-install." return 1 } @@ -1742,7 +1731,7 @@ installer() { # --install, --update, --update-master, --remove error "Failed to download CHANGELOG.md from github." return 1 } - Releaseversion="v$(cat CHANGELOG.md | grep "## \[" | grep -v 'Unreleased' | head -n1 | cut -d[ -f2 | cut -d] -f1)" + Releaseversion="v$(cat "CHANGELOG.md" | grep "## \[" | grep -v 'Unreleased' | head -n1 | cut -d[ -f2 | cut -d] -f1)" note "Downloading latest x11docker release $Releaseversion from github." download "https://codeload.github.com/mviereck/x11docker/$Format/$Releaseversion" "x11docker-update.$Format" || { error "Failed to download x11docker from github." @@ -1760,7 +1749,7 @@ installer() { # --install, --update, --update-master, --remove return 1 } echo "" - cd /tmp/x11docker-install/$(ls -l | grep drwx | rev | cut -d' ' -f1 | rev) || { + cd "/tmp/x11docker-install/$(ls -l | grep drwx | rev | cut -d' ' -f1 | rev)" || { error "Could not cd to /tmp/x11docker-update/$(ls -l | grep drwx | rev | cut -d' ' -f1 | rev)" return 1 } @@ -1770,7 +1759,7 @@ installer() { # --install, --update, --update-master, --remove # New version number case "${1:-}" in --install|--update|--update-master) - Newversion="$(bash $(pwd)/x11docker --version)" + Newversion="$(bash "$(pwd)/x11docker" --version)" ;; esac @@ -1807,7 +1796,7 @@ installer() { # --install, --update, --update-master, --remove case "${1:-}" in --update|--update-master) note "Excerpt of x11docker changelog: -$(sed -n "/${Key1}/,/${Key2}/p" CHANGELOG.md | head -n-1)" +$(sed -n "/${Key1}/,/${Key2}/p" "CHANGELOG.md" | head -n-1)" ;; esac @@ -1816,8 +1805,8 @@ $(sed -n "/${Key1}/,/${Key2}/p" CHANGELOG.md | head -n-1)" case "${1:-}" in --update|--update-master) note "Difference of installed version to new version: - $ diff -u -s -Z $Binpath/x11docker $(pwd)/x11docker -$(diff -u -s -Z $Binpath/x11docker $(pwd)/x11docker 2>&1 | sed "s/^+.*/${Colgreenbg}\0${Colnorm}/ ; s/^-.*/${Colredbg}\0${Colnorm}/ ; s/^@.*/${Coluline}\0${Colnorm}/")" + $ diff -u -s -Z '$(command -v x11docker)' '$(pwd)/x11docker' +$(diff -u -s -Z "$(command -v x11docker)" "$(pwd)/x11docker" 2>&1 | sed "s/^+.*/${Colgreenbg}\0${Colnorm}/ ; s/^-.*/${Colredbg}\0${Colnorm}/ ; s/^@.*/${Coluline}\0${Colnorm}/")" ;; esac } @@ -1825,50 +1814,49 @@ $(diff -u -s -Z $Binpath/x11docker $(pwd)/x11docker 2>&1 | sed "s/^+.*/${Colgree # Doing [ -z "$Installerarg" ] && case "${1:-}" in --install|--update|--update-master) - note "Installing x11docker in $Binpath" - cp x11docker "$Binpath/" || { - error "Could not copy x11docker to $Binpath" + note "Installing x11docker to ${Prefix}/bin" + cp "x11docker" "${Prefix}/bin/" || { + error "Could not copy x11docker to ${Prefix}/bin" return 1 } - chmod 755 "$Binpath/x11docker" || { + chmod 755 "${Prefix}/bin/x11docker" || { error "Could not set executable bit on x11docker" return 1 } - chown "$Binowner:$Bingroup" "$Binpath/x11docker" || warning "Could not set ownership '$Binowner:$Bingroup' to '$Binpath/x11docker'" + chown "root:root" "${Prefix}/bin/x11docker" || warning "Could not set ownership 'root:root' to '${Prefix}/bin/x11docker'" note "Installing icon for x11docker with xdg-icon-resource" - xdg-icon-resource install --context apps --novendor --mode system --size 64 "$(pwd)/x11docker.png" x11docker || warning "Could not install icon for x11docker. + xdg-icon-resource install --context apps --novendor --mode system --size 64 "$(pwd)/x11docker.png" "x11docker" || warning "Could not install icon for x11docker. Is 'xdg-icon-resource' (xdg-utils) installed on your system?" - xdg-icon-resource uninstall --size 72 x11docker ||: # deprecated icon size, may still be present. note "Storing README.md, CHANGELOG.md and LICENSE.txt in - /usr/share/doc/x11docker" - mkdir -p /usr/share/doc/x11docker && { - cp README.md /usr/share/doc/x11docker/ - cp CHANGELOG.md /usr/share/doc/x11docker/ - cp LICENSE.txt /usr/share/doc/x11docker/ + ${Prefix}/share/doc/x11docker" + mkdir -p "${Prefix}/share/doc/x11docker" && { + cp "README.md" "${Prefix}/share/doc/x11docker/" + cp "CHANGELOG.md" "${Prefix}/share/doc/x11docker/" + cp "LICENSE.txt" "${Prefix}/share/doc/x11docker/" } || note "Error while creating /usr/share/doc/x11docker" - note "Storing man page in /usr/share/man/man1/x11docker.1.gz" + note "Storing man page in ${Prefix}/share/man/man1/x11docker.1.gz" command -v gzip >/dev/null && { - gzip -c x11docker.man > /usr/share/man/man1/x11docker.1.gz + gzip -c "x11docker.man" > "${Prefix}/share/man/man1/x11docker.1.gz" } || note "Error storing man page." note "Installed x11docker version $Newversion" ;; - --remove) + --remove|--remove-oldprefix) note "Removing x11docker from your system." - cleanup - [ -x "$Binpath/x11docker" ] && rm -v "$Binpath/x11docker" - [ -x "$Binpath/x11docker-gui" ] && rm -v "$Binpath/x11docker-gui" - [ -e "/usr/share/applications/x11docker.desktop" ] && rm -v /usr/share/applications/x11docker.desktop - [ -e "/usr/share/doc/x11docker" ] && rm -R -v /usr/share/doc/x11docker - [ -e "/usr/share/icons/x11docker.png" ] && rm /usr/share/icons/x11docker.png - xdg-icon-resource uninstall --size 64 x11docker ||: - xdg-icon-resource uninstall --size 72 x11docker ||: # deprecated icon size, may still be present. + [ "${1:-}" = "--remove" ] && [ -n "$Backendbin" ] && { + note "Running --cleanup" + cleanup + } + [ -x "${Prefix}/bin/x11docker" ] && rm -v "${Prefix}/bin/x11docker" + [ -e "${Prefix}/share/doc/x11docker" ] && rm -v -R "${Prefix}/share/doc/x11docker" + [ -e "${Prefix}/share/man/man1/x11docker.1.gz" ] && rm -v "${Prefix}/share/man/man1/x11docker.1.gz" + [ "${1:-}" = "--remove" ] && xdg-icon-resource uninstall --size 64 "x11docker" ||: note "Will not remove files in your home folder. - There may be files left in \$HOME/.local/share/x11docker - The symbolic link \$HOME/x11docker may exist, too. + There might be files left in \$HOME/.local/share/x11docker + The symbolic link \$HOME/x11docker might exist, too. The cache folder \$HOME/.cache/x11docker should be removed already." ;; esac @@ -1878,7 +1866,7 @@ $(diff -u -s -Z $Binpath/x11docker $(pwd)/x11docker 2>&1 | sed "s/^+.*/${Colgree --update|--update-master) note "Removing downloaded temporary files." cd ~ - rm -R /tmp/x11docker-install + rm -R "/tmp/x11docker-install" ;; esac note "Ready." @@ -5409,7 +5397,15 @@ check_backend() { # options --backend, --rootless case "$Backend" in docker|podman|nerdctl|proot) - [ -z "$Backendbin" ] && error "Option --backend=$Backend: No binary found for $Backend." + case "$Installermode" in + "") + [ -z "$Backendbin" ] && error "Option --backend=$Backend: No binary found for $Backend." + ;; + *) + [ -z "$Backendbin" ] && note "Option --backend=$Backend: No binary found for $Backend." + return 1 + ;; + esac ;; host) Backendbin="" ;; esac @@ -9203,7 +9199,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,remove-oldprefix,update::,update-master::" # Installation # Longoptions="$Longoptions,experimental,keepcache,remountcgroup,xopt:,xorgconf:" # Experimental Longoptions="$Longoptions,dbus-system,enforce-i,exe,homedir:,hostipc,hostnet,iglx,kwin-xwayland" # Deprecated @@ -9400,11 +9396,11 @@ ${2:-}" ; shift ;; # Add custo --printpid1) Showcontainerpid1pid="${2:-yes}" ; shift ;; # Output of host PID of container PID 1 #### 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|--remove) Installermode="${1:-}" ;; # Installer + --build) Buildimage="yes" ;; # Build an image from x11docker repository + --cleanup) Cleanup="yes" ;; # Remove orphaned containers and cache files + --install|--remove|--remove-oldprefix) Installermode="${1:-}" ;; # Installer --update|--update-master) Installermode="${1:-}" ; Installerarg="${2:-}" ; shift ;; # Installer - --launcher) Createlauncher="yes" ;; # Create application launcher on desktop and exit + --launcher) Createlauncher="yes" ;; # Create application launcher on desktop and exit #### Experimental options --experimental) Experimental="yes" ;; # Allow some experimental code that might be changed at any time @@ -11319,6 +11315,10 @@ unpriv() { # run a command as unprivileged user. Needed if unpriv_backend() { # run container backend rootful or rootless local Command Command="$(oneline "${1:-}")" + [ -z "$Backendbin" ] && { + warning "Binary path for backend $Backend not set." + return 1 + } case "$Backendrootless" in yes) unpriv "$Command" ;; no|"") eval "env DOCKER_HOST= $Command" ;; @@ -11368,11 +11368,12 @@ main() { create_launcher # --launcher: Create application launcher icon on desktop finish } + check_backend # --backend [ "$Installermode" ] && { # --install, --update, --update-master, --remove case "$Packagedversion" in yes) case "$Installermode" in - --install|--update|--update-master|--remove) + --install|--update|--update-master|--remove|--remove-oldprefix) error "Options --install|--update|--update-master|--remove are not supported in packaged versions of x11docker. Please use your package manager instead." @@ -11380,11 +11381,10 @@ main() { esac ;; esac - check_optionset "$Installermode" "$(grep -v -E -- '--install|--update|--update-master|--remove' <<< "$Optionsetall")" ||: + check_optionset "$Installermode" "$(grep -v -E -- '--install|--update|--update-master|--remove|--remove-oldprefix' <<< "$Optionsetall")" ||: installer "$Installermode" finish } - check_backend # --backend [ "$Cleanup" ] && { # --cleanup: Clean up cache and orphaned x11docker containers check_optionset "--cleanup" "$(grep -v -E -- '--cleanup|--backend' <<< "$Optionsetall")" ||: cleanup diff --git a/x11docker.man b/x11docker.man index 5ea1ca3..01e1e86 100644 --- a/x11docker.man +++ b/x11docker.man @@ -608,10 +608,11 @@ installed and new version without installing it. \fB\-\-remove\fR Remove x11docker from your system. Includes \fB\-\-cleanup\fR. Preserves \fI~/.local/share/x11docker\fR from option \fB\-\-home\fR. -.PP -\fB\-\-update\fR, \fB\-\-update\-master\fR and \fB\-\-remove\fR regard a possible custom installation -path different from default \fI\,/usr/bin\/\fP directory. -Additional options are disregarded. +.TP +\fB\-\-remove-oldprefix\fR +Before version 7.6.0 x11docker installed itself +into /usr/bin. Now it installs into /usr/local/bin. +Use --remove-oldprefix to remove /usr/bin installations. .SH "DEPENDENCIES"