Changeset 765 for rpmbuild-bot


Ignore:
Timestamp:
May 27, 2016, 12:49:59 AM (9 years ago)
Author:
dmik
Message:

rpmbuid-bot: Add move command to move packages between repositories.

File:
1 edited

Legend:

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

    r749 r765  
    2323#
    2424# > rpmbuild-bot.sh SPEC[=VERSION]
    25 # >                 [ upload[=REPO] | test[=MODE] | clean[=test] | remove[=REPO] ]
     25# >                 [ upload[=REPO] | test[=MODE] | clean[=test] |
     26# >                   move[=FROM_REPO=TO_REPO] | remove[=REPO] ]
    2627# >                 [-f]
    2728#
     
    8182#
    8283# It is possible to configure which steps of the build to perform using the MODE
    83 # argument to the "test" command which may take one of the following values:
     84# parameter to the "test" command which may take one of the following values:
    8485#
    8586#   prep    Execute the %prep section of the spec file only.
     
    9394#           necessary for "pack" to succeed.
    9495#
    95 # When no MODE argument is given, all steps are executed in a proper order.
     96# When no MODE parameter is given, all steps are executed in a proper order.
    9697#
    9798# The results of the "test" command are stored in a log file in the logs/test
     
    108109# The "upload" command will upload the packages built with the "build"
    109110# command to the official distribution channel configured in
    110 # rpmbuild-bot-env.sh. The REPO argument specifies one of the configured
     111# rpmbuild-bot-env.sh. The REPO parameter specifies one of the configured
    111112# repositories. When REPO is not given, the default repository is used
    112113# (usually experimental or similar).
     
    130131# otherwise.
    131132#
    132 # If the "clean" command is given a "test" argument, it will clean up the
     133# If the "clean" command is given a "test" parameter, it will clean up the
    133134# results of the "test" command instead of "build". The log file from the
    134135# "test" command needs to be present or the command will fail.
     136#
     137# Moving packages between repositories
     138# ------------------------------------
     139#
     140# The "move" command allows to move a particular version of the packages
     141# built with the "build" command and uploaded with the "upload" command from one
     142# repository to another one. The "move" command is normally used to move
     143# packages from a test repository to a production one when they are ready for
     144# wide distribution.
     145#
     146# The "move" command needs log files from the "build" and "upload" commands
     147# and will fail otherwise. It also requires the VERSION parameter for the SPEC
     148# argument to be given (to specify the version of the packages to remove) and
     149# requires the FROM_REPO=TO_REPO parameter itself to specify the source
     150# repository and the target repository, respectively.
     151#
     152# The log files from the "build" and "upload" commands are not removed by the
     153# "move" command so it may be performed multiple times. The current location
     154# of the packages is not tracked in the log files so the command will fail
     155# if the source repository doesn't have the package files or if the target
     156# repository already has them.
    135157#
    136158# Removing packages
     
    144166#
    145167# The "remove" command needs log files from the "build" and "upload" commands
    146 # and will fail otherwise. It also requires the VERSION argument for the SPEC
    147 # parameter to be given (to specify the version of the packages to remove) and
    148 # accepts the REPO argument just like the "upload" command does (to specify a
    149 # repository to remove the packages from).
    150 #
    151 # Note that the log files from the "build" and "upload" commands are also removed
    152 # by this command upon sucessful package removal.
     168# and will fail otherwise. It also requires the VERSION parameter for the SPEC
     169# argument to be given (to specify the version of the packages to remove) and
     170# accepts the REPO parameter itself just like the "upload" command does (to
     171# specify a repository to remove the packages from).
     172#
     173# Note that the log files from the "build" and "upload" commands are also
     174# removed by this command upon sucessful package removal.
    153175#
    154176# Return value
     
    212234read_file_list()
    213235{
    214   # $1 = file list list filename
    215   # $2 = var name where to save read file names (optional)
    216   # $3 = function name to call for each file (optional)
     236  # $1 = file list filename
     237  # $2 = var name where to save the list of read file names (optional)
     238  # $3 = function name to call for each file (optional), it may assign a new
     239  #      file name to $file and also set $file_pre and $file_post that will
     240  #      be prepended and appended to $file when saving it to the list in $2
     241  #      (but not when checking for file existence and timestamp)
    217242
    218243  local list="$1"
     
    221246  # Check timestamps.
    222247  while read l; do
     248    local file_pre=
     249    local file_post=
    223250    local file="${l#*|}"
    224251    local ts="${l%%|*}"
     
    231258      die "Recorded timestamp $ts doesn't match actual timestamp $act_ts for '$file'."
    232259    fi
    233     _read_file_list_ret="$_read_file_list_ret${_read_file_list_ret:+ }$file"
     260    _read_file_list_ret="$_read_file_list_ret${_read_file_list_ret:+ }$file_pre$file$file_post"
    234261  done < "$list"
    235262  # Return the files (if requested).
     
    539566}
    540567
    541 remove_cmd()
     568move_cmd()
    542569{
    543570  # Check settings.
     
    546573  test -n "$RPMBUILD_BOT_UPLOAD_REPO_LIST" || die "RPMBUILD_BOT_UPLOAD_REPO_LIST is empty."
    547574
     575  local from_repo="${command_arg%%=*}"
     576  local to_repo="${command_arg#*=}"
     577
     578  [ -n "$from_repo" ] || die "FROM_REPO parameter is missing."
     579  [ "$from_repo" = "$to_repo" ] && die "TO_REPO parameter is missing (or equals to FROM_REPO)."
     580
     581  check_dir_var "RPMBUILD_BOT_UPLOAD_${from_repo}_DIR"
     582  check_dir_var "RPMBUILD_BOT_UPLOAD_${to_repo}_DIR"
     583
     584  local ver_list="$log_dir/archive/$spec_name.$spec_ver.list"
     585  [ -f "$ver_list" ] || die "File '$ver_list' is not found."
     586
     587  eval local from_base="\$RPMBUILD_BOT_UPLOAD_${from_repo}_DIR"
     588  eval local to_base="\$RPMBUILD_BOT_UPLOAD_${to_repo}_DIR"
     589
     590  local files=
     591  read_file_list "$ver_list" files '
     592local dir=
     593local base="$from_base"; repo_dir_for_file "$file" dir; file="${dir}/${file##*/}"
     594base="$to_base"; repo_dir_for_file "$file" dir; file_post=">${dir}"
     595'
     596  for f in $files; do
     597    local from="${f%%>*}"
     598    local to="${f#*>}"
     599    echo "Moving $from to $to/..."
     600    run mv "$from" "$to/"
     601  done
     602}
     603
     604remove_cmd()
     605{
     606  # Check settings.
     607  [ -n "$spec_ver" ] || die "SPEC parameter lacks version specification."
     608
     609  test -n "$RPMBUILD_BOT_UPLOAD_REPO_LIST" || die "RPMBUILD_BOT_UPLOAD_REPO_LIST is empty."
     610
    548611  local repo="$command_arg"
    549612  [ -z "$repo" ] && repo="${RPMBUILD_BOT_UPLOAD_REPO_LIST%% *}"
     
    551614  check_dir_var "RPMBUILD_BOT_UPLOAD_${repo}_DIR"
    552615
    553   eval local base="\$RPMBUILD_BOT_UPLOAD_${repo}_DIR"
    554 
    555616  local ver_list="$log_dir/archive/$spec_name.$spec_ver.list"
    556617  [ -f "$ver_list" ] || die "File '$ver_list' is not found."
     618
     619  eval local base="\$RPMBUILD_BOT_UPLOAD_${repo}_DIR"
    557620
    558621  local files=
     
    613676[ "$spec" = "$spec_ver" ] && spec_ver=
    614677
    615 command_name="${command%=*}"
     678command_name="${command%%=*}"
    616679command_arg="${command#*=}"
    617680[ "$command_name" = "$command_arg" ] && command_arg=
     
    624687    need_spec_file=1
    625688    ;;
    626   upload|clean|remove)
     689  upload|clean|move|remove)
    627690    ;;
    628691  *) usage
     
    662725run mkdir -p "$zip_dir"
    663726
    664 [ -z "$command" ] && command="build"
    665 
    666 command_name="${command%=*}"
    667 comand_arg="${command#*=}"
    668 [ "$command_name" = "$command_arg" ] && command_arg=
    669 
    670727log_base="$log_dir/$spec_name"
    671728spec_list="$log_base.list"
Note: See TracChangeset for help on using the changeset viewer.