cookutils annotate cooker @ rev 1019

cook: add fix() to use '--as-needed' linker flag in compile_rules(); cookit(): make QA fail on empty vars / bad values; remove_already_packed(): fix bug when $PACKAGE not listed in $SPLIT and we use this function for the default set. lighttpd/index.cgi: sort orphans. modules/precheck: separate error message by empty lines.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Dec 07 14:31:28 2017 +0200 (2017-12-07)
parents 9c835beabf65
children 54c97f545127
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
al@942 26 Usage: cooker [<command>] [<options>]
pankso@4 27
al@942 28 Commands with <options>:
al@942 29 -u | usage Display this short usage.
al@942 30 -s | setup Setup the Cooker environment.
al@942 31 setup-cron [<hours>] Setup a cron job for the Cooker.
al@942 32 check-cron Check Cooker cron job.
al@942 33 arch-db Create host arch packages DB.
al@942 34 -n | note <note_text> Add a note to the cooknotes.
al@942 35 -ns | notes Display all the cooknotes.
al@942 36 -b | block <package> Block a package so cook will skip it.
al@942 37 -ub | unblock <package> Unblock a blocked package.
al@942 38 -R | reverse <package> Cook all reverse dependencies for a package.
al@942 39 -p | pkg <package> Same as 'cook pkg' but with cooker log.
al@942 40 -f | flavor <flavor_name> Cook all packages of a flavor.
al@942 41 -l | list <list_file> Cook all packages in the given list.
al@942 42 -c | cat <category> Cook all packages of a category.
al@942 43 -r | rev <rev_number> Cook packages of a specific revision.
al@942 44 -a | all Find and cook all unbuilt packages.
al@942 45 -T | tasks List existing cooker tasks.
al@942 46 -t | task <task> Executing specified task.
al@957 47 -o | outgoing Find changes in wok that we can move to wok-hg.
pankso@4 48
pankso@4 49 EOT
pankso@4 50 exit 0
pankso@4 51 }
pankso@4 52
al@728 53
paul@54 54 # Some messages occur in activity but log verbose output when checking for commits
pankso@14 55 # into a log file.
al@728 56
pankso@14 57 log_commits() {
al@931 58 sed '/^.\//d' | sed '/^.hg/d' | tee -a $LOGS/commits.log
pankso@14 59 }
pankso@14 60
al@728 61
pankso@81 62 # Clean up before exit when check and cook commits finish.
al@728 63
pankso@81 64 clean_exit() {
al@728 65 rm -f $command; touch $command
pascal@766 66 [ "$previous_command" ] && ps | grep -q "${previous_command/:/ }" &&
pascal@766 67 echo -n "$previous_command" > $command
pankso@81 68 rm -f $pidfile
pankso@14 69 }
pankso@14 70
al@728 71
pankso@35 72 # Summary for commits.
al@728 73
pankso@35 74 commits_summary() {
pankso@35 75 msg="from revision $cur to $new"
pankso@35 76 [ "$new" == "$cur" ] && msg="revision $new"
pankso@35 77 echo "Will cook $msg"
pankso@35 78 separator
al@942 79 title "Summary for commits"
pankso@35 80 echo "Hg wok revision : $cur"
pankso@35 81 echo "Pulled revision : $new"
al@728 82 echo "Check date : $(date '+%F %T')"
pankso@35 83 }
pankso@35 84
al@728 85
al@942 86 # Return all the names of packages bundled in this receipt
al@942 87
al@942 88 all_names() {
al@942 89 local split=" $SPLIT "
al@942 90 unset SPLIT
al@942 91 . $wok/$pkg/receipt
al@942 92
al@942 93 if ! head -n1 $WOK/$pkg/receipt | fgrep -q 'v2'; then
al@942 94 # For receipts v1: $SPLIT may present in the $WANTED package,
al@942 95 # but split packages have their own receipts
al@942 96 echo $PACKAGE
al@942 97 elif [ "${split/ $PACKAGE /}" != "$split" ]; then
al@942 98 echo $SPLIT
al@942 99 else
al@942 100 echo $PACKAGE $SPLIT
al@942 101 fi
al@942 102 }
al@942 103
al@942 104
paul@54 105 # Scan packages build deps and fill up cookorder list.
al@728 106
pankso@4 107 cook_order_scan() {
al@942 108 rm -f $cookorder $cookorder.split
al@942 109 touch $cookorder $cookorder.split
al@942 110
al@942 111 # Make combined split table: beginning from actual information with fresh
al@942 112 # commits. Example:
al@942 113 # freetype freetype freetype-dev
al@942 114 # harfbuzz harfbuzz harfbuzz-apps harfbuzz-dev
al@942 115 while read pkg; do
al@942 116 echo "$pkg $(all_names)" >> $cookorder.split
al@942 117 done < $cooklist
al@942 118 cat $cache/split.db >> $cookorder.split
al@942 119
al@942 120 maxlen=$(wc -L < $cooklist)
al@942 121
al@931 122 while read pkg; do
pascal@273 123 unset WANTED BUILD_DEPENDS
pankso@14 124 . $wok/$pkg/receipt
al@942 125 bdeps=$(
al@942 126 # Substitite each package of BUILD_DEPENDS list by the "main"
al@942 127 # receipt which builds this package. Example:
al@942 128 # BUILD_DEPENDS="freetype-dev harfbuzz-dev" -> bdeps="freetype harfbuzz"
al@942 129 for i in $BUILD_DEPENDS; do
al@942 130 main="$(awk -F$'\t' -vi="$i" '{
al@942 131 if (index(" " $2 " ", i)) {print $1; exit}
al@942 132 }' $cookorder.split)"
al@942 133 echo ${main:-$i}
al@942 134 done
al@942 135 )
pankso@29 136 # The :: is for web interface color.
al@942 137 bdeps=$(echo $WANTED $bdeps | tr '\n' ' ')
al@942 138 printf "%-${maxlen}s :: %s\n" "$pkg" "$bdeps"
al@942 139 for dep in $bdeps; do
pankso@4 140 if grep -q "^$dep$" $cooklist; then
pankso@4 141 if ! grep -q "^$dep$" $cookorder; then
pankso@4 142 echo "$dep" >> $cookorder
pankso@4 143 fi
pankso@4 144 fi
pankso@4 145 done
al@931 146 done < $cooklist
pankso@383 147
paul@54 148 # Append unordered packages to cookorder.
al@931 149 while read pkg; do
pankso@4 150 if ! grep -q "^$pkg$" $cookorder; then
pankso@4 151 echo "$pkg" >> $cookorder
pankso@4 152 fi
al@931 153 done < $cooklist
pankso@4 154 }
pankso@4 155
al@728 156
paul@54 157 # Scan and rescan until the cooklist is ordered then handle WANTED.
al@728 158
pankso@4 159 cook_order() {
pankso@4 160 time=$(date +%s)
pankso@4 161 scan=0
al@942 162 rm -rf $cache/cookorder.d
al@942 163 mkdir -p $cache/cookorder.d
pankso@4 164
pankso@4 165 # Keep an original cooklist so we do a diff when ordering is finished.
pankso@4 166 cp -f $cooklist $cooklist.0
al@728 167 echo 'cookorder' > $command
al@942 168 title 'Initial Cooker order scan'
pankso@4 169 cook_order_scan
pankso@383 170
pankso@4 171 # Diff between the cooklist and new ordered list ? So copy the last
pankso@4 172 # cookorder to cooklist and rescan it.
al@728 173 while /bin/true; do
al@942 174 if ! cmp -s $cooklist $cookorder; then
pankso@4 175 scan=$(($scan + 1))
al@942 176 title "Diff scan: $scan"
al@942 177
al@942 178 md5stamp=$(md5sum $cookorder | cut -d' ' -f1)
al@942 179 if [ -e "$cache/cookorder.d/$md5stamp" ]; then
al@942 180 newline
al@942 181 echo 'A dependency loop was detected. Interrupting the cookorder.'
al@942 182 break
al@942 183 fi
al@942 184 touch $cache/cookorder.d/$md5stamp
al@942 185
pankso@4 186 mv -f $cookorder $cooklist
pankso@4 187 cook_order_scan
al@942 188
pankso@4 189 else
pankso@4 190 break
pankso@4 191 fi
pankso@4 192 done
al@942 193 # Clean
al@942 194 rm -rf $cache/cookorder.d; rm $cookorder.split
pankso@4 195
paul@647 196 # Keep a diff between submitted cooklist and the ordered.
pankso@4 197 diff $cooklist.0 $cooklist > $cooklist.diff
al@942 198 rm -f $cookorder $cooklist.0
pankso@4 199
pankso@107 200 # Scan finished: append pkg to WANTED or leave it in the ordered cooklist.
paul@214 201 # TODO: grep the line number to get pkg position and keep it higher.
al@942 202 title 'Handle WANTED package'
al@931 203 while read pkg; do
pankso@4 204 unset WANTED
pankso@14 205 . $wok/$pkg/receipt
al@728 206 for wanted in $WANTED; do
pascal@291 207 echo "$pkg :: $wanted"
pascal@291 208 if grep -q ^${wanted}$ $cooklist; then
al@931 209 sed -i -e "/^$pkg$/d" \
pascal@291 210 -e "/^$wanted$/ a $pkg" $cooklist
pankso@107 211 fi
pascal@291 212 done
al@931 213 done < $cooklist
pankso@4 214
pankso@4 215 # Show ordered cooklist
al@942 216 title 'Cooklist order'
pankso@4 217 cat $cooklist
pankso@4 218 separator
al@728 219
pankso@4 220 time=$(($(date +%s) - $time))
al@931 221 pkgs=$(wc -l < $cooklist)
al@942 222 title 'Summary for cookorder'
al@728 223 cat <<EOT
pankso@4 224 Ordered packages : $pkgs
pankso@4 225 Scans executed : $scan
pankso@4 226 Scan duration : ${time}s
pankso@4 227 EOT
al@728 228 separator
al@728 229
al@728 230 rm -f $command
pankso@4 231 }
pankso@4 232
al@728 233
pankso@14 234 # Remove blocked (faster this way than grepping before).
al@728 235
pankso@14 236 strip_blocked() {
al@931 237 while read pkg; do
al@931 238 sed -i "/^${pkg}$/d" $cooklist
al@931 239 done < $blocked
al@931 240 sed -i '/^$/d' $cooklist
pankso@14 241 }
pankso@14 242
al@728 243
paul@54 244 # Use in default mode and with all cmd.
al@728 245
pankso@4 246 cook_commits() {
pankso@4 247 if [ -s "$commits" ]; then
al@931 248 while read pkg; do
pascal@765 249 ps | grep -q "cook $pkg$" && continue
pankso@14 250 echo "cook:$pkg" > $command
pankso@394 251 cook $pkg || broken
al@931 252 sed -i "/^${pkg}$/d" $commits
al@931 253 done < $commits
pankso@4 254 fi
pankso@4 255 }
pankso@4 256
al@728 257
paul@54 258 # Cook all packages in a cooklist.
al@728 259
pankso@14 260 cook_list() {
al@931 261 while read pkg; do
pascal@765 262 ps | grep -q "cook $pkg$" && continue
pankso@79 263 cook $pkg || broken
al@931 264 sed -i "/^${pkg}$/d" $cooklist
al@931 265 done < $cooklist
pankso@14 266 }
pankso@14 267
al@728 268
paul@388 269 # Create a arch.$ARCH file for each package cooked for the target host
pankso@383 270 # architecture
pankso@383 271 #
al@931 272 # The deal: we don't want all packages handled by cooker commands and stats,
al@931 273 # since we don't cross compile all packages for each arch but only a set of
paul@388 274 # packages to provide one full featured desktop, servers and goodies useful
pankso@383 275 # for the host system.
pankso@383 276 #
al@728 277
pankso@383 278 arch_db() {
pankso@383 279 count=0
pankso@391 280 echo "Cleaning packages DB : arch.$ARCH"
pankso@390 281 rm -f $wok/*/arch.$ARCH && cd $wok
pankso@383 282 echo "Creating $ARCH packages DB..."
al@728 283 for pkg in *; do
pascal@800 284 [ -s $wok/$pkg/receipt ] || continue
pascal@693 285 HOST_ARCH=
pascal@693 286 . $wok/$pkg/receipt
pascal@693 287 if [ -n "$HOST_ARCH" ]; then
pankso@678 288 if $(echo "$HOST_ARCH" | egrep -q "$ARCH|any"); then
pankso@678 289 count=$(($count + 1))
pankso@678 290 echo "Adding: $pkg"
pankso@678 291 touch $pkg/arch.$ARCH
pankso@678 292 fi
pankso@678 293 unset HOST_ARCH
pankso@678 294 else
pankso@678 295 # HOST_ARCH not set --> in i486
al@728 296 if [ "$ARCH" == 'i486' ]; then
pankso@678 297 count=$(($count + 1))
pankso@678 298 echo "Adding: $pkg"
pankso@678 299 touch $pkg/arch.$ARCH
pankso@678 300 fi
pankso@383 301 fi
pankso@383 302 done
pankso@391 303 echo "Packages for $ARCH : $count"
pankso@383 304 }
pankso@383 305
al@728 306
al@957 307 # Compare wok and wok-hg file $1, display signs:
al@957 308 # '+' file added, '-' file removed, '~' file changed, '=' file not changed
al@957 309
al@957 310 compare_wok_file() {
al@957 311 local f1='n' f2='n' # n: not exists, e: exists
al@957 312 [ -e "$wok/$1" ] && f1='e'
al@957 313 [ -e "$wok-hg/$1" ] && f2='e'
al@957 314 case "$f1$f2" in
al@957 315 en) echo "+ $1";;
al@957 316 ne) [ -n "$del" ] && echo "- $1";;
al@957 317 ee)
al@957 318 if cmp -s "$wok/$1" "$wok-hg/$1"; then
al@957 319 [ -n "$eq" ] && echo "= $1"
al@957 320 else
al@957 321 echo "~ $1"
al@957 322 fi
al@957 323 ;;
al@957 324 esac
al@957 325 }
al@957 326
al@957 327
al@957 328 # Compare wok and wok-hg folder $1; process only:
al@957 329 # receipt, description.*txt, all files in the stuff folder
al@957 330
al@957 331 compare_wok_folder() {
al@957 332 IFS=$'\n'
al@957 333 {
al@957 334 for i in $wok $wok-hg; do
al@957 335 ls $i/$1/receipt 2>/dev/null
al@957 336 ls $i/$1/description.*txt 2>/dev/null
al@957 337 [ -d $i/$1/stuff ] && find $i/$1/stuff -type f
al@957 338 done
al@957 339 } | sed "s|$wok/$1/||; s|$wok-hg/$1/||" | sort -u | \
al@957 340 while read file; do
al@957 341 compare_wok_file "$1/$file"
al@957 342 done
al@957 343 }
al@957 344
al@957 345
al@957 346 # Compare entire wok
al@957 347
al@957 348 compare_wok() {
al@957 349 {
al@957 350 cd $wok; ls
al@957 351 cd $wok-hg; ls
al@957 352 } | sort -u | \
al@957 353 while read folder; do
al@957 354 result="$(compare_wok_folder $folder)"
al@957 355 [ -n "$result" ] && echo -e "$result\n"
al@957 356 done
al@957 357 }
al@957 358
al@957 359
pankso@4 360 #
pankso@4 361 # Commands
pankso@4 362 #
al@728 363
al@933 364 previous_command="$(cat $command 2>/dev/null)"
pankso@4 365 case "$1" in
pankso@31 366 usage|help|-u|-h)
pankso@4 367 usage ;;
al@728 368
pankso@31 369 setup|-s)
pankso@4 370 # Setup the Cooker environment.
al@942 371 title 'Setting up the Cooker'
pankso@349 372 mkdir -p $CACHE
pankso@31 373 echo "Cooker setup using: $SLITAZ" | log
al@728 374 for pkg in $SETUP_PKGS mercurial rsync tazlito; do
pankso@4 375 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
pankso@4 376 done
pankso@4 377 mkdir -p $SLITAZ && cd $SLITAZ
al@728 378 if [ -d "${wok}-hg" ]; then
al@728 379 echo -e 'Hg wok already exists.\n'
al@728 380 exit 1
al@728 381 fi
al@728 382 if [ -d "$wok" ]; then
al@728 383 echo -e 'Build wok already exists.\n'
al@728 384 exit 1
al@728 385 fi
pankso@4 386
pankso@4 387 # Directories and files
pankso@4 388 echo "mkdir's and touch files in: $SLITAZ"
pankso@311 389 mkdir -p $PKGS $LOGS $FEEDS $CACHE $SRC
al@728 390 for f in $activity $blocked $broken $commits $cooklist $command; do
pankso@4 391 touch $f
pankso@4 392 done
pankso@14 393 hg clone $WOK_URL ${wok}-hg || exit 1
pankso@60 394 [ -d "$flavors" ] || hg clone $FLAVORS_URL flavors
pankso@4 395 cp -a ${wok}-hg $wok
al@942 396 footer ;;
al@728 397
pankso@383 398 arch-db)
pankso@383 399 # Manually create arch packages DB.
pankso@383 400 arch_db ;;
al@728 401
pankso@341 402 setup-cron)
pankso@341 403 # Create cron job for the cooker.
pankso@341 404 [ "$2" ] || hours=2
pankso@341 405 if [ ! -f "$crontabs" ]; then
pankso@341 406 mkdir -p /var/spool/cron/crontabs
pankso@341 407 fi
pankso@341 408 if ! fgrep -q /usr/bin/cooker $crontabs; then
al@931 409 cat > $crontabs <<EOT
pascal@760 410 # Run SliTaz Cooker every $hours hours
pascal@777 411 59 */$hours * * * touch $CACHE/cooker-request
pascal@760 412 */5 * * * * [ $CACHE/cooker-request -nt $CACHE/activity ] && /usr/bin/cooker --output=html
pascal@777 413 */5 * * * * [ -z "$(pidof cooker)" ] && [ -s $CACHE/recook-packages ] && /usr/bin/cooker list $CACHE/recook-packages
pascal@760 414 EOT
pascal@773 415 touch $CACHE/cooker-request $CACHE/recook-packages
pascal@773 416 chmod 666 $CACHE/cooker-request $CACHE/recook-packages
pankso@341 417 killall crond 2>/dev/null && /etc/init.d/crond start
pankso@341 418 fi ;;
al@728 419
pankso@341 420 check-cron)
al@728 421 if [ ! -f "$crontabs" ]; then
al@728 422 echo "There is no $crontabs here. Use setup-cron option."
al@728 423 exit 1
al@728 424 fi
pankso@341 425 fgrep /usr/bin/cooker $crontabs ;;
al@728 426
pankso@31 427 note|-n)
al@728 428 # Blocked a pkg and want others to know why? Post a note!
al@728 429 [ -n "$2" ] && echo "$(date '+%F %R') : $2" >> $cooknotes ;;
al@728 430
pankso@31 431 notes|-ns)
pankso@29 432 # View cooknotes.
al@942 433 title 'Cooknotes'
pankso@29 434 cat $cooknotes
al@942 435 footer ;;
al@728 436
pankso@49 437 block|-b)
pankso@49 438 # Block a package.
pankso@49 439 [ "$pkg" ] && cook $pkg --block ;;
al@728 440
pankso@49 441 unblock|-ub)
pankso@49 442 # Unblock a package.
pankso@49 443 [ "$pkg" ] && cook $pkg --unblock ;;
al@728 444
pankso@31 445 reverse|-r)
paul@54 446 # Cook all reverse dependencies for a package. This command lets us
paul@54 447 # control the Cooker manually for commits that will cook a lot of packages.
pankso@14 448 #
al@728 449 # Use hg commit? Ex: hg commit -m "Message bla bla | cooker:reverse"
pankso@14 450 #
al@728 451 if [ ! -d "$wok/$pkg" ]; then
al@728 452 echo -e "\nNo package $2 found.\n"
al@728 453 exit 0
al@728 454 fi
al@728 455 rm -f $cooklist; touch $cooklist
al@942 456 title "Reverse cooklist for: $pkg"
al@728 457
al@728 458 cd $wok
al@728 459 for rev in *; do
pascal@800 460 [ -s $wok/$rev/receipt ] || continue
al@728 461 unset WANTED DEPENDS BUILD_DEPENDS; . $wok/$rev/receipt
pascal@273 462 if echo "$WANTED $DEPENDS $BUILD_DEPENDS" | fgrep -q $pkg; then
pankso@32 463 echo "$rev" | tee -a $cooklist
pankso@4 464 fi
al@728 465 done
al@942 466 footer "Reverse dependencies found: $(wc -l < $cooklist)"
pankso@32 467 strip_blocked
pankso@32 468 cook_order | tee $LOGS/cookorder.log
pankso@32 469 cook_list ;;
al@728 470
pankso@31 471 pkg|-p)
pankso@12 472 # Same as 'cook pkg' but with log for web interface.
pascal@765 473 ps | grep -q "cook $pkg$" && echo 'Already running' && continue
pankso@394 474 cook $pkg || broken
pankso@81 475 clean_exit ;;
al@728 476
pankso@31 477 cat|-c)
pankso@4 478 # Cook all packages of a category.
pankso@31 479 cat="$2"
al@728 480 rm -f $cooklist; touch $cooklist
al@728 481
al@728 482 cd $wok
al@728 483 for pkg in *; do
pascal@800 484 [ -s $pkg/receipt ] || continue
al@728 485 unset CATEGORY; . $pkg/receipt
pankso@4 486 [ "$CATEGORY" == "$cat" ] && echo $pkg >> $cooklist
pankso@4 487 done
pankso@14 488 strip_blocked
pankso@14 489 cook_order | tee $LOGS/cookorder.log
pankso@26 490 cook_list ;;
al@728 491
pankso@31 492 flavor|-f)
pankso@21 493 # Cook all packages of a flavor.
pankso@31 494 name="$2"
al@728 495 if [ ! -d "$flavors/$name" ]; then
al@728 496 echo -e "\nSpecified flavor does not exist: $name\n"
al@728 497 exit 1
al@728 498 fi
al@728 499 if [ -d "$flavors/.hg" ]; then
al@728 500 cd $flavors; hg pull -u
al@728 501 fi
al@728 502 list="$flavors/$name/packages.list"
pankso@21 503 cp -a $list $cooklist
pankso@21 504 strip_blocked
pankso@21 505 cook_order | tee $LOGS/cookorder.log
pankso@32 506 cook_list ;;
al@728 507
pankso@31 508 list|-l)
paul@54 509 # Cook a list of packages given in argument.
pankso@31 510 list="$2"
al@728 511 if [ ! -f "$list" ]; then
al@728 512 echo -e "\nSpecified list does not exist: $list\n"
al@728 513 exit 1
al@728 514 fi
pascal@774 515 cat $list >> $cooklist
pascal@774 516 echo -n > $list
pankso@26 517 strip_blocked
pankso@98 518 cook_order | tee $LOGS/cookorder.log
pankso@98 519 cook_list ;;
al@728 520
pankso@79 521 rev|-r)
pankso@79 522 # Cook or recook a specific Hg revision.
pankso@79 523 rev="$2"
pankso@79 524 [ "$rev" ] || exit 0
al@728 525 rm -f $cooklist; touch $cooklist
al@728 526
pankso@79 527 cd $wok
al@728 528 for pkg in $(hg log --rev=$rev --template "{files}"); do
al@728 529 echo "$pkg" | cut -d/ -f1 >> $cooklist
pankso@79 530 done
pankso@79 531 strip_blocked
pankso@26 532 cook_order | tee $LOGS/cookorder.log
pankso@26 533 cook_list ;;
al@728 534
pankso@31 535 all|-a)
pankso@4 536 # Try to build all unbuilt packages except blocked's.
al@728 537 echo 'cooker:all' > $command
al@728 538 rm -f $cooklist; touch $cooklist
al@942 539 title 'Cooker cooklist'
pankso@383 540
pankso@118 541 # Find all unbuilt packages. Get EXTRAVERSION from packed receipt
paul@132 542 # if it exists since extra version is added when packing the package.
al@728 543 echo 'Searching for all unbuilt packages' | log
al@728 544
al@728 545 cd $wok
al@728 546 for pkg in *; do
pascal@800 547 [ -s $pkg/receipt ] || continue
pankso@118 548 unset EXTRAVERSION
pankso@4 549 . $pkg/receipt
pankso@118 550 [ -f "$pkg/taz/$PACKAGE-$VERSION/receipt" ] && \
pankso@118 551 . $pkg/taz/$PACKAGE-$VERSION/receipt
al@728 552 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
al@728 553 echo $pkg; echo $pkg >> $cooklist
pankso@118 554 fi
pankso@4 555 done
pankso@14 556 strip_blocked
pankso@99 557 cook_order | tee $LOGS/cookorder.log
al@931 558 echo "Packages to cook: $(wc -l < $cooklist)" | log
pankso@79 559 cook_list ;;
al@728 560
al@942 561 tasks|-T)
al@942 562 # List existing cooker tasks
al@942 563 [ ! -d "$tasks" ] && echo 'There are no tasks.' && exit 0
al@942 564 title 'Cooker tasks list'
al@942 565 last=$(ls $tasks | tail -n1)
al@942 566 for task in $(ls $tasks); do
al@942 567 . $tasks/$task
al@942 568 echo "Task name : $task"
al@942 569 echo "Description : $DESC"
al@942 570 separator $([ $task != $last ] && echo '-')
al@942 571 done
al@942 572 newline ;;
al@942 573
al@942 574 task|-t)
al@942 575 # Executing specified task
al@942 576 task="$2"
al@942 577 title "Executing cooker task: $task"
al@942 578 . $tasks/$task; task
al@942 579 footer "Task $task finished" ;;
al@942 580
al@957 581 outgoing|-o)
al@957 582 # Find changes in wok that we can move to wok-hg
al@957 583 compare_wok
al@957 584 ;;
al@957 585
pankso@4 586 *)
pankso@81 587 # Default is to cook all commits if not yet running.
al@728 588 [ -n "$1" ] && usage
slaxemulator@489 589 cooklist=$commits
pankso@81 590 if [ -f "$pidfile" ]; then
slaxemulator@488 591 pid=$(cat $pidfile)
pascal@274 592 if [ -s /proc/$pid/status ]; then
al@728 593 echo -e "\nStill cooking latest commits with pid:"
al@728 594 echo -e " $pid\n"
al@728 595 exit 0
pascal@274 596 fi
pascal@274 597 rm -f "$pidfile"
pankso@81 598 fi
pankso@81 599
pankso@81 600 # Start and get a PID file.
pankso@14 601 rm -f $LOGS/commits.log
slaxemulator@486 602 newline
al@728 603 echo 'Checking for commits' | log_commits
pankso@14 604 separator | tee -a $LOGS/commits.log
pankso@383 605
pankso@82 606 echo $$ > $pidfile
pankso@233 607 trap 'echo -e "\nCooker stopped: PID $$\n" && \
pankso@233 608 rm -f $pidfile $command && exit 1' INT TERM
pankso@383 609
pankso@82 610 echo "Cooker PID : $$" | log_commits
al@728 611 echo "Cooker date : $(date '+%F %T')" | log_commits
pankso@383 612
paul@132 613 # Get revisions. Here we have 2 echoes since we want a msg on screen,
paul@132 614 # in commits log and activity DB without a space before.
pankso@60 615 cd $wok || exit 1
pankso@4 616 cur=$(hg head --template '{rev}\n')
pankso@82 617 echo "Updating wok : ${wok}-hg (rev $cur)" | log_commits
pankso@82 618 echo "Updating wok: ${wok}-hg" | log
al@728 619 echo 'hg:pull' > $command
al@728 620 cd $wok-hg; hg pull -u | log_commits
pankso@4 621 new=$(hg head --template '{rev}\n')
paul@168 622 # Store last rev to be used by CGI so it doesn't need to call hg head
pankso@164 623 # on each load.
slaxemulator@488 624 echo "$new" > $wokrev
pankso@383 625
paul@54 626 # Sync build wok with rsync so we don't take care about removing old
pankso@4 627 # files as before.
pankso@4 628 if [ "$new" -gt "$cur" ]; then
pankso@4 629 echo "Changes found from: $cur to $new" | log
al@728 630 echo 'Syncing build wok with Hg wok...' | log_commits
al@728 631 rsync -r -t -c -l -u -v -D -E $wok-hg/ $wok/ | \
al@931 632 sed '/^$/d' | log_commits
pankso@4 633 else
pankso@13 634 echo "No revision changes: $cur vs $new" | log
pankso@14 635 separator | log_commits
al@728 636 clean_exit; newline
al@728 637 exit 0
pankso@4 638 fi
pankso@383 639
pankso@35 640 # Get and display modifications.
al@728 641 cd $wok-hg
pankso@110 642 commits_summary | log_commits
pankso@14 643 cur=$(($cur + 1))
al@728 644 rm -f $commits.tmp; touch $commits.tmp
al@728 645 for rev in $(seq $cur $new); do
al@728 646 for file in $(hg log --rev=$rev --template "{files}"); do
al@728 647 pkg=$(echo $file | cut -d/ -f1)
pankso@36 648 desc=$(hg log --rev=$rev --template "{desc}" $file)
paul@388 649 echo "Committed package : $pkg - $desc" | log_commits
pankso@80 650 echo $pkg >> $commits.tmp
pankso@4 651 done
pankso@4 652 done
pankso@248 653
pankso@248 654 # We may have deleted packages and files in stuff/. Remove it and
pankso@248 655 # clean DB as well as log file.
pankso@248 656 cd $wok
al@728 657 for pkg in *; do
al@921 658 if [ ! -d "$wok-hg/$pkg" ]; then
pankso@248 659 echo "Removing package: $pkg" | log_commits
pascal@799 660 if [ -s $wok/$pkg/receipt ]; then
pascal@799 661 . $wok/$pkg/receipt
pascal@799 662 rm -f $PKGS/$PACKAGE-$VERSION*
pascal@799 663 fi
pascal@799 664 rm -rf $wok/$pkg $LOGS/$pkg.log
al@931 665 sed -i "/^${pkg}$/d" $blocked $broken $commits.tmp
al@949 666 sed -i "/^$pkg\t/d" $PKGS/packages.info
al@989 667 sed -i "/^$pkg:/d" $cache/files.list
pankso@248 668 fi
al@921 669 if [ -d "$wok/$pkg/stuff" ]; then
al@921 670 if [ ! -d "$wok-hg/$pkg/stuff" ]; then
al@921 671 echo "Removing stuff: $pkg/stuff" | log_commits
al@922 672 rm -rf $wok/$pkg/stuff
al@921 673 else
al@922 674 for stuff_file in $(cd $wok/$pkg/stuff; find \( -type f -o -type l \) | sed 's|^\./||'); do
al@921 675 if [ ! -f "$wok-hg/$pkg/stuff/$stuff_file" -a \
al@921 676 ! -h "$wok-hg/$pkg/stuff/$stuff_file" ]; then
al@921 677 echo "Removing file from stuff: $wok/$pkg/stuff/$stuff_file" | log_commits
al@922 678 rm -f $wok/$pkg/stuff/$stuff_file
al@922 679 rmdir --parents --ignore-fail-on-non-empty $(dirname "$wok/$pkg/stuff/$stuff_file")
al@921 680 fi
al@921 681 done
al@921 682 fi
al@921 683 fi
pankso@248 684 done
pankso@383 685
paul@54 686 # Keep previous commit and discard duplicate lines
al@931 687 cat $commits $commits.tmp | sed '/^$/d' > $commits.new
al@728 688 uniq $commits.new > $commits; rm $commits.*
pankso@383 689
paul@388 690 # Handle cross compilation. Create arch packages DB and remove pkgs
pankso@383 691 # not cooked for this arch from the commits list.
pankso@677 692 arch_db
al@931 693 while read pkg; do
pankso@677 694 if [ ! -f "$wok/$pkg/arch.$ARCH" ]; then
pankso@677 695 echo "Cooker arch : skip $pkg (not included in: $ARCH)" | \
pankso@677 696 log_commits
al@931 697 sed -i "/^${pkg}$/d" $commits
pankso@677 698 else
pankso@677 699 echo "Cooker arch : $ARCH" | log_commits
pankso@677 700 fi
al@931 701 done < $commits
al@728 702
al@988 703 # Re-create split database
al@988 704 cook splitdb
al@988 705
pankso@383 706 # Stats
al@931 707 pkgs=$(wc -l < $commits)
pankso@100 708 echo "Packages to cook: $pkgs" | log
pankso@109 709 echo "Packages to cook : $pkgs" | log_commits
pankso@35 710 separator | log_commits
slaxemulator@486 711 newline
pankso@14 712 strip_blocked
pankso@14 713 cook_order | tee $LOGS/cookorder.log
pankso@81 714 cook_commits
pankso@81 715 clean_exit ;;
pankso@4 716 esac
pankso@4 717
pankso@4 718 exit 0