cookutils annotate cookiso @ rev 446
cook: use pkgconfig file in sysroot
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue May 29 14:23:13 2012 +0000 (2012-05-29) |
parents | 3eaab50d2441 |
children | b7fc4308e7b4 |
rev | line source |
---|---|
pankso@318 | 1 #!/bin/sh |
pankso@318 | 2 # |
paul@325 | 3 # Cookiso utility - Build official ISOs in a chroot environment. |
paul@325 | 4 # The goal is to have a tool well integrated with cookutils but which |
paul@325 | 5 # can run on its own and automate official SliTaz ISO creation. |
pankso@318 | 6 # |
pankso@318 | 7 |
pankso@318 | 8 [ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf |
pankso@318 | 9 [ -f "cook.conf" ] && . ./cook.conf |
pankso@318 | 10 |
pankso@318 | 11 # --> cook.conf |
pankso@318 | 12 # SSH/RSA configuration to upload on a server. |
pankso@318 | 13 SSH_CMD="dbclient -i /root/.ssh/id_rsa.dropbear" |
pankso@318 | 14 SSH_ISO="/var/www/slitaz/mirror/iso" |
pankso@318 | 15 SSH_HOST="slitaz@mirror.slitaz.org" |
pankso@318 | 16 #BWLIMIT="--bwlimit=40" |
pankso@318 | 17 |
pankso@318 | 18 # Cookiso DB files. |
pankso@318 | 19 cache="$CACHE/cookiso" |
pankso@318 | 20 repo="$SLITAZ/flavors" |
pankso@318 | 21 iso="$SLITAZ/iso" |
pankso@318 | 22 activity="$cache/activity" |
pankso@318 | 23 command="$cache/command" |
pankso@318 | 24 rollog="$cache/rolling.log" |
pankso@326 | 25 synclog="$cache/rsync.log" |
pankso@318 | 26 commits="$cache/commits" |
pankso@318 | 27 |
pankso@318 | 28 # Parse cmdline options. |
pankso@318 | 29 for opt in "$@" |
pankso@318 | 30 do |
pankso@318 | 31 case "$opt" in |
pankso@318 | 32 --pkgdb) |
pankso@318 | 33 cook pkgdb --flavors ;; |
pankso@318 | 34 --push) |
pankso@335 | 35 push="yes" ;; |
pankso@318 | 36 --flavors=*) |
pankso@318 | 37 flavors=${opt#--flavors=} ;; |
pankso@318 | 38 --version=*) |
pankso@318 | 39 version=${opt#--version=} ;; |
pankso@318 | 40 esac |
pankso@318 | 41 done |
pankso@318 | 42 |
pankso@318 | 43 # Default to rolling, or: cookiso [cmd] --version=stable |
pankso@318 | 44 case "$version" in |
pankso@318 | 45 stable) |
pankso@318 | 46 string=$(cat /etc/slitaz-release) ;; |
pankso@318 | 47 cooking) |
pankso@318 | 48 string=cooking ;; |
pankso@318 | 49 *) |
pankso@318 | 50 version=cooking |
pankso@318 | 51 string=rolling ;; |
pankso@318 | 52 esac |
pankso@318 | 53 |
pankso@318 | 54 # Running command |
pankso@318 | 55 [ -d "$cache" ] && echo "$@" > $command |
pankso@318 | 56 trap 'rm -f $command && exit 1' INT TERM |
pankso@318 | 57 |
pankso@318 | 58 # |
pankso@318 | 59 # Functions |
pankso@318 | 60 # |
pankso@318 | 61 |
pankso@318 | 62 usage() { |
pankso@318 | 63 cat << EOT |
pankso@318 | 64 |
pankso@318 | 65 $(echo -e "\033[1mUsage:\033[0m") cookiso [command] [--option] |
pankso@318 | 66 |
pankso@318 | 67 $(echo -e "\033[1mCommands:\033[0m") |
pankso@318 | 68 usage Display this short usage. |
pankso@318 | 69 setup Setup Cookiso build environment. |
pankso@318 | 70 push Manually push ISO to a server via SSH. |
pankso@318 | 71 gen Generate specified flavors. |
pankso@318 | 72 4in1 Generate all 4in1 flavors. |
paul@325 | 73 rolling Build the rolling ISOs if any changes. |
pankso@318 | 74 |
pankso@318 | 75 $(echo -e "\033[1mOptions:\033[0m") |
pankso@318 | 76 --pkgdb Generate packages DB before building ISO. |
pankso@318 | 77 --push Upload freshly generated ISO to a server. |
pankso@318 | 78 --flavors= List of flavors to generate with 'gen' command. |
pankso@318 | 79 --version= Specify SliTaz version: [rolling|cooking|stable] |
pankso@318 | 80 |
pankso@318 | 81 EOT |
pankso@318 | 82 } |
pankso@318 | 83 |
pankso@318 | 84 spider() { |
pankso@318 | 85 echo ' // \\' |
pankso@318 | 86 echo ' _\\()//_' |
pankso@318 | 87 echo '/ // \\ \\' |
pankso@318 | 88 echo ' | \__/ |' |
pankso@318 | 89 } |
pankso@318 | 90 |
paul@325 | 91 # Check for some flavors on cmdline |
pankso@318 | 92 flavors_list() { |
pankso@318 | 93 if [ "$flavors" == "all" ]; then |
pankso@318 | 94 flavors=$(ls $SLITAZ/flavors) |
pankso@318 | 95 fi |
pankso@318 | 96 if [ ! "$flavors" ]; then |
pankso@318 | 97 echo "No flavor specified on cmdline. Use: --flavors=" |
pankso@318 | 98 rm -f $command && exit 0 |
pankso@318 | 99 fi |
pankso@318 | 100 } |
pankso@318 | 101 |
pankso@318 | 102 # Log activities, we want first letter capitalized. |
pankso@318 | 103 log() { |
pankso@318 | 104 grep ^[A-Z] | \ |
pankso@318 | 105 sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity |
pankso@318 | 106 } |
pankso@318 | 107 |
pankso@318 | 108 log_bot() { |
pankso@318 | 109 sed '/^.\//'d | sed '/^.hg/'d | tee -a $rollog |
pankso@318 | 110 } |
pankso@318 | 111 |
pankso@318 | 112 # Generate requested flavors. |
pankso@318 | 113 gen_flavors() { |
pankso@318 | 114 cd $SLITAZ/flavors && hg pull -u |
pankso@318 | 115 mkdir -p $cache && cd $cache |
pankso@318 | 116 rm -rf *.flavor *.list *.conf |
pankso@318 | 117 for flavor in $flavors |
pankso@318 | 118 do |
pankso@318 | 119 if [ "$flavor" != "core-4in1" ]; then |
pankso@318 | 120 name="slitaz-$string-$flavor" |
pankso@318 | 121 else |
pankso@318 | 122 name="slitaz-$string" |
pankso@318 | 123 fi |
pankso@318 | 124 log=$iso/$name.log |
pankso@318 | 125 rm -f $log && touch $log |
pankso@318 | 126 echo "Building $string <a href='?distro=$string-$flavor'>$flavor</a>" | log |
pankso@318 | 127 echo "Cookiso started: $(date '+%Y-%m-%d %H:%M')" | tee -a $log |
pankso@318 | 128 tazlito pack-flavor $flavor | tee -a $log |
pankso@318 | 129 tazlito get-flavor $flavor | tee -a $log |
paul@325 | 130 # BUG: script sometimes screws up conspy on Tank |
pankso@329 | 131 #script -c "yes '' | tazlito gen-distro" -a $log |
pankso@330 | 132 yes '' | tazlito gen-distro 2>&1 | tee -a $log |
pankso@318 | 133 # Rename ISO and md5 |
pankso@348 | 134 echo "Moving ISO to: $iso/$name.iso" | tee -a $log |
pankso@318 | 135 mv -f $SLITAZ/distro/slitaz-$flavor.iso $iso/$name.iso |
pankso@318 | 136 cd $iso && md5sum $name.iso > $name.md5 |
pankso@318 | 137 echo "Cookiso ended: $(date '+%Y-%m-%d %H:%M')" | tee -a $log |
pankso@318 | 138 done && echo "" |
pankso@335 | 139 # Push ISO to mirror if requested. |
pankso@335 | 140 [ "$push" ] && push_iso |
pankso@318 | 141 } |
pankso@318 | 142 |
pankso@318 | 143 # Push an ISO to a server. |
pankso@318 | 144 push_iso() { |
pankso@322 | 145 echo "Pushing to host: ${SSH_HOST}" |
pankso@318 | 146 export DROPBEAR_PASSWORD=none |
pankso@318 | 147 for flavor in $flavors |
pankso@318 | 148 do |
pankso@339 | 149 distro=slitaz-${string}-$flavor |
pankso@339 | 150 file=${distro%-core-4in1} |
pankso@335 | 151 rsync $BWLIMIT -vtP -e "$SSH_CMD" $iso/$file.* \ |
pankso@329 | 152 ${SSH_HOST}:$SSH_ISO/$string 2>&1 | tee $synclog |
pankso@318 | 153 done |
pankso@318 | 154 } |
pankso@318 | 155 |
pankso@318 | 156 # |
pankso@318 | 157 # Commands |
pankso@318 | 158 # |
pankso@318 | 159 |
pankso@318 | 160 case "$1" in |
pankso@318 | 161 setup) |
pankso@318 | 162 # Setup Hg repo and dirs |
pankso@318 | 163 echo -e "\nSetting up Cookiso environment..." |
pankso@318 | 164 cd $SLITAZ |
pankso@318 | 165 if [ ! -d "flavors" ]; then |
pankso@318 | 166 case $version in |
pankso@318 | 167 cooking|rolling) |
pankso@318 | 168 hg clone http://hg.slitaz.org/flavors ;; |
pankso@318 | 169 stable) |
pankso@318 | 170 hg clone http://hg.slitaz.org/flavors-stable flavors ;; |
pankso@318 | 171 esac |
pankso@318 | 172 fi |
pankso@318 | 173 # Needed packages |
pankso@318 | 174 for pkg in mercurial tazlito rsync dropbear |
pankso@318 | 175 do |
pankso@318 | 176 [ -d "/var/lib/tazpkg/installed/$pkg" ] || tazpkg -gi $pkg |
pankso@318 | 177 done |
pankso@318 | 178 echo "Creating directories and files..." |
pankso@318 | 179 mkdir -p $cache $iso |
pankso@318 | 180 touch $activity |
pankso@318 | 181 sed -i s'/^WORK_DIR=.*/WORK_DIR="\/home\/slitaz"/' \ |
pankso@318 | 182 /etc/tazlito/tazlito.conf |
pankso@318 | 183 echo "" |
pankso@318 | 184 echo "Flavors files : $SLITAZ/flavors" |
pankso@318 | 185 echo "Cache files : $cache" |
pankso@318 | 186 echo "ISO images : $iso" |
pankso@318 | 187 echo "" ;; |
pankso@318 | 188 push) |
pankso@318 | 189 # Manually upload an ISO to a server. |
pankso@322 | 190 flavors_list |
pankso@318 | 191 push_iso ;; |
pankso@318 | 192 gen) |
paul@325 | 193 # Build one or more flavors. |
pankso@318 | 194 flavors_list |
pankso@318 | 195 echo -e "\nGenerating flavors:\n$flavors" |
pankso@318 | 196 gen_flavors ;; |
pankso@318 | 197 4in1) |
paul@325 | 198 echo -e "\nGenerating 4in1 distros..." |
pankso@318 | 199 flavors="base justx gtkonly core core-4in1" |
pankso@318 | 200 gen_flavors ;; |
pankso@318 | 201 rolling) |
pankso@318 | 202 # |
paul@325 | 203 # Official SliTaz rolling release flavors are automatically built. |
pankso@318 | 204 # |
paul@325 | 205 # Check if packages list was modified or if any commits have been |
paul@325 | 206 # done in one of the rolling flavors and rebuild ISOs if needed. |
pankso@318 | 207 # |
pankso@318 | 208 pkgs=$SLITAZ/packages/packages.md5 |
pankso@318 | 209 last=$cache/packages.md5 |
pankso@318 | 210 diff=$cache/packages.diff |
pankso@350 | 211 cook="preinit core-4in1" |
pankso@318 | 212 |
pankso@318 | 213 # Log stuff |
pankso@318 | 214 rm -f $rollog && touch $rollog |
pankso@318 | 215 rm -f $commit $commits.tmp && touch $commits.tmp |
pankso@318 | 216 echo "Rolling tracking for changes" | log |
pankso@318 | 217 echo "Cookiso rolling started: $(date '+%Y-%m-%d %H:%M')" | log_bot |
pankso@318 | 218 |
pankso@318 | 219 # Packages changes |
pankso@318 | 220 [ -f "$last" ] || cp -f $pkgs $cache |
pankso@318 | 221 diff $last $pkgs > $diff |
pankso@318 | 222 if [ -s "$diff" ]; then |
paul@325 | 223 echo "Found new or rebuilt packages" | log_bot |
pankso@335 | 224 cat $diff | grep "^+" >> $rollog |
pankso@318 | 225 # |
pankso@318 | 226 # TODO: Check new pkg and see if it's part of one of the rolling |
pankso@318 | 227 # flavors, if not we have nothing to build. |
pankso@318 | 228 # |
pankso@318 | 229 for flavor in $cook |
pankso@318 | 230 do |
pankso@318 | 231 echo "$flavor" >> $commits.tmp |
pankso@318 | 232 echo "New packages for : $flavor" | log_bot |
pankso@318 | 233 done |
pankso@318 | 234 else |
pankso@318 | 235 echo "No changes found in packages MD5 sum" | log_bot |
pankso@318 | 236 echo "" > $commits.tmp |
pankso@318 | 237 fi |
pankso@318 | 238 cp -f $pkgs $cache |
pankso@318 | 239 |
pankso@318 | 240 # Hg changes |
pankso@318 | 241 cd $repo || exit 1 |
pankso@318 | 242 cur=$(hg head --template '{rev}\n') |
pankso@318 | 243 echo "Updating wok : $repo (rev $cur)" | log_bot |
pankso@318 | 244 cd $repo && hg pull -u | log_bot |
pankso@318 | 245 new=$(hg head --template '{rev}\n') |
pankso@318 | 246 cur=$(($cur + 1)) |
pankso@318 | 247 for rev in $(seq $cur $new) |
pankso@318 | 248 do |
pankso@318 | 249 for file in $(hg log --rev=$rev --template "{files}") |
pankso@318 | 250 do |
pankso@318 | 251 flavor=$(echo $file | cut -d "/" -f 1) |
pankso@318 | 252 desc=$(hg log --rev=$rev --template "{desc}" $file) |
paul@325 | 253 echo "Committed flavor : $flavor - $desc" | log_bot |
pankso@318 | 254 # Build only rolling flavor |
pankso@318 | 255 if echo "$cook" | fgrep -q $flavor; then |
pankso@318 | 256 echo $flavor >> $commits.tmp |
pankso@318 | 257 fi |
pankso@318 | 258 done |
pankso@318 | 259 done |
pankso@318 | 260 |
pankso@318 | 261 # Keep previous commit and discard duplicate lines |
pankso@318 | 262 cat $commits.tmp | sed /"^$"/d > $commits.new |
pankso@318 | 263 uniq $commits.new > $commits && rm $commits.* |
pankso@318 | 264 nb=$(cat $commits | wc -l) |
pankso@318 | 265 echo "Flavors to cook : $nb" | log_bot |
pankso@318 | 266 flavors=$(cat $commits) |
pankso@321 | 267 gen_flavors ;; |
pankso@318 | 268 spider) |
pankso@318 | 269 # SliTaz Easter egg command :-) |
pankso@318 | 270 spider ;; |
pankso@318 | 271 *) |
pankso@318 | 272 usage ;; |
pankso@318 | 273 esac |
pankso@318 | 274 |
pankso@318 | 275 rm -f $command |
pankso@318 | 276 exit 0 |