Changeset 738 for rpmbuild-bot
- Timestamp:
- Apr 11, 2016, 8:36:38 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
rpmbuild-bot/rpmbuild-bot.sh
r737 r738 31 31 # ----- 32 32 # 33 # > rpmbuild-bot.sh SPEC [ upload[=REPO] | test[=MODE] ] [-f] 33 # > rpmbuild-bot.sh SPEC[=VERSION] 34 # > [ upload[=REPO] | test[=MODE] | clean | remove[=REPO] ] 35 # > [-f] 34 36 # 35 37 # MYAPP is the name of the RPM package spec file (extension is optional, … … 113 115 # Upon successful completion, the "upload" command will remove all uploaded 114 116 # RPM and ZIP packages and will move all "build" log files to logs/archive. 117 # 118 # Cleaning packages 119 # ----------------- 120 # 121 # The "clean" command will delete packages built with the "build" command 122 # and their log files without uploading them to a repository. This is useful 123 # when the successful build needs to be canceled for some reason (wrong source 124 # tree state, wrong patches etc.). Note that normally you don't need to use 125 # this command; it's an emergency-only tool. 126 # 127 # Removing packages 128 # ----------------- 129 # 130 # The "remove" command allows to remove a particular version of the packages 131 # built with the "build" command and uploaded with the "upload" command from a 132 # repository. This is useful when the successful build needs to be canceled for 133 # some reason (wrong source tree state, wrong patches etc.). Note that normally 134 # you don't need to use this command; it's an emergency-only tool. 135 # 136 # The "remove" command needs log files from the "build" and "upload" commands 137 # and will fail otherwise. It also requires the VERSION argument for the SPEC 138 # parameter to be given (to specify the version of the packages to remove) and 139 # accepts the REPO argument just like the "upload" command does (to specify a 140 # repository to remove the packages from). 141 # 142 # Note that the log files from the "build" and "upload" commands are also removed 143 # by this command upon sucessful package removal. 115 144 # 116 145 # Return value … … 176 205 # $1 = file list list filename 177 206 # $2 = var name where to save read file names (optional) 178 207 # $3 = function name to call for each file (optional) 208 209 local list="$1" 179 210 local _read_file_list_ret= 211 180 212 # Check timestamps. 181 213 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'." 214 local file="${l#*|}" 215 local ts="${l%%|*}" 216 [ "$file" = "$ts" ] && die "Line '$l' in '$list' does not contain timestamps." 217 [ -n "$3" ] && eval $3 218 [ -f "$file" ] || die "File '$file' is not found." 219 echo "Checking tmestamp of $file..." 220 local act_ts=`stat -c '%Y' "$file"` 221 if [ "$ts" != "$act_ts" ] ; then 222 die "Recorded timestamp $ts doesn't match actual timestamp $act_ts for '$file'." 188 223 fi 189 _read_file_list_ret="$_read_file_list_ret${_read_file_list_ret:+ }$f "190 done < "$ 1"224 _read_file_list_ret="$_read_file_list_ret${_read_file_list_ret:+ }$file" 225 done < "$list" 191 226 # Return the files (if requested). 192 227 [ -n "$2" ] && eval "$2=\$_read_file_list_ret" … … 356 391 } 357 392 393 repo_dir_for_file() 394 { 395 # $1 = input file name 396 # $2 = var name to save dir to 397 398 [ -n "$1" -a -n "$2" ] || die "Invalid arguments." 399 400 local _repo_dir_for_file_ret= 401 case "$1" in 402 *.src.rpm) 403 eval _repo_dir_for_file_ret="$RPMBUILD_BOT_UPLOAD_REPO_LAYOUT_srpm" 404 ;; 405 *.*.rpm) 406 local arch="${1%.rpm}" 407 arch="${arch##*.}" 408 [ -n "$arch" ] || die "No arch spec in file name '$1'." 409 eval _repo_dir_for_file_ret="$RPMBUILD_BOT_UPLOAD_REPO_LAYOUT_rpm" 410 ;; 411 *.zip) 412 eval _repo_dir_for_file_ret="$RPMBUILD_BOT_UPLOAD_REPO_LAYOUT_zip" 413 ;; 414 esac 415 416 eval "$2=\$_repo_dir_for_file_ret" 417 } 418 358 419 upload_cmd() 359 420 { … … 375 436 read_file_list "$spec_list" files 376 437 for f in $files; do 377 case "$f" in 378 *.src.rpm) 379 eval local d="$RPMBUILD_BOT_UPLOAD_REPO_LAYOUT_srpm" 380 ;; 381 *.*.rpm) 382 local arch="${f%.rpm}" 383 arch="${arch##*.}" 384 [ -n "$arch" ] || die "No arch spec in file name '$f' in '$spec_list'." 385 eval d="$RPMBUILD_BOT_UPLOAD_REPO_LAYOUT_rpm" 386 ;; 387 *.zip) 388 eval d="$RPMBUILD_BOT_UPLOAD_REPO_LAYOUT_zip" 389 ;; 390 *) 391 die "Unsupported file name '$f' in '$spec_list'." 392 ;; 393 esac 438 local d= 439 repo_dir_for_file "$f" d 440 [ -n "$d" ] || die "Unsupported file name '$f' in '$spec_list'." 394 441 [ -d "$d" ] || die "'$d' is not a directory." 395 442 [ -f "$d/${f##*/}" -a -z "$force" ] && die \ … … 412 459 echo "Moving '$spec_name' logs to $log_dir/archive..." 413 460 run mv "$log_base".*.log "$log_base".*.list "$log_base".list "$log_dir/archive/" 461 } 462 463 clean_cmd() 464 { 465 [ -f "$spec_list" ] || die \ 466 "File '$spec_list' is not found. 467 You man need to build the packages using the 'build' command." 468 469 local files= 470 read_file_list "$spec_list" files 471 472 for f in $files; do 473 echo "Removing $f..." 474 run rm -f "$f" 475 done 476 477 echo "Removing '$spec_name' logs from $log_dir..." 478 rm -f "$log_base".*.log "$log_base".*.list "$log_base".list 479 } 480 481 remove_cmd() 482 { 483 # Check settings. 484 [ -n "$spec_ver" ] || die "SPEC parameter lacks version specification." 485 486 test -n "$RPMBUILD_BOT_UPLOAD_REPO_LIST" || die "RPMBUILD_BOT_UPLOAD_REPO_LIST is empty." 487 488 local repo="$command_arg" 489 [ -z "$repo" ] && repo="${RPMBUILD_BOT_UPLOAD_REPO_LIST%% *}" 490 491 check_dir_var "RPMBUILD_BOT_UPLOAD_${repo}_DIR" 492 493 eval local base="\$RPMBUILD_BOT_UPLOAD_${repo}_DIR" 494 495 local ver_list="$log_dir/archive/$spec_name.$spec_ver.list" 496 [ -f "$ver_list" ] || die "File '$ver_list' is not found." 497 498 local files= 499 read_file_list "$ver_list" files 'local dir=; repo_dir_for_file $file dir; file="${dir}/${file##*/}"' 500 501 for f in $files; do 502 echo "Removing $f..." 503 run rm -f "$f" 504 done 505 506 echo "Removing $ver_list..." 507 run rm -f "$ver_list" 508 509 # Also remove the logs of last "build" if we are removing the last "build" package. 510 if [ -L "$log_dir/archive/$spec_name.list" -a \ 511 `readlink "$log_dir/archive/$spec_name.list"` = "$spec_name.$spec_ver.list" ] ; then 512 echo "Removing '$spec_name' logs from $log_dir/archive..." 513 rm -f "$log_dir/archive/$spec_name".*.log "$log_dir/archive/$spec_name".list 514 fi 414 515 } 415 516 … … 448 549 [ -z "$command" ] && command="build" 449 550 551 spec_ver="${spec#*=}" 552 spec="${spec%=*}" 553 [ "$spec" = "$spec_ver" ] && spec_ver= 554 450 555 command_name="${command%=*}" 451 556 command_arg="${command#*=}" 452 557 [ "$command_name" = "$command_arg" ] && command_arg= 453 558 559 need_spec_file= 560 561 # Validate commands. 454 562 case "$command_name" in 455 build|upload|test) 563 build|test) 564 need_spec_file=1 565 ;; 566 upload|clean|remove) 456 567 ;; 457 568 *) usage … … 479 590 spec_name="${spec_name%.spec}" 480 591 481 [ - f "$spec_full" ] || die "Spec file '$spec_full' is not found."592 [ -z "$need_spec_file" -o -f "$spec_full" ] || die "Spec file '$spec_full' is not found." 482 593 483 594 # Prepare some (non-rpmbuild-standard) directories.
Note:
See TracChangeset
for help on using the changeset viewer.