cookutils rev 16
Cant use tazpkg to pack since it dont handle EXTRAVERSION and improving CGI
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Thu May 05 17:05:19 2011 +0200 (2011-05-05) |
parents | b6bbe55cd15e |
children | c3c30b1506b8 |
files | Makefile cat.list cook cooker web/cooker.cgi |
line diff
1.1 --- a/Makefile Thu May 05 05:04:15 2011 +0200 1.2 +++ b/Makefile Thu May 05 17:05:19 2011 +0200 1.3 @@ -17,8 +17,8 @@ 1.4 cp -r data/* $(DESTDIR)$(PREFIX)/share/cook 1.5 1.6 uninstall: 1.7 - rm -f \ 1.8 + rm -rf \ 1.9 $(DESTDIR)$(PREFIX)/bin/cook \ 1.10 $(DESTDIR)$(PREFIX)/bin/cooker \ 1.11 - $(DESTDIR)/etc/slitaz/cook*.* \ 1.12 + $(DESTDIR)/etc/slitaz/cook.* \ 1.13 $(DESTDIR)/var/www/cooker
2.1 --- a/cat.list Thu May 05 05:04:15 2011 +0200 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,20 +0,0 @@ 2.4 - 2.5 -[1mPackages categories[0m 2.6 -================================================================================ 2.7 -base-system 2.8 -x-window 2.9 -utilities 2.10 -network 2.11 -graphics 2.12 -multimedia 2.13 -office 2.14 -development 2.15 -system-tools 2.16 -security 2.17 -games 2.18 -misc 2.19 -meta 2.20 -non-free 2.21 -================================================================================ 2.22 -14 categories 2.23 -
3.1 --- a/cook Thu May 05 05:04:15 2011 +0200 3.2 +++ b/cook Thu May 05 17:05:19 2011 +0200 3.3 @@ -10,8 +10,9 @@ 3.4 [ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf 3.5 [ -f "cook.conf" ] && . ./cook.conf 3.6 3.7 -# Share activity and broken packages with the Cooker. 3.8 +# Share DB and status with the Cooker. 3.9 activity="$CACHE/activity" 3.10 +command="$CACHE/command" 3.11 broken="$CACHE/broken" 3.12 3.13 # 3.14 @@ -195,7 +196,7 @@ 3.15 cd $WOK/$pkg 3.16 [ -d install ] && prod=$(du -sh install | awk '{print $1}' 2>/dev/null) 3.17 fs=$(du -sh taz/* | awk '{print $1}') 3.18 - size=$(du -sh $PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.* | awk '{print $1}') 3.19 + size=$(du -sh $PKGS/$PACKAGE-${VERSION}*.tazpkg | awk '{print $1}') 3.20 files=$(cat taz/$PACKAGE-*/files.list | wc -l) 3.21 gettext "Summary for:"; echo " $PACKAGE $VERSION" 3.22 separator 3.23 @@ -297,7 +298,7 @@ 3.24 echo -n " $dep" 3.25 yes | tazpkg remove $dep >/dev/null 3.26 done 3.27 - echo "" 3.28 + echo -e "\n" 3.29 mv -f $CACHE/installed.diff $CACHE/installed.last.diff 3.30 fi 3.31 } 3.32 @@ -377,14 +378,6 @@ 3.33 # QA: No compile_rules so no error, valid. 3.34 mkdir -p $install 3.35 fi 3.36 - if grep -q ^genpkg_rules $pkgdir/receipt; then 3.37 - gettext -e "Executing: genpkg_rules\n" 3.38 - cd $pkgdir 3.39 - mkdir -p $fs && genpkg_rules || ( echo -e \ 3.40 - "\nERROR: genpkg_rules failed\n" | \ 3.41 - tee -a $LOGS/$pkg.log && exit 1 ) 3.42 - gettext -e "Now will pack the package.\n" 3.43 - fi 3.44 separator && echo "" 3.45 } 3.46 3.47 @@ -404,11 +397,18 @@ 3.48 fi 3.49 } 3.50 3.51 -# Create the package. 3.52 +# Create the package. Wanted to use Tazpkg to create a tazpkg package at first, 3.53 +# but it dont handle EXTRAVERSION. 3.54 packit() { 3.55 set_paths 3.56 - echo "Packing: $PACKAGE ${VERSION}${EXTRAVERSION}" 3.57 + echo "Packing: $PACKAGE $VERSION" 3.58 separator 3.59 + if grep -q ^genpkg_rules $pkgdir/receipt; then 3.60 + gettext -e "Executing: genpkg_rules\n" 3.61 + cd $pkgdir 3.62 + mkdir -p $fs && genpkg_rules || ( echo -e \ 3.63 + "\nERROR: genpkg_rules failed\n" | tee -a $LOGS/$pkg.log && exit 1 ) 3.64 + fi 3.65 cd $pkgdir/taz 3.66 strip_package 3.67 for file in receipt description.txt 3.68 @@ -418,9 +418,61 @@ 3.69 cp -f ../$file $pack && chown 0.0 $pack/$file && status 3.70 done 3.71 copy_generic_files 3.72 - # Use Tazpkg to create a tazpkg package... 3.73 - tazpkg pack $PACKAGE-${VERSION}${EXTRAVERSION} | grep "\[*\]" 3.74 - separator && echo "" 3.75 + 3.76 + # Create files.list with redirecting find outpout. 3.77 + gettext "Creating the list of files..." && cd $fs 3.78 + find . -type f -print > ../files.list 3.79 + find . -type l -print >> ../files.list 3.80 + cd .. && sed -i s/'^.'/''/ files.list 3.81 + status 3.82 + gettext "Creating md5sum of files..." 3.83 + while read file; do 3.84 + [ -L "fs$file" ] && continue 3.85 + [ -f "fs$file" ] || continue 3.86 + case "$file" in 3.87 + /lib/modules/*/modules.*|*.pyc) continue;; 3.88 + esac 3.89 + md5sum "fs$file" | sed 's/ fs/ /' 3.90 + done < files.list > md5sum 3.91 + status 3.92 + UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \ 3.93 + description.txt 2> /dev/null | awk \ 3.94 + '{ sz=$1 } END { print sz }') 3.95 + 3.96 + # Build cpio archives. 3.97 + gettext "Compressing the fs... " 3.98 + find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si 3.99 + rm -rf fs 3.100 + status 3.101 + PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \ 3.102 + md5sum description.txt 2> /dev/null | awk \ 3.103 + '{ sz=$1 } END { print sz }') 3.104 + gettext "Updating receipt sizes..." 3.105 + sed -i s/^PACKED_SIZE.*$// receipt 3.106 + sed -i s/^UNPACKED_SIZE.*$// receipt 3.107 + sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt 3.108 + status 3.109 + 3.110 + # Set extra version. 3.111 + if [ "$EXTRAVERSION" ]; then 3.112 + gettext "Updating receipt EXTRAVERSION: "; echo -n "$EXTRAVERSION" 3.113 + sed -i s/^EXTRAVERSION.*$// receipt 3.114 + sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt 3.115 + status 3.116 + fi 3.117 + 3.118 + # Compress. 3.119 + gettext "Creating full cpio archive... " 3.120 + find . -print | cpio -o -H newc --quiet > \ 3.121 + ../$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg 3.122 + status 3.123 + gettext "Restoring original package tree... " 3.124 + unlzma -c fs.cpio.lzma | cpio -idm --quiet 3.125 + status 3.126 + rm fs.cpio.lzma && cd .. 3.127 + separator && gettext "Package: " 3.128 + du -sh $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg 3.129 + echo "" 3.130 } 3.131 3.132 # Verify package quality and consitensy. 3.133 @@ -578,6 +630,7 @@ 3.134 pkg="$1" 3.135 [ -z "$pkg" ] && usage 3.136 check_pkg_in_wok && echo "" 3.137 + echo "cook:$pkg" > $command 3.138 unset inst 3.139 unset_receipt 3.140 cd $WOK/$pkg && . ./receipt 3.141 @@ -601,10 +654,11 @@ 3.142 cookit | tee $LOGS/$pkg.log 3.143 remove_deps | tee -a $LOGS/$pkg.log 3.144 cookit_quality 3.145 + 3.146 packit | tee -a $LOGS/$pkg.log 3.147 clean_log 3.148 packit_quality 3.149 - 3.150 + 3.151 # Time and summary 3.152 time=$(($(date +%s) - $time)) 3.153 summary | tee -a $LOGS/$pkg.log
4.1 --- a/cooker Thu May 05 05:04:15 2011 +0200 4.2 +++ b/cooker Thu May 05 17:05:19 2011 +0200 4.3 @@ -68,7 +68,7 @@ 4.4 } 4.5 4.6 # Clean up after cook sucess. 4.7 -clean_status() { 4.8 +emty_command() { 4.9 rm -f $command && touch $command 4.10 } 4.11 4.12 @@ -174,7 +174,7 @@ 4.13 if [ -s "$commits" ]; then 4.14 for pkg in $(cat $commits) 4.15 do 4.16 - echo "Cook started for: <a href='cooker.cgi?log=$pkg'>$pkg</a>" | log 4.17 + echo "Cook started for: <a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log 4.18 echo "cook:$pkg" > $command 4.19 cook $pkg || broken 4.20 sed -i /^${pkg}$/d $commits 4.21 @@ -187,7 +187,8 @@ 4.22 for pkg in $(cat $cooklist) 4.23 do 4.24 if [ ! -d "$wok/$pkg/install" ]; then 4.25 - echo "Cook started for: <a href='cooker.cgi?log=$pkg'>$pkg</a>" | log 4.26 + echo "Cook started for: <a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log 4.27 + 4.28 cook $pkg || broken 4.29 sed -i /^${pkg}$/d $cooklist 4.30 fi 4.31 @@ -243,13 +244,12 @@ 4.32 --pkg=*) 4.33 # Same as 'cook pkg' but with log for web interface. 4.34 pkg=${1#--pkg=} 4.35 - echo "cooker:$1" > $command 4.36 - echo "Cook started for: <a href='cooker.cgi?log=$pkg'>$pkg</a>" | log 4.37 - cook $pkg || broken ;; 4.38 + echo "Cook started for: <a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log 4.39 + cook $pkg || broken 4.40 + emty_command ;; 4.41 --cat=*) 4.42 # Cook all packages of a category. 4.43 cat=${1#--cat=} 4.44 - echo "cooker:$1" > $command 4.45 rm -f $cooklist && touch $cooklist && cd $wok 4.46 for pkg in * 4.47 do 4.48 @@ -259,7 +259,7 @@ 4.49 strip_blocked 4.50 cook_order | tee $LOGS/cookorder.log 4.51 cook_list 4.52 - clean_status ;; 4.53 + emty_command ;; 4.54 --all) 4.55 # Try to build all unbuilt packages except blocked's. 4.56 echo "cooker:--all" > $command 4.57 @@ -281,7 +281,7 @@ 4.58 echo "Packages to cook: $(cat $cooklist | wc -l)" | log 4.59 cook_order | tee $LOGS/cookorder.log 4.60 cook_list 4.61 - clean_status ;; 4.62 + emty_command ;; 4.63 *) 4.64 # Default is to cook all commits. 4.65 [ "$1" ] && usage 4.66 @@ -312,7 +312,7 @@ 4.67 else 4.68 echo "No revision changes: $cur vs $new" | log 4.69 separator | log_commits 4.70 - clean_status && echo "" && exit 0 4.71 + emty_command && echo "" && exit 0 4.72 fi 4.73 4.74 # Get modifications 4.75 @@ -323,7 +323,7 @@ 4.76 echo -e "Will cook $msg\n" 4.77 rm -f $commits.tmp && touch $commits.tmp 4.78 for rev in $(seq $cur $new); do 4.79 - log=$(hg log --rev=$rev --template "{files}\n" | cut -d "/" -f 1) 4.80 + pkg=$(hg log --rev=$rev --template "{files}\n" | cut -d "/" -f 1) 4.81 for file in $log; do 4.82 echo "Commited file: $file" log_commits 4.83 echo $file >> $commits.tmp 4.84 @@ -338,7 +338,7 @@ 4.85 strip_blocked 4.86 cook_order | tee $LOGS/cookorder.log 4.87 cook_commits 4.88 - clean_status ;; 4.89 + emty_command ;; 4.90 esac 4.91 4.92 exit 0
5.1 --- a/web/cooker.cgi Thu May 05 05:04:15 2011 +0200 5.2 +++ b/web/cooker.cgi Thu May 05 17:05:19 2011 +0200 5.3 @@ -33,7 +33,10 @@ 5.4 -e 's#ERROR:#<span class="span-error">ERROR:</span>#g' \ 5.5 -e s"#^Executing:\([^']*\).#<span class='span-sky'>\0</span>#"g \ 5.6 -e s"#^====\([^']*\).#<span class='span-line'>\0</span>#"g \ 5.7 - -e s"#http://\([^']*\).*#<a href='\0'>\1</a>#"g 5.8 + -e s"#ftp://\([^']*\).*#<a href='\0'>\0</a>#"g \ 5.9 + -e s"#http://\([^']*\).*#<a href='\0'>\0</a>#"g \ 5.10 + -e s"#^\#\([^']*\)#<span class='sh-comment'>\0</span>#"g 5.11 + #-e s"#\"\([^']*\)\"#<span class='sh-val'>\0</span>#"g 5.12 } 5.13 5.14 # Latest build pkgs. 5.15 @@ -71,39 +74,81 @@ 5.16 # 5.17 5.18 case "${QUERY_STRING}" in 5.19 - log=*) 5.20 - pkg=${QUERY_STRING#log=} 5.21 - if [ -f "$LOGS/$pkg.log" ]; then 5.22 - echo "<h2>Log for: $pkg</h2>" 5.23 + pkg=*) 5.24 + pkg=${QUERY_STRING#pkg=} 5.25 + log=$LOGS/$pkg.log 5.26 + echo "<h2>Package: $pkg</h2>" 5.27 + 5.28 + # Package info 5.29 + if [ -f "$wok/$pkg/receipt" ]; then 5.30 + . $wok/$pkg/receipt 5.31 + tazpkg=$PKGS/$pkg-${VERSION}.tazpkg 5.32 + if [ -f "$tazpkg" ]; then 5.33 + 5.34 + cooked=$(stat -c '%y' $tazpkg | cut -d . -f 1 | sed s/:[0-9]*$//) 5.35 + echo $cooked 5.36 + fi 5.37 + echo "<a href='cooker.cgi?receipt=$pkg'>receipt</a>" 5.38 + else 5.39 + echo "<p>No package named: $pkg<p>" 5.40 + fi 5.41 + 5.42 + # Check for a log file and display summary if exist. 5.43 + if [ -f "$log" ]; then 5.44 if fgrep -q "Summary " $LOGS/$pkg.log; then 5.45 - echo '<pre>' 5.46 - grep -A 8 "^Summary " $LOGS/$pkg.log | sed /^$/d | \ 5.47 - syntax_highlighter 5.48 - echo '</pre>' 5.49 - echo '<pre>' 5.50 - cat $LOGS/$pkg.log | syntax_highlighter 5.51 - echo '</pre>' 5.52 - else 5.53 if fgrep -q "cook:$pkg$" $command; then 5.54 echo "<pre>The Cooker is currently cooking: $pkg</pre>" 5.55 + else 5.56 + echo "<h3>Cook summary</h3>" 5.57 + echo '<pre>' 5.58 + grep -A 8 "^Summary " $LOGS/$pkg.log | sed /^$/d | \ 5.59 + syntax_highlighter 5.60 + echo '</pre>' 5.61 fi 5.62 - echo '<pre>' && cat $LOGS/$pkg.log | syntax_highlighter 5.63 - echo '</pre>' 5.64 fi 5.65 + if fgrep -q "ERROR:" $LOGS/$pkg.log; then 5.66 + fgrep "ERROR:" $LOGS/$pkg.log 5.67 + fi 5.68 + echo "<h3>Cook log</h3>" 5.69 + echo '<pre>' 5.70 + cat $log | syntax_highlighter 5.71 + echo '</pre>' 5.72 else 5.73 - echo "<pre>No log file found for: $pkg</pre>" 5.74 + echo "<pre>No log: $pkg</pre>" 5.75 + fi ;; 5.76 + log=*) 5.77 + log=${QUERY_STRING#log=} 5.78 + file=$LOGS/$log.log 5.79 + echo "<h2>Log for: $log</h2>" 5.80 + if [ -f "$LOGS/$log.log" ]; then 5.81 + echo '<pre>' 5.82 + cat $file | syntax_highlighter 5.83 + echo '</pre>' 5.84 + else 5.85 + echo "<pre>No log for: $log</pre>" 5.86 + fi ;; 5.87 + receipt=*) 5.88 + pkg=${QUERY_STRING#receipt=} 5.89 + echo "<h2>Receipt: $pkg</h2>" 5.90 + if [ -f "$wok/$pkg/receipt" ]; then 5.91 + echo '<pre>' 5.92 + cat $wok/$pkg/receipt | syntax_highlighter 5.93 + echo '</pre>' 5.94 + else 5.95 + echo "<pre>No receipt for: $log</pre>" 5.96 fi ;; 5.97 *) 5.98 cat << EOT 5.99 <div style="float: right;"> 5.100 <form method="get" action="$SCRIPT_NAME"> 5.101 - Show log: 5.102 - <input type="text" name="log" /> 5.103 + Package: 5.104 + <input type="text" name="pkg" /> 5.105 </form> 5.106 </div> 5.107 5.108 <h2>Summary</h2> 5.109 <pre> 5.110 +Running command : $([ -s "$command" ] && cat $command || echo "Not running") 5.111 Cooked packages : $(ls $PKGS/*.tazpkg | wc -l) 5.112 Packages in wok : $(ls $WOK | wc -l) 5.113 Wok revision : <a href="http://hg.slitaz.org/wok">$(cd $WOK && hg head --template '{rev}\n')</a> 5.114 @@ -118,7 +163,7 @@ 5.115 5.116 <h2>Activity</h2> 5.117 <pre> 5.118 -$(tac $CACHE/activity | sed s"#^\([^']* : \)#<span class='span-date'>\0</span>#"g) 5.119 +$(tac $CACHE/activity | sed s"#^\([^']* : \)#<span class='log-date'>\0</span>#"g) 5.120 </pre> 5.121 5.122 <h2>Commits</h2>