wok rev 25705

fusecloop/extract_compressed_fs: can convert to v0.68 or v1.0
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jun 22 12:48:49 2024 +0000 (6 months ago)
parents d2f587b805fb
children ac7aeefa3415
files BootProg/receipt BootProg/stuff/boot16.asm BootProg/stuff/boot32.asm BootProg/stuff/bootex.asm BootProg/stuff/bootprog.sh fusecloop/stuff/fusecloop.u hiawatha/receipt
line diff
     1.1 --- a/BootProg/receipt	Tue Jun 04 16:57:31 2024 +0000
     1.2 +++ b/BootProg/receipt	Sat Jun 22 12:48:49 2024 +0000
     1.3 @@ -12,7 +12,7 @@
     1.4  
     1.5  bootprog_data()
     1.6  {
     1.7 -	sed "1,2d;s|FAT32SZ|$(stat -c %s boot32.bin)|" $stuff/bootprog.sh
     1.8 +	sed "1,2d;s|FAT32SZ|$(stat -c %s boot32.bin)|" bootprog.sh
     1.9  	cat ${1// /.bin }.bin
    1.10  }
    1.11  
    1.12 @@ -28,11 +28,13 @@
    1.13  	for i in $bs ; do
    1.14  		nasm $i.asm -f bin -o $i.bin -l $i.lst || return 1
    1.15  	done
    1.16 -	sed '1,2!d' $stuff/bootprog.sh > bootprog.lzma
    1.17 -	bootprog_data "$bs" | xz -z --format=lzma --lzma1=lc=0,pb=0,nice=33,dict=4k >> bootprog.lzma
    1.18 +	fna=$((0x$(awk '/times Name/{print $2}' bootex.lst)))
    1.19 +	sed "s|499 count=11;;|$fna count=$((510-$fna));;|" $stuff/bootprog.sh > bootprog.sh
    1.20 +	sed '1,2!d' bootprog.sh > bootprog.lzma
    1.21 +	bootprog_data "$bs" | xz -z --format=lzma --lzma1=lc=0,pb=0,nice=60,dict=4k >> bootprog.lzma
    1.22  	bootprog_data "$bs" | gzip -9 > bootprog.gz
    1.23  	advdef -z4 -i 1200 bootprog.gz
    1.24 -	sed '1,2!d;s|unlzma|zcat|' $stuff/bootprog.sh | cat - bootprog.gz > bootprog.gzip
    1.25 +	sed '1,2!d;s|unlzma|zcat|' bootprog.sh | cat - bootprog.gz > bootprog.gzip
    1.26  	rm bootprog.gz
    1.27  	chmod +x bootprog.lzma bootprog.gzip
    1.28  }
     2.1 --- a/BootProg/stuff/boot16.asm	Tue Jun 04 16:57:31 2024 +0000
     2.2 +++ b/BootProg/stuff/boot16.asm	Sat Jun 22 12:48:49 2024 +0000
     2.3 @@ -19,7 +19,7 @@
     2.4  ;;   Its maximum size can be up to 635KB without Extended BIOS Data area.   ;;
     2.5  ;;                                                                          ;;
     2.6  ;; - Prints an error if the file isn't found or couldn't be read            ;;
     2.7 -;;   ("File not found" or "Read error")                                     ;;
     2.8 +;;   ("No bootfile" or "Read error")                                        ;;
     2.9  ;;   and waits for a key to be pressed, then executes the Int 19h           ;;
    2.10  ;;   instruction and lets the BIOS continue bootstrap.                      ;;
    2.11  ;;                                                                          ;;
    2.12 @@ -324,7 +324,7 @@
    2.13  
    2.14  FindNameFailed:
    2.15          call    Error
    2.16 -        db      "File not found."
    2.17 +        db      "No bootfile."
    2.18  
    2.19  FindNameFound:
    2.20          push    si
     3.1 --- a/BootProg/stuff/boot32.asm	Tue Jun 04 16:57:31 2024 +0000
     3.2 +++ b/BootProg/stuff/boot32.asm	Sat Jun 22 12:48:49 2024 +0000
     3.3 @@ -20,7 +20,7 @@
     3.4  ;;   Its maximum size can be up to 637KB without Extended BIOS Data area.   ;;
     3.5  ;;                                                                          ;;
     3.6  ;; - Prints an error if the file isn't found or couldn't be read            ;;
     3.7 -;;   ("File not found" or "Read error")                                     ;;
     3.8 +;;   ("No bootfile" or "Read error")                                        ;;
     3.9  ;;   and waits for a key to be pressed, then executes the Int 19h           ;;
    3.10  ;;   instruction and lets the BIOS continue bootstrap.                      ;;
    3.11  ;;                                                                          ;;
    3.12 @@ -191,7 +191,9 @@
    3.13  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    3.14  
    3.15          mov     es, ax                  ; cs:0 = ds:0 = ss:0 -> top - 512 - StackSize
    3.16 -%if ExtraBootSector == 0
    3.17 +%if ExtraBootSector != 0
    3.18 +        add     al, 32
    3.19 +%else
    3.20          mov     ss, ax
    3.21          mov     sp, 512+StackSize ; bytes 0-511 are reserved for the boot code
    3.22  %endif
    3.23 @@ -229,7 +231,6 @@
    3.24  %if ExtraBootSector != 0
    3.25  %macro MovedCode 0
    3.26  main:
    3.27 -        add     dl, 32
    3.28          push    dx
    3.29  %else
    3.30  main:
    3.31 @@ -321,7 +322,7 @@
    3.32          jnc     RootDirReadContinue     ; continue to the next root dir cluster
    3.33  ErrFind:
    3.34          call    Error                   ; end of root directory (dir end reached)
    3.35 -        db      "File not found."
    3.36 +        db      "No bootfile."
    3.37  %if ExtraBootSector != 0
    3.38  %endm
    3.39  %macro BootFileName 0
     4.1 --- a/BootProg/stuff/bootex.asm	Tue Jun 04 16:57:31 2024 +0000
     4.2 +++ b/BootProg/stuff/bootex.asm	Sat Jun 22 12:48:49 2024 +0000
     4.3 @@ -19,7 +19,7 @@
     4.4  ;;   Its maximum size can be up to 637KB without Extended BIOS Data area.   ;;
     4.5  ;;                                                                          ;;
     4.6  ;; - Prints an error if the file isn't found or couldn't be read            ;;
     4.7 -;;   ("File not found" or "Read error")                                     ;;
     4.8 +;;   ("No bootfile" or "Read error")                                        ;;
     4.9  ;;   and waits for a key to be pressed, then executes the Int 19h           ;;
    4.10  ;;   instruction and lets the BIOS continue bootstrap.                      ;;
    4.11  ;;                                                                          ;;
    4.12 @@ -80,7 +80,7 @@
    4.13  %define si(label)       si+label-boot
    4.14  NullEntryCheck          equ     1               ; +3/5 bytes
    4.15  ReadRetry               equ     1               ; +7 bytes
    4.16 -SectorOf512Bytes        equ     1               ; -12 bytes
    4.17 +SectorOf512Bytes        equ     0               ; -11 bytes
    4.18  CheckAttrib             equ     0               ; +16/18 bytes
    4.19  WaitForKey              equ     0               ; +5 bytes
    4.20  TfatSupport             equ     1               ; +10 bytes
    4.21 @@ -290,7 +290,14 @@
    4.22          test    byte [si], VolumeLabel+SubDirectory
    4.23  SkipFindName:
    4.24  %endif
    4.25 +%if SectorOf512Bytes == 0
    4.26 +        mov     esi, [bx+StartCluster]
    4.27 +        push    es
    4.28          je      FindNameFound           ; cx = 0
    4.29 +        pop     es
    4.30 +%else
    4.31 +        je      FindNameFound           ; cx = 0
    4.32 +%endif
    4.33          popa                            ; restore ax, cx, si, di
    4.34  
    4.35          add     di, byte 32
    4.36 @@ -302,9 +309,7 @@
    4.37  FindNameFailed:                         ; end of root directory (dir end reached)
    4.38          mov     dl, [bx(DriveNumber)]   ; restore BIOS boot drive number
    4.39          call    Error
    4.40 -        db      "File not found."
    4.41 -FindNameFound:
    4.42 -        mov     esi, [bx+StartCluster]
    4.43 +        db      "No bootfile."
    4.44  
    4.45  ;;;;;;;;;;;;;;;;;;;;;;;;;;
    4.46  ;; Load the entire file ;;
    4.47 @@ -312,15 +317,17 @@
    4.48  ;;        CX  = 0       ;; 
    4.49  ;;;;;;;;;;;;;;;;;;;;;;;;;;
    4.50  
    4.51 -        push    es
    4.52  %if SectorOf512Bytes == 0
    4.53 -        xor     bp, bp
    4.54  FileReadContinue:
    4.55          shr     bp, 4                   ; bytes to paragraphs
    4.56          mov     di, es
    4.57          add     di, bp                  ; adjust segment for next sector
    4.58          mov     es, di                  ; es:0 updated
    4.59 +FindNameFound:
    4.60  %else
    4.61 +FindNameFound:
    4.62 +        mov     esi, [bx+StartCluster]
    4.63 +        push    es
    4.64  FileReadContinue:
    4.65  %endif
    4.66          call    ReadCluster             ; read one more sector of the boot file
    4.67 @@ -579,14 +586,24 @@
    4.68  ;; Fill free space with zeroes ;;
    4.69  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    4.70  
    4.71 -                times (512-13-($-$$)) db 0
    4.72 +;                times (512-13-($-$$)) db 0
    4.73  
    4.74  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    4.75  ;; Name of the file to load and run ;;
    4.76  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    4.77  
    4.78 -NameLength      equ   11
    4.79 -ProgramName     times NameLength db 0   ; name and extension
    4.80 +%if 512-2-($-$$) > 15
    4.81 +NameLength      equ   15
    4.82 +%else
    4.83 +NameLength      equ   512-2-($-$$)
    4.84 +%endif
    4.85 +ProgramName     times NameLength db 0
    4.86 +
    4.87 +%if NameLength < 11
    4.88 +%warning "Short program name"
    4.89 +%endif
    4.90 +
    4.91 +                times (512-2-($-$$)) db 0
    4.92  
    4.93  ;;;;;;;;;;;;;;;;;;;;;;;;;;
    4.94  ;; End of the sector ID ;;
     5.1 --- a/BootProg/stuff/bootprog.sh	Tue Jun 04 16:57:31 2024 +0000
     5.2 +++ b/BootProg/stuff/bootprog.sh	Sat Jun 22 12:48:49 2024 +0000
     5.3 @@ -11,17 +11,17 @@
     5.4  do	[ "${FS:-$($r=5 bs=1 skip=$c)}" = "$f" ] || continue
     5.5  	echo "Install $f bootsector on $1."
     5.6  	for a in "$o skip=$((o+b)) count=$((s-o))" "0 skip=$b count=11"
     5.7 -	do sed '1,/^exit/d' $0 | $w=$a; done
     5.8 -	echo -n $f | $w=$c
     5.9 -	echo "Set boot file $2" && echo -n "$2" | case "$f" in
    5.10 -	E*)	sed 's| |.|;s| ||g' | cat - /dev/zero;;
    5.11 -	*)	tr a-z A-Z | sed 's|\.|       |;s|^\(.\{8\}\) *|\1|;s|$|   |'
    5.12 -	esac | $w=499 count=11
    5.13 -	case "$f" in
    5.14 +	do sed 1,/^exit/d $0|$w=$a;done
    5.15 +	echo -n $f|$w=$c
    5.16 +	echo "Set boot file $2" && echo -n "$2" | case $f in
    5.17 +	E*)	sed 's| |.|;s| ||g'|cat - /dev/zero|$w=499 count=11;;
    5.18 +	*)	tr a-z A-Z|sed 's|\.|       |;s|^\(.\{8\}\) *|\1|;s|$|   |'|$w=499 count=11
    5.19 +	esac
    5.20 +	case $f in
    5.21  	*32)	$w=$(($(od -An -j50 -N2 -d $1)<<9)) if=$1 count=$s;;
    5.22 -	E*)	$r=11 bs=1b | od -vAn -tu1 -w1 - | LANG=C awk '
    5.23 -{ if (++i!=107 && i!=108 && i!=113) a=or(lshift(and(a,1),31),$1+a/2) }
    5.24 -END { b=a/256;c=b/256; for (;i>0;i-=44) printf "%c%c%c%c",a%256,b%256,c%256,(c/256)%256 }' | $w=5632
    5.25 +	E*)	$r=11 bs=1b|od -vAn -tu1 -w1 -|LANG=C awk '
    5.26 +{if(++i!=107&&i!=108&&i!=113)a=or(lshift(and(a,1),31),$1+a/2)}
    5.27 +END{b=a/256;c=b/256;for(;i>0;i-=44)printf "%c%c%c%c",a%256,b%256,c%256,(c/256)%256}'|$w=5632
    5.28  	esac
    5.29  	exit 0
    5.30  done<<s 2>/dev/null
     6.1 --- a/fusecloop/stuff/fusecloop.u	Tue Jun 04 16:57:31 2024 +0000
     6.2 +++ b/fusecloop/stuff/fusecloop.u	Sat Jun 22 12:48:49 2024 +0000
     6.3 @@ -2444,3 +2444,133 @@
     6.4   	if (getenv("CLOOP_TABLE") != NULL) {
     6.5   		fprintf(stderr, "CLOOP_TABLE ascii: offset, size, flags\n");
     6.6   		for (i = 0; i < num_blocks; i++) {
     6.7 +=== convert to v0 and v1 
     6.8 +--- extract_compressed_fs.c
     6.9 ++++ extract_compressed_fs.c
    6.10 +@@ -1,7 +1,8 @@
    6.11 + /* Extracts a filesystem back from a compressed fs file */
    6.12 + #define _LARGEFILE64_SOURCE
    6.13 + #include "common_header.h"
    6.14 +-#define CLOOP_PREAMBLE "#!/bin/sh\n" "#V2.0 Format\n" "modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1\n" "exit $?\n"
    6.15 ++//#define CLOOP_PREAMBLE "#!/bin/sh\n" "#V2.0 Format\n" "modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1\n" "exit $?\n"
    6.16 ++#define CLOOP_PREAMBLE "modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1\n" "exit $?\n"
    6.17 + 
    6.18 + #include "cloopunpack.c"
    6.19 + static char *packnames[CLOOP_COMPRESSOR_MAX+1] = { CLOOP_COMPRESSOR_NAMES };
    6.20 +@@ -72,7 +73,7 @@
    6.21 + {
    6.22 + 	struct cloop_head head;
    6.23 + 	unsigned int i, v4_header_last;
    6.24 +-	unsigned long n, len;
    6.25 ++	unsigned long n, p, len;
    6.26 + 	uLongf ulen;
    6.27 + 	off64_t end;
    6.28 + 
    6.29 +@@ -81,7 +82,8 @@
    6.30 + #ifdef CLOOP_DEBUG
    6.31 + 			"[CLOOP_TAIL=1|CLOOP_ZINDEX=1|CLOOP_INDEX=1|CLOOP_TABLE=1] "
    6.32 + #endif
    6.33 +-			"extract_compressed_fs file [--convert-to-v2] > output\n");
    6.34 ++//			"extract_compressed_fs file [--convert-to-v2] > output\n");
    6.35 ++			"extract_compressed_fs file [--convert-to {0|1|2}] > output\n");
    6.36 + 		exit(1);
    6.37 + 	}
    6.38 + 
    6.39 +@@ -118,7 +120,7 @@
    6.40 + 		void *table;
    6.41 + 		struct cloop_tail tail;
    6.42 + 		unsigned long table_size;
    6.43 +-		
    6.44 ++
    6.45 + 		end = lseek64(handle, 0, SEEK_END);
    6.46 + 		if (lseek64(handle, end - sizeof(tail), SEEK_SET) < 0 ||
    6.47 + 		    read(handle, &tail, sizeof(tail)) != sizeof(tail) ||
    6.48 +@@ -128,6 +130,15 @@
    6.49 + 			exit(1);
    6.50 + 		}
    6.51 + #ifdef CLOOP_DEBUG
    6.52 ++struct cloop_tail
    6.53 ++{
    6.54 ++	u_int32_t table_size; 
    6.55 ++	u_int32_t index_size; /* size:4 unused:3 ctrl-c:1 lastlen:24 */
    6.56 ++#define CLOOP3_INDEX_SIZE(x)    ((unsigned int)((x) & 0xF))
    6.57 ++#define CLOOP3_TRUNCATED(x)     ((unsigned int)((x) & 0x80) >> 7)
    6.58 ++#define CLOOP3_LASTLEN(x)       (unsigned int)((x) >> 8)
    6.59 ++	u_int32_t num_blocks;
    6.60 ++};
    6.61 + 		if (getenv("CLOOP_TAIL") != NULL) {
    6.62 + 			fprintf(stderr, "Table size:32 %u, index_size:4 %u, unused:3\n",
    6.63 + 				tail.table_size,CLOOP3_INDEX_SIZE(tail.index_size));
    6.64 +@@ -183,7 +194,7 @@
    6.65 + 			exit(1);
    6.66 + 		}
    6.67 + 	}
    6.68 +-	
    6.69 ++
    6.70 + 	if (v4_header_last) {
    6.71 + 		lseek64(handle, 0, SEEK_SET);
    6.72 + 	}
    6.73 +@@ -214,24 +225,55 @@
    6.74 + 
    6.75 + 	if (argc > 2) {
    6.76 + 		loff_t data, ofs = ((num_blocks + 1) * sizeof(ofs)) + sizeof(head);
    6.77 ++		unsigned long data32;
    6.78 ++		int version = 2;
    6.79 + 		
    6.80 +-		strcpy(head.preamble, CLOOP_PREAMBLE);
    6.81 ++		memset(head.preamble, 0, sizeof(head.preamble));
    6.82 ++		strcpy(head.preamble, "#!/bin/sh\n");
    6.83 ++		if (argc > 3) {
    6.84 ++			switch (*argv[3]) {
    6.85 ++			case '0':
    6.86 ++				version = 0;
    6.87 ++				ofs = ((num_blocks + 1) * sizeof(data32)) + sizeof(head);
    6.88 ++				break;
    6.89 ++			case '1':
    6.90 ++				version = 1;
    6.91 ++				strcat(head.preamble, "#V1.0 Format\n");
    6.92 ++			}
    6.93 ++		}
    6.94 ++		if (version == 2) {
    6.95 ++			strcat(head.preamble, "#V2.0 Format\n");
    6.96 ++		}
    6.97 ++		strcat(head.preamble, CLOOP_PREAMBLE);
    6.98 + 		write(STDOUT_FILENO, &head, n = sizeof(head));
    6.99 +-		for (i = 0; i < num_blocks; i++) {
   6.100 +-			data = __be64_to_cpu(ofs);
   6.101 +-			write(STDOUT_FILENO, &data, sizeof(data));
   6.102 +-			n += sizeof(data);
   6.103 ++		for (i = 0; i <= num_blocks; i++) {
   6.104 ++			p = n;
   6.105 ++			switch (version) {
   6.106 ++			case 0:
   6.107 ++				data32 = __le32_to_cpu(ofs);
   6.108 ++				n += sizeof(data32);
   6.109 ++				write(STDOUT_FILENO, &data32, sizeof(data32));
   6.110 ++				break;
   6.111 ++			case 1:
   6.112 ++				data = __le64_to_cpu(ofs);
   6.113 ++				n += sizeof(data);
   6.114 ++				write(STDOUT_FILENO, &data, sizeof(data));
   6.115 ++				break;
   6.116 ++			case 2:
   6.117 ++				data = __be64_to_cpu(ofs);
   6.118 ++				n += sizeof(data);
   6.119 ++				write(STDOUT_FILENO, &data, sizeof(data));
   6.120 ++			}
   6.121 + 			if (offsets[i].flags == CLOOP_COMPRESSOR_ZLIB)
   6.122 + 				ofs += offsets[i].size;
   6.123 + 			else
   6.124 + 				ofs += get_block(i,argc);
   6.125 + 		}
   6.126 +-		data = __be64_to_cpu(ofs);
   6.127 +-		write(STDOUT_FILENO, &data, sizeof(data));
   6.128 ++		n = p;
   6.129 + 	}
   6.130 + 	for (i = 0; i < num_blocks; i++) {
   6.131 + 	
   6.132 +-		fprintf(stderr, "Block %u %s at %llu length %lu ",
   6.133 ++		fprintf(stderr, "Block %u %s at %Lu length %u ",
   6.134 + 			i, packnames[offsets[i].flags], offsets[i].offset, offsets[i].size);
   6.135 + 		ulen = get_block(i, argc);
   6.136 + 		fprintf(stderr, " => %lu\n", ulen);
     7.1 --- a/hiawatha/receipt	Tue Jun 04 16:57:31 2024 +0000
     7.2 +++ b/hiawatha/receipt	Sat Jun 22 12:48:49 2024 +0000
     7.3 @@ -7,7 +7,7 @@
     7.4  SHORT_DESC="Advanced and secure webserver."
     7.5  MAINTAINER="pascal.bellard@slitaz.org"
     7.6  LICENSE="GPL2"
     7.7 -WEB_SITE="https://www.hiawatha-webserver.org/"
     7.8 +WEB_SITE="https://hiawatha.leisink.net/"
     7.9  
    7.10  TARBALL="$PACKAGE-$VERSION.tar.gz"
    7.11  WGET_URL="https://hiawatha.leisink.net/files/$TARBALL"