cookutils view lib/libcook.sh @ rev 549
libcookorder.sh: Add comments to explain lots of functions. More to come.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Tue Oct 16 15:02:10 2012 +0000 (2012-10-16) |
parents | 0b6c1c223f1c |
children | 5fb0c06f85e7 |
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 live="$SLITAZ/live"
42 crontabs="/var/spool/cron/crontabs/root"
44 wan_db="$INCOMING/wanted.txt"
45 dep_db="$INCOMING/depends.txt"
46 lib_db="$INCOMING/libraries.txt"
47 # full cookorder
48 fullco="$PKGS/fullco.txt"
50 # Lograte activity.
51 [ -s "$activity" ] && tail -n 60 $activity > /tmp/tail-$$ && \
52 mv -f /tmp/tail-$$ $activity
54 # Log activities, we want first letter capitalized.
55 # TODO: use /lib/libtaz.sh log() but need to change all:
56 # echo "Message" | log --> log "Message"
57 log() {
58 grep ^[A-Z] | \
59 sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity
60 }
62 # Remove blocked (faster this way than grepping before).
63 strip_blocked() {
64 local pkg
65 for pkg in $(cat $blocked)
66 do
67 sed -i /^${pkg}$/d $cooklist
68 PACKAGE="$pkg"
69 for i in $(look_for_rwanted); do
70 sed -i /^${i}$/d $cooklist
71 done
72 done && sed -i /^$/d $cooklist
73 }
75 # Initialize files used in $CACHE
76 init_db_files() {
77 gettext "Creating directories structure in:"; echo " $SLITAZ"
78 mkdir -p $INCOMING $PKGS $SRC $FEEDS $CACHE $LOGS
79 gettext "Creating DB files in:"; echo " $CACHE"
80 for f in $activity $command $broken $blocked $commits $cookorder $cooklist $command $wan_db $dep_db $fullco $lib_db $unbuild
81 do
82 touch $f
83 done
84 if [ -f $PKGS/libraries.txt ]; then
85 cp -a $PKGS/libraries.txt $lib_db
86 fi
87 }