cookutils rev 431

move internal vars to libcook.sh and broken function
author Christophe Lincoln <pankso@slitaz.org>
date Sun May 20 01:40:43 2012 +0200 (2012-05-20)
parents 78bc0994b506
children 5492820f7f9f
files cook cooker lib/libcook.sh
line diff
     1.1 --- a/cook	Sun May 20 01:12:34 2012 +0200
     1.2 +++ b/cook	Sun May 20 01:40:43 2012 +0200
     1.3 @@ -8,12 +8,6 @@
     1.4  #
     1.5  . /usr/lib/slitaz/libcook.sh
     1.6  
     1.7 -# Share DB and status with the Cooker.
     1.8 -activity="$CACHE/activity"
     1.9 -command="$CACHE/command"
    1.10 -broken="$CACHE/broken"
    1.11 -blocked="$CACHE/blocked"
    1.12 -
    1.13  #
    1.14  # Functions
    1.15  #
    1.16 @@ -66,13 +60,6 @@
    1.17  		-e s'|\[0;39m \]||' $LOGS/$pkg.log
    1.18  }
    1.19  
    1.20 -# Log broken packages.
    1.21 -broken() {
    1.22 -	if ! grep -q "^$pkg$" $broken; then
    1.23 -		echo "$pkg" >> $broken
    1.24 -	fi
    1.25 -}
    1.26 -
    1.27  # Be sure package exists in wok.
    1.28  check_pkg_in_wok() {
    1.29  	if [ ! -d "$WOK/$pkg" ]; then
    1.30 @@ -134,12 +121,6 @@
    1.31  	done
    1.32  }
    1.33  
    1.34 -# Executed before sourcing a receipt.
    1.35 -unset_receipt() {
    1.36 -	unset DEPENDS BUILD_DEPENDS WANTED EXTRAVERSION WGET_URL PROVIDE TARBALL
    1.37 -	unset HOST_ARCH CROSS_BUGS
    1.38 -}
    1.39 -
    1.40  # Paths used in receipt and by cook itself.
    1.41  set_paths() {
    1.42  	pkgdir=$WOK/$PACKAGE
     2.1 --- a/cooker	Sun May 20 01:12:34 2012 +0200
     2.2 +++ b/cooker	Sun May 20 01:40:43 2012 +0200
     2.3 @@ -6,25 +6,11 @@
     2.4  # here since it's not an end user tool and it's not useful, all devs should
     2.5  # at least understand basic English.
     2.6  #
     2.7 -
     2.8 -[ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf
     2.9 -[ -f "cook.conf" ] && . ./cook.conf
    2.10 +. /usr/lib/slitaz/libcook.sh
    2.11  
    2.12  # Set pkg name and use same wok as cook.
    2.13  pkg="$2"
    2.14  wok="$WOK"
    2.15 -flavors="$SLITAZ/flavors"
    2.16 -
    2.17 -# Cooker DB files.
    2.18 -activity="$CACHE/activity"
    2.19 -commits="$CACHE/commits"
    2.20 -cooklist="$CACHE/cooklist"
    2.21 -cookorder="$CACHE/cookorder"
    2.22 -command="$CACHE/command"
    2.23 -blocked="$CACHE/blocked"
    2.24 -broken="$CACHE/broken"
    2.25 -cooknotes="$CACHE/cooknotes"
    2.26 -crontabs="/var/spool/cron/crontabs/root"
    2.27  
    2.28  # PID file.
    2.29  pidfile='/var/run/cooker.pid'
    2.30 @@ -58,33 +44,12 @@
    2.31  	exit 0
    2.32  }
    2.33  
    2.34 -separator() {
    2.35 -	echo "================================================================================"
    2.36 -}
    2.37 -
    2.38 -# Lograte activity.
    2.39 -[ -s "$activity" ] && tail -n 60 $activity > /tmp/tail && \
    2.40 -	mv -f /tmp/tail $activity
    2.41 -
    2.42 -# Log activities, we want first letter capitalized.
    2.43 -log() {
    2.44 -	grep ^[A-Z] | \
    2.45 -		sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity
    2.46 -}
    2.47 -
    2.48  # Some messages occur in activity but log verbose output when checking for commits
    2.49  # into a log file.
    2.50  log_commits() {
    2.51  	sed '/^.\//'d | sed '/^.hg/'d | tee -a $LOGS/commits.log
    2.52  }
    2.53  
    2.54 -# Log broken packages.
    2.55 -broken() {
    2.56 -	if ! grep -q "^$pkg$" $broken; then
    2.57 -		echo "$pkg" >> $broken
    2.58 -	fi
    2.59 -}
    2.60 -
    2.61  # Clean up before exit when check and cook commits finish.
    2.62  clean_exit() {
    2.63  	rm -f $command && touch $command
     3.1 --- a/lib/libcook.sh	Sun May 20 01:12:34 2012 +0200
     3.2 +++ b/lib/libcook.sh	Sun May 20 01:40:43 2012 +0200
     3.3 @@ -13,3 +13,35 @@
     3.4  # System wide config can be overwriten by a cook.conf in current path.
     3.5  [ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf
     3.6  [ -f "cook.conf" ] && . ./cook.conf
     3.7 +
     3.8 +# Shared DB between Cook, the Cooker and Cookiso.
     3.9 +# In cookiso: repo= --> flavors
    3.10 +flavors="$SLITAZ/flavors"
    3.11 +activity="$CACHE/activity"
    3.12 +commits="$CACHE/commits"
    3.13 +cooklist="$CACHE/cooklist"
    3.14 +cookorder="$CACHE/cookorder"
    3.15 +command="$CACHE/command"
    3.16 +blocked="$CACHE/blocked"
    3.17 +broken="$CACHE/broken"
    3.18 +cooknotes="$CACHE/cooknotes"
    3.19 +crontabs="/var/spool/cron/crontabs/root"
    3.20 +
    3.21 +# Lograte activity.
    3.22 +[ -s "$activity" ] && tail -n 60 $activity > /tmp/tail-$$ && \
    3.23 +	mv -f /tmp/tail-$$ $activity
    3.24 +
    3.25 +# Log activities, we want first letter capitalized.
    3.26 +# TODO: use /lib/libtaz.sh log() but need to change all:
    3.27 +# echo "Message" | log --> log "Message"
    3.28 +log() {
    3.29 +	grep ^[A-Z] | \
    3.30 +		sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity
    3.31 +}
    3.32 +
    3.33 +# Log broken packages.
    3.34 +broken() {
    3.35 +	if ! grep -q "^$pkg$" $broken; then
    3.36 +		echo "$pkg" >> $broken
    3.37 +	fi
    3.38 +}