4 ## @brief Download, compile, and install Geeqie on Debian-based systems.
6 ## If run from a folder that already contains the Geeqie sources, the source
7 ## code will be updated from the repository.
8 ## Dialogs allow the user to install additional features.
13 Geeqie is an image viewer.
14 This script will download, compile, and install Geeqie on Debian-based systems.
15 If run from a folder that already contains the Geeqie sources, the source
16 code will be updated from the repository.
17 Dialogs allow the user to install additional features.
19 Command line options are:
20 -v --version The version of this file
21 -h --help Output this text
22 -c --commit=ID Checkout and compile commit ID
23 -t --tag=TAG Checkout and compile TAG (e.g. v1.4 or v1.3)
24 -b --back=N Checkout commit -N (e.g. "-b 1" for last-but-one commit)
25 -l --list List required dependencies
28 # Essential for compiling
39 optional_array="LCMS (for color management)
41 exiv2 (for exif handling)
43 evince (for print preview)
45 lua (for --remote commands)
47 libffmpegthumbnailer (for mpeg thumbnails)
48 libffmpegthumbnailer-dev
49 libtiff (for tiff support)
51 libjpeg (for jpeg support)
53 librsvg2 (for viewing .svg images)
55 libwmf (for viewing .wmf images)
57 exiftran (for image rotation)
59 imagemagick (for image rotation)
61 exiv2 command line (for jpeg export)
63 jpgicc (for jpeg export color correction)
65 pandoc (for generating README help file)
67 gphoto2 (for tethered photography and camera download plugins)
69 libimage-exiftool-perl (for jpeg extraction plugin)
70 libimage-exiftool-perl
71 libheif (for HEIF support)
73 webp-pixbuf-loader (for WebP images)
75 libdjvulibre (for DjVu images)
77 libopenjp2 (for JP2 images)
79 libraw (for CR3 images)
81 libomp (required by libraw)
83 libarchive (for compressed files e.g. zip, including timezone)
85 libgspell (for spelling checks)
87 libchamplain gtk (for GPS maps)
88 libchamplain-gtk-0.12-dev
89 libchamplain (for GPS maps)
91 libpoppler (for pdf file preview)
94 ####################################################################
96 # Derived from: https://github.com/coto/server-easy-install (GPL)
97 ####################################################################
100 printf '%b\n' "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
105 OS="$(lowercase "$(uname)")"
109 if [ "${OS}" = "windowsnt" ]
112 elif [ "${OS}" = "darwin" ]
117 if [ "${OS}" = "SunOS" ]
121 OSSTR="${OS} ${REV}(${ARCH} $(uname -v))"
122 elif [ "${OS}" = "AIX" ]
124 # shellcheck disable=SC2034
125 OSSTR="${OS} $(oslevel) ($(oslevel -r))"
126 elif [ "${OS}" = "Linux" ]
128 if [ -f /etc/redhat-release ]
130 DistroBasedOn='RedHat'
131 DIST=$(sed s/\ release.*// /etc/redhat-release)
132 PSUEDONAME=$(sed s/.*\(// /etc/redhat-release | sed s/\)//)
133 REV=$(sed s/.*release\ // /etc/redhat-release | sed s/\ .*//)
134 elif [ -f /etc/SuSE-release ]
137 PSUEDONAME=$(tr "\n" ' ' < /etc/SuSE-release | sed s/VERSION.*//)
138 REV=$(tr "\n" ' ' < /etc/SuSE-release | sed s/.*=\ //)
139 elif [ -f /etc/mandrake-release ]
141 DistroBasedOn='Mandrake'
142 PSUEDONAME=$(sed s/.*\(// /etc/mandrake-release | sed s/\)//)
143 REV=$(cat | sed s/.*release\ // /etc/mandrake-release | sed s/\ .*//)
144 elif [ -f /etc/debian_version ]
146 DistroBasedOn='Debian'
147 if [ -f /etc/lsb-release ]
149 DIST=$(grep '^DISTRIB_ID' /etc/lsb-release | awk -F= '{ print $2 }')
150 PSUEDONAME=$(grep '^DISTRIB_CODENAME' /etc/lsb-release | awk -F= '{ print $2 }')
151 REV=$(grep '^DISTRIB_RELEASE' /etc/lsb-release | awk -F= '{ print $2 }')
154 if [ -f /etc/UnitedLinux-release ]
156 DIST="${DIST}[$(tr "\n" ' ' < /etc/UnitedLinux-release | sed s/VERSION.*//)]"
159 DistroBasedOn=$(lowercase $DistroBasedOn)
162 readonly DistroBasedOn
175 for file in $essential_array
177 if [ $((i % 2)) -ne 0 ]
179 if package_query "$file"
181 package_install "$file"
190 if package_query "libgtk-3-dev"
192 package_install libgtk-3-dev
195 if package_query "libgtk2.0-dev"
197 package_install libgtk2.0-dev
208 # shellcheck disable=SC2086
221 current_dir="$(basename "$PWD")"
222 if [ "$current_dir" = "geeqie" ]
225 sudo --askpass ninja -C build uninstall
227 if ! zenity --title="Uninstall Geeqie" --width=370 --text="WARNING.\nThis will delete folder:\n\n$PWD\n\nand all sub-folders!" --question --ok-label="Cancel" --cancel-label="OK" 2> /dev/null
230 sudo --askpass rm -rf geeqie
233 zenity --title="Uninstall Geeqie" --width=370 --text="This is not a geeqie installation folder!\n\n$PWD" --warning 2> /dev/null
241 if [ "$DistroBasedOn" = "debian" ]
244 # shellcheck disable=SC2086
245 res=$(dpkg-query --show --showformat='${Status}' "$1" 2>> $install_log)
246 if [ "${res}" = "install ok installed" ]
258 if [ "$DistroBasedOn" = "debian" ]
260 # shellcheck disable=SC2024
261 sudo --askpass apt-get --assume-yes install "$@" >> "$install_log" 2>&1
267 rm "$install_pass_script" > /dev/null 2>&1
269 if [ -p "$zen_pipe" ]
271 printf '%b\n' "100" > "$zen_pipe"
272 printf '%b\n' "#End" > "$zen_pipe"
275 zenity --title="$title" --width=370 --text="Geeqie is not installed\nLog file: $install_log" --info 2> /dev/null
277 rm "$zen_pipe" > /dev/null 2>&1
287 # If uninstall has been run, maybe the current directory no longer exists
290 zenity --error --title="Install Geeqie and dependencies" --width=370 --text="Folder $PWD does not exist!" 2> /dev/null
297 if [ "$DistroBasedOn" != "debian" ]
299 zenity --error --title="Install Geeqie and dependencies" --width=370 --text="Unknown operating system:\n
300 Operating System: $OS
302 Psuedoname: $PSUEDONAME
304 DistroBasedOn: $DistroBasedOn
306 Machine: $MACH" 2> /dev/null
311 # Parse the command line
312 OPTS=$(getopt -o vhc:t:b:ld: --long version,help,commit:,tag:,back:,list,debug: -- "$@")
319 printf '%b\n' "$version"
323 printf '%b\n' "$description"
354 printf '%b\n' "Essential libraries:"
355 for file in $essential_array
357 printf '%b\n' "$file"
361 printf '%b\n' "Optional libraries:"
362 for file in $optional_array
364 printf '%b\n' "$file"
370 # If a Geeqie folder already exists here, warn the user
373 zenity --info --title="Install Geeqie and dependencies" --width=370 --text="This script is for use on Ubuntu and other\nDebian-based installations.\nIt will download, compile, and install Geeqie source\ncode and its dependencies.\n\nA sub-folder named \"geeqie\" will be created in the\nfolder this script is run from, and the source code\nwill be downloaded to that sub-folder.\n\nA sub-folder of that name already exists.\nPlease try another folder." 2> /dev/null
378 # If it looks like a Geeqie download folder, assume an update
379 if [ -d ".git" ] && [ -d "src" ] && [ -f "geeqie.1" ]
383 # If it looks like something else is already installed here, warn the user
384 if [ -d ".git" ] || [ -d "src" ]
386 zenity --info --title="Install Geeqie and dependencies" --width=370 --text="This script is for use on Ubuntu and other\nDebian-based installations.\nIt will download, compile, and install Geeqie source\ncode and its dependencies.\n\nIt looks like you are running this script from a folder which already has software installed.\n\nPlease try another folder." 2> /dev/null
394 # Use GTK3 as default
397 if [ "$mode" = "install" ]
399 message="This script is for use on Ubuntu and other\nDebian-based installations.\nIt will download, compile, and install Geeqie source\ncode and its dependencies.\n\nA sub-folder named \"geeqie\" will be created in the\nfolder this script is run from, and the source code\nwill be downloaded to that sub-folder.\n\nIn subsequent dialogs you may choose which\noptional features to install."
401 title="Install Geeqie and dependencies"
404 message="This script is for use on Ubuntu and other\nDebian-based installations.\nIt will update the Geeqie source code and its\ndependencies, and will compile and install Geeqie.\n\nIn subsequent dialogs you may choose which\noptional features to install."
406 title="Update Geeqie and re-install"
410 # Ask whether to install GTK3 or uninstall
412 if ! gtk_version=$(zenity --title="$title" --width=370 --text="$message" --list --radiolist --column "" --column "" "$gtk3_installed" "Install" FALSE "Uninstall" --cancel-label="Cancel" --ok-label="OK" --hide-header 2> /dev/null)
417 # Environment variable SUDO_ASKPASS cannot be "zenity --password",
418 # so create a temporary script containing the command
419 install_pass_script=$(mktemp "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
420 printf '%b\n' "#!/bin/sh
421 if zenity --password --title=\"$title\" --width=370 2>/dev/null
424 fi" > "$install_pass_script"
425 chmod +x "$install_pass_script"
426 export SUDO_ASKPASS=$install_pass_script
428 if [ "$gtk_version" = "Uninstall" ]
434 # Put the install log in tmp, to avoid writing to PWD during a new install
435 rm install.log 2> /dev/null
436 install_log=$(mktemp "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
438 sleep 100 | zenity --title="$title" --text="Checking for installed files" --width=370 --progress --pulsate 2> /dev/null &
441 # Get the standard options that are not yet installed
443 for file in $optional_array
445 if [ $((i % 2)) -eq 0 ]
447 package_title="$file"
449 if package_query "$file"
451 if [ -z "$option_string" ]
453 option_string="${install_option:+${install_option}}\n${package_title}\n${file}"
455 option_string="${option_string:+${option_string}}\n$install_option\n${package_title}\n${file}"
462 kill $zen_pid 2> /dev/null
464 # Ask the user which options to install
465 if [ -n "$option_string" ]
467 if ! options=$(printf '%b\n' "$option_string" | zenity --title="$title" --width=400 --height=500 --list --checklist --text 'Select which library files to install:' --column='Select' --column='Library files' --column='Library' --hide-column=3 --print-column=3 2> /dev/null)
473 # Start of Zenity progress section
474 zen_pipe=$(mktemp -u "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
476 (tail -f "$zen_pipe" 2> /dev/null) | zenity --progress --title="$title" --width=370 --text="Installing options..." --auto-close --auto-kill --percentage=0 2> /dev/null &
478 printf '%b\n' "2" > "$zen_pipe"
479 printf '%b\n' "#Installing essential libraries..." > "$zen_pipe"
481 install_essential "$gtk_version"
483 printf '%b\n' "4" > "$zen_pipe"
484 printf '%b\n' "#Installing options..." > "$zen_pipe"
488 printf '%b\n' "6" > "$zen_pipe"
489 printf '%b\n' "#Installing extra loaders..." > "$zen_pipe"
491 printf '%b\n' "10" > "$zen_pipe"
492 printf '%b\n' "#Getting new sources from server..." > "$zen_pipe"
494 if [ "$mode" = "install" ]
496 if ! git clone git://geeqie.org/geeqie.git >> "$install_log" 2>&1
498 git_error=$(tail -n5 "$install_log" 2>&1)
499 zenity --title="$title" --width=370 --height=400 --error --text="Git error:\n\n$git_error" 2> /dev/null
503 if ! git checkout master >> "$install_log" 2>&1
505 git_error="$(tail -n25 "$install_log" 2>&1)"
506 zenity --title="$title" --width=370 --height=400 --error --text="Git error:\n\n$git_error" 2> /dev/null
509 if ! git pull >> "$install_log" 2>&1
511 git_error=$(tail -n5 "$install_log" 2>&1)
512 zenity --title="$title" --width=370 --height=400 --error --text="Git error:\n\n$git_error" 2> /dev/null
517 printf '%b\n' "20" > "$zen_pipe"
518 printf '%b\n' "#Cleaning installed version..." > "$zen_pipe"
520 if [ $mode = "install" ]
524 sudo --askpass ninja -C build uninstall
527 printf '%b\n' "30" > "$zen_pipe"
528 printf '%b\n' "#Checkout required version..." > "$zen_pipe"
532 if ! git checkout master~"$BACK" >> "$install_log" 2>&1
534 git_error=$(tail -n5 "$install_log" 2>&1)
535 zenity --title="$title" --width=370 --height=400 --error --text="Git error:\n\n$git_error" 2> /dev/null
541 if ! git checkout "$COMMIT" >> "$install_log" 2>&1
543 git_error=$(tail -n5 "$install_log" 2>&1)
544 zenity --title="$title" --width=370 --height=400 --error --text="Git error:\n\n$git_error" 2> /dev/null
549 if ! git checkout "$TAG" >> "$install_log" 2>&1
551 git_error=$(tail -n5 "$install_log" 2>&1)
552 zenity --title="$title" --width=370 --height=400 --error --text="Git error:\n\n$git_error" 2> /dev/null
558 printf '%b\n' "40" > "$zen_pipe"
559 printf '%b\n' "#Creating configuration files..." > "$zen_pipe"
561 if [ -z "${gtk_version%%GTK3*}" ]
564 printf '%b\n' "90 " > "$zen_pipe"
565 printf '%b\n' "#Installing Geeqie..." > "$zen_pipe"
566 ninja -C build install
569 meson configure build
570 printf '%b\n' "90 " > "$zen_pipe"
571 printf '%b\n' "#Installing Geeqie..." > "$zen_pipe"
572 ninja -C build install
575 rm "$install_pass_script"
576 mv -f "$install_log" "./build/install.log"
578 printf '%b\n' "100 " > "$zen_pipe"
581 (for i in $(seq 0 4 100)
585 done) | zenity --progress --title="$title" --width=370 --text="Geeqie installation complete...\n" --auto-close --percentage=0 2> /dev/null