From 1e37af8772c69890fcf94e483d10b7a5814b1eec Mon Sep 17 00:00:00 2001 From: cage Date: Fri, 20 Aug 2021 14:23:21 +0200 Subject: [PATCH] - added dependency on 'unzip'; - added 'unzip-file'; - fixed zip-info conatant name. --- Makefile.in | 1 + configure | 49 +++++++++++++++++++++++++++++++++++++++++++ configure.ac | 7 +++++++ src/config.lisp.in | 4 +++- src/config.lisp.in.in | 4 +++- src/os-utils.lisp | 14 +++++++++++++ src/package.lisp | 4 +++- src/zip-info.lisp | 6 +++--- 8 files changed, 83 insertions(+), 6 deletions(-) diff --git a/Makefile.in b/Makefile.in index eda980e..c050343 100644 --- a/Makefile.in +++ b/Makefile.in @@ -327,6 +327,7 @@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ +UNZIP = @UNZIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XDG_OPEN = @XDG_OPEN@ diff --git a/configure b/configure index cc25d10..0546926 100755 --- a/configure +++ b/configure @@ -594,6 +594,7 @@ GIT OPENSSL XDG_OPEN BASH +UNZIP GPG CURL LISP_COMPILER @@ -6314,6 +6315,54 @@ if test "$GPG" = "no" ; then exit 1; fi +# Extract the first word of "unzip", so it can be a program name with args. +set dummy unzip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_UNZIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $UNZIP in + [\\/]* | ?:[\\/]*) + ac_cv_path_UNZIP="$UNZIP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_UNZIP="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_UNZIP" && ac_cv_path_UNZIP="no" + ;; +esac +fi +UNZIP=$ac_cv_path_UNZIP +if test -n "$UNZIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UNZIP" >&5 +$as_echo "$UNZIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + +if test "$GPG" = "no" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Can not find unzip, genpub support will be disabled." >&5 +$as_echo "$as_me: WARNING: Can not find unzip, genpub support will be disabled." >&2;} + exit 1; +fi + # Extract the first word of "bash", so it can be a program name with args. set dummy bash; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 diff --git a/configure.ac b/configure.ac index 2acc049..993e2f1 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,13 @@ if test "$GPG" = "no" ; then exit 1; fi +AC_PATH_PROG([UNZIP],[unzip],[no]) + +if test "$GPG" = "no" ; then + AC_MSG_WARN([Can not find unzip, genpub support will be disabled.]) + exit 1; +fi + AC_PATH_PROG([BASH],[bash],[no]) if test "$BASH" = "no" ; then diff --git a/src/config.lisp.in b/src/config.lisp.in index 6db116f..a1b0720 100644 --- a/src/config.lisp.in +++ b/src/config.lisp.in @@ -15,7 +15,9 @@ (alexandria:define-constant +openssl-bin+ "/usr/bin/openssl" :test #'string=) -(alexandria:define-constant +xdg-open-bin+ "/usr/bin/xdg-open" :test #'string=) +(alexandria:define-constant +xdg-open-bin+ "/usr/bin/xdg-open" :test #'string=) + +(alexandria:define-constant +unzip-bin+ "/usr/bin/unzip" :test #'string=) (defmacro with-return-untranslated ((untranslated) &body body) `(handler-bind ((i18n-conditions:no-translation-table-error diff --git a/src/config.lisp.in.in b/src/config.lisp.in.in index dd6aba0..4db4d58 100644 --- a/src/config.lisp.in.in +++ b/src/config.lisp.in.in @@ -15,7 +15,9 @@ (alexandria:define-constant +openssl-bin+ "@OPENSSL@" :test #'string=) -(alexandria:define-constant +xdg-open-bin+ "@XDG_OPEN@" :test #'string=) +(alexandria:define-constant +xdg-open-bin+ "@XDG_OPEN@" :test #'string=) + +(alexandria:define-constant +unzip-bin+ "@UNZIP@" :test #'string=) (defmacro with-return-untranslated ((untranslated) &body body) `(handler-bind ((i18n-conditions:no-translation-table-error diff --git a/src/os-utils.lisp b/src/os-utils.lisp index 7e16dbe..2c10e54 100644 --- a/src/os-utils.lisp +++ b/src/os-utils.lisp @@ -162,3 +162,17 @@ give-focus-to-message-window) (os-utils:open-link-with-program program resource)) (os-utils:xdg-open resource)))) + +(defun unzip-file (zip-file destination-dir) + (cond + ((not (fs:file-exists-p zip-file)) + (error (format nil (_ "File ~s does not exists")))) + ((not (fs:directory-exists-p destination-dir)) + (error (format nil (_ "Destination directory ~s does not exists")))) + (t + (run-external-program +unzip-bin+ + (list "-o" zip-file "-d" destination-dir) + :search t + :wait t + :output *standard-output* + :error *standard-output*)))) diff --git a/src/package.lisp b/src/package.lisp index a598b8d..ff7f65f 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -34,6 +34,7 @@ :+issue-tracker+ :+openssl-bin+ :+xdg-open-bin+ + :+unzip-bin+ :_ :n_)) @@ -340,7 +341,8 @@ :generate-ssl-certificate :send-to-pipe :open-link-with-program - :open-resource-with-external-program)) + :open-resource-with-external-program + :unzip-file)) (defpackage :text-utils (:use diff --git a/src/zip-info.lisp b/src/zip-info.lisp index f7531d7..8018ec1 100644 --- a/src/zip-info.lisp +++ b/src/zip-info.lisp @@ -43,11 +43,11 @@ +eocd-tot-no-entry-cd+ +eocd-cd-size+ +eocd-cd-offset+ - +zip-file-comment-length+) + +eocd-zip-file-comment-length+) :test #'=) (alexandria:define-constant +eocd-zip-file-comment-offset+ (- +eocd-fixed-size+ - +zip-file-comment-length+) + +eocd-zip-file-comment-length+) :test #'=) (defun open-file (path) @@ -83,6 +83,6 @@ (eocd-offset-minus-zip-comment (- eocd-fixed-part-offset +eocd-zip-file-comment-length+))) (file-position stream eocd-offset-minus-zip-comment) - (let ((comment-size (read-bytes->int stream +zip-file-comment-length+))) + (let ((comment-size (read-bytes->int stream +eocd-zip-file-comment-length+))) (= (+ eocd-fixed-part-offset comment-size) file-size))))))))