wok-tiny rev 141

linux: pack setup (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jul 07 11:56:18 2018 +0200 (10 months ago)
parents d71bd8881bcd
children 3de5e6325aab
files linux/receipt linux/stuff/pack linux/stuff/unpacklz4.S
line diff
     1.1 --- a/linux/receipt	Wed Jul 04 20:33:53 2018 +0200
     1.2 +++ b/linux/receipt	Sat Jul 07 11:56:18 2018 +0200
     1.3 @@ -24,7 +24,8 @@
     1.4  
     1.5  S2bin()
     1.6  {
     1.7 -	cc -o $1.o -Wa,-algms=$1.lst -c $stuff/$1.S
     1.8 +	[ -s $stuff/$1.S ] &&
     1.9 +	cc -o $1.o -Wa,-algms=$1.lst -c $stuff/$1.S &&
    1.10  	objcopy -O binary $1.o $1.bin
    1.11  }
    1.12  
    1.13 @@ -36,25 +37,28 @@
    1.14  	bzcat $SRC/$(basename $PATCH) | patch -p1
    1.15  	patch -p0 < $stuff/linux-2.6.14-unpack.u
    1.16  	patch -p0 < $stuff/jsclipboard.u
    1.17 -	sed -i 's|\([>\.]\)val|\1u.val|;s|\([>\.]\)next|\1u.next|;216s|};|} u;|' lib/inflate.c
    1.18 +	sed -i 's|\([>\.]\)val|\1u.val|;s|\([>\.]\)next|\1u.next|;216s|};|} u;|' \
    1.19 +		lib/inflate.c
    1.20  	sed '/DEBUG/,/* kstrdup/d' < mm/slab.c > mm/kstrdup.c
    1.21  	echo 'obj-y += kstrdup.o' >> mm/Makefile
    1.22  	sed -i 's|3.1024|11*256|' arch/i386/boot/compressed/misc.c
    1.23  	sed -i 's/O_CREAT/&|O_TRUNC/' init/initramfs.c
    1.24  	which advdef 2> /dev/null &&
    1.25 -	sed -i 's|gzip)|&\n	advdef -z4 $@|' usr/Makefile arch/i386/boot/compressed/Makefile
    1.26 +	sed -i 's|gzip)|&\n	advdef -z4 $@|' \
    1.27 +		usr/Makefile arch/i386/boot/compressed/Makefile
    1.28  	which zopfli 2> /dev/null &&
    1.29  	sed -i 's|gzip -f -9 <|time zopfli --i100 -c|' scripts/Makefile.lib
    1.30  
    1.31 -	if [ ! -s $WOK/busybox/source/busybox*/rootfs.cpio ]; then
    1.32 -		tazwok cook busybox
    1.33 -	fi
    1.34 +	[ -s $WOK/busybox/source/busybox*/rootfs.cpio ] || tazwok cook busybox
    1.35  	cp $WOK/busybox/source/busybox*/rootfs.cpio $src
    1.36  	cp $WOK/busybox/source/busybox*/.config $src/config-busybox
    1.37  	mkdir $src/slitaz
    1.38  	cp $stuff/list_modules.sh $src/slitaz
    1.39  	S2bin bootloader
    1.40 +	S2bin helper
    1.41  	S2bin unpacklz4
    1.42 +	cp $stuff/pack .
    1.43 +	./pack --build
    1.44  
    1.45  	sed -i '/config %config:/{NNNps/config %config:/%config:/}' Makefile
    1.46  	sed -i 's/^config %config:/config:/' Makefile
    1.47 @@ -77,7 +81,7 @@
    1.48  	cp -a $src/arch/i386/boot/bzImage $fs/boot/
    1.49  	dd if=$src/bootloader.bin of=$fs/boot/bzImage conv=notrunc
    1.50  	dd if=$src/cmdline.bin bs=1 seek=560 of=$fs/boot/bzImage conv=notrunc
    1.51 -	#( cd $src ; $stuff/pack $fs/boot/bzImage )
    1.52 +	cp -a $src/pack $fs/boot/
    1.53  	cp -a $src/System.map $fs/boot/
    1.54  	cp -a $src/.config $fs/boot/config
    1.55  	cp -a $src/config-busybox $fs/boot
    1.56 @@ -87,31 +91,34 @@
    1.57  # Pre and post install commands for Tazpkg.
    1.58  post_install()
    1.59  {
    1.60 -    echo "Processing post-install commands..."
    1.61 -    chroot "$1/" /boot/depmod -a $VERSION-slitaz
    1.62 -    [ -s $1/boot/cmdline ] && cat $1/boot/cmdline | sed 's/^ *//' | \
    1.63 -	dd of=$1/boot/bzImage conv=notrunc bs=1 seek=768 count=3072
    1.64 -    # GRUB stuff.
    1.65 -    if [ -f "$1/boot/grub/menu.lst" ]; then
    1.66 -    	root_dev=`cat $1/boot/grub/menu.lst | grep root= | sed 's/.*root=\([^ ]*\).*/\1/' | head -n 1`
    1.67 -		grub_dev=`cat $1/boot/grub/menu.lst | grep "root (" | head -n 1`
    1.68 +	echo "Processing post-install commands..."
    1.69 +	chroot "$1/" /boot/depmod -a $VERSION-slitaz
    1.70 +	[ -s $1/boot/cmdline ] && cat $1/boot/cmdline | sed 's/^ *//' | \
    1.71 +	dd of=$1/boot/bzImage conv=notrunc bs=1 seek=768 count=3072 2> /dev/null
    1.72 +	$1/boot/pack $1/boot/bzImage
    1.73 +
    1.74 +	# GRUB stuff.
    1.75 +	if [ -f "$1/boot/grub/menu.lst" ]; then
    1.76 +		root_dev=$(sed '/root=/!d;s/.*root=\([^ ]*\).*/\1/' \
    1.77 +				< $1/boot/grub/menu.lst | head -n 1)
    1.78 +		grub_dev=$(grep "root (" < $1/boot/grub/menu.lst | head -n 1)
    1.79  		# Add new kernel entry in case of upgrade for installed system.
    1.80 -		if ! grep -q $SOURCE-$VERSION-slitaz $1/boot/grub/menu.lst; then
    1.81 -    		cat >> $1/boot/grub/menu.lst << EOT
    1.82 +		grep -q $SOURCE-$VERSION-slitaz $1/boot/grub/menu.lst ||
    1.83 +		[ -s $1/boot/cmdline ] && cmdline=" $(cat $1/boot/cmdline)"
    1.84 +		cat >> $1/boot/grub/menu.lst << EOT
    1.85  
    1.86  title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
    1.87  $grub_dev
    1.88 -kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
    1.89 +kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev$cmdline
    1.90  EOT
    1.91 -		fi
    1.92  		# Display information message.
    1.93 -    	cat <<EOT
    1.94 +		cat <<EOT
    1.95  ----
    1.96  GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
    1.97  
    1.98  title  SliTaz GNU/Linux (Kernel $VERSION-slitaz)
    1.99  $grub_dev
   1.100 -kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
   1.101 +kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev$cmdline
   1.102  ----
   1.103  EOT
   1.104  	fi
     2.1 --- a/linux/stuff/pack	Wed Jul 04 20:33:53 2018 +0200
     2.2 +++ b/linux/stuff/pack	Sat Jul 07 11:56:18 2018 +0200
     2.3 @@ -1,5 +1,13 @@
     2.4  #!/bin/sh
     2.5  
     2.6 +if [ "$1" == "--build" ]; then	#install-begin
     2.7 +	uuencode -m - < unpacklz4.bin | sed -e '/^unpacklz4\.bin$/r/dev/stdin' \
     2.8 +		-e '/^unpacklz4\.bin$/d' -i $0
     2.9 +	cat helper.bin 2>/dev/null | uuencode -m - | sed -e \
    2.10 +		'/^helper\.bin$/r/dev/stdin' -e '/^helper\.bin$/d' -i $0
    2.11 +	sed '/install-begin$/,/install-end$/d' -i $0
    2.12 +	exit
    2.13 +fi	#install-end
    2.14  ddq()
    2.15  {
    2.16  	dd "$@" 2> /dev/null
    2.17 @@ -23,12 +31,14 @@
    2.18  	echo $(od -j $(($1)) -N ${3:-2} -t u${3:-2} -An "$2")
    2.19  }
    2.20  
    2.21 -if [ ! -s "$1" ]; then
    2.22 -	cat << EOT
    2.23 -Usage: $0 bzImage [bootsector helper] [bootsector]
    2.24 +helper()
    2.25 +{
    2.26 +uudecode << EOT
    2.27 +helper.bin
    2.28  EOT
    2.29 -	exit 1
    2.30 -fi
    2.31 +}
    2.32 +
    2.33 +[ ! -s "$1" ] && echo "Usage: $0 bzImage" && exit 1
    2.34  
    2.35  if which lz4 > /dev/null ; then
    2.36  
    2.37 @@ -37,7 +47,9 @@
    2.38  ddq if=$1 bs=1 count=$param > /tmp/setup$$
    2.39  
    2.40  # unlz4 + data
    2.41 -ddq if=unpacklz4.bin >> /tmp/setup$$
    2.42 +uudecode >> /tmp/setup$$ << EOT
    2.43 +unpacklz4.bin
    2.44 +EOT
    2.45  setupsz=$(get 0x1F1 $1 1)
    2.46  ddq if=$1 bs=1 skip=$param count=$(($setupsz*512-$param+512)) | \
    2.47  	lz4 -l -12 | ddq bs=4 skip=1 >> /tmp/setup$$
    2.48 @@ -45,6 +57,7 @@
    2.49  # version string
    2.50  word $(get 0x20E $1) >> /tmp/setup$$
    2.51  word $setupsz 1 >> /tmp/setup$$
    2.52 +setupend=$(stat -Lc %s "/tmp/setup$$")
    2.53  versionofs=
    2.54  version="$(ddq if=$1 bs=1 skip=$((0x200+$(get 0x20E $1))) | strings | sed q)"
    2.55  if grep --help 2>&1 | grep -q byte-offset; then
    2.56 @@ -56,18 +69,18 @@
    2.57  fi
    2.58  store 0x20E $(($versionofs-512)) /tmp/setup$$
    2.59  
    2.60 -helpersz=0
    2.61 -[ -n "$2" ] && helpersz=$(stat -Lc %s "$2")
    2.62 +helpersz=$(helper | wc -c)
    2.63  newsetupsz=$((($(stat -c %s /tmp/setup$$)+$helpersz-1)/512))
    2.64  [ $newsetupsz -lt 4 ] && newsetupsz=4
    2.65 -store 0x1F1 $newsetupsz /tmp/setup$$ 1
    2.66  
    2.67  if [ $newsetupsz -lt $setupsz ]; then
    2.68 -	ddq of=/tmp/setup$$ bs=512 seek=$(($newsetupsz+1)) count=0
    2.69 -	[ -n "$2" ] && ddq if="$2" bs=1 of=/tmp/setup$$ \
    2.70 +	while [ $(($setupend + $helpersz)) -gt $((512 + 512*$newsetupsz)) ]; do
    2.71 +		newsetupsz=$(($newsetupsz+1))
    2.72 +	done
    2.73 +#	ddq of=/tmp/setup$$ bs=512 seek=$(($newsetupsz+1)) count=0
    2.74 +	store 0x1F1 $newsetupsz /tmp/setup$$ 1
    2.75 +	helper | ddq bs=1 of=/tmp/setup$$ \
    2.76  		seek=$((512 + 512*$newsetupsz - $helpersz))
    2.77 -	[ -n "$3" ] && [ $(stat -Lc %s "$3") -eq 497 ] &&
    2.78 -		ddq if="$3" conv=notrunc of=/tmp/setup$$
    2.79  	ddq if=$1 bs=512 skip=$((1+$setupsz)) >> /tmp/setup$$
    2.80  	cp /tmp/setup$$ $1
    2.81  fi
     3.1 --- a/linux/stuff/unpacklz4.S	Wed Jul 04 20:33:53 2018 +0200
     3.2 +++ b/linux/stuff/unpacklz4.S	Sat Jul 07 11:56:18 2018 +0200
     3.3 @@ -5,6 +5,7 @@
     3.4  
     3.5  #define LZMA		0
     3.6  #define HOLE		0x4000
     3.7 +#define DS_OFS		0x0200
     3.8  
     3.9  start:
    3.10  	cld
    3.11 @@ -17,12 +18,12 @@
    3.12  	rep movsb %ds:(%si), %es:(%di)	// move setup
    3.13  	pushw	%cs			// CS
    3.14  	pushw	%cx			// IP = 0
    3.15 +	//pushaw
    3.16  	call	packed_moved
    3.17  next:
    3.18  	popw	%bx
    3.19 -	//leaw	packed-next(%bx,%si), %si
    3.20 -	.byte	0x8D,0x70,packed-next
    3.21 -	leaw	start-next(%bx), %di
    3.22 +	leaw	DS_OFS+start-next(%bx), %di
    3.23 +	leaw	DS_OFS+packed-next(%bx,%si), %si
    3.24  #if LZMA
    3.25  	call	unlzma
    3.26  #else
    3.27 @@ -101,13 +102,11 @@
    3.28  	jb	lz4string
    3.29  #endif
    3.30  done:
    3.31 -	movw	$0x000E, %di
    3.32 +	movw	$0x020E, %di
    3.33  	movsw				// version string
    3.34 -	//movw	%ds, %ax
    3.35 -	//decw	%ax
    3.36 -	//movw	%ax, %es
    3.37 -	//movw	$0x0001, %di
    3.38 -	//movsb				// setup size
    3.39 +	movw	$0x01F1, %di
    3.40 +	movsb				// setup size
    3.41 +	//popaw
    3.42  	retf
    3.43  
    3.44  #if LZMA