~sourcemage/sorcery

b51691a21562867bf6d536dafbe7303becb7d148 — Jaka Kranjc 12 years ago f473b8a + c9152dc
Merge branch 'test-1.14' into my-stable

Conflicts:
	ChangeLog
	etc/sorcery/version
M ChangeLog => ChangeLog +16 -0
@@ 1,6 1,22 @@
2010-01-01 Jaka Kranjc <lynxlynxlynx@sourcemage.org>
	* libsorcery: avoid passing bad parameters when PAGER has none

2010-12-30 Jaka Kranjc <lynxlynxlynx@sourcemage.org>
	* libsorcery: default the pager to cat if nothing is specified and less
	  is not present on the system

2010-12-30 Jaka Kranjc <lynxlynxlynx@sourcemage.org>
	* libmisc: fixed remove_files_and_dirs not removing some dirs #15804

2010-12-30 Jaka Kranjc <lynxlynxlynx@sourcemage.org>
	* config, libsorcery: be a bit more smart about setting the pager #15793

2010-12-30 Jaka Kranjc <lynxlynxlynx@sourcemage.org>
	* libtrack, common: newer installwatch has a different log variable #13873

2010-10-19 Bor Kraljič <pyrobor@ver.si>
	* libsummon: moved sanity check of source to right after download (#15886)

2010-10-19 Jaka Kranjc <lynxlynxlynx@sourcemage.org>
	* version: 1.14.5 released


M etc/sorcery/config => etc/sorcery/config +1 -7
@@ 47,13 47,6 @@ FORCE_BASESYSTEM_DEPENDS=${FORCE_BASESYSTEM_DEPENDS:-off}

 URL_HTTP_FTP_TIMEOUT=${URL_HTTP_FTP_TIMEOUT:=90}

                    # pager info
                    # -R: display color codes properly
                    # -E: quit at eof (otherwise scribe pauses on empty updates)
                    # -X: dont do screen init and deinit, gaze install
                    # of a small spell is effectively useless otherwise as the
                    # screen is cleared afterwards.
                PAGER=${PAGER:=less -R -F -X -f}
             FILEPROG=${FILEPROG:=file}
           DIALOGPROG=${DIALOGPROG:=dialog}



@@ 164,6 157,7 @@ PROGRESS_SPINNER_CHARS='-\|/'
          STANDARD_IFS=$WHITESPACE_IFS

. $SUBROUTINES
set_pager

. $MEDIA_CONFIG
. $ROOTS_CONFIG

M etc/sorcery/version => etc/sorcery/version +1 -1
@@ 1,1 1,1 @@
1.14.5
1.14.6-rc1

M var/lib/sorcery/modules/libmisc => var/lib/sorcery/modules/libmisc +7 -1
@@ 1078,7 1078,13 @@ function misc_is_function()  {
#---------------------------------------------------------------------
function remove_files_and_dirs() {
    cat $1 | while read file; do
      test -d $file || rm -f $file
      if [[ ! -d $file ]]; then
        rm -f $file
      else
        # also try to remove empty dirs, as
        # the leaves are not taken care of by the next block #15804
        rmdir $file &>/dev/null
      fi
    done

    # remove possibly empty directories, rmdir WILL have error output

M var/lib/sorcery/modules/libsorcery => var/lib/sorcery/modules/libsorcery +37 -0
@@ 1640,6 1640,43 @@ function filename_indicates_compression()  {


#---------------------------------------------------------------------
## Sets the most appropriate params for PAGER
## @Globals PAGER
#---------------------------------------------------------------------
function set_pager() {
  if [[ -z $PAGER ]]; then
    if real_spell_ok less; then
      # pager info
      # -R: display color codes properly
      # -F: quit on one-screenfull of data (otherwise scribe pauses on empty updates)
      # -X: dont do screen init and deinit, gaze install
      # of a small spell is effectively useless otherwise as the
      # screen is cleared afterwards.
      # -f: force it, since we may not be dealing with a regular file
      PAGER="less -R -F -X -f"
    else
      PAGER=cat
    fi
    return
  fi

  local pager_prog
  local pager_params=${PAGER#* }
  smgl_basename "${PAGER%% *}" pager_prog
  # setting PAGER to a single word would give bad parameters
  [[ $pager_prog == $PAGER ]] && unset pager_params

  # TODO: add any needed options for the rest of the pagers
  case $pager_prog in
    less) PAGER="less -R -F -X -f $pager_params" ;;
    most) PAGER="most $pager_params" ;;
    w3m)  PAGER="w3m $pager_params" ;;
    more) PAGER="more $pager_params";;
    *) ;;
  esac
}

#---------------------------------------------------------------------
##
## This software is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by

M var/lib/sorcery/modules/libsummon => var/lib/sorcery/modules/libsummon +23 -14
@@ 252,14 252,6 @@ function download_src_args() {
    if [[ $summon_target != $target ]] ; then
      mv -f "$summon_target" "$target"
    fi
    local type
    if ! source_sanity "$target" "type"; then
      message "${PROBLEM_COLOR}Sanity check of${DEFAULT_COLOR}" \
              "${FILE_COLOR}${target}${DEFAULT_COLOR}" \
              "${PROBLEM_COLOR}failed:${DEFAULT_COLOR}"
      message "$type"
      return 1
    fi
  else
    message "${PROBLEM_COLOR}Unknown download type: \"$summon_type\""\
            "at \"$summon_target\". Please file a bug if you see this." \


@@ 295,16 287,23 @@ function download_src_sub()  {
  {
    [[ $guess_type == file ]] &&
    download_from_leapforward "$target" "$url_list" "$hints" \
                            "$_summon_target" "$_summon_type"
                            "$_summon_target" "$_summon_type" &&
    source_sanity "$target"
  } ||

  url_download_expand_sort "$target" "$url_list" "$hints" \
                           "$_summon_target" "$_summon_type" ||
  {
    url_download_expand_sort "$target" "$url_list" "$hints" \
                             "$_summon_target" "$_summon_type"  &&
    if [[ $guess_type == file ]]; then
      source_sanity "$target"
    fi
  } ||

  { # dont use fallback if the type is not a file (bug 9847)
    [[ $guess_type == file ]] &&
    download_from_fallback "$target" "$url_list" "$hints" \
                           "$_summon_target" "$_summon_type"
                           "$_summon_target" "$_summon_type" &&
    source_sanity "$target"
  }

}


@@ 434,20 433,30 @@ function unpack_for_update() {
## the requested file, which then successfully downloads (which is
## the correct thing to do). We catch that here rather than wait for
## file verification to catch it.
## @param file to check
## @Stdout error message if file fails the check
## @return 1 if file fails the check
## @return 0 if file passes the check
#---------------------------------------------------------------------
function source_sanity() {
  [[ "$1" ]] || return 0
  [[ "$SUMMON_SANITY" == off ]] && return 0
  local core_msg
  core_msg="${PROBLEM_COLOR}Sanity check of${DEFAULT_COLOR}"
  core_msg="$core_msg ${FILE_COLOR}$1${DEFAULT_COLOR}"
  core_msg="$core_msg ${PROBLEM_COLOR}failed:${DEFAULT_COLOR}\n"

  if ! test -s "$1"; then
    upvar "$2" "Empty"
    message "$core_msg Empty"
    return 1
  fi

  if [[ "$1" != "${1%.tar.bz2}" ]] ||
     [[ "$1" != "${1%.tar.gz}" ]] ||
     [[ "$1" != "${1%.tgz}" ]]; then
    local _type=$(file -bi "$1")
    if echo $_type | grep -iq "text/"; then
      upvar "$2" "$_type"
      message "$core_msg $_type"
      return 1
    fi
  fi