Ignore:
Timestamp:
Apr 11, 2016, 7:26:31 PM (9 years ago)
Author:
dmik
Message:

rpmbuild-bot: Save timestamps of generated files in list.

This is used to check if the actual files match the ones that
were generated by rpmbuild-bot when performing uploading or
cleanup.

File:
1 edited

Legend:

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

    r736 r737  
    172172}
    173173
     174read_file_list()
     175{
     176  # $1 = file list list filename
     177  # $2 = var name where to save read file names (optional)
     178
     179  local _read_file_list_ret=
     180  # Check timestamps.
     181  while read l; do
     182    local f="${l#*|}"
     183    local t="${l%%|*}"
     184    [ "$f" = "$t" ] && die "Line '$l' in '$1' does not contain timestamps."
     185    local a=`stat -c '%Y' "$f"`
     186    if [ "$t" != "$a" ] ; then
     187      die "Recorded timestamp $t doesn't match actual timestamp $a for file '$f'."
     188    fi
     189    _read_file_list_ret="$_read_file_list_ret${_read_file_list_ret:+ }$f"
     190  done < "$1"
     191  # Return the files (if requested).
     192  [ -n "$2" ] && eval "$2=\$_read_file_list_ret"
     193}
     194
    174195usage()
    175196{
     
    199220
    200221    echo "Detected successful build in $spec_list, cleaning up due to -f option..."
    201     while read f; do
     222    local files=
     223    read_file_list "$spec_list" files
     224    for f in $files; do
    202225      echo "Removing $f..."
    203       rm -f "$f"
    204     done < "$spec_list"
     226      run rm -f "$f"
     227    done
     228    unset files
    205229
    206230    echo "Removing $log_base.*.log and .list files..."
     
    259283  # Generate list of all generated packages for further reference.
    260284  echo "Creating list file ($ver_list)..."
    261   echo "$src_rpm" > "$ver_list"
    262   echo "$zip" >> "$ver_list"
     285  echo `stat -c '%Y' "$src_rpm"`"|$src_rpm" > "$ver_list"
     286  echo `stat -c '%Y' "$zip"`"|$zip" >> "$ver_list"
    263287  # Save base arch RPMs.
    264   for f in "$rpms" ; do
    265     echo "$f" >> "$ver_list"
     288  for f in $rpms ; do
     289    echo `stat -c '%Y' "$f"`"|$f" >> "$ver_list"
    266290  done
    267291  # Save other arch RPMs.
     
    270294    [ -n "$rpms" ] || die "Cannot find .$arch.rpm file names in '$log_base.arch.log'."
    271295    for f in $rpms ; do
    272       echo "$f" >> "$ver_list"
     296      echo `stat -c '%Y' "$f"`"|$f" >> "$ver_list"
    273297    done
    274298  done
     
    323347    if [ -n "$rpms" ] ; then
    324348      echo "Successfully generated the following RPMs:"
    325       for f in "$rpms" ; do
     349      for f in $rpms ; do
    326350        echo "$f"
    327351      done
     
    346370  [ -f "$spec_list" ] || die \
    347371"File '$spec_list' is not found.
    348 You man need to build the packages using the 'build' command."
    349 
    350   while read f; do
     372You may need to build the packages using the 'build' command."
     373
     374  local files=
     375  read_file_list "$spec_list" files
     376  for f in $files; do
    351377    case "$f" in
    352378      *.src.rpm)
     
    373399    echo "Copying $f to $d..."
    374400    run cp -p "$f" "$d"
    375   done < "$spec_list"
     401  done
    376402
    377403  # On success, delete the uploaded packages and archive log files.
    378   while read f; do
     404  for f in $files; do
    379405    echo "Removing $f..."
    380     rm -f "$f"
    381   done < "$spec_list"
     406    run rm -f "$f"
     407  done
    382408
    383409  # Note: versioned .list file will remain in archive forever (for further reference).
Note: See TracChangeset for help on using the changeset viewer.