cookutils view lib/libcook.sh @ rev 502

Merge default.
author Christopher Rogers <slaxemulator@gmail.com>
date Wed Jun 20 23:17:27 2012 +0000 (2012-06-20)
parents deff72d6ad0d 3ff0467577c7
children 090c28f00d6d
line source
1 #!/bin/sh
2 #
3 # Cook library - Shared configs and functions between cook, the cooker and
4 # cookiso. Read the README before adding or modifing any code in libcook.sh!
5 #
6 # Copyright (C) SliTaz GNU/Linux - GNU gpl v3
7 # Author: Christophe Lincoln <pankso@slitaz.org>
8 #
9 . /lib/libtaz.sh
10 . /usr/lib/slitaz/libpkg.sh
11 . /etc/slitaz/slitaz.conf
13 # System wide config can be overwriten by a cook.conf in current path.
14 [ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf
15 [ -f "cook.conf" ] && . ./cook.conf
17 # Shared DB between Cook, the Cooker and Cookiso.
18 # In cookiso: repo= --> flavors
19 if [ "$(basename $0)" = "cookiso" ]; then
20 cache="$CACHE/cookiso"
21 #cookiso variables
22 repo="$SLITAZ/flavors"
23 iso="$SLITAZ/iso"
24 rollog="$cache/rolling.log"
25 synclog="$cache/rsync.log"
26 else
27 cache="$CACHE"
28 fi
30 flavors="$SLITAZ/flavors"
31 activity="$cache/activity"
32 commits="$cache/commits"
33 cooklist="$cache/cooklist"
34 cookorder="$cache/cookorder"
35 command="$cache/command"
36 blocked="$cache/blocked"
37 broken="$cache/broken"
38 unbuild="$cache/unbuild"
39 wokrev="$cache/wokrev"
40 cooknotes="$cache/cooknotes"
41 crontabs="/var/spool/cron/crontabs/root"
43 wan_db="$INCOMING/wanted.txt"
44 dep_db="$INCOMING/depends.txt"
45 lib_db="$INCOMING/libraries.txt"
46 # full cookorder
47 fullco="$PKGS/fullco.txt"
49 # Lograte activity.
50 [ -s "$activity" ] && tail -n 60 $activity > /tmp/tail-$$ && \
51 mv -f /tmp/tail-$$ $activity
53 # Log activities, we want first letter capitalized.
54 # TODO: use /lib/libtaz.sh log() but need to change all:
55 # echo "Message" | log --> log "Message"
56 log() {
57 grep ^[A-Z] | \
58 sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity
59 }
61 # Log broken packages.
62 broken() {
63 if ! grep -q "^$pkg$" $broken; then
64 echo "$pkg" >> $broken
65 fi
66 }
68 # Remove blocked (faster this way than grepping before).
69 strip_blocked() {
70 local pkg
71 for pkg in $(cat $blocked)
72 do
73 sed -i /^${pkg}$/d $cooklist
74 PACKAGE="$pkg"
75 for i in $(look_for_rwanted); do
76 sed -i /^${i}$/d $cooklist
77 done
78 done && sed -i /^$/d $cooklist
79 }