# HG changeset patch # User Pascal Bellard # Date 1530957378 -7200 # Node ID d22f6fcf51da6c96df904b2cf9ac84fc57f5a2e0 # Parent d71bd8881bcd20bf8440c04f63d6a28eac78ba5c linux: pack setup (again) diff -r d71bd8881bcd -r d22f6fcf51da linux/receipt --- a/linux/receipt Wed Jul 04 20:33:53 2018 +0200 +++ b/linux/receipt Sat Jul 07 11:56:18 2018 +0200 @@ -24,7 +24,8 @@ S2bin() { - cc -o $1.o -Wa,-algms=$1.lst -c $stuff/$1.S + [ -s $stuff/$1.S ] && + cc -o $1.o -Wa,-algms=$1.lst -c $stuff/$1.S && objcopy -O binary $1.o $1.bin } @@ -36,25 +37,28 @@ bzcat $SRC/$(basename $PATCH) | patch -p1 patch -p0 < $stuff/linux-2.6.14-unpack.u patch -p0 < $stuff/jsclipboard.u - sed -i 's|\([>\.]\)val|\1u.val|;s|\([>\.]\)next|\1u.next|;216s|};|} u;|' lib/inflate.c + sed -i 's|\([>\.]\)val|\1u.val|;s|\([>\.]\)next|\1u.next|;216s|};|} u;|' \ + lib/inflate.c sed '/DEBUG/,/* kstrdup/d' < mm/slab.c > mm/kstrdup.c echo 'obj-y += kstrdup.o' >> mm/Makefile sed -i 's|3.1024|11*256|' arch/i386/boot/compressed/misc.c sed -i 's/O_CREAT/&|O_TRUNC/' init/initramfs.c which advdef 2> /dev/null && - sed -i 's|gzip)|&\n advdef -z4 $@|' usr/Makefile arch/i386/boot/compressed/Makefile + sed -i 's|gzip)|&\n advdef -z4 $@|' \ + usr/Makefile arch/i386/boot/compressed/Makefile which zopfli 2> /dev/null && sed -i 's|gzip -f -9 <|time zopfli --i100 -c|' scripts/Makefile.lib - if [ ! -s $WOK/busybox/source/busybox*/rootfs.cpio ]; then - tazwok cook busybox - fi + [ -s $WOK/busybox/source/busybox*/rootfs.cpio ] || tazwok cook busybox cp $WOK/busybox/source/busybox*/rootfs.cpio $src cp $WOK/busybox/source/busybox*/.config $src/config-busybox mkdir $src/slitaz cp $stuff/list_modules.sh $src/slitaz S2bin bootloader + S2bin helper S2bin unpacklz4 + cp $stuff/pack . + ./pack --build sed -i '/config %config:/{NNNps/config %config:/%config:/}' Makefile sed -i 's/^config %config:/config:/' Makefile @@ -77,7 +81,7 @@ cp -a $src/arch/i386/boot/bzImage $fs/boot/ dd if=$src/bootloader.bin of=$fs/boot/bzImage conv=notrunc dd if=$src/cmdline.bin bs=1 seek=560 of=$fs/boot/bzImage conv=notrunc - #( cd $src ; $stuff/pack $fs/boot/bzImage ) + cp -a $src/pack $fs/boot/ cp -a $src/System.map $fs/boot/ cp -a $src/.config $fs/boot/config cp -a $src/config-busybox $fs/boot @@ -87,31 +91,34 @@ # Pre and post install commands for Tazpkg. post_install() { - echo "Processing post-install commands..." - chroot "$1/" /boot/depmod -a $VERSION-slitaz - [ -s $1/boot/cmdline ] && cat $1/boot/cmdline | sed 's/^ *//' | \ - dd of=$1/boot/bzImage conv=notrunc bs=1 seek=768 count=3072 - # GRUB stuff. - if [ -f "$1/boot/grub/menu.lst" ]; then - root_dev=`cat $1/boot/grub/menu.lst | grep root= | sed 's/.*root=\([^ ]*\).*/\1/' | head -n 1` - grub_dev=`cat $1/boot/grub/menu.lst | grep "root (" | head -n 1` + echo "Processing post-install commands..." + chroot "$1/" /boot/depmod -a $VERSION-slitaz + [ -s $1/boot/cmdline ] && cat $1/boot/cmdline | sed 's/^ *//' | \ + dd of=$1/boot/bzImage conv=notrunc bs=1 seek=768 count=3072 2> /dev/null + $1/boot/pack $1/boot/bzImage + + # GRUB stuff. + if [ -f "$1/boot/grub/menu.lst" ]; then + root_dev=$(sed '/root=/!d;s/.*root=\([^ ]*\).*/\1/' \ + < $1/boot/grub/menu.lst | head -n 1) + grub_dev=$(grep "root (" < $1/boot/grub/menu.lst | head -n 1) # Add new kernel entry in case of upgrade for installed system. - if ! grep -q $SOURCE-$VERSION-slitaz $1/boot/grub/menu.lst; then - cat >> $1/boot/grub/menu.lst << EOT + grep -q $SOURCE-$VERSION-slitaz $1/boot/grub/menu.lst || + [ -s $1/boot/cmdline ] && cmdline=" $(cat $1/boot/cmdline)" + cat >> $1/boot/grub/menu.lst << EOT title SliTaz GNU/Linux (Kernel $VERSION-slitaz) $grub_dev -kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev +kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev$cmdline EOT - fi # Display information message. - cat </dev/null | uuencode -m - | sed -e \ + '/^helper\.bin$/r/dev/stdin' -e '/^helper\.bin$/d' -i $0 + sed '/install-begin$/,/install-end$/d' -i $0 + exit +fi #install-end ddq() { dd "$@" 2> /dev/null @@ -23,12 +31,14 @@ echo $(od -j $(($1)) -N ${3:-2} -t u${3:-2} -An "$2") } -if [ ! -s "$1" ]; then - cat << EOT -Usage: $0 bzImage [bootsector helper] [bootsector] +helper() +{ +uudecode << EOT +helper.bin EOT - exit 1 -fi +} + +[ ! -s "$1" ] && echo "Usage: $0 bzImage" && exit 1 if which lz4 > /dev/null ; then @@ -37,7 +47,9 @@ ddq if=$1 bs=1 count=$param > /tmp/setup$$ # unlz4 + data -ddq if=unpacklz4.bin >> /tmp/setup$$ +uudecode >> /tmp/setup$$ << EOT +unpacklz4.bin +EOT setupsz=$(get 0x1F1 $1 1) ddq if=$1 bs=1 skip=$param count=$(($setupsz*512-$param+512)) | \ lz4 -l -12 | ddq bs=4 skip=1 >> /tmp/setup$$ @@ -45,6 +57,7 @@ # version string word $(get 0x20E $1) >> /tmp/setup$$ word $setupsz 1 >> /tmp/setup$$ +setupend=$(stat -Lc %s "/tmp/setup$$") versionofs= version="$(ddq if=$1 bs=1 skip=$((0x200+$(get 0x20E $1))) | strings | sed q)" if grep --help 2>&1 | grep -q byte-offset; then @@ -56,18 +69,18 @@ fi store 0x20E $(($versionofs-512)) /tmp/setup$$ -helpersz=0 -[ -n "$2" ] && helpersz=$(stat -Lc %s "$2") +helpersz=$(helper | wc -c) newsetupsz=$((($(stat -c %s /tmp/setup$$)+$helpersz-1)/512)) [ $newsetupsz -lt 4 ] && newsetupsz=4 -store 0x1F1 $newsetupsz /tmp/setup$$ 1 if [ $newsetupsz -lt $setupsz ]; then - ddq of=/tmp/setup$$ bs=512 seek=$(($newsetupsz+1)) count=0 - [ -n "$2" ] && ddq if="$2" bs=1 of=/tmp/setup$$ \ + while [ $(($setupend + $helpersz)) -gt $((512 + 512*$newsetupsz)) ]; do + newsetupsz=$(($newsetupsz+1)) + done +# ddq of=/tmp/setup$$ bs=512 seek=$(($newsetupsz+1)) count=0 + store 0x1F1 $newsetupsz /tmp/setup$$ 1 + helper | ddq bs=1 of=/tmp/setup$$ \ seek=$((512 + 512*$newsetupsz - $helpersz)) - [ -n "$3" ] && [ $(stat -Lc %s "$3") -eq 497 ] && - ddq if="$3" conv=notrunc of=/tmp/setup$$ ddq if=$1 bs=512 skip=$((1+$setupsz)) >> /tmp/setup$$ cp /tmp/setup$$ $1 fi diff -r d71bd8881bcd -r d22f6fcf51da linux/stuff/unpacklz4.S --- a/linux/stuff/unpacklz4.S Wed Jul 04 20:33:53 2018 +0200 +++ b/linux/stuff/unpacklz4.S Sat Jul 07 11:56:18 2018 +0200 @@ -5,6 +5,7 @@ #define LZMA 0 #define HOLE 0x4000 +#define DS_OFS 0x0200 start: cld @@ -17,12 +18,12 @@ rep movsb %ds:(%si), %es:(%di) // move setup pushw %cs // CS pushw %cx // IP = 0 + //pushaw call packed_moved next: popw %bx - //leaw packed-next(%bx,%si), %si - .byte 0x8D,0x70,packed-next - leaw start-next(%bx), %di + leaw DS_OFS+start-next(%bx), %di + leaw DS_OFS+packed-next(%bx,%si), %si #if LZMA call unlzma #else @@ -101,13 +102,11 @@ jb lz4string #endif done: - movw $0x000E, %di + movw $0x020E, %di movsw // version string - //movw %ds, %ax - //decw %ax - //movw %ax, %es - //movw $0x0001, %di - //movsb // setup size + movw $0x01F1, %di + movsb // setup size + //popaw retf #if LZMA