wok-stable rev 3670

mirror-tools/mkpkgiso: add --auto-install and --loram-detect
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jul 11 01:02:28 2009 +0200 (2009-07-11)
parents 7a46cf13f72a
children 9bba2e65be4d
files mirror-tools/stuff/usr/bin/mkpkgiso
line diff
     1.1 --- a/mirror-tools/stuff/usr/bin/mkpkgiso	Fri Jul 10 22:26:19 2009 +0200
     1.2 +++ b/mirror-tools/stuff/usr/bin/mkpkgiso	Sat Jul 11 01:02:28 2009 +0200
     1.3 @@ -5,15 +5,17 @@
     1.4  # Authors : Eric Joseph-Alexandre <erjo@slitaz.org>
     1.5  #	    Pascal Bellard <pascal.bellard@slitaz.org>
     1.6  
     1.7 -VERSION=0.4
     1.8 +VERSION=0.5
     1.9  
    1.10  ROOT=/home/slitaz/iso
    1.11  TEMP_DIR=${ROOT}/_iso.$$
    1.12 +SORT_FILE=${ROOT}/_sort.$$
    1.13  PKG_VER=$1
    1.14  shift
    1.15  OPTIONS=$@
    1.16  PKG_DIR=$TEMP_DIR/packages/$PKG_VER
    1.17  REPOS=/var/www/slitaz/mirror/packages/$PKG_VER
    1.18 +PXE_DIR=/var/www/slitaz/mirror/pxe
    1.19  ISO_DIR=/var/www/slitaz/mirror/iso/$PKG_VER
    1.20  LOG=$PWD/$(basename $0).log
    1.21  
    1.22 @@ -25,7 +27,11 @@
    1.23  
    1.24  # Check command line option.
    1.25  if [ -z $PKG_VER ]; then
    1.26 -	echo "Usage: $(basename $0) <Version> [--boot|--webboot][--filter]"
    1.27 +	cat <<EOT
    1.28 +Usage: $(basename $0) <Version> 
    1.29 +	[--boot [--auto-install] [--loram-detect]]|--webboot] [--filter]
    1.30 +	[--wok] [--wok-stable] [--website][--dry-run]
    1.31 +EOT
    1.32  	exit 1
    1.33  fi
    1.34  
    1.35 @@ -74,19 +80,63 @@
    1.36  #!/bin/sh
    1.37  #
    1.38  
    1.39 -DIR=\$(cd \$(dirname \$0); pwd)
    1.40 +DIR=\$(cd \$(busybox dirname \$0); pwd)
    1.41 +
    1.42 +# Handle --auto-install case
    1.43 +if [ "\$DIR" == "/etc/init.d" ]; then
    1.44 +  DIR=/mnt
    1.45 +
    1.46 +  # Handle loram on hybrid hard disk / usb key case
    1.47 +  if [ ! -d /usr/bin ]; then
    1.48 +    if [ -d /.usr.rw ]; then
    1.49 +      echo -n "Mounting /usr read-write... "
    1.50 +      usr=.usr.ro
    1.51 +    else
    1.52 +      echo -n "Mounting /usr read-only... "
    1.53 +      usr=usr
    1.54 +    fi
    1.55 +    FS=\$DIR/usr.cromfs
    1.56 +    if [ -f \$FS ]; then
    1.57 +      /bin/cromfs-driver \$FS /\$usr -o ro,dev,suid,allow_other
    1.58 +    elif [ -f \$DIR/usr.sqfs ]; then
    1.59 +      FS=\$DIR/usr.sqfs
    1.60 +      mount -o loop,ro -t squashfs \$FS /\$usr
    1.61 +    elif [ -L /\$usr ]; then
    1.62 +      FS=\$DIR/usr
    1.63 +    fi
    1.64 +    status
    1.65 +    if [ -d /.usr.rw ]; then
    1.66 +      if [ -x /bin/funionfs ]; then
    1.67 +        /bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other -o suid,dev NONE /usr
    1.68 +      else
    1.69 +        /bin/mount -t aufs -o br:/.usr.rw:/.usr.ro none /usr
    1.70 +      fi
    1.71 +    fi
    1.72 +  fi
    1.73 +fi
    1.74  
    1.75  echo "Install packages..."
    1.76  [ -d /var/cache/tazpkg ] || mkdir -p /var/cache/tazpkg
    1.77  ls -d \$DIR/packages/* > /var/lib/tazpkg/mirror
    1.78  ln -fs \$DIR/packages/*/*.tazpkg /var/cache/tazpkg/
    1.79  ln -fs \$DIR/packages/*/packages.* /var/lib/tazpkg
    1.80 +echo "=> all $PKG_VER package are available for tazpkg/tazpkgbox"
    1.81  EOF
    1.82  [ -e files.list.lzma ] && cat >>$TEMP_DIR/install.sh<<EOF
    1.83  ln -fs \$DIR/packages/*/files.list.lzma /var/lib/tazpkg
    1.84  EOF
    1.85  
    1.86  status
    1.87 +cat > $SORT_FILE <<EOT
    1.88 +install.sh 8
    1.89 +README 8
    1.90 +index.html 8
    1.91 +md5sum 8
    1.92 +style.css 8
    1.93 +images/header.png 8
    1.94 +EOT
    1.95 +( cd $TEMP_DIR ; ls packages/*/packages* packages/*/files.list.lzma ) | \
    1.96 +		awk '{ printf "%s 4\n",$0 }' >> $SORT_FILE
    1.97  chmod 755  $TEMP_DIR/install.sh
    1.98  
    1.99  case " $OPTIONS " in
   1.100 @@ -131,16 +181,31 @@
   1.101  for i in $OPTIONS ; do
   1.102  case "$i" in
   1.103  --wok)
   1.104 -	get_from_hg wok "wok (cooking)";;
   1.105 +	cat >>$TEMP_DIR/install.sh<<EOF
   1.106 +echo "=> Wok (cooking) is in \$DIR/wok"
   1.107 +EOF
   1.108 +	if get_from_hg wok "wok (cooking)"; then
   1.109 +		( cd $TEMP_DIR ; find wok -not -type d ) | \
   1.110 +			awk '{ printf "%s 2\n",$0 }' >> $SORT_FILE
   1.111 +	fi;;
   1.112  --wok-stable)
   1.113 -	get_from_hg wok-stable "wok (stable)";;
   1.114 +	cat >>$TEMP_DIR/install.sh<<EOF
   1.115 +echo "=> Wok (stable) is in \$DIR/wok"
   1.116 +EOF
   1.117 +	if get_from_hg wok-stable "wok (stable)"; then
   1.118 +		mv $TEMP_DIR/wok-stable $TEMP_DIR/wok
   1.119 +		( cd $TEMP_DIR ; find wok -not -type d ) | \
   1.120 +			awk '{ printf "%s 2\n",$0 }' >> $SORT_FILE
   1.121 +	fi;;
   1.122  --website)
   1.123  	if get_from_hg website "web site"; then
   1.124 +		( cd $TEMP_DIR ; find website -not -type d ) | \
   1.125 +			awk '{ printf "%s 5\n",$0 }' >> $SORT_FILE
   1.126  		cat >>$TEMP_DIR/install.sh<<EOF
   1.127 -echo "Install http://127.0.0.1/website ..."
   1.128  [ -d /var/www ] || mkdir -p /var/www
   1.129  ln -s \$DIR/website /var/www
   1.130 -tazpkg list | grep -q ^lighttpd || yes y | tazpkg get-install lighttpd
   1.131 +tazpkg list | grep -q ^lighttpd || yes y | tazpkg get-install lighttpd > /dev/null 2>&1
   1.132 +echo "=> slitaz web site installed in http://localhost/website"
   1.133  EOF
   1.134  	fi;;
   1.135  esac
   1.136 @@ -162,6 +227,7 @@
   1.137  # Gen boot part
   1.138  BOOT_OPT=""
   1.139  iso=$ISO_DIR/slitaz-$PKG_VER.iso
   1.140 +isoloram=$ISO_DIR/flavors/slitaz-loram-cdrom-sqfs.iso
   1.141  case " $OPTIONS " in
   1.142  *\ --boot\ *)
   1.143      echo -n "Creating boot tree"
   1.144 @@ -174,7 +240,34 @@
   1.145  	done
   1.146  	status
   1.147  	BOOT_OPT="-b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
   1.148 --no-emul-boot -boot-load-size 4 -boot-info-table"
   1.149 +-no-emul-boot -boot-load-size 4 -boot-info-table -sort $SORT_FILE"
   1.150 +    case " $OPTIONS " in
   1.151 +	*\ --auto-install\ *)
   1.152 +    	echo -n "Enable auto install"
   1.153 +		cat >>$TEMP_DIR/install.sh<<EOF
   1.154 +echo "mount -o ro -t iso9660 LABEL=packages-$PKG_VER /mnt" >> /etc/init.d/local.sh
   1.155 +EOF
   1.156 +		sed -i "s/rw root/rw config=LABEL=packages-$PKG_VER,install.sh root/" \
   1.157 +			$TEMP_DIR/boot/isolinux/*.cfg
   1.158 +		status
   1.159 +		;;
   1.160 +	esac
   1.161 +    [ -f $PXE_DIR/ifmem.c32 -a -f $isoloram ] && case " $OPTIONS " in
   1.162 +	*\ --loram-detect\ *)
   1.163 +    	echo -n "Enable loram autodetection"
   1.164 +		cp $PXE_DIR/ifmem.c32 "$TEMP_DIR/boot/isolinux"
   1.165 +		isoinfo -R -x "/usr.sqfs" -i $isoloram > "$TEMP_DIR/usr.sqfs"
   1.166 +		echo 'usr.sqfs 8' >> $SORT_FILE
   1.167 +		isoinfo -R -x "/boot/rootfs.gz" -i $isoloram > \
   1.168 +			"$TEMP_DIR/boot/loram.gz"
   1.169 +		sed -i -e 's|kernel /boot/bzImage|kernel /boot/isolinux/ifmem.c32\n\tappend 160768 core loram\n|' \
   1.170 +			-e 's|\(.*/\)rootfs\(.gz .*\)$|label core\n\tkernel /boot/bzImage\n\1rootfs\2\n\nlabel loram\n\tkernel /boot/bzImage\n\1loram\2|' \
   1.171 +			$TEMP_DIR/boot/isolinux/*.cfg
   1.172 +		status
   1.173 +		;;
   1.174 +	esac
   1.175 +	( cd $TEMP_DIR ; find boot -not -type d ) | \
   1.176 +		awk '{ printf "%s 9\n",$0 }' >> $SORT_FILE
   1.177  	;;
   1.178  *\ --webboot\ *)
   1.179  	if extract_boot gpxe; then
   1.180 @@ -183,22 +276,30 @@
   1.181  		isoinfo -x "/BOOT/ISOLINUX/ISOLINUX.BIN;1" -i $iso > \
   1.182  			$TEMP_DIR/boot/isolinux/isolinux.bin
   1.183  		mv $TEMP_DIR/boot/gpxe $TEMP_DIR/boot/isolinux
   1.184 +		( cd $TEMP_DIR ; find boot -not -type d ) | \
   1.185 +			awk '{ printf "%s 9\n",$0 }' >> $SORT_FILE
   1.186  		cat > $TEMP_DIR/boot/isolinux/isolinux.cfg <<EOT
   1.187  default gpxe
   1.188  append http://mirror.slitaz.org/pxe/pxelinux.0
   1.189  EOT
   1.190  		status
   1.191  		BOOT_OPT="-b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
   1.192 --no-emul-boot -boot-load-size 4 -boot-info-table"
   1.193 +-no-emul-boot -boot-load-size 4 -boot-info-table -sort $SORT_FILE"
   1.194  	fi
   1.195  	;;
   1.196  esac
   1.197  
   1.198  if [ -n "$BOOT_OPT" ]; then
   1.199 -	sed -i 's/vga=/mount-packages vga=/' $TEMP_DIR/boot/isolinux/*.cfg 
   1.200 -	echo "$(du -hs $TEMP_DIR/boot | awk '{ print $1 }') used by boot."
   1.201 +	echo "$(du -chs $TEMP_DIR/boot $TEMP_DIR/usr.sqfs 2> /dev/null | \
   1.202 +		    tail -1 | awk '{ print $1 }') used by boot."
   1.203  fi
   1.204  
   1.205 +case " $OPTIONS " in
   1.206 +*\ --dry-run\ *)
   1.207 +	echo "Please check and remove $TEMP_DIR and $SORT_FILE"
   1.208 +	exit
   1.209 +	;;
   1.210 +esac
   1.211  # Gen ISO
   1.212  echo -n "Generating iso image"
   1.213  /usr/bin/genisoimage -R -J -f -V $VOLUME_ID \
   1.214 @@ -222,7 +323,6 @@
   1.215  mv $(basename $IMAGE .iso).md5 $ISO_DIR
   1.216  status
   1.217  
   1.218 +# Cleaning temp files
   1.219 +rm -rf $TEMP_DIR $SORT_FILE
   1.220  
   1.221 -# Cleaning temp files
   1.222 -rm -rf $TEMP_DIR
   1.223 -