Remove ZoneDetect .bin file from repository
authorColin Clark <colin.clark@cclark.uk>
Mon, 20 Aug 2018 13:34:57 +0000 (14:34 +0100)
committerColin Clark <colin.clark@cclark.uk>
Mon, 20 Aug 2018 13:34:57 +0000 (14:34 +0100)
A Debian maintainer has pointed out that Debian does not permit .bin
files in the packages they create.
The ZoneDetect database file, timezone21.bin has therefore been removed
from the repository.

New users must download the .bin file themself if they require UTC/DST
time offset.

This situation exists because the ZoneDetect developer has not yet put
the source code for the database generator onto GitHub - when that
happens, the database file will be generated by Geeqie (using the
ZoneDetect sources) during the installation procedure.

README.md
configure.in
plugins/Makefile.am
plugins/ZoneDetect/Makefile.am [deleted file]
plugins/ZoneDetect/timezone21.bin [deleted file]
src/exif-common.c
web/geeqie-install-debian.sh

index f61d860..9fb4ad4 100644 (file)
--- a/README.md
+++ b/README.md
@@ -231,6 +231,13 @@ And either the ChangeLog file or [Geeqie ChangeLog](http://geeqie.org/cgi-bin/gi
         for displaying pdf files
         disable with configure option: --disable-pdf
 
+    ZoneDetect
+        For displaying timezone and UTC/DST time offset
+        Download file:
+        https://github.com/BertoldVdb/ZoneDetect/raw/master/database/timezone21.bin
+        and copy to the location of the Geeqie ancilliary files, which is usually:
+        /usr/local/lib/geeqie/
+
 ### Code hackers:
 
 If you plan on making any major changes to the code that will be offered for
index da4e7e0..6fb207e 100644 (file)
@@ -619,7 +619,6 @@ AC_CONFIG_FILES([
     plugins/ufraw/Makefile
     plugins/import/Makefile
     plugins/geocode-parameters/Makefile
-    plugins/ZoneDetect/Makefile
     geeqie.spec
 ])
 
@@ -685,4 +684,3 @@ cat <<EOF
   (or you take blue pill and the story ends :)
 
 EOF
-
index 4b57bd0..9d1aaca 100644 (file)
@@ -1,6 +1,6 @@
 #FIXME enable or disable individual plugins from configure
 
-SUBDIRS = rotate symlink ufraw import geocode-parameters ZoneDetect
+SUBDIRS = rotate symlink ufraw import geocode-parameters
 qq_desktoptemplatedir = $(appdir)
 qq_desktoptemplate_DATA = template.desktop
 
diff --git a/plugins/ZoneDetect/Makefile.am b/plugins/ZoneDetect/Makefile.am
deleted file mode 100644 (file)
index adead9a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-dist_gq_bin_SCRIPTS = timezone21.bin
diff --git a/plugins/ZoneDetect/timezone21.bin b/plugins/ZoneDetect/timezone21.bin
deleted file mode 100644 (file)
index 02b6645..0000000
Binary files a/plugins/ZoneDetect/timezone21.bin and /dev/null differ
index e3b4af4..c060dd6 100644 (file)
@@ -724,52 +724,55 @@ static gchar *exif_build_formatted_localtime(ExifData *exif)
                        }
 
                zd_path = g_build_filename(GQ_BIN_DIR, TIMEZONE_DATABASE, NULL);
-               cd = ZDOpenDatabase(zd_path);
-               if (cd)
+               if (g_file_test(zd_path, G_FILE_TEST_EXISTS))
                        {
-                       results = ZDLookup(cd, latitude, longitude, NULL);
-                       zone_selected = zd_tz(results);
-                       time_zone = g_strconcat("TZ=", zone_selected, NULL);
-                       time_zone_org = g_strconcat("TZ=", getenv("TZ"), NULL);
-                       putenv("TZ=UTC");
-                       g_free(zone_selected);
-
-                       memset(&tm_utc, 0, sizeof(tm_utc));
-                       if (text_date_time && strptime(text_date_time, "%Y:%m:%d:%H:%M:%S", &tm_utc))
+                       cd = ZDOpenDatabase(zd_path);
+                       if (cd)
                                {
-                               stamp = mktime(&tm_utc);        // Convert the struct to a Unix timestamp
-                               putenv(time_zone);      // Switch to destination time zone
+                               results = ZDLookup(cd, latitude, longitude, NULL);
+                               zone_selected = zd_tz(results);
+                               time_zone = g_strconcat("TZ=", zone_selected, NULL);
+                               time_zone_org = g_strconcat("TZ=", getenv("TZ"), NULL);
+                               putenv("TZ=UTC");
+                               g_free(zone_selected);
+
+                               memset(&tm_utc, 0, sizeof(tm_utc));
+                               if (text_date_time && strptime(text_date_time, "%Y:%m:%d:%H:%M:%S", &tm_utc))
+                                       {
+                                       stamp = mktime(&tm_utc);        // Convert the struct to a Unix timestamp
+                                       putenv(time_zone);      // Switch to destination time zone
 
-                               tm_local = localtime(&stamp);
+                                       tm_local = localtime(&stamp);
 
-                               /* Convert to localtime using locale */
-                               buflen = strftime(buf, sizeof(buf), "%x %X", tm_local);
-                               if (buflen > 0)
-                                       {
-                                       tmp = g_locale_to_utf8(buf, buflen, NULL, NULL, &error);
-                                       if (error)
+                                       /* Convert to localtime using locale */
+                                       buflen = strftime(buf, sizeof(buf), "%x %X", tm_local);
+                                       if (buflen > 0)
                                                {
-                                               log_printf("Error converting locale strftime to UTF-8: %s\n", error->message);
-                                               g_error_free(error);
-                                               }
-                                       else
-                                               {
-                                               g_free(text_date_time);
-                                               text_date_time = g_strdup(tmp);
+                                               tmp = g_locale_to_utf8(buf, buflen, NULL, NULL, &error);
+                                               if (error)
+                                                       {
+                                                       log_printf("Error converting locale strftime to UTF-8: %s\n", error->message);
+                                                       g_error_free(error);
+                                                       }
+                                               else
+                                                       {
+                                                       g_free(text_date_time);
+                                                       text_date_time = g_strdup(tmp);
+                                                       }
                                                }
+                                               g_free(tmp);
                                        }
-                                       g_free(tmp);
-                               }
-                       putenv(time_zone_org);
+                               putenv(time_zone_org);
 
-                       g_free(time_zone);
-                       g_free(time_zone_org);
-                       }
-               else
-                       {
-                       log_printf("Error: Init of timezone database %s failed\n", zd_path);
+                               g_free(time_zone);
+                               g_free(time_zone_org);
+                               }
+                       else
+                               {
+                               log_printf("Error: Init of timezone database %s failed\n", zd_path);
+                               }
+                       ZDCloseDatabase(cd);
                        }
-               ZDCloseDatabase(cd);
                g_free(zd_path);
                }
 
@@ -839,18 +842,21 @@ static gchar *exif_build_formatted_timezone(ExifData *exif)
                        longitude = -longitude;
                        }
                zd_path = g_build_filename(GQ_BIN_DIR, TIMEZONE_DATABASE, NULL);
-               cd = ZDOpenDatabase(zd_path);
-               if (cd)
+               if (g_file_test(zd_path, G_FILE_TEST_EXISTS))
                        {
-                       results = ZDLookup(cd, latitude, longitude, NULL);
-                       time_zone = zd_tz(results);
-                       ZDFreeResults(results);
-                       }
-               else
-                       {
-                       log_printf("Error: Init of timezone database %s failed\n", zd_path);
+                       cd = ZDOpenDatabase(zd_path);
+                       if (cd)
+                               {
+                               results = ZDLookup(cd, latitude, longitude, NULL);
+                               time_zone = zd_tz(results);
+                               ZDFreeResults(results);
+                               }
+                       else
+                               {
+                               log_printf("Error: Init of timezone database %s failed\n", zd_path);
+                               }
+                       ZDCloseDatabase(cd);
                        }
-               ZDCloseDatabase(cd);
                g_free(zd_path);
                }
 
index 745d938..52bd289 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-version="2018-08-06"
+version="2018-08-20"
 description=$'
 Geeqie is an image viewer.
 This script will download, compile, and install Geeqie on Debian-based systems.
@@ -14,6 +14,7 @@ Command line options are:
 -c --commit=ID Checkout and compile commit ID
 -t --tag=TAG Checkout and compile TAG (e.g. v1.4 or v1.3)
 -b --back=N Checkout commit -N (e.g. "-b 1" for last-but-one commit)
+-d --debug=yes Compile with debug output
 '
 
 # Essential for compiling
@@ -151,190 +152,190 @@ systemProfile()
 
 install_essential()
 {
-arraylength=${#essential_array[@]}
-for (( i=0; i<${arraylength}; i=i+1 ));
-do
-       package_query ${essential_array[$i]}
-       if [ $? != 0 ]
-       then
-               package_install ${essential_array[$i]}
-       fi
-done
+       arraylength=${#essential_array[@]}
+       for (( i=0; i<${arraylength}; i=i+1 ));
+       do
+               package_query ${essential_array[$i]}
+               if [ $? != 0 ]
+               then
+                       package_install ${essential_array[$i]}
+               fi
+       done
 
-if [[ $1 == "GTK3" ]]
-then
-       package_query "libgtk-3-dev"
-       if [ $? != 0 ]
-       then
-               package_install libgtk-3-dev
-       fi
-else
-       package_query "libgtk2.0-dev"
-       if [ $? != 0 ]
+       if [[ $1 == "GTK3" ]]
        then
-               package_install libgtk2.0-dev
+               package_query "libgtk-3-dev"
+               if [ $? != 0 ]
+               then
+                       package_install libgtk-3-dev
+               fi
+       else
+               package_query "libgtk2.0-dev"
+               if [ $? != 0 ]
+               then
+                       package_install libgtk2.0-dev
+               fi
        fi
-fi
 }
 
 install_options()
 {
-if [ -n "$options" ]
-then
-       OLDIFS=$IFS
-       IFS='|'
-       set $options
-       while [ $# -gt 0 ];
-       do
-               package_install $1
-               shift
-       done
-       IFS=$OLDIFS
-fi
+       if [ -n "$options" ]
+       then
+               OLDIFS=$IFS
+               IFS='|'
+               set $options
+               while [ $# -gt 0 ];
+               do
+                       package_install $1
+                       shift
+               done
+               IFS=$OLDIFS
+       fi
 }
 
 install_webp()
 {
-rm -rf webp-pixbuf-loader-master
-package_install libglib2.0-dev libgdk-pixbuf2.0-dev libwebp-dev python-minimal
-wget https://github.com/aruiz/webp-pixbuf-loader/archive/master.zip
-unzip master.zip
-cd webp-pixbuf-loader-master
-./waf configure
-./waf build
-sudo --askpass ./waf install
-sudo --askpass gdk-pixbuf-query-loaders --update-cache
-cd -
-rm -rf webp-pixbuf-loader-master
-rm master.zip
+       rm -rf webp-pixbuf-loader-master
+       package_install libglib2.0-dev libgdk-pixbuf2.0-dev libwebp-dev python-minimal
+       wget https://github.com/aruiz/webp-pixbuf-loader/archive/master.zip
+       unzip master.zip
+       cd webp-pixbuf-loader-master
+       ./waf configure
+       ./waf build
+       sudo --askpass ./waf install
+       sudo --askpass gdk-pixbuf-query-loaders --update-cache
+       cd -
+       rm -rf webp-pixbuf-loader-master
+       rm master.zip
 }
 
 install_psd()
 {
-rm -rf gdk-pixbuf-psd
-git clone https://github.com/and-rom/gdk-pixbuf-psd.git
-cd gdk-pixbuf-psd
-./autogen.sh
-make
-sudo --askpass make install
-sudo --askpass gdk-pixbuf-query-loaders --update-cache
-cd -
-rm -rf gdk-pixbuf-psd
+       rm -rf gdk-pixbuf-psd
+       git clone https://github.com/and-rom/gdk-pixbuf-psd.git
+       cd gdk-pixbuf-psd
+       ./autogen.sh
+       make
+       sudo --askpass make install
+       sudo --askpass gdk-pixbuf-query-loaders --update-cache
+       cd -
+       rm -rf gdk-pixbuf-psd
 }
 
 install_xcf()
 {
-rm -rf xcf-pixbuf-loader
-package_install libbz2-dev
-git clone https://github.com/StephaneDelcroix/xcf-pixbuf-loader.git
-cd xcf-pixbuf-loader
-./autogen.sh
-make
-
-# There must be a better way...
-loader_locn=$(gdk-pixbuf-query-loaders | grep "LoaderDir" | tr -d '#[:space:]')
-
-OLDIFS=$IFS
-IFS='='
-set $loader_locn
-OLDIFS=$IFS
-
-if [ -d $2 ]
-then
-       sudo --askpass cp .libs/libioxcf.so $2
-       sudo --askpass gdk-pixbuf-query-loaders --update-cache
-fi
-cd -
-rm -rf xcf-pixbuf-loader
+       rm -rf xcf-pixbuf-loader
+       package_install libbz2-dev
+       git clone https://github.com/StephaneDelcroix/xcf-pixbuf-loader.git
+       cd xcf-pixbuf-loader
+       ./autogen.sh
+       make
+
+       # There must be a better way...
+       loader_locn=$(gdk-pixbuf-query-loaders | grep "LoaderDir" | tr -d '#[:space:]')
+
+       OLDIFS=$IFS
+       IFS='='
+       set $loader_locn
+       OLDIFS=$IFS
+
+       if [ -d $2 ]
+       then
+               sudo --askpass cp .libs/libioxcf.so $2
+               sudo --askpass gdk-pixbuf-query-loaders --update-cache
+       fi
+       cd -
+       rm -rf xcf-pixbuf-loader
 }
 
 install_extra_loaders()
 {
-if [ -n "$extra_loaders" ]
-then
-       OLDIFS=$IFS
-       IFS='|'
-       set $extra_loaders
-       while [ $# -gt 0 ];
-       do
-               case $1 in
-               "webp" )
-                       install_webp
-               ;;
-               "psd" )
-                       install_psd
-               ;;
-               "xcf" )
-                       install_xcf
-               ;;
-               esac
-
-               shift
-       done
-       IFS=$OLDIFS
-fi
-return
+       if [ -n "$extra_loaders" ]
+       then
+               OLDIFS=$IFS
+               IFS='|'
+               set $extra_loaders
+               while [ $# -gt 0 ];
+               do
+                       case $1 in
+                       "webp" )
+                               install_webp
+                       ;;
+                       "psd" )
+                               install_psd
+                       ;;
+                       "xcf" )
+                               install_xcf
+                       ;;
+                       esac
+
+                       shift
+               done
+               IFS=$OLDIFS
+       fi
+       return
 }
 
 uninstall()
 {
-current_dir=$(basename $PWD)
-if [[ $current_dir == "geeqie" ]]
-then
-       sudo --askpass make uninstall
-       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
-
-       if [[ $? == 1 ]]
+       current_dir=$(basename $PWD)
+       if [[ $current_dir == "geeqie" ]]
        then
-               cd ..
-               sudo --askpass rm -rf geeqie
+               sudo --askpass make uninstall
+               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
+
+               if [[ $? == 1 ]]
+               then
+                       cd ..
+                       sudo --askpass rm -rf geeqie
+               fi
+       else
+               zenity --title="Uninstall Geeqie" --width=370 --text="This is not a geeqie installation folder!\n\n$PWD" --warning 2>/dev/null
        fi
-else
-       zenity --title="Uninstall Geeqie" --width=370 --text="This is not a geeqie installation folder!\n\n$PWD" --warning 2>/dev/null
-fi
 
-exit_install
+       exit_install
 }
 
 package_query()
 {
-if [[ $DistroBasedOn == "debian" ]]
-then
-       res=$(dpkg-query --show --showformat='${Status}' $1 2>>$install_log)
-       if [[ "$res" == "install ok installed"* ]]
+       if [[ $DistroBasedOn == "debian" ]]
        then
-               status=0
-       else
-               status=1
+               res=$(dpkg-query --show --showformat='${Status}' $1 2>>$install_log)
+               if [[ "$res" == "install ok installed"* ]]
+               then
+                       status=0
+               else
+                       status=1
+               fi
        fi
-fi
-return $status
+       return $status
 }
 
 package_install()
 {
-if [[ $DistroBasedOn == "debian" ]]
-then
-       sudo --askpass apt-get --assume-yes install $@ >>$install_log 2>&1
-fi
+       if [[ $DistroBasedOn == "debian" ]]
+       then
+               sudo --askpass apt-get --assume-yes install $@ >>$install_log 2>&1
+       fi
 }
 
 exit_install()
 {
-rm $install_pass_script >/dev/null 2>&1
-#~ rm $install_log >/dev/null 2>&1
+       rm $install_pass_script >/dev/null 2>&1
+       #~ rm $install_log >/dev/null 2>&1
 
-if [[ -p $zen_pipe ]]
-then
-       echo "100" > $zen_pipe
-       echo "#End" > $zen_pipe
-fi
+       if [[ -p $zen_pipe ]]
+       then
+               echo "100" > $zen_pipe
+               echo "#End" > $zen_pipe
+       fi
 
-zenity --title="$title" --width=370 --text=$'Geeqie is not installed\nLog file: '$install_log --info 2>/dev/null
+       zenity --title="$title" --width=370 --text=$'Geeqie is not installed\nLog file: '$install_log --info 2>/dev/null
 
-rm $zen_pipe >/dev/null 2>&1
+       rm $zen_pipe >/dev/null 2>&1
 
-exit 1
+       exit 1
 }
 
 # Entry point
@@ -365,7 +366,7 @@ Machine: $MACH" 2>/dev/null
 fi
 
 # Parse the comand line
-OPTS=$(getopt -o vhc:t:b: --long version,help,commit:,tag:,back: -- "$@")
+OPTS=$(getopt -o vhc:t:b:d: --long version,help,commit:,tag:,back:,debug: -- "$@")
 eval set -- "$OPTS"
 
 while true;
@@ -394,6 +395,11 @@ do
                shift;
                shift
                ;;
+       -d | --debug )
+               DEBUG="$2"
+               shift;
+               shift
+               ;;
        * ) break
                ;;
        esac
@@ -674,15 +680,21 @@ then
                exit
        fi
 fi
+if [[ "$DEBUG" == "yes" ]]
+then
+       debug_opt=""
+else
+       debug_opt="--disable-debug-log"
+fi
 
 echo "40" > $zen_pipe
 echo "#Creating configuration files..." > $zen_pipe
 
 if [[ $gtk_version == "GTK3"* ]]
 then
-       ./autogen.sh >>$install_log 2>&1
+       ./autogen.sh "$debug_opt" >>$install_log 2>&1
 else
-       ./autogen.sh --disable-gtk3 >>$install_log 2>&1
+       ./autogen.sh "$debug_opt" --disable-gtk3 >>$install_log 2>&1
 fi
 
 echo "60" > $zen_pipe
@@ -692,17 +704,40 @@ export CFLAGS=$CFLAGS" -Wno-deprecated-declarations"
 export CXXFLAGS=$CXXFLAGS" -Wno-deprecated-declarations"
 make -j >>$install_log 2>&1
 
+if [[ $? != 0 ]]
+then
+       zenity --title="$title" --width=370 --height=400 --error --text=$'Compile error' 2>/dev/null
+       exit_install
+       exit
+fi
+
 echo "90 " > $zen_pipe
 echo "#Installing Geeqie..." > $zen_pipe
 
 sudo --askpass make install >>$install_log 2>&1
 
+# This is a temporary fix until the ZoneDetect project releases its source code
+zonedetect_message="ZoneDetect database not loaded"
+if [[ -d "/usr/local/lib/geeqie" ]]
+then
+       if [[ ! -f "/usr/local/lib/geeqie/timezone21.bin" ]]
+       then
+               sudo --askpass wget --directory-prefix=/usr/local/lib/geeqie/ https://github.com/BertoldVdb/ZoneDetect/raw/master/database/timezone21.bin >>$install_log 2>&1
+               if [[ $? == 0 ]]
+               then
+                       zonedetect_message=""
+               fi
+       else
+               zonedetect_message=""
+       fi
+fi
+
 rm $install_pass_script
 mv -f $install_log install.log;
 
 echo "100 " > $zen_pipe
 rm $zen_pipe
 
-(for i in $(seq 0 4 100); do echo "$i"; sleep 0.1; done) | zenity --progress --title="$title" --width=370 --text="Geeqie installation complete...\n" --auto-close 2>/dev/null
+(for i in $(seq 0 4 100); do echo "$i"; sleep 0.1; done) | zenity --progress --title="$title" --width=370 --text="Geeqie installation complete...\n$zonedetect_message" --auto-close --percentage=0 2>/dev/null
 
 exit