tiny-slitaz rev 27

Multi floppy support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Sep 17 08:38:04 2019 +0200 (2019-09-17)
parents 406c6fe80674
children 912635ac019d
files download.php helper step5.php
line diff
     1.1 --- a/download.php	Sat Sep 07 11:54:26 2019 +0200
     1.2 +++ b/download.php	Tue Sep 17 08:38:04 2019 +0200
     1.3 @@ -25,8 +25,10 @@
     1.4  	case "packag" : download("fs/etc/packages.conf");
     1.5  	case "Config" : shell_exec("sudo ./helper --mkcfg ".$_POST['tmp_dir']); 
     1.6  			download("config_files.cpio.gz");
     1.7 -	case "Floppy" : shell_exec("./helper --mkimg ".$_POST['tmp_dir']); 
     1.8 -			download("slitaz.img");
     1.9 +	case "Floppy" : $n=substr($_POST['download'],6,1);
    1.10 +			shell_exec("./helper --mkimg ".$_POST['tmp_dir']." ".
    1.11 +			$_POST['fdsize']." ".$n); 
    1.12 +			download("floppy".$n.".img");
    1.13  	case "DOS/EX" : shell_exec("./helper --mkexe ".$_POST['tmp_dir']); 
    1.14  			download("slitaz.exe");
    1.15  	case "ISO im" : shell_exec("sudo ./helper --mkiso ".$_POST['tmp_dir']); 
     2.1 --- a/helper	Sat Sep 07 11:54:26 2019 +0200
     2.2 +++ b/helper	Tue Sep 17 08:38:04 2019 +0200
     2.3 @@ -45,7 +45,10 @@
     2.4  		UNPACKED_SIZE='-'
     2.5  		PACKED_SIZE='-'
     2.6  		checked=''; hidden_var=''
     2.7 +		GROUP=
     2.8 +		CATEGORY=
     2.9  		. $i
    2.10 +		[ "$GROUP" ] || GROUP="$CATEGORY"
    2.11  		case " $@ " in
    2.12  			*\ $PACKAGE\ *)	checked='checked="checked"';;
    2.13  			*) [ -n "$2" ] && checked="";;
    2.14 @@ -63,6 +66,7 @@
    2.15  			checked='disabled';;
    2.16  		esac
    2.17  		cat <<EOT
    2.18 +		<!-- $GROUP -->
    2.19  		<tr>
    2.20  			<td>$hidden_var
    2.21  				<input type="checkbox" name="selected[]" value="$PACKAGE" $checked /></td>
    2.22 @@ -166,8 +170,11 @@
    2.23  			pkgs/module-*/receipt);;
    2.24  			*) continue;;
    2.25  		esac
    2.26 +		GROUP=
    2.27 +		CATEGORY=
    2.28  		UNPACKED_SIZE='-'
    2.29  		. $i
    2.30 +		[ "$GROUP" ] || GROUP="$CATEGORY"
    2.31  		checked=''
    2.32  		case " $@ " in
    2.33  			*\ $PACKAGE\ *)	checked='checked="checked"' ;;
    2.34 @@ -175,9 +182,10 @@
    2.35  		grep -qs "^$PACKAGE " $TMPDIR/uploadconf &&
    2.36  			checked='checked="checked"'
    2.37  		cat <<EOT
    2.38 +		<!-- $GROUP -->
    2.39  		<tr>
    2.40  			<td><input type="checkbox" name="selected[]" value="$PACKAGE" $checked/></td>
    2.41 -			<td>${PACKAGE#module-}</td>
    2.42 +			<td><a href="?dl=$PACKAGE-$VERSION&amp;tmp=$TMPDIR">${PACKAGE#module-}</a></td>
    2.43  			<td>$VERSION</td>
    2.44  			<td>$SHORT_DESC</td>
    2.45  			<td>$PACKED_SIZE</td>
    2.46 @@ -378,6 +386,12 @@
    2.47  }
    2.48  
    2.49  
    2.50 +compressto()
    2.51 +{
    2.52 +	[ "$(which zopfli 2> /dev/null)" ] &&
    2.53 +	zopfli --i100 -c /dev/stdin > $1 || gzip -9 > $1
    2.54 +	[ "$(which advdef 2> /dev/null)" ] && advdef -z4 $1 > /dev/null
    2.55 +}
    2.56  
    2.57  
    2.58  case "$1" in
    2.59 @@ -408,17 +422,16 @@
    2.60  		cp ../kernel boot/bzImage
    2.61  	fi
    2.62  	find -user bellard -exec chown root.root {} \;
    2.63 -	find | grep -v ^./boot | cpio -o -H newc | gzip -9 > ../rootfs.gz
    2.64 -	which advdef 2> /dev/null && advdef -z4 ../rootfs.gz
    2.65 +	find | grep -v ^./boot | cpio -o -H newc | compressto ../rootfs.gz
    2.66  fi
    2.67  if [ "x$1" = "x--mkiso" ]; then
    2.68  	tmp=$2
    2.69  	mkdir -p $tmp/iso/boot/isolinux $tmp/iso/data
    2.70 -	cat $tmp/fs/boot/System.map | gzip -9 > $tmp/iso/data/sysmap.gz
    2.71 -	cat $tmp/fs/boot/config | gzip -9 > $tmp/iso/data/linconf.gz
    2.72 -	cat $tmp/fs/boot/config-busybox | gzip -9 > $tmp/iso/data/bbconf.gz
    2.73 +	cat $tmp/fs/boot/System.map | compressto $tmp/iso/data/sysmap.gz
    2.74 +	cat $tmp/fs/boot/config | compressto $tmp/iso/data/linconf.gz
    2.75 +	cat $tmp/fs/boot/config-busybox | compressto $tmp/iso/data/bbconf.gz
    2.76  	cp $tmp/fs/boot/bundle $tmp/iso/data/bundle.sh
    2.77 -	cat $tmp/post_install.log | gzip -9 > $tmp/iso/data/log.gz
    2.78 +	cat $tmp/post_install.log | compressto $tmp/iso/data/log.gz
    2.79  	cp $tmp/config_files $tmp/iso/data/files.cnf
    2.80  	cp $tmp/fs/etc/packages.conf $tmp/iso/data/packages.cnf
    2.81  	[ -s wok/busybox/receipt ] && tar czf $tmp/iso/data/wok.tgz wok/*
    2.82 @@ -427,9 +440,28 @@
    2.83  	cp $tmp/rootfs.gz $tmp/iso/boot/rootfs
    2.84  	cp /boot/isolinux/isolinux.bin $tmp/iso/boot/isolinux
    2.85  	cat > $tmp/iso/boot/isolinux/isolinux.cfg <<EOT
    2.86 -label slitaz
    2.87 +label slitaz slitqw
    2.88  	kernel /boot/bzImage
    2.89  	append initrd=/boot/rootfs rw root=/dev/null vga=normal
    2.90 +
    2.91 +EOT
    2.92 +	while read bin keys; do
    2.93 +		[ -s $tmp/fs/boot/$bin ] &&
    2.94 +		cp $tmp/fs/boot/$bin $tmp/iso/boot/ &&
    2.95 +		KEY="$KEY ${keys%% *}" &&
    2.96 +		cat >> $tmp/iso/boot/isolinux/isolinux.cfg <<EOT
    2.97 +label $keys
    2.98 +	kernel /boot/$bin
    2.99 +
   2.100 +EOT
   2.101 +	done <<EOT
   2.102 +memtest		test memtest mem
   2.103 +ipxe		web zeb ipxe pxe
   2.104 +EOT
   2.105 +	[ -s $tmp/fs/boot/ipxe ] && cp $tmp/fs/boot/ipxe $tmp/iso/boot/ &&
   2.106 +	[ "$KEY" ] && echo "say You can boot: slitaz (default)$KEY" >> \
   2.107 +		$tmp/iso/boot/isolinux/isolinux.cfg
   2.108 +	cat >> $tmp/iso/boot/isolinux/isolinux.cfg <<EOT
   2.109  default slitaz
   2.110  implicit 0	
   2.111  prompt 1	
   2.112 @@ -453,31 +485,35 @@
   2.113  if [ "x$1" = "x--mkimg" ]; then
   2.114  	tmp=$2
   2.115  	cd $tmp
   2.116 -	cp fs/boot/bzImage slitaz.img
   2.117 -	sh fs/boot/bundle slitaz.img rootfs.gz
   2.118 -	if [ -s fs/boot/ipxe ] && [ -s fs/boot/memtest ]; then
   2.119 -		sh fs/boot/bundle out "   SliTaz boot menu" slitaz.img \
   2.120 -			"Tiny SliTaz" fs/boot/ipxe "SliTaz web boot" \
   2.121 -			fs/boot/memtest "Check memory"
   2.122 -	elif [ -s fs/boot/ipxe ]; then
   2.123 -		sh fs/boot/bundle out "   SliTaz boot menu" slitaz.img \
   2.124 -			"Tiny SliTaz" fs/boot/ipxe "SliTaz web boot"
   2.125 -	elif [ -s fs/boot/memtest ]; then
   2.126 -		sh fs/boot/bundle out "   SliTaz boot menu" slitaz.img \
   2.127 -			"Tiny SliTaz" fs/boot/memtest "Check memory"
   2.128 -		mv -f out slitaz.img
   2.129 -	else
   2.130 -		cp slitaz.img out
   2.131 +	if [ ! -s out ]; then
   2.132 +		cp fs/boot/bzImage slitaz.img
   2.133 +		sh fs/boot/bundle slitaz.img rootfs.gz
   2.134 +		if [ -s fs/boot/ipxe ] && [ -s fs/boot/memtest ]; then
   2.135 +			sh fs/boot/bundle out "   SliTaz boot menu" slitaz.img \
   2.136 +				"Tiny SliTaz" fs/boot/ipxe "SliTaz web boot" \
   2.137 +				fs/boot/memtest "Check memory"
   2.138 +		elif [ -s fs/boot/ipxe ]; then
   2.139 +			sh fs/boot/bundle out "   SliTaz boot menu" slitaz.img \
   2.140 +				"Tiny SliTaz" fs/boot/ipxe "SliTaz web boot"
   2.141 +		elif [ -s fs/boot/memtest ]; then
   2.142 +			sh fs/boot/bundle out "   SliTaz boot menu" slitaz.img \
   2.143 +				"Tiny SliTaz" fs/boot/memtest "Check memory"
   2.144 +		else
   2.145 +			mv slitaz.img out
   2.146 +		fi
   2.147  	fi
   2.148 -	[ $(stat -c %s out) -le 1474560 ] && mv -f out slitaz.img || rm -f out
   2.149 -	[ $(stat -c %s slitaz.img) -lt 1474560 ] &&
   2.150 -	dd of=slitaz.img bs=18k seek=80 count=0 2> /dev/null
   2.151 +	rm -f xa* 2> /dev/null
   2.152 +	split -b ${3:-1474560} out
   2.153 +	A="-abcdefghijklmnopqrstuvwxyz"
   2.154 +	mv xa${A:${4:-1}:1} floppy$4.img || mv xaa floppy1.img
   2.155 +	[ $(stat -c %s floppy${4:-1}.img) -lt ${3:-1474560} ] &&
   2.156 +	dd of=floppy${4:-1}.img bs=1 seek=${3:-1474560} count=0 2> /dev/null
   2.157  fi
   2.158  if [ "x$1" = "x--mkcfg" ]; then
   2.159  	tmp=$2
   2.160  	cd $tmp/fs
   2.161  	for i in $(sed 's#^/##' < ../config_files); do find $i; done | \
   2.162 -		sort | uniq | cpio -o -H newc | gzip -9 > ../config_files.cpio.gz
   2.163 +		sort | uniq | cpio -o -H newc | compressto ../config_files.cpio.gz
   2.164  fi
   2.165  if [ "x$1" = "x--chkdist" ]; then
   2.166  	if [ pkgs/busybox-*/fs.cpio.lzma -nt dist/rootfs.cpio ]; then
     3.1 --- a/step5.php	Sat Sep 07 11:54:26 2019 +0200
     3.2 +++ b/step5.php	Tue Sep 17 08:38:04 2019 +0200
     3.3 @@ -20,16 +20,22 @@
     3.4  
     3.5  <table>
     3.6  	<tr><td class="first">Bootable images:</td><td>
     3.7 -
     3.8 +		<div id="floppyset">
     3.9 +		</div>
    3.10 +		<select name="fdsize" id="fdsize" onchange="floppy_form()">
    3.11  <?php
    3.12        $title="Neither Windows nor emm386 supported. Needs a real mode DOS";
    3.13 -      if ((filesize($_POST['tmp_dir']."rootfs.gz") + 
    3.14 -	   filesize($_POST['tmp_dir']."fs/boot/bzImage")) <= 18*80*1024) {
    3.15 -	   $title .= ". Tip: can be split in several boot floppies too";
    3.16 -	    ?>
    3.17 -		<input name="download" value="Floppy image" type="submit"
    3.18 -		       title="You can use dd or rawrite to create the 1.44M floppy disk" />
    3.19 -<?php } ?>
    3.20 +      if (!file_exists($_POST['tmp_dir']."out")) 
    3.21 +	   shell_exec("sudo ./helper --mkimg ".$_POST['tmp_dir']);
    3.22 +      if (!isset($_POST['fdsize'])) $_POST['fdsize']="1474560";
    3.23 +      foreach(array("737280" => "720K", "1228800" => "1.2M",
    3.24 +		    "1474560" => "1.44M", "1720320" => "1.72M",
    3.25 +		    "1966080" => "1.92M", "2949120" => "2.88M") as $sz => $nm) {
    3.26 +	  echo "		<option value=\"$sz\"";
    3.27 +	  if ($sz == $_POST['fdsize']) echo " selected";
    3.28 +	  echo ">$nm</option>\n";
    3.29 +      } ?>
    3.30 +		</select>
    3.31  		<input name="download" value="DOS/EXE" type="submit"
    3.32  		       title="<?php echo $title; ?>" />
    3.33  <?php if (file_exists("/boot/isolinux/isolinux.bin")) {
    3.34 @@ -92,6 +98,28 @@
    3.35  </form>
    3.36  </div>
    3.37  
    3.38 +<script>
    3.39 +function floppy_form()
    3.40 +{
    3.41 +	var fds=document.getElementById("fdsize");
    3.42 +	for (i=1;;i++) {
    3.43 +		element=document.getElementById("Floppy"+i);
    3.44 +		if (element) document.getElementById("floppyset").removeChild(element);
    3.45 +		else break;
    3.46 +	}
    3.47 +	for (i=<?php echo filesize($_POST['tmp_dir']."out"); ?>, j=1; i > 0; j++, i -= fds.value) {
    3.48 +		var element = document.createElement("input");
    3.49 +		element.name = "download";
    3.50 +		element.type = "submit";
    3.51 +		element.value = element.id = "Floppy"+j;
    3.52 +		element.title = "You can use dd or rawrite to create the floppy disk";
    3.53 +		document.getElementById("floppyset").appendChild(element);
    3.54 +	}
    3.55 +}
    3.56 +
    3.57 +floppy_form();
    3.58 +</script>
    3.59 +
    3.60  <h2>Going further</h2>
    3.61  
    3.62  <p>Tiny SliTaz should be smaller to have more functionality and/or needs less