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