diff options
author | Bor Kraljič | 2011-10-22 16:17:34 +0200 |
---|---|---|
committer | Bor Kraljič | 2011-10-22 16:17:34 +0200 |
commit | 1fd98acc7d3c39bd2cd0aa4c7d238d331ed5fda4 (patch) | |
tree | 90399817fc1550e775ae23b29a2feed3ac86bef4 | |
parent | 58458a554ab07079e3b5145382c545f5fbd6f87d (diff) | |
parent | 941886ec683daa692089ee7b797897b3470308cc (diff) |
Merge branch 'master' into pyrobor-cleandevel-pyrobor2
-rw-r--r-- | ChangeLog | 1 | ||||
-rwxr-xr-x | var/lib/sorcery/modules/libapi | 23 | ||||
-rwxr-xr-x | var/lib/sorcery/modules/libunpack | 188 |
3 files changed, 8 insertions, 204 deletions
@@ -8,6 +8,7 @@ 2011-10-16 Jaka Kranjc <lynxlynxlynx@sourcemage.org> * libressurect: clarified a merge message * alter, vcast: removed last mentions of cast --fix + * libapi, libunpack: removed oldworld md5 support 2011-10-21 Bor Kraljič <pyrobor@ver.si> * libsummon: added msg with information that file was downloaded diff --git a/var/lib/sorcery/modules/libapi b/var/lib/sorcery/modules/libapi index 8fba3bee..4b75ccd3 100755 --- a/var/lib/sorcery/modules/libapi +++ b/var/lib/sorcery/modules/libapi @@ -78,7 +78,6 @@ # suggest_depends (libdepends) # track_manual (libtrack) # uncompress (libunpack) -# unpack (libunpack) (deprecated) # unpack_file (libunpack) # unpack_file_simple (libunpack) # using_gcc (libgcc2) @@ -1124,25 +1123,6 @@ function uncompress () { #--------------------------------------------------------------------- ## @Type API -## @param file to unpack -## @param md5sum -## @See <@function var.lib.sorcery.modules.libunpack.html,real_unpack> for more details. -## -## Given a file, unpack runs the decompression program for that file, -## as well as untar'ing the file if appropriate and if the MD5 -## matches. -## Note: zip is a special case because it doesn't work with streams. -## Note: This function is deprecated and kept for spells that still -## use the old verification methods (MD5[0]=). -## -#--------------------------------------------------------------------- -function unpack () { - debug "libapi" "unpack - $*" - real_unpack "$@" -} - -#--------------------------------------------------------------------- -## @Type API ## @param SOURCE suffix ## @See <@function var.lib.sorcery.modules.libunpack.html,real_unpack_file> for more details. ## @@ -1199,9 +1179,6 @@ function unpack () { ## see unpack_ignore ## ## Otherwise, it falls back to MISSING mode, see unpack_missing -## (or for now) -## Otherwise, it falls back to old uncompressed md5sum check with MD5[n]. -## see real_unpack() ## ## The default verification level is "WORKS_FOR_ME" ## diff --git a/var/lib/sorcery/modules/libunpack b/var/lib/sorcery/modules/libunpack index 4d1436f0..aa57add8 100755 --- a/var/lib/sorcery/modules/libunpack +++ b/var/lib/sorcery/modules/libunpack @@ -75,9 +75,6 @@ ## see unpack_ignore ## ## Otherwise, it falls back to MISSING mode, see unpack_missing -## (or for now) -## Otherwise, it falls back to old uncompressed md5sum check with MD5[n]. -## see real_unpack() ## ## The default verification level is "WORKS_FOR_ME" ## @@ -133,19 +130,13 @@ function real_unpack_file() { 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}" - rc="$?" - case "$rc" in - 0) uncompress_unpack "${!SVAR}"; return "$?" ;; - *) return "$rc" ;; - esac - else - debug "libgrimoire" "falling back to regular MD5[]" - local MD5NUM="$([ -z "$FILENUM" ] && echo 0 || echo "$(($FILENUM - 1))")" - real_unpack "${!SVAR}" "${MD5[$MD5NUM]}" - fi + debug "libgrimoire" "falling back to missing verification" + unpack_missing "${!SVAR}" + rc="$?" + case "$rc" in + 0) uncompress_unpack "${!SVAR}"; return "$?" ;; + *) return "$rc" ;; + esac } @@ -693,171 +684,6 @@ function locate_spell_file() { } - -#===================== libunpack oldworld ============================ - -#--------------------------------------------------------------------- -## @Type API -## @param file to unpack -## @param md5sum -## -## Given a file, unpack runs the decompression program for that file, -## as well as untar'ing the file if appropriate and if the MD5 -## matches. -## Note: zip is a special case because it doesn't work with streams. -## -#--------------------------------------------------------------------- -function real_unpack() { - debug "libgrimoire" "Running unpack -- $*" - - message "${MESSAGE_COLOR}Unpacking source file ${SPELL_COLOR}${1}${DEFAULT_COLOR}" \ - "${MESSAGE_COLOR}for spell" \ - "${SPELL_COLOR}${SPELL}${DEFAULT_COLOR}${MESSAGE_COLOR}.${DEFAULT_COLOR}" - - FILENAME="$(guess_filename "$SOURCE_CACHE/$1")" && - COMPRESSOR="$(guess_compressor "$FILENAME")" - - if [[ ! $FILENAME ]] || ! test -f "$FILENAME" ; then - message "${PROBLEM_COLOR}Source file not found.${DEFAULT_COLOR}" - return 1 - fi - - uncompress_md5 "$FILENAME" "$COMPRESSOR" "$2" | - unpack_core "$FILENAME" "$COMPRESSOR" && - { - - # This section takes care of what happens if the md5sum doesn't match. - # $TMP_DIR/libgrimoire.uncompress.$$ is set in uncompress. It's the only - # way to get the return value since it's in a pipe. - if ! [[ $2 ]] ; then - - rm "$TMP_DIR/libgrimoire.uncompress.$$" - - message "${SPELL_COLOR}${SPELL}${DEFAULT_COLOR}:" \ - "${QUERY_COLOR}doesn't have an MD5 sum for the uncompressed $1." - - case "$MD5SUM_DL" in - off) message "${RED}Continuing!${DEFAULT_COLOR}"; return 0 ;; - ask_ignore) query "Abort?" "n" && return 1 || return 0 ;; - ask_risky|ask_abort) query "Abort?" "y" && return 1 || return 0 ;; - on|abort_all|*) message "${RED}Aborting.${DEFAULT_COLOR}" ; return 1 ;; - esac - - elif [[ $2 == "IGNORE" ]] ; then - - rm "$TMP_DIR/libgrimoire.uncompress.$$" - - message "${SPELL_COLOR}${SPELL}${DEFAULT_COLOR}: ${QUERY_COLOR}MD5 sum was" \ - "purposefully left out for the uncompressed $1." - message "${QUERY_COLOR}Would you like to abort so you can validate" \ - "the source yourself via some alternate method?" - - case "$MD5SUM_DL" in - off) message "${RED}Continuing!${DEFAULT_COLOR}"; return 0 ;; -ask_risky|ask_ignore) query "Abort?" "n" && return 1 || return 0 ;; - abort_all) message "${RED}Aborting.${DEFAULT_COLOR}" ; return 1 ;; - ask_abort|on|*) query "Abort?" "y" && return 1 || return 0 ;; - esac - - elif [[ "$(cat $TMP_DIR/libgrimoire.uncompress.$$)" != 0 ]] ; then - - rm "$TMP_DIR/libgrimoire.uncompress.$$" - - message "${SPELL_COLOR}${SPELL}${DEFAULT_COLOR}:" \ - "${QUERY_COLOR}MD5 sum is different for uncompressed $1." - - case "$MD5SUM_DL" in - off) message "${RED}Continuing!${DEFAULT_COLOR}"; return 0 ;; - ask_ignore) query "Abort?" "n" && return 1 || return 0 ;; - ask_risky|ask_abort) query "Abort?" "y" && return 1 || return 0 ;; - on|abort_all|*) message "${RED}Aborting.${DEFAULT_COLOR}" ; return 1 ;; - esac - - fi - - rm "$TMP_DIR/libgrimoire.uncompress.$$" - - } - - #By this point, the archive is unarchived, and we know the MD5 check was good. - return 0 - -} - - -#--------------------------------------------------------------------- -## @param filename -## @param compressor -## @param md5 -## @Stdout uncompressed -## -## Uncompress_md5 dumps the expanded file via tee to md5_tar_check where it -## is gobbled up by the bitbucket. It also dumps the main stream out to -## stdout. -## -#--------------------------------------------------------------------- -function uncompress_md5() { - debug "libgrimoire" "uncompress_md5 - $*" - - # This is here so Duff's super debugging info doesn't screw the next step up - set +x - - # Outer subshell is necessary to redirect stderr to stdout - ( - uncompress_core "$1" "$2" | - tee /dev/stderr | - md5_tar_check "$3" 2>&1 1>/dev/null #we must avoid this printing - ) 2>&1 - - # This temp file is here because this function MUST NOT send - # anything to stdout or stderr, and upack needs a way to get the success or - # failure of this function. - - local a="$?" - [[ $SUPER_DEBUG ]] && set -x #turn this back on as soon as possible - echo "$a" > "$TMP_DIR/libgrimoire.uncompress.$$" - return "$a" - -} - - -#--------------------------------------------------------------------- -## @param md5 -## -## Checks that the stdin matches the argument. -## Note that DEBUG output may dissapear if it's /dev/stderr due to -## uncompress' 2>/dev/null. -## -#--------------------------------------------------------------------- -function md5_tar_check() { - debug "libgrimoire" "md5_tar_check() - Checking MD5 sum" - - local md5 - - #Do the md5 - md5="$(md5sum /dev/stdin | awk '{print $1}')" - debug "libgrimoire" "md5_tar_check() - MD5 of tarball is $md5." - debug "libgrimoire" "md5_tar_check() - argument received is $1." - - #See if they match - if [[ $1 == $md5 ]] ; then - debug "libgrimoire" "md5_tar_check() - MD5 Sum Success ( $1 == $md5 )" - return 0 - fi - - #See of we need to md5sum it at all - if [[ ${MD5SUM_DL:-on} == off ]] || ! [[ $1 ]] ; then - debug "libgrimoire" "md5_tar_check() - Skipping check" - return 0 - fi - - #If we get here, the md5's don't match, but should. - debug "libgrimoire" "md5_tar_check() - bad md5" - return 1 - -} - - #--------------------------------------------------------------------- ## @License ## |