tiny-slitaz annotate helper @ rev 0
Initial move from slitaz-pizza
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Mar 23 19:37:38 2012 +0100 (2012-03-23) |
parents | |
children | d203aafad141 |
rev | line source |
---|---|
pascal@0 | 1 #!/bin/sh |
pascal@0 | 2 # $0 kernel size [initrd] |
pascal@0 | 3 |
pascal@0 | 4 list_pkgs() |
pascal@0 | 5 { |
pascal@0 | 6 TMPDIR=$2 |
pascal@0 | 7 shift 2 |
pascal@0 | 8 cat <<EOT |
pascal@0 | 9 <table> |
pascal@0 | 10 <tr> |
pascal@0 | 11 <th></th> |
pascal@0 | 12 <th>Package</th> |
pascal@0 | 13 <th>Version</th> |
pascal@0 | 14 <th>Description</th> |
pascal@0 | 15 <th>Disk</th> |
pascal@0 | 16 <th>Memory</th> |
pascal@0 | 17 <th></th> |
pascal@0 | 18 </tr> |
pascal@0 | 19 EOT |
pascal@0 | 20 for i in $TMPDIR/pkgs/*/receipt pkgs/*/receipt ; do |
pascal@0 | 21 [ -s $i ] || continue |
pascal@0 | 22 case "$i" in |
pascal@0 | 23 pkgs/kernel-*/receipt) continue;; |
pascal@0 | 24 pkgs/module-*/receipt) continue;; |
pascal@0 | 25 esac |
pascal@0 | 26 AUTO_SELECTION="" |
pascal@0 | 27 UNPACKED_SIZE="-" |
pascal@0 | 28 PACKED_SIZE="-" |
pascal@0 | 29 checked="" |
pascal@0 | 30 . $i |
pascal@0 | 31 case " $@ " in |
pascal@0 | 32 *\ $PACKAGE\ *) checked='checked="checked"';; |
pascal@0 | 33 *) [ -n "$2" ] && checked="";; |
pascal@0 | 34 esac |
pascal@0 | 35 grep -qs "^$PACKAGE " $TMPDIR/uploadconf && |
pascal@0 | 36 checked='checked="checked"' |
pascal@0 | 37 if [ -n "$AUTO_SELECTION" ]; then |
pascal@0 | 38 checked='checked="checked" disabled' |
pascal@0 | 39 cat <<EOT |
pascal@0 | 40 <input type="hidden" name="selected[]" value="$PACKAGE" /> |
pascal@0 | 41 EOT |
pascal@0 | 42 fi |
pascal@0 | 43 cat <<EOT |
pascal@0 | 44 <tr> |
pascal@0 | 45 <td><input type="checkbox" name="selected[]" value="$PACKAGE" $checked /></td> |
pascal@0 | 46 <td><a href="?dl=$PACKAGE-$VERSION&tmp=$TMPDIR">$PACKAGE</a></td> |
pascal@0 | 47 <td>$VERSION</td> |
pascal@0 | 48 <td>$SHORT_DESC</td> |
pascal@0 | 49 <td>$PACKED_SIZE</td> |
pascal@0 | 50 <td>$UNPACKED_SIZE</td> |
pascal@0 | 51 <td>$(grep -qs ^config_form $i && echo '»')</td> |
pascal@0 | 52 </tr> |
pascal@0 | 53 EOT |
pascal@0 | 54 done |
pascal@0 | 55 cat <<EOT |
pascal@0 | 56 </table> |
pascal@0 | 57 <p> |
pascal@0 | 58 </p> |
pascal@0 | 59 EOT |
pascal@0 | 60 exit |
pascal@0 | 61 } |
pascal@0 | 62 |
pascal@0 | 63 list_kernels() |
pascal@0 | 64 { |
pascal@0 | 65 TMPDIR=$2 |
pascal@0 | 66 shift 2 |
pascal@0 | 67 cat <<EOT |
pascal@0 | 68 <table> |
pascal@0 | 69 <tr> |
pascal@0 | 70 <th></th> |
pascal@0 | 71 <th>Kernel</th> |
pascal@0 | 72 <th>Version</th> |
pascal@0 | 73 <th>Description</th> |
pascal@0 | 74 <!-- th>Size</th --> |
pascal@0 | 75 </tr> |
pascal@0 | 76 EOT |
pascal@0 | 77 checked='checked="checked"' |
pascal@0 | 78 for i in $TMPDIR/pkgs/*/receipt pkgs/*/receipt ; do |
pascal@0 | 79 [ -s $i ] || continue |
pascal@0 | 80 case "$i" in |
pascal@0 | 81 pkgs/kernel-*/receipt);; |
pascal@0 | 82 *) continue;; |
pascal@0 | 83 esac |
pascal@0 | 84 UNPACKED_SIZE="-" |
pascal@0 | 85 . $i |
pascal@0 | 86 case " $@ " in |
pascal@0 | 87 *\ $PACKAGE\ *) checked='checked="checked"' ;; |
pascal@0 | 88 *) [ -n "$2" ] && checked="";; |
pascal@0 | 89 esac |
pascal@0 | 90 cat <<EOT |
pascal@0 | 91 <tr> |
pascal@0 | 92 <td><input type="radio" name="kernel" value="$PACKAGE" $checked/></td> |
pascal@0 | 93 <td>${PACKAGE#kernel-}</td> |
pascal@0 | 94 <td>$VERSION</td> |
pascal@0 | 95 <td>$SHORT_DESC</td> |
pascal@0 | 96 <!-- td>$UNPACKED_SIZE</td --> |
pascal@0 | 97 </tr> |
pascal@0 | 98 EOT |
pascal@0 | 99 checked="" |
pascal@0 | 100 done |
pascal@0 | 101 cat <<EOT |
pascal@0 | 102 </table> |
pascal@0 | 103 EOT |
pascal@0 | 104 exit |
pascal@0 | 105 } |
pascal@0 | 106 |
pascal@0 | 107 list_modules() |
pascal@0 | 108 { |
pascal@0 | 109 TMPDIR=$2 |
pascal@0 | 110 shift 2 |
pascal@0 | 111 cat <<EOT |
pascal@0 | 112 <table> |
pascal@0 | 113 <tr> |
pascal@0 | 114 <th></th> |
pascal@0 | 115 <th>Module</th> |
pascal@0 | 116 <th>Version</th> |
pascal@0 | 117 <th>Description</th> |
pascal@0 | 118 <th>Size</th> |
pascal@0 | 119 <th></th> |
pascal@0 | 120 </tr> |
pascal@0 | 121 EOT |
pascal@0 | 122 for i in $TMPDIR/pkgs/*/receipt pkgs/*/receipt ; do |
pascal@0 | 123 [ -s $i ] || continue |
pascal@0 | 124 case "$i" in |
pascal@0 | 125 pkgs/module-*/receipt);; |
pascal@0 | 126 *) continue;; |
pascal@0 | 127 esac |
pascal@0 | 128 UNPACKED_SIZE="-" |
pascal@0 | 129 . $i |
pascal@0 | 130 checked="" |
pascal@0 | 131 case " $@ " in |
pascal@0 | 132 *\ $PACKAGE\ *) checked='checked="checked"' ;; |
pascal@0 | 133 esac |
pascal@0 | 134 grep -qs "^$PACKAGE " $TMPDIR/uploadconf && |
pascal@0 | 135 checked='checked="checked"' |
pascal@0 | 136 cat <<EOT |
pascal@0 | 137 <tr> |
pascal@0 | 138 <td><input type="checkbox" name="selected[]" value="$PACKAGE" $checked/></td> |
pascal@0 | 139 <td>${PACKAGE#module-}</td> |
pascal@0 | 140 <td>$VERSION</td> |
pascal@0 | 141 <td>$SHORT_DESC</td> |
pascal@0 | 142 <td>$UNPACKED_SIZE</td> |
pascal@0 | 143 <td>$(grep -qs ^config_form $i && echo '?')</td> |
pascal@0 | 144 </tr> |
pascal@0 | 145 EOT |
pascal@0 | 146 done |
pascal@0 | 147 cat <<EOT |
pascal@0 | 148 </table> |
pascal@0 | 149 EOT |
pascal@0 | 150 exit |
pascal@0 | 151 } |
pascal@0 | 152 |
pascal@0 | 153 get_receipt() |
pascal@0 | 154 { |
pascal@0 | 155 grep -l "PACKAGE=\"$1\"" $2/pkgs/*/receipt pkgs/*/receipt | head -1 |
pascal@0 | 156 } |
pascal@0 | 157 |
pascal@0 | 158 get_package() |
pascal@0 | 159 { |
pascal@0 | 160 local pkg |
pascal@0 | 161 pkg=pkgs/$1/receipt |
pascal@0 | 162 [ -s $pkg ] || pkg=$2/pkgs/$1/receipt |
pascal@0 | 163 [ -s $pkg ] || pkg=$(get_receipt $@) |
pascal@0 | 164 . $pkg |
pascal@0 | 165 cd $(dirname $pkg) |
pascal@0 | 166 pkg=$2$PACKAGE-$VERSION.tazpkg |
pascal@0 | 167 find * | cpio -o -H newc > $pkg |
pascal@0 | 168 echo -n $pkg |
pascal@0 | 169 } |
pascal@0 | 170 |
pascal@0 | 171 get_note() |
pascal@0 | 172 { |
pascal@0 | 173 pkg=$(get_receipt $1 $2) |
pascal@0 | 174 [ -n "$pkg" ] || exit |
pascal@0 | 175 grep -qs ^config_note $pkg || exit |
pascal@0 | 176 . $pkg |
pascal@0 | 177 config_note |
pascal@0 | 178 } |
pascal@0 | 179 |
pascal@0 | 180 get_form() |
pascal@0 | 181 { |
pascal@0 | 182 pkg=$(get_receipt $1 $2) |
pascal@0 | 183 [ -n "$pkg" ] || exit |
pascal@0 | 184 grep -qs ^config_form $pkg || exit |
pascal@0 | 185 . $pkg |
pascal@0 | 186 if [ -s $2/uploadconf ]; then |
pascal@0 | 187 awk "{ |
pascal@0 | 188 if (found) { |
pascal@0 | 189 if (/^ /) print; |
pascal@0 | 190 else exit; |
pascal@0 | 191 } |
pascal@0 | 192 if (/^$PACKAGE /) found=1 |
pascal@0 | 193 }" < $2/uploadconf | sed -e 's/ //' -e 's/ \([A-Z_0-9]*=\)/export \1/' > $2/vars |
pascal@0 | 194 . $2/vars |
pascal@0 | 195 fi |
pascal@0 | 196 config_form $2/fs |
pascal@0 | 197 exit |
pascal@0 | 198 } |
pascal@0 | 199 |
pascal@0 | 200 do_pre_install() |
pascal@0 | 201 { |
pascal@0 | 202 pkg=$(get_receipt $1 $2) |
pascal@0 | 203 [ -n "$pkg" ] || exit |
pascal@0 | 204 CONFIG_FILES="" |
pascal@0 | 205 . $pkg |
pascal@0 | 206 grep -qs ^pre_install $pkg && pre_install $2/fs |
pascal@0 | 207 [ -n "$CONFIG_FILES" ] && for i in $CONFIG_FILES; do echo $i >> $2/config_files; done |
pascal@0 | 208 unlzma -c $(dirname $pkg)/fs.cpio.lzma | ( cd $2 ; cpio -idmu ) |
pascal@0 | 209 exit |
pascal@0 | 210 } |
pascal@0 | 211 |
pascal@0 | 212 do_post_install() |
pascal@0 | 213 { |
pascal@0 | 214 pkg=$(get_receipt $1 $2) |
pascal@0 | 215 [ -n "$pkg" ] || exit |
pascal@0 | 216 . $pkg |
pascal@0 | 217 echo "$1 $VERSION $(md5sum $(dirname $pkg)/fs.cpio.lzma | awk '{ print $1 }')" >> $2/fs/etc/packages.conf |
pascal@0 | 218 if grep -qs ^post_install $pkg; then |
pascal@0 | 219 . $2/vars |
pascal@0 | 220 echo "=== $pkg: $(date) ===" >> $2/post_install.log 2>&1 |
pascal@0 | 221 post_install $2/fs >> $2/post_install.log 2>&1 |
pascal@0 | 222 sed -e 's/^export/ /' -e 's/^/ /' < $2/vars >> $2/fs/etc/packages.conf |
pascal@0 | 223 fi |
pascal@0 | 224 rm -f $2/vars |
pascal@0 | 225 exit |
pascal@0 | 226 } |
pascal@0 | 227 |
pascal@0 | 228 scan_depends() |
pascal@0 | 229 { |
pascal@0 | 230 local pkg |
pascal@0 | 231 for pkg in $@ ; do |
pascal@0 | 232 case " $OUTPUT " in |
pascal@0 | 233 *\ $pkg\ *) continue ;; |
pascal@0 | 234 esac |
pascal@0 | 235 DEPENDS="" |
pascal@0 | 236 . $(get_receipt $pkg $TMPDIR) |
pascal@0 | 237 scan_depends $DEPENDS |
pascal@0 | 238 case " $OUTPUT " in |
pascal@0 | 239 *\ $pkg\ *) continue ;; |
pascal@0 | 240 esac |
pascal@0 | 241 OUTPUT="$OUTPUT $pkg" |
pascal@0 | 242 done |
pascal@0 | 243 } |
pascal@0 | 244 |
pascal@0 | 245 get_depends() |
pascal@0 | 246 { |
pascal@0 | 247 TMPDIR=$2 |
pascal@0 | 248 shift 2 |
pascal@0 | 249 OUTPUT="" |
pascal@0 | 250 scan_depends $@ |
pascal@0 | 251 echo -n $OUTPUT |
pascal@0 | 252 exit |
pascal@0 | 253 } |
pascal@0 | 254 |
pascal@0 | 255 pkgs_extract() |
pascal@0 | 256 { |
pascal@0 | 257 cd $2 |
pascal@0 | 258 mkdir pkgs |
pascal@0 | 259 if cpio -t < $1 | grep -q receipt; then |
pascal@0 | 260 mv $1 pkgs |
pascal@0 | 261 elif tar tf $1 | grep -q tazpkg; then |
pascal@0 | 262 tar xf $1 -C pkgs |
pascal@0 | 263 elif tar tzf $1 | grep -q tazpkg; then |
pascal@0 | 264 tar xzf $1 -C pkgs |
pascal@0 | 265 elif tar tjf $1 | grep -q tazpkg; then |
pascal@0 | 266 tar xjf $1 -C pkgs |
pascal@0 | 267 else |
pascal@0 | 268 rm -rf $1 pkgs |
pascal@0 | 269 exit |
pascal@0 | 270 fi |
pascal@0 | 271 cd pkgs |
pascal@0 | 272 for i in *; do |
pascal@0 | 273 mkdir tmp |
pascal@0 | 274 cd tmp |
pascal@0 | 275 cpio -i < ../$i |
pascal@0 | 276 . ./receipt |
pascal@0 | 277 cd .. |
pascal@0 | 278 mv tmp $PACKAGE-$VERSION |
pascal@0 | 279 done |
pascal@0 | 280 exit |
pascal@0 | 281 } |
pascal@0 | 282 |
pascal@0 | 283 lzma_set_size() |
pascal@0 | 284 { |
pascal@0 | 285 n=$(unlzma -c $1 | wc -c) |
pascal@0 | 286 for i in $(seq 1 8); do |
pascal@0 | 287 printf '\\\\x%02X' $(($n & 255)) |
pascal@0 | 288 n=$(($n >> 8)) |
pascal@0 | 289 done | xargs echo -en | dd of=$1 conv=notrunc bs=1 seek=5 2> /dev/null |
pascal@0 | 290 } |
pascal@0 | 291 |
pascal@0 | 292 case "$1" in |
pascal@0 | 293 --list-modules) list_modules $@ ;; |
pascal@0 | 294 --list-kernels) list_kernels $@ ;; |
pascal@0 | 295 --list-pkgs) list_pkgs $@ ;; |
pascal@0 | 296 --get-form) get_form $2 $3 ;; |
pascal@0 | 297 --get-note) get_note $2 $3 ;; |
pascal@0 | 298 --pre-install) do_pre_install $2 $3 ;; |
pascal@0 | 299 --post-install) do_post_install $2 $3 ;; |
pascal@0 | 300 --depends) get_depends $@ ;; |
pascal@0 | 301 --pkgs-extract) pkgs_extract $2 $3 ;; |
pascal@0 | 302 --remove) rm -rf $2; exit ;; |
pascal@0 | 303 --get-pkg) get_package $2 $3 ;; |
pascal@0 | 304 esac |
pascal@0 | 305 |
pascal@0 | 306 if [ "x$1" == "x--mkrootfs" ]; then |
pascal@0 | 307 tmp=$2 |
pascal@0 | 308 cd $tmp/fs |
pascal@0 | 309 if [ ! -d boot -a -s ../kernel ]; then # custom kernel |
pascal@0 | 310 mkdir boot |
pascal@0 | 311 cp ../kernel boot/bzImage |
pascal@0 | 312 fi |
pascal@0 | 313 find -user bellard -exec chown root.root {} \; |
pascal@0 | 314 find | grep -v ^./boot | cpio -o -H newc | lzma e ../rootfs.gz -si |
pascal@0 | 315 lzma_set_size ../rootfs.gz |
pascal@0 | 316 fi |
pascal@0 | 317 if [ "x$1" == "x--mkiso" ]; then |
pascal@0 | 318 tmp=$2 |
pascal@0 | 319 mkdir -p $tmp/iso/boot/isolinux $tmp/iso/data |
pascal@0 | 320 cat $tmp/fs/boot/System.map | gzip -9 > $tmp/iso/data/sysmap.gz |
pascal@0 | 321 cat $tmp/fs/boot/config | gzip -9 > $tmp/iso/data/linconf.gz |
pascal@0 | 322 cat $tmp/fs/boot/config-busybox | gzip -9 > $tmp/iso/data/bbconf.gz |
pascal@0 | 323 cp $tmp/config_files $tmp/iso/data/files.cnf |
pascal@0 | 324 cp $tmp/fs/etc/packages.conf $tmp/iso/data/packages.cnf |
pascal@0 | 325 cp $tmp/fs/boot/bzImage $tmp/iso/boot/bzImage |
pascal@0 | 326 cp $tmp/rootfs.gz $tmp/iso/boot/rootfs |
pascal@0 | 327 cp /boot/isolinux/isolinux.bin $tmp/iso/boot/isolinux |
pascal@0 | 328 cat > $tmp/iso/boot/isolinux/isolinux.cfg <<EOT |
pascal@0 | 329 label slitaz |
pascal@0 | 330 kernel /boot/bzImage |
pascal@0 | 331 append initrd=/boot/rootfs rw root=/dev/null vga=normal |
pascal@0 | 332 default slitaz |
pascal@0 | 333 implicit 0 |
pascal@0 | 334 prompt 1 |
pascal@0 | 335 timeout 50 |
pascal@0 | 336 EOT |
pascal@0 | 337 genisoimage -o $tmp/slitaz.iso -b boot/isolinux/isolinux.bin \ |
pascal@0 | 338 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \ |
pascal@0 | 339 -V "Tiny SliTaz" -p "www.slitaz.org" -input-charset iso8859-1 \ |
pascal@0 | 340 -boot-info-table $tmp/iso > /dev/null 2>&1 |
pascal@0 | 341 [ -x /usr/bin/isohybrid ] && |
pascal@0 | 342 /usr/bin/isohybrid $tmp/slitaz.iso 2> /dev/null |
pascal@0 | 343 fi |
pascal@0 | 344 if [ "x$1" == "x--mkimg" ]; then |
pascal@0 | 345 tmp=$2 |
pascal@0 | 346 exe=$PWD |
pascal@0 | 347 cd $tmp |
pascal@0 | 348 $exe/bootloader fs/boot/bzImage --initrd rootfs.gz --format 0 |
pascal@0 | 349 mv floppy. slitaz.img |
pascal@0 | 350 # $exe/bootloader fs/boot/bzImage --initrd rootfs.gz |
pascal@0 | 351 # cat floppy.* > slitaz.img && rm -f floppy.* |
pascal@0 | 352 fi |
pascal@0 | 353 if [ "x$1" == "x--mkcfg" ]; then |
pascal@0 | 354 tmp=$2 |
pascal@0 | 355 cd $tmp/fs |
pascal@0 | 356 for i in $(sed 's#^/##' < ../config_files); do find $i; done | \ |
pascal@0 | 357 sort | uniq | cpio -o -H newc | gzip -9 > ../config_files.cpio.gz |
pascal@0 | 358 fi |