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