Changeset 1159 for rpmbuild-bot


Ignore:
Timestamp:
Jun 6, 2017, 10:47:00 PM (8 years ago)
Author:
dmik
Message:

rpmbuild-bot: Add option to log rpmbuild output to screen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rpmbuild-bot/rpmbuild-bot.sh

    r1033 r1159  
    2222# -----
    2323#
    24 # > rpmbuild-bot.sh SPEC[=VERSION]
     24# > rpmbuild-bot.sh [-l] SPEC[=VERSION]
    2525# >                 [ upload[=REPO] | test[=MODE] | clean[=test] |
    2626# >                   move[=FROM_REPO=TO_REPO] | remove[=REPO] ]
    2727# >                 [-f]
    2828#
    29 # MYAPP is the name of the RPM package spec file (extension is optional,
     29# SPEC is the name of the RPM package spec file (extension is optional,
    3030# .spec is assumed). The spec file is searched in the SPECS directory of the
    3131# rpmbuild tree (usually $USER/rpmbuild/SPECS, rpmbuild --eval='%_specdir'
     
    3535# The second argument defines the command to perform. The default command is
    3636# "build". The following sections will describe each command.
     37#
     38# Global options:
     39#
     40# -l -- Log output of the rpmbuild command to screen in addition to putting it
     41#       to a dedicated log file.
    3742#
    3843# Building packages
     
    238243}
    239244
     245log()
     246{
     247  echo $@
     248}
     249
    240250log_run()
    241251{
     
    243253  shift
    244254  rm -f "$log"
    245   "$@" >"$log" 2>&1
     255  if [ -n "$log_to_console" ] ; then
     256    "$@" 2>&1 | tee "$log"
     257  else
     258    "$@" >"$log" 2>&1
     259  fi
    246260  local rc=$?
    247   if test $rc != 0 ; then
    248     echo "ERROR: The following command failed with error code $rc:"
    249     echo $@
    250     echo "You will find more information in file '$log'."
    251     echo "Here are the last 10 lines of output:"
    252     echo "------------------------------------------------------------------------------"
    253     tail "$log" -n 10
    254     echo "------------------------------------------------------------------------------"
     261  if [ $rc != 0 ] ; then
     262    log "ERROR: The following command failed with error code $rc:"
     263    log $@
     264    log "You will find more information in file '$log'."
     265    if [ -z "$log_to_console" ] ; then
     266      # Note: echo instead of log to avoid putting this to the main log file.
     267      echo "Here are the last 10 lines of the command output:"
     268      echo "------------------------------------------------------------------------------"
     269      tail "$log" -n 10
     270      echo "------------------------------------------------------------------------------"
     271    fi
    255272    quit $rc
    256273  fi
     
    403420            f="${f%.*}.dbg"
    404421            masks="$masks${masks:+ }'*$f'"
    405             # Save the file for later inclusion into debugfiles.list (%debug_package magic in brp-strip.os2)
     422            # Save the file for later inclusion into debugfiles.list (%debug_package magic in brp-strip-os2)
    406423            run echo "$f" >> "$dbgfilelist"
    407424          done < "$tgt_dir.files.list"
     
    841858  case "$1" in
    842859  -*)
    843     options="$*"
    844     while [ -n "$1" ] ; do
     860    if [ -z "$command" ] ; then
     861      # Global options
    845862      case "$1" in
    846       -f) force="-f"
     863      -l) log_to_console="$1"
    847864        ;;
    848865      *) usage
    849866        ;;
    850867      esac
    851       shift
    852     done
    853     break
     868    else
     869      # Command's options
     870      options="$*"
     871      while [ -n "$1" ] ; do
     872        case "$1" in
     873        -f) force="$1"
     874          ;;
     875        -l) log_to_console="$1"
     876          ;;
     877        *) usage
     878          ;;
     879        esac
     880        shift
     881      done
     882      break
     883    fi
    854884    ;;
    855885  *)
Note: See TracChangeset for help on using the changeset viewer.