From: Perforce Review Daemon <p4review AT smee.org>
To: "Andrew Stitt" <a AT t.armory.com>, "Arjan Bouter" <abouter AT gmail.com>, "Arwed von Merkatz" <v.merkatz AT gmx.net>, "SM-Commit Daemon" <sm-commit AT lists.ibiblio.org>, "David Michael Leo Brown Jr." <dmlb2000 AT gmail.com>, "David Kowis" <dkowis+smgl-p4 AT shlrm.org>, "duane_malcolm" <d.malcolm AT auckland.ac.nz>, "Eric Sandall" <eric AT sandall.us>, "Jason Flatt" <jflatt AT sourcemage.org>, "Jeremy Blosser" <jblosser AT sourcemage.org>, "Ladislav Hagara" <ladislav.hagara AT unob.cz>, "Maurizio Boriani" <baux AT member.fsf.org>, "Robin Cook" <rcook AT wyrms.net>, "Unet" <unet AT sourcemage.org>, "vladimir_marek" <vlmarek AT volny.cz>
Subject: [SM-Commit] PERFORCE change 76792 by David Michael Leo Brown Jr. for review
Date: Sat, 25 Mar 2006 23:05:01 +0000 (GMT)
Change 76792 by david_brown@dmlb2000-dmlb2004 on 2006/03/25 23:00:20
@@ -1,4 +1,13 @@
2006-03-25 Andrew Stitt <astitt AT sourcemage.org>
+ * libunpack: check for spell or actual command before assuming
+ verification cannot be done.
+
+2006-03-25 Andrew Stitt <astitt AT sourcemage.org>
+ * libunpack: move verification code out of unpack_file and into
+ new verify_file function. Removed un-used inner loop.
+ * libapi: add entry point for verify_file. Fixes bug 10684.
+
+2006-03-25 Andrew Stitt <astitt AT sourcemage.org>
* libsorcery: remove LC_ALL hack
* cast: put slightly safer LC_ALL hack in cast around the build
phase. This fixes bug 10546, see also bug 2910.
@@ -77,6 +77,7 @@
# unpack (libunpack) (deprecated)
# unpack_file (libunpack)
# unpack_file_simple (libunpack)
+# verify_file (libunpack)
#
# Read-only variable that might be of use to a spell:
# SOURCE_CACHE, OPTS, BUILD HOST, INSTALL_ROOT
@@ -1076,6 +1077,21 @@
#---------------------------------------------------------------------
## @Type API
+## @param SOURCE suffix
+## @See <@function var.lib.sorcery.modules.libunpack.html,real_verify_file>
for more details.
+##
+## verify_file takes the SOURCE suffix and verifies the file without
+## unpacking it. It does not work with the old 'MD5[0]=...' style.
+## Only with the "new" SOURCEn_(GPG|HASH|IGNORE) style.
+##
+#---------------------------------------------------------------------
+function verify_file () {
+ debug "libapi" "verify_file - $*"
+ real_verify_file "$@"
+}
+
+#---------------------------------------------------------------------
+## @Type API
## @param Target of the trigger
## @param Action to execute
## @See <@function var.lib.sorcery.modules.libdepends.html,real_up_triggers>
for more details.
- local GPGNUM="$1"
- local SVAR="SOURCE${GPGNUM}"
+ local FILENUM="$1"
+ local SVAR="SOURCE${FILENUM}"
- local crypto_func
- for crypto_func in GPG HASH IGNORE; do
- debug "libgrimoire" "checking $crypto_func verification"
- local AVAR="SOURCE${GPGNUM}_${crypto_func}"
- local AVARN="$AVAR"
- local iter=0
- local rc=""
- # NOTE ## date: 2005-08-25
- # This while loop runs through the SOURCEn_{GPG|HASH|IGNORE}m not the
- # SOURCEn_*[m] set of vars this is kinda confusing we might rip it out
- while [ -n "${!AVARN}" ]; do
- local lcase_crypto_func="$(echo $crypto_func | tr 'A-Z' 'a-z')"
- unpack_$lcase_crypto_func "${!SVAR}" "${!AVARN}"
- rc="$?"
- case "$rc" in
- 200) debug "libgrimoire" "falling back from $AVARN"; rc="" ;;
- 1) return "$rc" ;;
- 0) uncompress_unpack "${!SVAR}"; return "$?" ;;
- esac
- (( iter++ ))
- AVARN="$AVAR[$iter]"
- done
- [ -n "$rc" ] && return "$rc"
- done
-
+ real_verify_file "$@"
+ rc=$?
+ case "$rc" in
+ 200) debug "libunpack" "unable to verify $SVAR ${!SVAR}" ;;
+ 1) return 1 ;; # verification failed
+ 0) uncompress_unpack ${!SVAR}; return $? ;;
+ esac
+
if false; then # <------ here's the switch to disable oldworld -------
debug "libgrimoire" "falling back to missing verification"
unpack_missing "${!SVAR}"
@@ -160,13 +143,48 @@
esac
else
debug "libgrimoire" "falling back to regular MD5[]"
- local MD5NUM="$([ -z "$GPGNUM" ] && echo 0 || echo "$(($GPGNUM - 1))")"
+ local MD5NUM="$([ -z "$FILENUM" ] && echo 0 || echo "$(($FILENUM - 1))")"
real_unpack "${!SVAR}" "${MD5[$MD5NUM]}"
fi
}
#---------------------------------------------------------------------
+## @Type API
+## @param SOURCE suffix
+##
+## Does the work of verifying a file with the new-world verification
+## system.
+#---------------------------------------------------------------------
+function real_verify_file() {
+ debug "libunpack" "real_verify_file - $*"
+
+ local FILENUM="$1"
+ local SVAR="SOURCE${FILENUM}"
+
+ local crypto_func
+ for crypto_func in GPG HASH IGNORE; do
+ debug "libgrimoire" "checking $crypto_func verification"
+
+ local AVAR="SOURCE${FILENUM}_${crypto_func}"
+ [[ -n ${!AVAR} ]] || continue
+
+ local rc=""
+ local lcase_crypto_func="$(echo $crypto_func | tr 'A-Z' 'a-z')"
+ unpack_$lcase_crypto_func "${!SVAR}" "${!AVAR}"
+ rc="$?"
+
+ case "$rc" in
+ 200) debug "libgrimoire" "unable to verify $AVAR with $crypto_func" ;;
+ *) return $rc ;;
+ esac
+
+ done
+ return 200
+}
+
+
+#---------------------------------------------------------------------
## @param filename
## @param compressor
## @Stdout uncompressed
@@ -260,9 +278,10 @@
function unpack_spell_required() {
debug "libgrimoire" "Running unpack_spell_required -- $1"
- if ! spell_ok "$1" ; then
+ local x
+ if ! spell_ok "$1" && ! smgl_which $2 x &> /dev/null; then
query "This spell has an option to check its integrity via spell "\
-"${SPELL_COLOR}${1}${QUERY_COLOR} for $2, you might consider casting it. "\
+"${SPELL_COLOR}${1}${QUERY_COLOR} with the $2 command for $3, you might
consider installing it. "\
"Abort?" n &&
return 1 ||
return 200
@@ -372,7 +391,7 @@