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
40 optional_array="LCMS (for color management)
42 exiv2 (for exif handling)
44 evince (for print preview)
46 lua (for --remote commands)
48 libffmpegthumbnailer (for mpeg thumbnails)
49 libffmpegthumbnailer-dev
50 libtiff (for tiff support)
52 libjpeg (for jpeg support)
54 librsvg2 (for viewing .svg images)
56 libwmf (for viewing .wmf images)
58 exiftran (for image rotation)
60 imagemagick (for image rotation)
62 exiv2 command line (for jpeg export)
64 jpgicc (for jpeg export color correction)
66 pandoc (for generating README help file)
68 gphoto2 (for tethered photography and camera download plugins)
70 libimage-exiftool-perl (for jpeg extraction plugin)
71 libimage-exiftool-perl
72 libheif (for HEIF support)
74 libwebp (for WebP images)
76 libdjvulibre (for DjVu images)
78 libopenjp2 (for JP2 images)
80 libraw (for CR3 images)
82 libomp (required by libraw)
84 libarchive (for compressed files e.g. zip, including timezone)
86 libgspell (for spelling checks)
88 libchamplain gtk (for GPS maps)
89 libchamplain-gtk-0.12-dev
90 libchamplain (for GPS maps)
92 libpoppler (for pdf file preview)
94 libjxl (for viewing .jxl images)
97 ####################################################################
99 # Derived from: https://github.com/coto/server-easy-install (GPL)
100 ####################################################################
103 printf '%b\n' "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
108 OS="$(lowercase "$(uname)")"
112 if [ "${OS}" = "windowsnt" ]
115 elif [ "${OS}" = "darwin" ]
120 if [ "${OS}" = "SunOS" ]
124 OSSTR="${OS} ${REV}(${ARCH} $(uname -v))"
125 elif [ "${OS}" = "AIX" ]
127 # shellcheck disable=SC2034
128 OSSTR="${OS} $(oslevel) ($(oslevel -r))"
129 elif [ "${OS}" = "Linux" ]
131 if [ -f /etc/redhat-release ]
133 DistroBasedOn='RedHat'
134 DIST=$(sed s/\ release.*// /etc/redhat-release)
135 PSUEDONAME=$(sed s/.*\(// /etc/redhat-release | sed s/\)//)
136 REV=$(sed s/.*release\ // /etc/redhat-release | sed s/\ .*//)
137 elif [ -f /etc/SuSE-release ]
140 PSUEDONAME=$(tr "\n" ' ' < /etc/SuSE-release | sed s/VERSION.*//)
141 REV=$(tr "\n" ' ' < /etc/SuSE-release | sed s/.*=\ //)
142 elif [ -f /etc/mandrake-release ]
144 DistroBasedOn='Mandrake'
145 PSUEDONAME=$(sed s/.*\(// /etc/mandrake-release | sed s/\)//)
146 REV=$(cat | sed s/.*release\ // /etc/mandrake-release | sed s/\ .*//)
147 elif [ -f /etc/debian_version ]
149 DistroBasedOn='Debian'
150 if [ -f /etc/lsb-release ]
152 DIST=$(grep '^DISTRIB_ID' /etc/lsb-release | awk -F= '{ print $2 }')
153 PSUEDONAME=$(grep '^DISTRIB_CODENAME' /etc/lsb-release | awk -F= '{ print $2 }')
154 REV=$(grep '^DISTRIB_RELEASE' /etc/lsb-release | awk -F= '{ print $2 }')
157 if [ -f /etc/UnitedLinux-release ]
159 DIST="${DIST}[$(tr "\n" ' ' < /etc/UnitedLinux-release | sed s/VERSION.*//)]"
161 OS=$(lowercase "$OS")
162 DistroBasedOn=$(lowercase "$DistroBasedOn")
165 readonly DistroBasedOn
176 for file in $essential_array
178 if package_query "$file"
180 package_install "$file"
186 if package_query "libgtk-3-dev"
188 package_install libgtk-3-dev
191 if package_query "libgtk2.0-dev"
193 package_install libgtk2.0-dev
204 # shellcheck disable=SC2086
217 current_dir="$(basename "$PWD")"
218 if [ "$current_dir" = "geeqie" ]
221 sudo --askpass ninja -C build uninstall
223 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
226 sudo --askpass rm -rf geeqie
229 zenity --title="Uninstall Geeqie" --width=370 --text="This is not a geeqie installation folder!\n\n$PWD" --warning 2> /dev/null
237 if [ "$DistroBasedOn" = "debian" ]
240 # shellcheck disable=SC2086
241 res=$(dpkg-query --show --showformat='${Status}' "$1" 2>> $install_log)
242 if [ "${res}" = "install ok installed" ]
254 if [ "$DistroBasedOn" = "debian" ]
256 # shellcheck disable=SC2024
257 sudo --askpass apt-get --assume-yes install "$@" >> "$install_log" 2>&1
263 rm "$install_pass_script" > /dev/null 2>&1
265 if [ -p "$zen_pipe" ]
267 printf '%b\n' "100" > "$zen_pipe"
268 printf '%b\n' "#End" > "$zen_pipe"
271 zenity --title="$title" --width=370 --text="Geeqie is not installed\nLog file: $install_log" --info 2> /dev/null
273 rm "$zen_pipe" > /dev/null 2>&1
283 # If uninstall has been run, maybe the current directory no longer exists
286 zenity --error --title="Install Geeqie and dependencies" --width=370 --text="Folder $PWD does not exist!" 2> /dev/null
293 if [ "$DistroBasedOn" != "debian" ]
295 zenity --error --title="Install Geeqie and dependencies" --width=370 --text="Unknown operating system:\n
296 Operating System: $OS
298 Psuedoname: $PSUEDONAME
300 DistroBasedOn: $DistroBasedOn
302 Machine: $MACH" 2> /dev/null
307 # Parse the command line
308 OPTS=$(getopt -o vhc:t:b:ld: --long version,help,commit:,tag:,back:,list,debug: -- "$@")
315 printf '%b\n' "$version"
319 printf '%b\n' "$description"
350 printf '%b\n' "Essential libraries:"
351 for file in $essential_array
353 printf '%b\n' "$file"
357 printf '%b\n' "Optional libraries:"
358 for file in $optional_array
360 printf '%b\n' "$file"
366 # If a Geeqie folder already exists here, warn the user
369 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
374 # If it looks like a Geeqie download folder, assume an update
375 if [ -d ".git" ] && [ -d "src" ] && [ -f "geeqie.1" ]
379 # If it looks like something else is already installed here, warn the user
380 if [ -d ".git" ] || [ -d "src" ]
382 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
390 # Use GTK3 as default
393 if [ "$mode" = "install" ]
395 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."
397 title="Install Geeqie and dependencies"
400 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."
402 title="Update Geeqie and re-install"
406 # Ask whether to install GTK3 or uninstall
408 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)
413 # Environment variable SUDO_ASKPASS cannot be "zenity --password",
414 # so create a temporary script containing the command
415 install_pass_script=$(mktemp "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
416 printf '%b\n' "#!/bin/sh
417 if zenity --password --title=\"$title\" --width=370 2>/dev/null
420 fi" > "$install_pass_script"
421 chmod +x "$install_pass_script"
422 export SUDO_ASKPASS="$install_pass_script"
424 if [ "$gtk_version" = "Uninstall" ]
429 # Put the install log in tmp, to avoid writing to PWD during a new install
430 rm install.log 2> /dev/null
431 install_log=$(mktemp "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
433 sleep 100 | zenity --title="$title" --text="Checking for installed files" --width=370 --progress --pulsate 2> /dev/null &
436 # Get the standard options that are not yet installed
438 for file in $optional_array
440 if [ $((i % 2)) -eq 0 ]
442 package_title="$file"
444 if package_query "$file"
446 if [ -z "$option_string" ]
448 option_string="${install_option:+${install_option}}\n${package_title}\n${file}"
450 option_string="${option_string:+${option_string}}\n$install_option\n${package_title}\n${file}"
457 kill "$zen_pid" 2> /dev/null
459 # Ask the user which options to install
460 if [ -n "$option_string" ]
462 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)
468 # Start of Zenity progress section
469 zen_pipe=$(mktemp -u "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
471 (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 &
473 printf '%b\n' "2" > "$zen_pipe"
474 printf '%b\n' "#Installing essential libraries..." > "$zen_pipe"
476 install_essential "$gtk_version"
478 printf '%b\n' "4" > "$zen_pipe"
479 printf '%b\n' "#Installing options..." > "$zen_pipe"
483 printf '%b\n' "6" > "$zen_pipe"
484 printf '%b\n' "#Installing extra loaders..." > "$zen_pipe"
486 printf '%b\n' "10" > "$zen_pipe"
487 printf '%b\n' "#Getting new sources from server..." > "$zen_pipe"
489 if [ "$mode" = "install" ]
491 if ! git clone http://git.geeqie.org/git/geeqie.git >> "$install_log" 2>&1
493 git_error=$(tail -n5 "$install_log" 2>&1)
494 zenity --title="$title" --width=370 --height=400 --error --text="Git error:\n\n$git_error" 2> /dev/null
498 if ! git checkout master >> "$install_log" 2>&1
500 git_error="$(tail -n25 "$install_log" 2>&1)"
501 zenity --title="$title" --width=370 --height=400 --error --text="Git error:\n\n$git_error" 2> /dev/null
504 if ! git pull >> "$install_log" 2>&1
506 git_error=$(tail -n5 "$install_log" 2>&1)
507 zenity --title="$title" --width=370 --height=400 --error --text="Git error:\n\n$git_error" 2> /dev/null
512 printf '%b\n' "20" > "$zen_pipe"
513 printf '%b\n' "#Cleaning installed version..." > "$zen_pipe"
515 if [ "$mode" = "install" ]
519 sudo --askpass ninja -C build uninstall
522 printf '%b\n' "30" > "$zen_pipe"
523 printf '%b\n' "#Checkout required version..." > "$zen_pipe"
527 if ! git checkout master~"$BACK" >> "$install_log" 2>&1
529 git_error=$(tail -n5 "$install_log" 2>&1)
530 zenity --title="$title" --width=370 --height=400 --error --text="Git error:\n\n$git_error" 2> /dev/null
533 elif [ -n "$COMMIT" ]
536 if ! git checkout "$COMMIT" >> "$install_log" 2>&1
538 git_error=$(tail -n5 "$install_log" 2>&1)
539 zenity --title="$title" --width=370 --height=400 --error --text="Git error:\n\n$git_error" 2> /dev/null
544 if ! git checkout "$TAG" >> "$install_log" 2>&1
546 git_error=$(tail -n5 "$install_log" 2>&1)
547 zenity --title="$title" --width=370 --height=400 --error --text="Git error:\n\n$git_error" 2> /dev/null
552 printf '%b\n' "40" > "$zen_pipe"
553 printf '%b\n' "#Creating configuration files..." > "$zen_pipe"
555 if [ -z "${gtk_version%%GTK3*}" ]
558 printf '%b\n' "90 " > "$zen_pipe"
559 printf '%b\n' "#Installing Geeqie..." > "$zen_pipe"
560 ninja -C build install
563 meson configure --no-pager build
564 printf '%b\n' "90 " > "$zen_pipe"
565 printf '%b\n' "#Installing Geeqie..." > "$zen_pipe"
566 sudo --askpass meson install -C build
569 rm "$install_pass_script"
570 mv -f "$install_log" "./build/install.log"
572 printf '%b\n' "100 " > "$zen_pipe"
575 (for i in $(seq 0 4 100)
579 done) | zenity --progress --title="$title" --width=370 --text="Geeqie installation complete...\n" --auto-close --percentage=0 2> /dev/null