slitaz-forge rev 716

mirror/floppies: multi-format support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jul 23 16:41:12 2021 +0000 (11 months ago)
parents cfad9fa3f53c
children 291e2d88bab3
files mirror/floppies/format.js mirror/floppies/mkfdrolling.sh mirror/floppies/mkindex.sh mirror/floppies/sets.sh mirror/info/graphs.php mirror/info/index.php tank/web/graphs.php tank/web/index.php
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mirror/floppies/format.js	Fri Jul 23 16:41:12 2021 +0000
     1.3 @@ -0,0 +1,79 @@
     1.4 +window.URL = window.URL || window.webkitURL;
     1.5 +function download(ref, range, name) {
     1.6 +	var xhr = new XMLHttpRequest();
     1.7 +      
     1.8 +	xhr.open('GET', ref, true);
     1.9 +	xhr.setRequestHeader("Range", "bytes="+range);
    1.10 +	xhr.responseType = 'blob';
    1.11 +	xhr.onload = function () {
    1.12 +	    var a = document.createElement('a'), file;
    1.13 +	    file = new Blob([xhr.response], { type : 'application/octet-stream' });
    1.14 +	    a.href = window.URL.createObjectURL(file);
    1.15 +	    a.download = name;
    1.16 +	    a.click();
    1.17 +	};
    1.18 +	xhr.send();
    1.19 +}
    1.20 +
    1.21 +function format(size) {
    1.22 +	var max = sets[sets.length-1];
    1.23 +	var cols = Math.floor(Math.sqrt(max/size)+2);
    1.24 +	var lines = Math.floor(((max/size)+1)/cols+1);
    1.25 +	var e = document.getElementById('floppies');
    1.26 +	var s, i, j, ofs, fd, fds, curset;
    1.27 +	for (i = 0, ofs = 0, curset = 0, fd = 1, s = ""; i < lines; i++) {
    1.28 +		s += "<tr>";
    1.29 +		for (j = 0; j < cols; j++) {
    1.30 +			fds = ""+fd; if (fd < 100) fds = "0"+fds; if (fd < 10) fds = "0"+fds;
    1.31 +			s += "<td>";
    1.32 +			if (ofs < max) {
    1.33 +				s += "<a href=\"javascript:download('"+dir+"/fd.img', '"+ofs+"-";
    1.34 +				ofs = Number.parseInt(ofs)+Number.parseInt(size);
    1.35 +				s += (ofs-1)+"', 'fd"+fds+".img')\">fd"+fds+"</a>";
    1.36 +				if (ofs >= sets[curset]) {
    1.37 +					curset++;
    1.38 +					fd = (Math.floor(fd/100)+1)*100;
    1.39 +				} else fd++;
    1.40 +			}
    1.41 +			if (i == lines-1 && j == cols-1) {
    1.42 +				s += "<a href=\""+dir+"/"+size+"/md5sum\">md5</a>"
    1.43 +			}
    1.44 +			s += "</td>";
    1.45 +		}
    1.46 +		s += "</tr>";
    1.47 +	}
    1.48 +	e.innerHTML = s;
    1.49 +	for (i = 0, ofs = 0, curset = 0, fd = 0; ofs < max;) {
    1.50 +		i++; fd++;
    1.51 +		ofs = Number.parseInt(ofs)+Number.parseInt(size);
    1.52 +		if (ofs >= sets[curset]) {
    1.53 +			fds = ""+fd; if (fd < 100) fds = "0"+fds; if (fd < 10) fds = "0"+fds;
    1.54 +			e = document.getElementById('cnt'+curset);
    1.55 +			if (e) e.innerHTML = i;
    1.56 +			e = document.getElementById('last'+curset);
    1.57 +			if (e) e.innerHTML = fds;
    1.58 +			curset++;
    1.59 +			fd = (Math.floor(fd/100)+1)*100-1;
    1.60 +		}
    1.61 +	}
    1.62 +}
    1.63 +
    1.64 +var e = document.getElementById('format');
    1.65 +try {
    1.66 +	var dummy = new Blob();
    1.67 +	e.innerHTML="<select onChange='format(this.value)' style='background: #666; color: #FFF;'>" +
    1.68 +		"<option value='368640' title='/dev/fd0h360 (2,20) or /dev/fd0d360 (2,4) 5¼'>360K</option>" +
    1.69 +		"<option value='737280' title='/dev/fd0u720 3½ DD (2,16)'>720K</option>" +
    1.70 +		"<option value='819200' title='/dev/fd0u800 3½ DD (2,120)'>800K</option>" +
    1.71 +		"<option value='1228800' title='/dev/fd0h1200 5¼ (2,8)'>1.2MB</option>" +
    1.72 +		"<option value='1474560' title='/dev/fd0u1440 3½ HD (2,28) or /dev/fd0h1440 5¼ (2,40)' selected>1.44MB</option>" +
    1.73 +		"<option value='1638400' title='/dev/fd0u1600 3½ HD (2,124) or /dev/fd0h1600 5¼ (2,92)'>1.60MB</option>" +
    1.74 +		"<option value='1720320' title='/dev/fd0u1680 3½ HD (2,44)'>1.68MB</option>" +
    1.75 +		"<option value='1966080' title='/dev/fd0u1920 3½ HD (2,100)'>1.92MB</option>" +
    1.76 +		"<option value='2949120' title='/dev/fd0u2880 3½ ED (2,32)'>2.88MB</option>" +
    1.77 +		"<option value='3932160' title='/dev/fd0u3840 3½ ED (2,112)'>3.84MB</option>" +
    1.78 +		"</select>";
    1.79 +}
    1.80 +catch (err) {
    1.81 +	e.innerHTML="1.44MB"; 
    1.82 +}
     2.1 --- a/mirror/floppies/mkfdrolling.sh	Mon Feb 01 10:57:24 2021 +0000
     2.2 +++ b/mirror/floppies/mkfdrolling.sh	Fri Jul 23 16:41:12 2021 +0000
     2.3 @@ -19,7 +19,7 @@
     2.4  		mtime=$(LC_ALL=C date '+%d %B %Y' -d $mtime)
     2.5  	set -- $(sed '/ifmem/!d;s/.*ifmem //' $mnt/boot/isolinux/isolinux.cfg \
     2.6  		| sed 's|^|echo |;s|\([0-9][0-9]*\) |$((\1/1024))M |g' | sh)
     2.7 -	umount $mnt
     2.8 +	umount $mnt 2> /dev/null || umount -l $mnt
     2.9  	rmdir $mnt
    2.10  		cat > description.html <<EOT
    2.11  <p>This floppy set uses the BIOS instead of the linux driver. You can boot
    2.12 @@ -41,9 +41,9 @@
    2.13  			eval flavor=\$$((($n - $i)*2))
    2.14  			eval ram=\$$((($n - $i)*2 -1))
    2.15  			cat >> description.html <<EOT
    2.16 -	<li><b>$flavor</b> needs ${ram}B of RAM and $(ls fd* | \
    2.17 -		awk "/fd$(($i+1))/{q=1}{if(!q)n++}END{print n}") floppies:
    2.18 -		<tt>fd001.img</tt> to <tt>$(ls -r fd${i}* | sed q)</tt>.<br>
    2.19 +	<li><b>$flavor</b> needs ${ram}B of RAM and <span id="cnt$i">$(ls fd* | \
    2.20 +		awk "/fd$(($i+1))/{q=1}{if(!q)n++}END{print n}")</span> floppies:
    2.21 +		<tt>fd001.img</tt> to <tt>fd<span id="last$i">$(ls -r fd${i}* | sed 's|fd||;s|.img||;q')</span>.img</tt>.<br>
    2.22  		$flavor provides $(while read f d; do 
    2.23  			[ $f = $flavor ] && echo $d; done <<EOT
    2.24  base the minimum SliTaz distribution subset in text mode
     3.1 --- a/mirror/floppies/mkindex.sh	Mon Feb 01 10:57:24 2021 +0000
     3.2 +++ b/mirror/floppies/mkindex.sh	Fri Jul 23 16:41:12 2021 +0000
     3.3 @@ -12,6 +12,7 @@
     3.4  
     3.5  build_page() {
     3.6  	DIR=$1
     3.7 +	SETS="$(echo $(./sets.sh $1))"
     3.8  	case "$DIR" in
     3.9  	*.*)	stable=stable;;
    3.10  	*)	stable=development;;
    3.11 @@ -138,11 +139,12 @@
    3.12  
    3.13  	<!-- Navigation -->
    3.14  	<nav>
    3.15 -		<header>1.44MB SliTaz$TYPE $VERSION floppy images</header>
    3.16 -		<div class="large"><table>
    3.17 +		<header><span id="format">1.44MB</span> SliTaz$TYPE $VERSION floppy images</header>
    3.18 +			
    3.19 +		<div class="large"><table id="floppies">
    3.20  $(
    3.21  n=0
    3.22 -for f in $DIR/fd*img ; do
    3.23 +for f in $DIR/fd???.img ; do
    3.24  	[ $n -eq 0 ] && echo "			<tr>"
    3.25  	echo "				<td><a href=\"$f\">$(basename $f .img)</a></td>"
    3.26  	n=$(( ($n+1)%6 ))
    3.27 @@ -160,6 +162,16 @@
    3.28  	</nav>
    3.29  </div></div>
    3.30  
    3.31 +EOT
    3.32 +	[ -n "$SETS" ] && cat <<EOT
    3.33 +<script type="text/javascript">
    3.34 +var dir = "$VERSION";
    3.35 +var sets = [${SETS// /,}];
    3.36 +//-->
    3.37 +</script>
    3.38 +<script type="text/javascript" src="format.js"></script>
    3.39 +EOT
    3.40 +	cat <<EOT
    3.41  
    3.42  <!-- Content -->
    3.43  <main>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/mirror/floppies/sets.sh	Fri Jul 23 16:41:12 2021 +0000
     4.3 @@ -0,0 +1,72 @@
     4.4 +#!/bin/sh
     4.5 +
     4.6 +get()
     4.7 +{
     4.8 +	hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %u\n\"" "$2"
     4.9 +}
    4.10 +
    4.11 +n=$((1 + $(get 497 $1/fd001.img 1) + 1 + ($(get 500 $1/fd001.img 4)-1)/32))
    4.12 +last=$(($n*512))
    4.13 +first=$last
    4.14 +dir=$1
    4.15 +n=$((512*$(get 497 $1/fd001.img 1) + 512 - 20))
    4.16 +SET=""
    4.17 +if [ -s $1/fd100.img ]; then
    4.18 +	for i in 0 1 2 3; do
    4.19 +		x=$(get $n $1/fd001.img 4)
    4.20 +		last=$(($last+$x))
    4.21 +		[ $x -eq 0 ] && SET="" && break
    4.22 +		SET="$SET $last"
    4.23 +		n=$(($n+4))
    4.24 +	done
    4.25 +	file=$1/fd.img
    4.26 +	cat $1/fd???.img > $file
    4.27 +	set -- $first $SET
    4.28 +	while [ -n "$2" ]; do
    4.29 +		n=$(get $1 $file)
    4.30 +		shift
    4.31 +		case $n in
    4.32 +		\ 14128|\ 93) continue ;;
    4.33 +		esac
    4.34 +		rm $file
    4.35 +		SET=""
    4.36 +		break
    4.37 +	done
    4.38 +else
    4.39 +	if [ $(get 494 $1/fd001.img) -eq 490 ]; then
    4.40 +		SET="$(($first+$(get 490 $1/fd001.img 4)))"
    4.41 +		cat $1/fd???.img > $1/fd.img
    4.42 +		set -- $SET
    4.43 +	fi
    4.44 +fi
    4.45 +if [ -n "$SET" ]; then
    4.46 +	size=$1
    4.47 +	best=$1
    4.48 +	cd $dir
    4.49 +	for i in $(sed '/option value/!d;s|.*value=.||;s|. title.*||' ../format.js); do
    4.50 +		s=$((((($size-1)/$i)+1)*$i))
    4.51 +		[ $s -gt $best ] && best=$s
    4.52 +		dd of=fd.img bs=1 count=0 seek=$s 2> /dev/null
    4.53 +		[ -d $i ] || mkdir $i
    4.54 +		cd $i
    4.55 +		split -b $i ../fd.img xx
    4.56 +		set -- $SET
    4.57 +		n=1; sz=0
    4.58 +		ls xx* | while read x; do
    4.59 +			mv $x $(printf "fd%03d.img" $n)
    4.60 +			n=$(($n+1))
    4.61 +			sz=$(($sz+$i))
    4.62 +			if [ $sz -ge $1 ]; then
    4.63 +				n=$(($n-($n%100)+100))
    4.64 +				shift
    4.65 +				[ -n "$1" ] || break
    4.66 +			fi
    4.67 +		done
    4.68 +		md5sum fd* > md5sum
    4.69 +		rm fd*
    4.70 +		cd ..
    4.71 +	done
    4.72 +	dd of=fd.img bs=1 count=0 seek=$best 2> /dev/null
    4.73 +	cd ..
    4.74 +	echo $SET
    4.75 +fi
     5.1 --- a/mirror/info/graphs.php	Mon Feb 01 10:57:24 2021 +0000
     5.2 +++ b/mirror/info/graphs.php	Fri Jul 23 16:41:12 2021 +0000
     5.3 @@ -36,10 +36,11 @@
     5.4  	<!-- Information/image -->
     5.5  	<div class="block_info">
     5.6  		<header>Codename: <?php echo $host; ?></header>
     5.7 +		<p>
     5.8 +			This is the SliTaz GNU/Linux main mirror. The server runs naturally 
     5.9 +			SliTaz (stable) in a virtual machine gracefully hosted by 
    5.10 +			<a href="https://www.linkedin.com/company/balinor-technologies/">balinor-technologies</a>.
    5.11  		</p>
    5.12 -			<p>This is the SliTaz GNU/Linux main mirror. The server runs naturally 
    5.13 -			SliTaz (stable) in a virtual machine gracefully hosted by 
    5.14 -			<a href="https://www.linkedin.com/company/balinor-technologies/">balinor-technologies</a>.</p>
    5.15  		<p>
    5.16  			Mirror CPU is a <?php
    5.17  system("( sed '/cpuinfo=/!d;" .
     6.1 --- a/mirror/info/index.php	Mon Feb 01 10:57:24 2021 +0000
     6.2 +++ b/mirror/info/index.php	Fri Jul 23 16:41:12 2021 +0000
     6.3 @@ -40,10 +40,11 @@
     6.4  	<!-- Top block begin -->
     6.5  	<div class="block_info">
     6.6  		<header>Codename: <?php echo $host; ?></header>
     6.7 +		<p>
     6.8 +			This is the SliTaz GNU/Linux main mirror. The server runs naturally 
     6.9 +			SliTaz (stable) in a virtual machine gracefully hosted by 
    6.10 +			<a href="https://www.linkedin.com/company/balinor-technologies/">balinor-technologies</a>.
    6.11  		</p>
    6.12 -			<p>This is the SliTaz GNU/Linux main mirror. The server runs naturally 
    6.13 -			SliTaz (stable) in a virtual machine gracefully hosted by 
    6.14 -			<a href="https://www.linkedin.com/company/balinor-technologies/">balinor-technologies</a>.</p>
    6.15  		<p>Mirror CPU is a <?php
    6.16  system("( sed '/cpuinfo=/!d;" .
    6.17  	"s/.*cpuinfo=\\([^ ]*\).*/: \\1/;s/_/ /g' /proc/cmdline ; grep '^model name' /etc/cpuinfo) | sed -e 's/.*Intel(R) //;" .
     7.1 --- a/tank/web/graphs.php	Mon Feb 01 10:57:24 2021 +0000
     7.2 +++ b/tank/web/graphs.php	Fri Jul 23 16:41:12 2021 +0000
     7.3 @@ -38,11 +38,9 @@
     7.4  			Tank CPU is a <?php system("sed -e '/^model name/!d;s/.*Intel(R) //;" .         
     7.5  			"s/@//;s/(.*)//;s/CPU //;s/.*AMD //;s/.*: //;s/Processor //' </etc/cpuinfo |" .
     7.6  			" awk '{ s=$0; n++ } END { if (n == 2) printf \"dual \";" .
     7.7 -			"if (n == 4) printf \"quad \"; print s }' ")?> -
     7.8 -			<?php system("free | awk '/Mem:/ { x=2*$2-1; while (x >= 1024) { x /= 1024; ".
     7.9 -			"n++ }; y=1; while (x > 2) { x /= 2; y *= 2}; ".
    7.10 -			"printf \"%d%cB RAM\",y,substr(\"MG\",n,1) }' ")?>  - Located in Paris,
    7.11 -			France.
    7.12 +			"if (n == 4) printf \"quad \"; if (n == 8) printf \"octo \"; print s }' ")?> -
    7.13 +			<?php system("free -g | awk '/Mem:/ { print $2 \"GB RAM\" }'")?> -
    7.14 +			Located in Paris, France.
    7.15  		</p>
    7.16  	</div>
    7.17  </div>
     8.1 --- a/tank/web/index.php	Mon Feb 01 10:57:24 2021 +0000
     8.2 +++ b/tank/web/index.php	Fri Jul 23 16:41:12 2021 +0000
     8.3 @@ -48,11 +48,9 @@
     8.4  			Tank CPU is a <?php system("sed -e '/^model name/!d;s/.*Intel(R) //;" .         
     8.5  			"s/@//;s/(.*)//;s/CPU //;s/.*AMD //;s/.*: //;s/Processor //' </etc/cpuinfo |" .
     8.6  			" awk '{ s=$0; n++ } END { if (n == 2) printf \"dual \";" .
     8.7 -			"if (n == 4) printf \"quad \"; print s }' ")?> -
     8.8 -			<?php system("free | awk '/Mem:/ { x=2*$2-1; while (x >= 1024) { x /= 1024; ".
     8.9 -			"n++ }; y=1; while (x > 2) { x /= 2; y *= 2}; ".
    8.10 -			"printf \"%d%cB RAM\",y,substr(\"MG\",n,1) }' ")?>  - Located in Paris,
    8.11 -			France. Tank is also monitored by RRDtool which provides 
    8.12 +			"if (n == 4) printf \"quad \"; if (n == 8) printf \"octo \"; print s }' ")?> -
    8.13 +			<?php system("free -g | awk '/Mem:/ { print $2 \"GB RAM\" }'")?> -
    8.14 +			Located in Paris, France. Tank is also monitored by RRDtool which provides 
    8.15  			<a href="graphs.php">graphical stats</a>.
    8.16  		</p>
    8.17  	</div>