~sourcemage/sorcery

80d53a2f46b2f848598059d22f12cde44be3c2d2 — Ismael Luceno 5 months ago 43e2cd7
Revert "Implement logging by reusing file descriptors"

This reverts commit e9a142540638bf09792acc31fd8d715e3b59d962.
M usr/sbin/alter => usr/sbin/alter +6 -4
@@ 43,17 43,19 @@ EOF
  [ -n "$COM_DATA" ] && echo "$COM_DATA" > "$C_LOG"
  message "${MESSAGE_COLOR}Altering...${DEFAULT_COLOR}"

  reserve_fds VOYEUR_STDOUT VOYEUR_STDERR
  if [ "$VOYEUR" == "on" -a -z "$SILENT" ]; then
    eval "exec $((VOYEUR_STDOUT))>&1 $((VOYEUR_STDERR))>&2"
    VOYEUR_STDOUT=/dev/stdout
    VOYEUR_STDERR=/dev/stderr
  else
    VOYEUR_STDOUT=/dev/null
    VOYEUR_STDERR=/dev/null
  fi

  invoke_installwatch
  (
    echo "$@"
    echo "$@" | bash
  ) 2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
     > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
  ) 2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) > >(tee -a $C_LOG > $VOYEUR_STDOUT)
  devoke_installwatch
  touch $IW_LOG $MD5_LOG $C_LOG_COMP
  create_install_log $IW_LOG $INST_LOG

M usr/sbin/delve => usr/sbin/delve +42 -40
@@ 102,16 102,11 @@ delve_log_helper() {
  CASTFS_DBGLOG=${CASTFS_DBGLOG:="/tmp/sorcery/delve/$SPELL.iwdbglog"}
  C_FIFO=${C_FIFO:="/dev/stdout"}
  IW_LOG=${IW_LOG:="/tmp/sorcery/delve/$SPELL.iw"}
  VOYEUR_STDOUT=${VOYEUR_STDOUT:="/dev/stdout"}
  VOYEUR_STDERR=${VOYEUR_STDERR:="/dev/stderr"}
  S_PWD=${S_PWD:="/tmp/sorcery/delve/$SPELL.pwd"}
  touch $C_LOG
  if [ -z "$VOYEUR_STDOUT" ]; then
     reserve_fds VOYEUR_STDOUT
     eval "exec $((VOYEUR_STDOUT))>&1"
  fi
  if [ -z "$VOYEUR_STDERR" ]; then
     reserve_fds VOYEUR_STDERR
     eval "exec $((VOYEUR_STDERR))>&2"
  fi

}

#---------------------------------------------------------------------------


@@ 156,20 151,22 @@ delve_build() {
  debug "delve" "Running $FUNCNAME"
  delve_is_valid_step BUILD 1 2 || return 1
  delve_log_helper
  ( run_build ) \
    3> >(tee -a "$C_LOG") \
    2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
     > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
  (
    run_build
  ) 3> >(tee -a $C_LOG >> /dev/stdout) \
    2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
     > >(tee -a $C_LOG > $VOYEUR_STDOUT)
}

delve_pre_install() {
  debug "delve" "Running $FUNCNAME"
  delve_is_valid_step PRE_INSTALL 2 || return 1
  delve_log_helper
  ( run_pre_install ) \
    3> >(tee -a "$C_LOG") \
    2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
     > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
  (
    run_pre_install
  ) 3> >(tee -a $C_LOG >> /dev/stdout) \
    2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
     > >(tee -a $C_LOG > $VOYEUR_STDOUT)
}

delve_staged_install_setup() {


@@ 200,11 197,11 @@ delve_install() {
    else
      $CHROOT_CMD delve $SPELL INSTALL
    fi
  ) 3> >(tee -a "$C_LOG") \
    2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
     > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
  ) 3> >(tee -a $C_LOG >> /dev/stdout) \
    2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
     > >(tee -a $C_LOG > $VOYEUR_STDOUT)
  local rc=$?
  if [[ -n "$CHROOT_CMD" && "$STAGED_INSTALL" = castfs ]]
  if [[ $CHROOT_CMD ]]
  then
    devoke_stage_root
  fi &&


@@ 224,11 221,11 @@ delve_install_extras() {
    else
      $CHROOT_CMD delve $SPELL INSTALL_EXTRAS
    fi
  ) 3> >(tee -a "$C_LOG") \
    2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
     > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
  ) 3> >(tee -a $C_LOG >> /dev/stdout) \
    2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
     > >(tee -a $C_LOG > $VOYEUR_STDOUT)
  local rc=$?
  if [[ -n "$CHROOT_CMD" && "$STAGED_INSTALL" = castfs ]]
  if [[ $CHROOT_CMD ]]
  then
    devoke_stage_root
  fi &&


@@ 245,30 242,33 @@ delve_post_build() {
    return 1
  }
  cd $SOURCE_DIRECTORY
  ( run_post_build ) \
    3> >(tee -a "$C_LOG") \
    2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
     > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
  (
    run_post_build
  ) 3> >(tee -a $C_LOG >> /dev/stdout) \
    2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
     > >(tee -a $C_LOG > $VOYEUR_STDOUT)
}

delve_post_install() {
  debug "delve" "Running $FUNCNAME"
  delve_is_valid_step POST_INSTALL 1 2 || return 1
  delve_log_helper
  ( run_post_install ) \
    3> >(tee -a "$C_LOG") \
    2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
     > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
  (
    run_post_install
  ) 3> >(tee -a $C_LOG >> /dev/stdout) \
    2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
     > >(tee -a $C_LOG > $VOYEUR_STDOUT)
}

delve_transfer() {
  debug "delve" "Running $FUNCNAME"
  delve_is_valid_step TRANSFER 2 || return 1
  delve_log_helper
  ( run_transfer ) \
    3> >(tee -a "$C_LOG") \
    2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
     > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
  (
    run_transfer
  ) 3> >(tee -a $C_LOG >> /dev/stdout) \
    2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
     > >(tee -a $C_LOG > $VOYEUR_STDOUT)
}

delve_final() {


@@ 277,10 277,12 @@ delve_final() {
  delve_log_helper
  devoke_installwatch &&
  STAGED_INSTALL=off
  ( run_final ) \
    3> >(tee -a "$C_LOG") \
    2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
     > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
  (
    run_final
  ) 3> >(tee -a $C_LOG >> /dev/stdout) \
    2> >(tee -a $C_LOG 1>&2 > $VOYEUR_STDERR) \
     > >(tee -a $C_LOG > $VOYEUR_STDOUT)

}

delve_triggers() {

M var/lib/sorcery/modules/build_api/api1 => var/lib/sorcery/modules/build_api/api1 +12 -5
@@ 30,13 30,19 @@ run_build_spell() {
  STAGED_INSTALL=off
  rm -f $C_LOG
  touch $C_LOG
  reserve_fds VOYEUR_STDOUT VOYEUR_STDERR
  if [[ $SCREEN_NAME ]] ; then
    screen_new_window "$SCREEN_NAME" $SCREEN_CAST_WIN "cast $SPELL" \
      tail -f -s 0.1 $C_LOG
    screen_switch_window "$SCREEN_NAME" $SCREEN_MAIN_WIN

    VOYEUR_STDOUT=/dev/null
    VOYEUR_STDERR=/dev/null
  elif [ "$VOYEUR" == "on" -a -z "$SILENT" ] ; then
    eval "exec $((VOYEUR_STDOUT))>&1 $((VOYEUR_STDERR))>&2"
    VOYEUR_STDOUT=/dev/stdout
    VOYEUR_STDERR=/dev/stderr
  else
    VOYEUR_STDOUT=/dev/null
    VOYEUR_STDERR=/dev/null
  fi
  # should OPTS get set here?



@@ 116,9 122,10 @@ run_build()  {
  message "$SPELL    $VERSION"

  run_config_loc
  ( run_spell_file BUILD build ) \
    2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
     > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
  (
    run_spell_file BUILD build
  ) 2> >(tee -a $C_LOG 1>&2 >> $VOYEUR_STDERR) \
     > >(tee -a $C_LOG >> $VOYEUR_STDOUT) # see bug 7201

  if  [  "$?"  !=  0  ];  then
    message  "${PROBLEM_COLOR}"      \

M var/lib/sorcery/modules/build_api/api2 => var/lib/sorcery/modules/build_api/api2 +16 -8
@@ 36,16 36,24 @@ run_build_spell() {
  export VOYEUR_STDOUT VOYEUR_STDERR
  export __DELVE_IN_CAST=on

  >"$CASTFS_DBGLOG"
  >"$C_LOG"
  rm  -f $CASTFS_DBGLOG
  touch $CASTFS_DBGLOG
  rm  -f $C_LOG
  touch $C_LOG

  reserve_fds VOYEUR_STDOUT VOYEUR_STDERR
  if [[ $SCREEN_NAME ]] ; then
    screen_new_window "$SCREEN_NAME" $SCREEN_CAST_WIN "cast $SPELL" \
      tail -f -s 0.1 "$C_LOG"
      tail -f -s 0.1 $C_LOG
    screen_switch_window "$SCREEN_NAME" $SCREEN_MAIN_WIN

    VOYEUR_STDOUT=/dev/null
    VOYEUR_STDERR=/dev/null
  elif [ "$VOYEUR" == "on" -a -z "$SILENT" ] ; then
    eval "exec $((VOYEUR_STDOUT))>&1 $((VOYEUR_STDERR))>&2"
    VOYEUR_STDOUT=/dev/stdout
    VOYEUR_STDERR=/dev/stderr
  else
    VOYEUR_STDOUT=/dev/null
    VOYEUR_STDERR=/dev/null
  fi

  if [[ -z $STAGED_INSTALL ]]


@@ 84,9 92,9 @@ run_build_spell() {
      devoke_installwatch                   &&
      STAGED_INSTALL=off                    &&
      run_final | append_to_notice_log      || return 3
    ) 3> >(tee -a "$C_LOG") \
      2> >(tee -a "$C_LOG" >& "$VOYEUR_STDERR") \
       > >(tee -a "$C_LOG" >& "$VOYEUR_STDOUT")
    ) 3> >(tee -a $C_LOG >> /dev/stdout) \
      2> >(tee -a $C_LOG 1>&2 >> $VOYEUR_STDERR) \
       > >(tee -a $C_LOG >> $VOYEUR_STDOUT) \
  )
  rs=$?
  unset __DELVE_IN_CAST

M var/lib/sorcery/modules/libmisc => var/lib/sorcery/modules/libmisc +0 -17
@@ 1764,23 1764,6 @@ show_file() {
}

#---------------------------------------------------------------------
##
## Reserve file descriptors; connects them to /dev/null.
##
#---------------------------------------------------------------------
SORCERY_LAST_RESERVED_FD=2
reserve_fds() {
  while [ $# -gt 0 ]; do
    if ! : >& "$((SORCERY_LAST_RESERVED_FD))"; then
      eval "$1=$((SORCERY_LAST_RESERVED_FD)) &&
            exec $((SORCERY_LAST_RESERVED_FD))> /dev/null" &&
      shift
    fi 2>/dev/null
    let ++SORCERY_LAST_RESERVED_FD
  done
}

#---------------------------------------------------------------------
## @param title
## @Globals TERM
##