wok-6.x rev 4466

mirror-tools/mkpkgiso: remove hg dependancy
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Nov 09 15:44:14 2009 +0100 (2009-11-09)
parents c1315b822a63
children cb468df31fdb
files mirror-tools/stuff/usr/bin/mkpkgiso
line diff
     1.1 --- a/mirror-tools/stuff/usr/bin/mkpkgiso	Sun Nov 08 23:30:24 2009 +0100
     1.2 +++ b/mirror-tools/stuff/usr/bin/mkpkgiso	Mon Nov 09 15:44:14 2009 +0100
     1.3 @@ -5,19 +5,23 @@
     1.4  # Authors : Eric Joseph-Alexandre <erjo@slitaz.org>
     1.5  #	    Pascal Bellard <pascal.bellard@slitaz.org>
     1.6  
     1.7 -VERSION=0.6
     1.8 +VERSION=0.7
     1.9  
    1.10 +PKG_VER=$1
    1.11  ROOT=/home/slitaz/iso
    1.12 +REPOS=/var/www/slitaz/mirror/packages/$PKG_VER
    1.13 +IFMEM_C32=/var/www/slitaz/mirror/pxe/ifmem.c32
    1.14 +ISO_DIR=/var/www/slitaz/mirror/iso/$PKG_VER
    1.15 +
    1.16 +[ -s /etc/slitaz/mkpkgiso.conf ] && . /etc/slitaz/mkpkgiso.conf
    1.17 +[ -s ./mkpkgiso.conf ] && . ./mkpkgiso.conf
    1.18 +
    1.19  SORT_DIR=${ROOT}/_iso.$$
    1.20  TEMP_DIR=${ROOT}/_iso.$$
    1.21  SORT_FILE=${ROOT}/_sort.$$
    1.22 -PKG_VER=$1
    1.23  shift
    1.24  OPTIONS=$@
    1.25  PKG_DIR=$TEMP_DIR/packages/$PKG_VER
    1.26 -REPOS=/var/www/slitaz/mirror/packages/$PKG_VER
    1.27 -PXE_DIR=/var/www/slitaz/mirror/pxe
    1.28 -ISO_DIR=/var/www/slitaz/mirror/iso/$PKG_VER
    1.29  LOG=$PWD/$(basename $0).log
    1.30  
    1.31  #
    1.32 @@ -32,6 +36,8 @@
    1.33  Usage: $(basename $0) <Version> 
    1.34  	[--boot [--auto-install] [--loram-detect]]|--webboot] [--filter]
    1.35  	[--wok] [--wok-stable] [--website][--dry-run]
    1.36 +Example:
    1.37 +$(basename $0) cooking --boot --auto-install --loram-detect --filter --wok --website
    1.38  EOT
    1.39  	exit 1
    1.40  fi
    1.41 @@ -45,18 +51,33 @@
    1.42  # Status function.
    1.43  status()
    1.44  {
    1.45 -    local CHECK=$?
    1.46 -    echo -en "\\033[70G[ "
    1.47 -    if [ $CHECK = 0 ]; then
    1.48 -        echo -en "\\033[1;33mOK"
    1.49 -    else
    1.50 -        echo -en "\\033[1;31mFailed"
    1.51 -    fi
    1.52 -    echo -e "\\033[0;39m ]"
    1.53 +	local CHECK=$?
    1.54 +	echo -en "\\033[70G[ "
    1.55 +	if [ $CHECK = 0 ]; then
    1.56 +		echo -en "\\033[1;33mOK"
    1.57 +	else
    1.58 +		echo -en "\\033[1;31mFailed"
    1.59 +	fi
    1.60 +	echo -e "\\033[0;39m ]"
    1.61 +}
    1.62 +
    1.63 +need()
    1.64 +{
    1.65 +	found=1
    1.66 +	for i in $@ ; do
    1.67 +		[ -s $i ] && continue
    1.68 +		echo "Missing: $i "
    1.69 +		found=0
    1.70 +	done
    1.71 +	[ $found -ne 0 ] && return
    1.72 +	status
    1.73 +	rm -rf $TEMP_DIR $SORT_FILE
    1.74 +	exit 1
    1.75  }
    1.76  
    1.77  # Create temp directory
    1.78  mkdir -p $TEMP_DIR/packages/$PKG_VER
    1.79 +which genisoimage > /dev/null || need /usr/bin/genisoimage
    1.80  
    1.81  # Prepare evrything for ISO
    1.82  
    1.83 @@ -176,12 +197,9 @@
    1.84  # Copy hg subtree
    1.85  get_from_hg()
    1.86  {
    1.87 -[ /slitaz/home/slitaz/hg/$1 ] || return
    1.88  echo -n "Adding $2"
    1.89 -/usr/sbin/chroot /slitaz hg --repository /home/slitaz/hg/$1 pull >/dev/null
    1.90 -/usr/sbin/chroot /slitaz hg --repository /home/slitaz/hg/$1 update >/dev/null
    1.91 -mkdir $TEMP_DIR/$1
    1.92 -cp -a /slitaz/home/slitaz/hg/$1/* $TEMP_DIR/$1
    1.93 +wget -q -O - http://hg.slitaz.org/$1/archive/tip.tar.bz2 | tar xjf - -C $TEMP_DIR
    1.94 +mv $TEMP_DIR/$1-* $TEMP_DIR/$1
    1.95  status
    1.96  echo "$(du -hs $TEMP_DIR/$1 | awk '{ print $1 }') used by $2."
    1.97  }
    1.98 @@ -210,8 +228,6 @@
    1.99  --website)
   1.100  	if get_from_hg website "web site"; then
   1.101  		echo "$SORT_DIR/website -6000" >> $SORT_FILE
   1.102 -		echo "$(echo $SORT_DIR/packages/*/lighttpd-[0-9]*) -7100" >> $SORT_FILE
   1.103 -		echo "$(echo $SORT_DIR/packages/*/pcre-[0-9]*) -7100" >> $SORT_FILE
   1.104  		cat >>$TEMP_DIR/install.sh<<EOF
   1.105  echo "=> slitaz web site installed in file://\$DIR/website/index.html"
   1.106  EOF
   1.107 @@ -238,7 +254,9 @@
   1.108  isoloram=$ISO_DIR/flavors/slitaz-loram-cdrom-sqfs.iso
   1.109  case " $OPTIONS " in
   1.110  *\ --boot\ *)
   1.111 -    echo -n "Creating boot tree"
   1.112 +	echo -n "Creating boot tree"
   1.113 +	need $iso
   1.114 +	which isoinfo > /dev/null || need /usr/bin/isoinfo
   1.115  	isoinfo -R -l -i $iso | awk '/^Directory/ { path=$4 } /^-/ { print path$12  }' | while read file; do
   1.116  		[ "$(basename $file)" == ".." ] && continue
   1.117  		[ "$file" = "/boot/isolinux/boot.cat" ] && continue
   1.118 @@ -249,22 +267,24 @@
   1.119  	if [ -f "$(echo $TEMP_DIR/boot/vmlinuz*)" ]; then
   1.120  		rm -f $TEMP_DIR/boot/bzImage
   1.121  		ln $TEMP_DIR/boot/vmlinuz* $TEMP_DIR/boot/bzImage
   1.122 -    fi
   1.123 +	fi
   1.124  	status
   1.125  	BOOT_OPT="-sort $SORT_FILE -b boot/isolinux/isolinux.bin \
   1.126  -c boot/isolinux/boot.cat  -no-emul-boot -boot-load-size 4 -boot-info-table"
   1.127 -    case " $OPTIONS " in
   1.128 +	case " $OPTIONS " in
   1.129  	*\ --auto-install\ *)
   1.130 -    	echo -n "Enable auto install"
   1.131 +		echo -n "Enable auto install"
   1.132  		sed -i "s/rw root/rw config=LABEL=packages-$PKG_VER,install.sh root/" \
   1.133  			$TEMP_DIR/boot/isolinux/*.cfg
   1.134  		status
   1.135  		;;
   1.136  	esac
   1.137 -    [ -f $PXE_DIR/ifmem.c32 -a -f $isoloram ] && case " $OPTIONS " in
   1.138 +	case " $OPTIONS " in
   1.139  	*\ --loram-detect\ *)
   1.140 -    	echo -n "Enable loram autodetection"
   1.141 -		cp $PXE_DIR/ifmem.c32 "$TEMP_DIR/boot/isolinux"
   1.142 +		echo -n "Enable loram autodetection"
   1.143 +		need $IFMEM_C32 $isoloram
   1.144 +		which isoinfo > /dev/null || need /usr/bin/isoinfo
   1.145 +		cp $IFMEM_C32 "$TEMP_DIR/boot/isolinux"
   1.146  		isoinfo -R -x "/usr.sqfs" -i $isoloram > "$TEMP_DIR/usr.sqfs"
   1.147  		echo "$SORT_DIR/usr.sqfs -5000" >> $SORT_FILE
   1.148  		isoinfo -R -x "/boot/rootfs.gz" -i $isoloram > \
   1.149 @@ -300,18 +320,19 @@
   1.150  	;;
   1.151  *\ --webboot\ *)
   1.152  	if extract_boot gpxe; then
   1.153 -    	echo -n "Creating web boot tree"
   1.154 -		mkdir $TEMP_DIR/boot/isolinux/
   1.155 -		isoinfo -x "/BOOT/ISOLINUX/ISOLINUX.BIN;1" -i $iso > \
   1.156 -			$TEMP_DIR/boot/isolinux/isolinux.bin
   1.157 -		mv $TEMP_DIR/boot/gpxe $TEMP_DIR/boot/isolinux
   1.158 -		echo "$SORT_DIR/boot 0" >> $SORT_FILE
   1.159 -		cat > $TEMP_DIR/boot/isolinux/isolinux.cfg <<EOT
   1.160 +	echo -n "Creating web boot tree"
   1.161 +	which isoinfo > /dev/null || need /usr/bin/isoinfo
   1.162 +	mkdir $TEMP_DIR/boot/isolinux/
   1.163 +	isoinfo -R -x "/boot/isolinux/isolinux.bin" -i $iso > \
   1.164 +		$TEMP_DIR/boot/isolinux/isolinux.bin
   1.165 +	mv $TEMP_DIR/boot/gpxe $TEMP_DIR/boot/isolinux
   1.166 +	echo "$SORT_DIR/boot 0" >> $SORT_FILE
   1.167 +	cat > $TEMP_DIR/boot/isolinux/isolinux.cfg <<EOT
   1.168  default gpxe
   1.169  append http://mirror.slitaz.org/pxe/pxelinux.0
   1.170  EOT
   1.171 -		status
   1.172 -		BOOT_OPT="-sort $SORT_FILE -b boot/isolinux/isolinux.bin \
   1.173 +	status
   1.174 +	BOOT_OPT="-sort $SORT_FILE -b boot/isolinux/isolinux.bin \
   1.175  -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
   1.176  	fi
   1.177  	;;
   1.178 @@ -319,7 +340,7 @@
   1.179  
   1.180  if [ -n "$BOOT_OPT" ]; then
   1.181  	echo "$(du -chs $TEMP_DIR/boot $TEMP_DIR/usr.sqfs 2> /dev/null | \
   1.182 -		    tail -1 | awk '{ print $1 }') used by boot."
   1.183 +		    awk 'END { print $1 }') used by boot."
   1.184  fi
   1.185  
   1.186  case " $OPTIONS " in
   1.187 @@ -330,7 +351,7 @@
   1.188  esac
   1.189  # Gen ISO
   1.190  echo -n "Generating iso image"
   1.191 -/usr/bin/genisoimage -R -J -f -V $VOLUME_ID \
   1.192 +genisoimage -R -J -f -V $VOLUME_ID \
   1.193   -P "$PUBLISHER" -md5-list $REPOS/packages.md5 \
   1.194   -quiet -o $OUTPUT $BOOT_OPT $TEMP_DIR
   1.195  status 
   1.196 @@ -339,11 +360,11 @@
   1.197  
   1.198  cd ${ROOT}
   1.199  echo -n "Create hybrid DVD/CDROM"
   1.200 -[ -x /usr/bin/isohybrid ] && /usr/bin/isohybrid $IMAGE 2> /dev/null
   1.201 +which isohybrid > /dev/null && isohybrid $IMAGE 2> /dev/null
   1.202  status
   1.203  
   1.204  echo -n "Calculate md5sum"
   1.205 -/usr/bin/md5sum $IMAGE > $(basename $IMAGE .iso).md5
   1.206 +md5sum $IMAGE > $(basename $IMAGE .iso).md5
   1.207  status
   1.208  
   1.209  echo -n "Moving file to mirror"