cookutils annotate cooker @ rev 848

cook: add cook_split_rm(); web/cooker.cgi: visualize console colorizations (existed in the bash log)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Dec 14 23:03:59 2016 +0200 (2016-12-14)
parents 2850833e8670
children 71118129435e
rev   line source
pankso@4 1 #!/bin/sh
pankso@4 2 #
pankso@383 3 # SliTaz Build Bot. The Cooker is a tool to automate and test SliTaz package
pankso@383 4 # building. Please read the Cookbook documentation for more information
paul@54 5 # and discuss with the AUTHORS before adding anything here. PS: no translations
paul@495 6 # here since it's not an end user tool and it's not useful. All devs should
pankso@4 7 # at least understand basic English.
pankso@4 8 #
al@728 9
pankso@431 10 . /usr/lib/slitaz/libcook.sh
pankso@4 11
pankso@49 12 # Set pkg name and use same wok as cook.
pankso@49 13 pkg="$2"
pankso@4 14 wok="$WOK"
pankso@4 15
pankso@81 16 # PID file.
pankso@81 17 pidfile='/var/run/cooker.pid'
pankso@81 18
pankso@4 19 #
pankso@4 20 # Functions
pankso@4 21 #
pankso@4 22
pankso@4 23 usage() {
al@728 24 cat <<EOT
pankso@4 25
pankso@341 26 Usage: cooker [command] [pkg|list|note|hours]
pankso@4 27
pankso@4 28 Options:
pankso@49 29 usage|-u Display this short usage.
pankso@49 30 setup|-s Setup the Cooker environment.
pankso@341 31 setup-cron Setup a cron job for the Cooker.
pankso@383 32 arch-db Create host arch packages DB.
pankso@49 33 note|-n Add a note to the cooknotes.
pankso@49 34 notes|-ns Display all the cooknotes.
pankso@49 35 block|-b Block a package so cook will skip it.
pankso@49 36 unblock|-ub Unblock a blocked package.
pankso@49 37 pkg|-p Same as 'cook pkg' but with cooker log.
pankso@49 38 flavor|-f Cook all packages of a flavor.
paul@54 39 list|-l Cook all packages in the given list.
pankso@49 40 cat|-c Cook all packages of a category.
pankso@79 41 rev|-r Cook packages of a specific revision.
pankso@49 42 all|-a Find and cook all unbuilt packages.
pankso@4 43
pankso@4 44 EOT
pankso@4 45 exit 0
pankso@4 46 }
pankso@4 47
al@728 48
paul@54 49 # Some messages occur in activity but log verbose output when checking for commits
pankso@14 50 # into a log file.
al@728 51
pankso@14 52 log_commits() {
pankso@35 53 sed '/^.\//'d | sed '/^.hg/'d | tee -a $LOGS/commits.log
pankso@14 54 }
pankso@14 55
al@728 56
pankso@81 57 # Clean up before exit when check and cook commits finish.
al@728 58
pankso@81 59 clean_exit() {
al@728 60 rm -f $command; touch $command
pascal@766 61 [ "$previous_command" ] && ps | grep -q "${previous_command/:/ }" &&
pascal@766 62 echo -n "$previous_command" > $command
pankso@81 63 rm -f $pidfile
pankso@14 64 }
pankso@14 65
al@728 66
pankso@35 67 # Summary for commits.
al@728 68
pankso@35 69 commits_summary() {
pankso@35 70 msg="from revision $cur to $new"
pankso@35 71 [ "$new" == "$cur" ] && msg="revision $new"
pankso@35 72 echo "Will cook $msg"
pankso@35 73 separator
pankso@35 74 echo -e "\nSummary for commits"
pankso@35 75 separator
pankso@35 76 echo "Hg wok revision : $cur"
pankso@35 77 echo "Pulled revision : $new"
al@728 78 echo "Check date : $(date '+%F %T')"
pankso@35 79 }
pankso@35 80
al@728 81
paul@54 82 # Scan packages build deps and fill up cookorder list.
al@728 83
pankso@4 84 cook_order_scan() {
pankso@124 85 rm -f $cookorder
pankso@383 86 touch $cookorder
al@728 87 for pkg in $(cat $cooklist); do
pascal@273 88 unset WANTED BUILD_DEPENDS
pankso@14 89 . $wok/$pkg/receipt
pankso@29 90 # The :: is for web interface color.
pascal@273 91 [ "$WANTED$BUILD_DEPENDS" ] && echo "$pkg :: $WANTED $BUILD_DEPENDS"
al@728 92 for dep in $WANTED $BUILD_DEPENDS; do
pankso@4 93 if grep -q "^$dep$" $cooklist; then
pankso@4 94 if ! grep -q "^$dep$" $cookorder; then
pankso@4 95 echo "$dep" >> $cookorder
pankso@4 96 fi
pankso@4 97 fi
pankso@4 98 done
pankso@4 99 done
pankso@383 100
paul@54 101 # Append unordered packages to cookorder.
al@728 102 for pkg in $(cat $cooklist); do
pankso@4 103 if ! grep -q "^$pkg$" $cookorder; then
pankso@4 104 echo "$pkg" >> $cookorder
pankso@4 105 fi
pankso@4 106 done
pankso@4 107 }
pankso@4 108
al@728 109
paul@54 110 # Scan and rescan until the cooklist is ordered then handle WANTED.
al@728 111
pankso@4 112 cook_order() {
pankso@4 113 time=$(date +%s)
pankso@4 114 scan=0
pankso@4 115
pankso@4 116 # Keep an original cooklist so we do a diff when ordering is finished.
pankso@4 117 cp -f $cooklist $cooklist.0
al@728 118 echo 'cookorder' > $command
al@728 119 echo -e '\nInitial Cooker order scan'
pankso@4 120 separator
pankso@4 121 cook_order_scan
pankso@383 122
pankso@4 123 # Diff between the cooklist and new ordered list ? So copy the last
pankso@4 124 # cookorder to cooklist and rescan it.
al@728 125 while /bin/true; do
pankso@4 126 diff $cooklist $cookorder > $cookorder.diff
pankso@4 127 if [ -s "$cookorder.diff" ]; then
pankso@4 128 scan=$(($scan + 1))
pankso@4 129 echo -e "\nDiff scan: $scan"
pankso@4 130 separator
pankso@4 131 mv -f $cookorder $cooklist
pankso@4 132 cook_order_scan
pankso@4 133 else
pankso@4 134 break
pankso@4 135 fi
pankso@4 136 done
pankso@4 137
paul@647 138 # Keep a diff between submitted cooklist and the ordered.
pankso@4 139 diff $cooklist.0 $cooklist > $cooklist.diff
pankso@4 140 rm -f $cookorder $cookorder.diff $cooklist.0
pankso@4 141
pankso@107 142 # Scan finished: append pkg to WANTED or leave it in the ordered cooklist.
paul@214 143 # TODO: grep the line number to get pkg position and keep it higher.
al@728 144 echo -e '\nHandle WANTED package'
pankso@4 145 separator
al@728 146 for pkg in $(cat $cooklist); do
pankso@4 147 unset WANTED
pankso@14 148 . $wok/$pkg/receipt
al@728 149 for wanted in $WANTED; do
pascal@291 150 echo "$pkg :: $wanted"
pascal@291 151 if grep -q ^${wanted}$ $cooklist; then
pankso@107 152 sed -i -e "/^$pkg$/"d \
pascal@291 153 -e "/^$wanted$/ a $pkg" $cooklist
pankso@107 154 fi
pascal@291 155 done
pankso@4 156 done
pankso@4 157
pankso@4 158 # Show ordered cooklist
al@728 159 echo -e '\nCooklist order'
pankso@4 160 separator
pankso@4 161 cat $cooklist
pankso@4 162 separator
al@728 163
pankso@4 164 time=$(($(date +%s) - $time))
pankso@4 165 pkgs=$(cat $cooklist | wc -l)
al@728 166 echo -e '\nSummary for cookorder'
pankso@4 167 separator
al@728 168 cat <<EOT
pankso@4 169 Ordered packages : $pkgs
pankso@4 170 Scans executed : $scan
pankso@4 171 Scan duration : ${time}s
pankso@4 172 EOT
al@728 173 separator
al@728 174
al@728 175 rm -f $command
pankso@4 176 }
pankso@4 177
al@728 178
pankso@14 179 # Remove blocked (faster this way than grepping before).
al@728 180
pankso@14 181 strip_blocked() {
al@728 182 for pkg in $(cat $blocked); do
pankso@14 183 sed -i /^${pkg}$/d $cooklist
al@728 184 done
al@728 185 sed -i /^$/d $cooklist
pankso@14 186 }
pankso@14 187
al@728 188
paul@54 189 # Use in default mode and with all cmd.
al@728 190
pankso@4 191 cook_commits() {
pankso@4 192 if [ -s "$commits" ]; then
al@728 193 for pkg in $(cat $commits); do
pascal@765 194 ps | grep -q "cook $pkg$" && continue
pankso@14 195 echo "cook:$pkg" > $command
pankso@394 196 cook $pkg || broken
pankso@4 197 sed -i /^${pkg}$/d $commits
pankso@4 198 done
pankso@4 199 fi
pankso@4 200 }
pankso@4 201
al@728 202
paul@54 203 # Cook all packages in a cooklist.
al@728 204
pankso@14 205 cook_list() {
al@728 206 for pkg in $(cat $cooklist); do
pascal@765 207 ps | grep -q "cook $pkg$" && continue
pankso@79 208 cook $pkg || broken
pankso@79 209 sed -i /^${pkg}$/d $cooklist
pankso@14 210 done
pankso@14 211 }
pankso@14 212
al@728 213
paul@388 214 # Create a arch.$ARCH file for each package cooked for the target host
pankso@383 215 # architecture
pankso@383 216 #
pankso@383 217 # The deal: we dont want all packages handled by cooker commands and stats,
pankso@383 218 # since we dont cross compile all packages for each arch but only a set of
paul@388 219 # packages to provide one full featured desktop, servers and goodies useful
pankso@383 220 # for the host system.
pankso@383 221 #
al@728 222
pankso@383 223 arch_db() {
pankso@383 224 count=0
pankso@391 225 echo "Cleaning packages DB : arch.$ARCH"
pankso@390 226 rm -f $wok/*/arch.$ARCH && cd $wok
pankso@383 227 echo "Creating $ARCH packages DB..."
al@728 228 for pkg in *; do
pascal@800 229 [ -s $wok/$pkg/receipt ] || continue
pascal@693 230 HOST_ARCH=
pascal@693 231 . $wok/$pkg/receipt
pascal@693 232 if [ -n "$HOST_ARCH" ]; then
pankso@678 233 if $(echo "$HOST_ARCH" | egrep -q "$ARCH|any"); then
pankso@678 234 count=$(($count + 1))
pankso@678 235 echo "Adding: $pkg"
pankso@678 236 touch $pkg/arch.$ARCH
pankso@678 237 fi
pankso@678 238 unset HOST_ARCH
pankso@678 239 else
pankso@678 240 # HOST_ARCH not set --> in i486
al@728 241 if [ "$ARCH" == 'i486' ]; then
pankso@678 242 count=$(($count + 1))
pankso@678 243 echo "Adding: $pkg"
pankso@678 244 touch $pkg/arch.$ARCH
pankso@678 245 fi
pankso@383 246 fi
pankso@383 247 done
pankso@391 248 echo "Packages for $ARCH : $count"
pankso@383 249 }
pankso@383 250
al@728 251
pankso@4 252 #
pankso@4 253 # Commands
pankso@4 254 #
al@728 255
pascal@764 256 previous_command="$(cat $command)"
pankso@4 257 case "$1" in
pankso@31 258 usage|help|-u|-h)
pankso@4 259 usage ;;
al@728 260
pankso@31 261 setup|-s)
pankso@4 262 # Setup the Cooker environment.
al@728 263 echo -e '\nSetting up the Cooker'
pankso@349 264 mkdir -p $CACHE
pankso@31 265 echo "Cooker setup using: $SLITAZ" | log
pankso@4 266 separator
al@728 267 for pkg in $SETUP_PKGS mercurial rsync tazlito; do
pankso@4 268 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
pankso@4 269 done
pankso@4 270 mkdir -p $SLITAZ && cd $SLITAZ
al@728 271 if [ -d "${wok}-hg" ]; then
al@728 272 echo -e 'Hg wok already exists.\n'
al@728 273 exit 1
al@728 274 fi
al@728 275 if [ -d "$wok" ]; then
al@728 276 echo -e 'Build wok already exists.\n'
al@728 277 exit 1
al@728 278 fi
pankso@4 279
pankso@4 280 # Directories and files
pankso@4 281 echo "mkdir's and touch files in: $SLITAZ"
pankso@311 282 mkdir -p $PKGS $LOGS $FEEDS $CACHE $SRC
al@728 283 for f in $activity $blocked $broken $commits $cooklist $command; do
pankso@4 284 touch $f
pankso@4 285 done
pankso@14 286 hg clone $WOK_URL ${wok}-hg || exit 1
pankso@60 287 [ -d "$flavors" ] || hg clone $FLAVORS_URL flavors
pankso@4 288 cp -a ${wok}-hg $wok
al@728 289 separator; newline ;;
al@728 290
pankso@383 291 arch-db)
pankso@383 292 # Manually create arch packages DB.
pankso@383 293 arch_db ;;
al@728 294
pankso@341 295 setup-cron)
pankso@341 296 # Create cron job for the cooker.
pankso@341 297 [ "$2" ] || hours=2
pankso@341 298 if [ ! -f "$crontabs" ]; then
pankso@341 299 mkdir -p /var/spool/cron/crontabs
pankso@341 300 fi
pankso@341 301 if ! fgrep -q /usr/bin/cooker $crontabs; then
pascal@760 302 cat > $crontabs << EOT
pascal@760 303 # Run SliTaz Cooker every $hours hours
pascal@777 304 59 */$hours * * * touch $CACHE/cooker-request
pascal@760 305 */5 * * * * [ $CACHE/cooker-request -nt $CACHE/activity ] && /usr/bin/cooker --output=html
pascal@777 306 */5 * * * * [ -z "$(pidof cooker)" ] && [ -s $CACHE/recook-packages ] && /usr/bin/cooker list $CACHE/recook-packages
pascal@760 307 EOT
pascal@773 308 touch $CACHE/cooker-request $CACHE/recook-packages
pascal@773 309 chmod 666 $CACHE/cooker-request $CACHE/recook-packages
pankso@341 310 killall crond 2>/dev/null && /etc/init.d/crond start
pankso@341 311 fi ;;
al@728 312
pankso@341 313 check-cron)
al@728 314 if [ ! -f "$crontabs" ]; then
al@728 315 echo "There is no $crontabs here. Use setup-cron option."
al@728 316 exit 1
al@728 317 fi
pankso@341 318 fgrep /usr/bin/cooker $crontabs ;;
al@728 319
pankso@31 320 note|-n)
al@728 321 # Blocked a pkg and want others to know why? Post a note!
al@728 322 [ -n "$2" ] && echo "$(date '+%F %R') : $2" >> $cooknotes ;;
al@728 323
pankso@31 324 notes|-ns)
pankso@29 325 # View cooknotes.
al@728 326 echo -e '\nCooknotes'
pankso@29 327 separator
pankso@29 328 cat $cooknotes
al@728 329 separator; newline ;;
al@728 330
pankso@49 331 block|-b)
pankso@49 332 # Block a package.
pankso@49 333 [ "$pkg" ] && cook $pkg --block ;;
al@728 334
pankso@49 335 unblock|-ub)
pankso@49 336 # Unblock a package.
pankso@49 337 [ "$pkg" ] && cook $pkg --unblock ;;
al@728 338
pankso@31 339 reverse|-r)
paul@54 340 # Cook all reverse dependencies for a package. This command lets us
paul@54 341 # control the Cooker manually for commits that will cook a lot of packages.
pankso@14 342 #
al@728 343 # Use hg commit? Ex: hg commit -m "Message bla bla | cooker:reverse"
pankso@14 344 #
al@728 345 if [ ! -d "$wok/$pkg" ]; then
al@728 346 echo -e "\nNo package $2 found.\n"
al@728 347 exit 0
al@728 348 fi
al@728 349 rm -f $cooklist; touch $cooklist
pankso@32 350 echo -e "\nReverse cooklist for: $pkg"
al@728 351 separator
al@728 352
al@728 353 cd $wok
al@728 354 for rev in *; do
pascal@800 355 [ -s $wok/$rev/receipt ] || continue
al@728 356 unset WANTED DEPENDS BUILD_DEPENDS; . $wok/$rev/receipt
pascal@273 357 if echo "$WANTED $DEPENDS $BUILD_DEPENDS" | fgrep -q $pkg; then
pankso@32 358 echo "$rev" | tee -a $cooklist
pankso@4 359 fi
al@728 360 done
al@728 361 separator
pankso@32 362 echo -e "Reverse dependencies found: $(cat $cooklist | wc -l)\n"
pankso@32 363 strip_blocked
pankso@32 364 cook_order | tee $LOGS/cookorder.log
pankso@32 365 cook_list ;;
al@728 366
pankso@31 367 pkg|-p)
pankso@12 368 # Same as 'cook pkg' but with log for web interface.
pascal@765 369 ps | grep -q "cook $pkg$" && echo 'Already running' && continue
pankso@394 370 cook $pkg || broken
pankso@81 371 clean_exit ;;
al@728 372
pankso@31 373 cat|-c)
pankso@4 374 # Cook all packages of a category.
pankso@31 375 cat="$2"
al@728 376 rm -f $cooklist; touch $cooklist
al@728 377
al@728 378 cd $wok
al@728 379 for pkg in *; do
pascal@800 380 [ -s $pkg/receipt ] || continue
al@728 381 unset CATEGORY; . $pkg/receipt
pankso@4 382 [ "$CATEGORY" == "$cat" ] && echo $pkg >> $cooklist
pankso@4 383 done
pankso@14 384 strip_blocked
pankso@14 385 cook_order | tee $LOGS/cookorder.log
pankso@26 386 cook_list ;;
al@728 387
pankso@31 388 flavor|-f)
pankso@21 389 # Cook all packages of a flavor.
pankso@31 390 name="$2"
al@728 391 if [ ! -d "$flavors/$name" ]; then
al@728 392 echo -e "\nSpecified flavor does not exist: $name\n"
al@728 393 exit 1
al@728 394 fi
al@728 395 if [ -d "$flavors/.hg" ]; then
al@728 396 cd $flavors; hg pull -u
al@728 397 fi
al@728 398 list="$flavors/$name/packages.list"
pankso@21 399 cp -a $list $cooklist
pankso@21 400 strip_blocked
pankso@21 401 cook_order | tee $LOGS/cookorder.log
pankso@32 402 cook_list ;;
al@728 403
pankso@31 404 list|-l)
paul@54 405 # Cook a list of packages given in argument.
pankso@31 406 list="$2"
al@728 407 if [ ! -f "$list" ]; then
al@728 408 echo -e "\nSpecified list does not exist: $list\n"
al@728 409 exit 1
al@728 410 fi
pascal@774 411 cat $list >> $cooklist
pascal@774 412 echo -n > $list
pankso@26 413 strip_blocked
pankso@98 414 cook_order | tee $LOGS/cookorder.log
pankso@98 415 cook_list ;;
al@728 416
pankso@79 417 rev|-r)
pankso@79 418 # Cook or recook a specific Hg revision.
pankso@79 419 rev="$2"
pankso@79 420 [ "$rev" ] || exit 0
al@728 421 rm -f $cooklist; touch $cooklist
al@728 422
pankso@79 423 cd $wok
al@728 424 for pkg in $(hg log --rev=$rev --template "{files}"); do
al@728 425 echo "$pkg" | cut -d/ -f1 >> $cooklist
pankso@79 426 done
pankso@79 427 strip_blocked
pankso@26 428 cook_order | tee $LOGS/cookorder.log
pankso@26 429 cook_list ;;
al@728 430
pankso@31 431 all|-a)
pankso@4 432 # Try to build all unbuilt packages except blocked's.
al@728 433 echo 'cooker:all' > $command
al@728 434 rm -f $cooklist; touch $cooklist
al@728 435 newline
al@728 436 echo 'Cooker cooklist'
pankso@4 437 separator
pankso@383 438
pankso@118 439 # Find all unbuilt packages. Get EXTRAVERSION from packed receipt
paul@132 440 # if it exists since extra version is added when packing the package.
al@728 441 echo 'Searching for all unbuilt packages' | log
al@728 442
al@728 443 cd $wok
al@728 444 for pkg in *; do
pascal@800 445 [ -s $pkg/receipt ] || continue
pankso@118 446 unset EXTRAVERSION
pankso@4 447 . $pkg/receipt
pankso@118 448 [ -f "$pkg/taz/$PACKAGE-$VERSION/receipt" ] && \
pankso@118 449 . $pkg/taz/$PACKAGE-$VERSION/receipt
al@728 450 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
al@728 451 echo $pkg; echo $pkg >> $cooklist
pankso@118 452 fi
pankso@4 453 done
pankso@14 454 strip_blocked
pankso@99 455 cook_order | tee $LOGS/cookorder.log
pankso@13 456 echo "Packages to cook: $(cat $cooklist | wc -l)" | log
pankso@79 457 cook_list ;;
al@728 458
pankso@4 459 *)
pankso@81 460 # Default is to cook all commits if not yet running.
al@728 461 [ -n "$1" ] && usage
slaxemulator@489 462 cooklist=$commits
pankso@81 463 if [ -f "$pidfile" ]; then
slaxemulator@488 464 pid=$(cat $pidfile)
pascal@274 465 if [ -s /proc/$pid/status ]; then
al@728 466 echo -e "\nStill cooking latest commits with pid:"
al@728 467 echo -e " $pid\n"
al@728 468 exit 0
pascal@274 469 fi
pascal@274 470 rm -f "$pidfile"
pankso@81 471 fi
pankso@81 472
pankso@81 473 # Start and get a PID file.
pankso@14 474 rm -f $LOGS/commits.log
slaxemulator@486 475 newline
al@728 476 echo 'Checking for commits' | log_commits
pankso@14 477 separator | tee -a $LOGS/commits.log
pankso@383 478
pankso@82 479 echo $$ > $pidfile
pankso@233 480 trap 'echo -e "\nCooker stopped: PID $$\n" && \
pankso@233 481 rm -f $pidfile $command && exit 1' INT TERM
pankso@383 482
pankso@82 483 echo "Cooker PID : $$" | log_commits
al@728 484 echo "Cooker date : $(date '+%F %T')" | log_commits
pankso@383 485
paul@132 486 # Get revisions. Here we have 2 echoes since we want a msg on screen,
paul@132 487 # in commits log and activity DB without a space before.
pankso@60 488 cd $wok || exit 1
pankso@4 489 cur=$(hg head --template '{rev}\n')
pankso@82 490 echo "Updating wok : ${wok}-hg (rev $cur)" | log_commits
pankso@82 491 echo "Updating wok: ${wok}-hg" | log
al@728 492 echo 'hg:pull' > $command
al@728 493 cd $wok-hg; hg pull -u | log_commits
pankso@4 494 new=$(hg head --template '{rev}\n')
paul@168 495 # Store last rev to be used by CGI so it doesn't need to call hg head
pankso@164 496 # on each load.
slaxemulator@488 497 echo "$new" > $wokrev
pankso@383 498
paul@54 499 # Sync build wok with rsync so we don't take care about removing old
pankso@4 500 # files as before.
pankso@4 501 if [ "$new" -gt "$cur" ]; then
pankso@4 502 echo "Changes found from: $cur to $new" | log
al@728 503 echo 'Syncing build wok with Hg wok...' | log_commits
al@728 504 rsync -r -t -c -l -u -v -D -E $wok-hg/ $wok/ | \
pankso@35 505 sed '/^$/'d | log_commits
pankso@4 506 else
pankso@13 507 echo "No revision changes: $cur vs $new" | log
pankso@14 508 separator | log_commits
al@728 509 clean_exit; newline
al@728 510 exit 0
pankso@4 511 fi
pankso@383 512
pankso@35 513 # Get and display modifications.
al@728 514 cd $wok-hg
pankso@110 515 commits_summary | log_commits
pankso@14 516 cur=$(($cur + 1))
al@728 517 rm -f $commits.tmp; touch $commits.tmp
al@728 518 for rev in $(seq $cur $new); do
al@728 519 for file in $(hg log --rev=$rev --template "{files}"); do
al@728 520 pkg=$(echo $file | cut -d/ -f1)
pankso@36 521 desc=$(hg log --rev=$rev --template "{desc}" $file)
paul@388 522 echo "Committed package : $pkg - $desc" | log_commits
pankso@80 523 echo $pkg >> $commits.tmp
pankso@4 524 done
pankso@4 525 done
pankso@248 526
pankso@248 527 # We may have deleted packages and files in stuff/. Remove it and
pankso@248 528 # clean DB as well as log file.
pankso@248 529 cd $wok
al@728 530 for pkg in *; do
pankso@248 531 if [ ! -d "${wok}-hg/$pkg" ]; then
pankso@248 532 echo "Removing package: $pkg" | log_commits
pascal@799 533 if [ -s $wok/$pkg/receipt ]; then
pascal@799 534 . $wok/$pkg/receipt
pascal@799 535 rm -f $PKGS/$PACKAGE-$VERSION*
pascal@799 536 fi
pascal@799 537 rm -rf $wok/$pkg $LOGS/$pkg.log
slaxemulator@489 538 sed -i "/^${pkg}$/"d $blocked $broken $commits.tmp
pankso@248 539 fi
pankso@248 540 done
pankso@383 541
paul@54 542 # Keep previous commit and discard duplicate lines
pankso@4 543 cat $commits $commits.tmp | sed /"^$"/d > $commits.new
al@728 544 uniq $commits.new > $commits; rm $commits.*
pankso@383 545
paul@388 546 # Handle cross compilation. Create arch packages DB and remove pkgs
pankso@383 547 # not cooked for this arch from the commits list.
pankso@677 548 arch_db
al@728 549 for pkg in $(cat $commits); do
pankso@677 550 if [ ! -f "$wok/$pkg/arch.$ARCH" ]; then
pankso@677 551 echo "Cooker arch : skip $pkg (not included in: $ARCH)" | \
pankso@677 552 log_commits
pankso@677 553 sed -i "/^${pkg}$/"d $commits
pankso@677 554 else
pankso@677 555 echo "Cooker arch : $ARCH" | log_commits
pankso@677 556 fi
pankso@677 557 done
al@728 558
pankso@383 559 # Stats
pankso@109 560 pkgs=$(cat $commits | wc -l)
pankso@100 561 echo "Packages to cook: $pkgs" | log
pankso@109 562 echo "Packages to cook : $pkgs" | log_commits
pankso@35 563 separator | log_commits
slaxemulator@486 564 newline
pankso@14 565 strip_blocked
pankso@14 566 cook_order | tee $LOGS/cookorder.log
pankso@81 567 cook_commits
pankso@81 568 clean_exit ;;
pankso@4 569 esac
pankso@4 570
pankso@4 571 exit 0