cookutils annotate cooker @ rev 1095

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