Skip to content

Commit

Permalink
--update: support tar beside unzip #115
Browse files Browse the repository at this point in the history
  • Loading branch information
mviereck committed May 5, 2019
1 parent 599f113 commit 234ef69
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Project website: https://github.com/mviereck/x11docker
### Fixed
- WSL: Add Windows System32 path to `PATH`. Can miss with `sudo`.
[(#153)](https://github.com/mviereck/x11docker/issues/153)
- `--update`, `--update-master`: Support more common `tar` beside `unzip`.
[(#115)](https://github.com/mviereck/x11docker/issues/115)

## [5.6.0](https://github.com/mviereck/x11docker/releases/tag/v5.6.0) - 2019-05-02
### Added
Expand Down
36 changes: 20 additions & 16 deletions x11docker
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ installer() { # --install, --update, --update-master, --remove
# - download and install latest master version from github
# --remove
# - remove installed files
local Key1= Key2= Oldversion= Newversion=
local Key1= Key2= Oldversion= Newversion= Format=
export PATH="${PATH:-}:/usr/local/bin" # avoid bug on opensuse where root does not have this in $PATH. Will become obsolete as new default is /usr/bin

# Prepairing
Expand All @@ -1069,29 +1069,33 @@ installer() { # --install, --update, --update-master, --remove
note "Current installed version: x11docker $Oldversion"

[ -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"
mkdir -p /tmp/x11docker-install && cd /tmp/x11docker-install || error "Could not create or cd to /tmp/x11docker-install."
download || error "Neither wget nor curl found. Need 'wget' or 'curl'for download.
Please install wget or curl."
command -v unzip >/dev/null || error "Can not unpack archive. Please install 'unzip'."
command -v unzip >/dev/null && Format="zip"
command -v tar >/dev/null && Format="tar.gz"
[ "$Format" ] || error "Cannot extract archive. Please install 'unzip' or 'tar'."

case ${1:-} in
--update-master)
note "Downloading latest x11docker master version from github"
download "https://codeload.github.com/mviereck/x11docker/zip/master" "x11docker-update.zip" || error "Could not download x11docker-master from github"
note "Downloading latest x11docker master version from github."
download "https://codeload.github.com/mviereck/x11docker/$Format/master" "x11docker-update.$Format" || error "Failed to download x11docker from github."
;;
--update)
download "https://raw.githubusercontent.com/mviereck/x11docker/master/CHANGELOG.md" "CHANGELOG.md" || error "Could not download CHANGELOG.md from github."
download "https://raw.githubusercontent.com/mviereck/x11docker/master/CHANGELOG.md" "CHANGELOG.md" || error "Failed to download CHANGELOG.md from github."
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://github.com/mviereck/x11docker/archive/$Releaseversion.zip" "x11docker-update.zip" || error "Could not download latest x11docker release from github."
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."
;;
esac

note "Unpacking archive"
unzip x11docker-update.zip || error "Could not unzip archive."

note "Extracting $Format archive."
case $Format in
zip) unzip "x11docker-update.$Format" ;;
tar.gz) tar xzf "x11docker-update.$Format" ;;
esac || error "Failed to extract $Format archive."
echo ""
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)"
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)"
;;
esac

Expand All @@ -1110,7 +1114,7 @@ installer() { # --install, --update, --update-master, --remove
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 "Creating application entry for x11docker"
note "Creating application entry for x11docker."
[ -e "/usr/bin/x11docker-gui" ] && {
echo "[Desktop Entry]
Version=1.0
Expand Down Expand Up @@ -1141,7 +1145,7 @@ installer() { # --install, --update, --update-master, --remove
note "Installed x11docker version $Newversion"
;;
--remove)
note "Removing x11docker from your system"
note "Removing x11docker from your system."
cleanup
[ -x /usr/local/bin/x11docker ] && { # from older installations. /usr/bin is default now as /usr/local/bin can miss in $PATH for root
rm -v /usr/local/bin/x11docker
Expand All @@ -1166,7 +1170,7 @@ installer() { # --install, --update, --update-master, --remove
# Cleanup
case ${1:-} in
--update|--update-master)
note "Removing downloaded temporary files ..."
note "Removing downloaded temporary files."
cd ~
rm -R /tmp/x11docker-install
;;
Expand Down Expand Up @@ -7349,7 +7353,7 @@ main "$@"

#### ToDo notes for development
todo() {
# BUG --runtime=kata-runtime: ALT-GR works wrong.
# BUG --runtime=kata-runtime --nxagent: ALT-GR works wrong.
# x11docker/check: --alsa: check soundcard iteration

# FIXME: myrealpath(): If realpath is missing, the path argument is returned without resolving.
Expand Down

0 comments on commit 234ef69

Please sign in to comment.