wok rev 370

Slitaz-loram*: more flexible
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Mar 08 11:30:12 2008 +0000 (2008-03-08)
parents c570ed86d31a
children 1408dfa76481
files slitaz-loram-cdrom/receipt slitaz-loram-cdrom/stuff/loram.extract slitaz-loram-cdrom/stuff/loram.rootfs slitaz-loram/receipt slitaz-loram/stuff/loram.extract
line diff
     1.1 --- a/slitaz-loram-cdrom/receipt	Sat Mar 08 01:10:18 2008 +0000
     1.2 +++ b/slitaz-loram-cdrom/receipt	Sat Mar 08 11:30:12 2008 +0000
     1.3 @@ -1,7 +1,7 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="slitaz-loram-cdrom"
     1.7 -VERSION="1.0"
     1.8 +VERSION="1.1"
     1.9  CATEGORY="misc"
    1.10  SHORT_DESC="Rules to build low ram system using cdrom."
    1.11  MAINTAINER="pascal.bellard@slitaz.org"
    1.12 @@ -10,44 +10,55 @@
    1.13  genpkg_rules()
    1.14  {
    1.15      mkdir -p $fs/etc/tazlito
    1.16 -    cp stuff/loram.rootfs $fs/etc/tazlito
    1.17 +    cp stuff/loram.* $fs/etc/tazlito
    1.18  }
    1.19  
    1.20  get_patch()
    1.21  {
    1.22 +    local tag
    1.23 +    local line
    1.24 +    local i
    1.25 +    tag="Handle kernel cmdline parameter config"
    1.26 +    i=$(grep -n "$tag" /etc/init.d/rcS | cut -d: -f1)
    1.27 +    i=$(($i-1))
    1.28 +    tag=$(grep "$tag" /etc/init.d/rcS)
    1.29 +    if [ "$1" = "-R" ]; then
    1.30 +    	line="-$(($i-24)),26 +$(($i-24)),2"
    1.31 +	i="-"
    1.32 +    else
    1.33 +    	line="-$i,2 +$i,26"
    1.34 +	i="+"
    1.35 +    fi
    1.36      cat <<EOF
    1.37  --- /etc/init.d/rcS
    1.38  +++ /etc/init.d/rcS
    1.39 -@@ -53,4 +53,4 @@
    1.40 - /bin/dmesg > /var/log/dmesg.log
    1.41 --/usr/bin/vcsa2txt < /dev/vcsa1 > /var/log/boot.log
    1.42 --/usr/bin/script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log
    1.43 -+busybox vcsa2txt < /dev/vcsa1 > /var/log/boot.log
    1.44 -+busybox script -a -q -c '/etc/init.d/rcS logged' /var/log/boot.log
    1.45 +@@ $line @@
    1.46   
    1.47 -@@ -62,4 +62,4 @@
    1.48 - #
    1.49 --DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
    1.50 --if [ ! "`readlink /dev/cdrom`" ]; then
    1.51 -+DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | busybox cut -f 3`
    1.52 -+if [ ! "`busybox readlink /dev/cdrom`" ]; then
    1.53 - 	echo -n "Creating symlink : /dev/cdrom..."
    1.54 -@@ -87,2 +87,15 @@
    1.55 - 
    1.56 -+# Mount /usr
    1.57 -+if [ -d /cdrom ]; then
    1.58 -+	echo -n "Mounting /usr read-only from /cdrom... "
    1.59 -+	mount -o ro -t iso9660 /dev/cdrom /cdrom
    1.60 -+	if [ -f /cdrom/usr.sqfs ]; then
    1.61 -+		mount -o loop,ro -t squashfs /cdrom/usr.sqfs /usr
    1.62 -+	elif [ ! -L /usr ]; then
    1.63 -+		umount /cdrom
    1.64 -+		false
    1.65 -+	fi
    1.66 -+	status 
    1.67 -+fi
    1.68 -+
    1.69 - # Handle kernel cmdline parameter config=<device>,<path> to source a 
    1.70 +$i# Mount /usr
    1.71 +$i if [ -d /cdrom ]; then
    1.72 +$i	mount -o ro -t iso9660 /dev/cdrom /cdrom
    1.73 +$i	if [ -d /.usr.rw -a -x /bin/funionfs ]; then
    1.74 +$i		echo -n "Mounting /usr read-write... "
    1.75 +$i		usr=.usr.ro
    1.76 +$i	else
    1.77 +$i		echo -n "Mounting /usr read-only... "
    1.78 +$i		usr=usr
    1.79 +$i	fi
    1.80 +$i	if [ -f /cdrom/usr.cromfs ]; then
    1.81 +$i		/bin/cromfs-driver /cdrom/usr.cromfs /\$usr
    1.82 +$i	elif [ -f /cdrom/usr.sqfs ]; then
    1.83 +$i		mount -o loop,ro -t squashfs /cdrom/usr.sqfs /\$usr
    1.84 +$i	elif [ ! -L /\$usr ]; then
    1.85 +$i		umount /cdrom
    1.86 +$i		false
    1.87 +$i	fi
    1.88 +$i	status 
    1.89 +$i	if [ -d /.usr.rw -a -x /bin/funionfs ]; then
    1.90 +$i		/bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other NONE /usr
    1.91 +$i	fi
    1.92 +$i fi
    1.93 +$i
    1.94 + $tag
    1.95  EOF
    1.96  }
    1.97  
    1.98 @@ -67,5 +78,5 @@
    1.99  # Pre remove commands for Tazpkg.
   1.100  pre_remove()
   1.101  {
   1.102 -    [ -L /usr/bin/patch ] || get_patch | patch -R -p0
   1.103 +    get_patch -R | patch -p0
   1.104  }
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/slitaz-loram-cdrom/stuff/loram.extract	Sat Mar 08 11:30:12 2008 +0000
     2.3 @@ -0,0 +1,32 @@
     2.4 +# remove link to cdrom
     2.5 +[ -d cdrom ] && rmdir cdrom
     2.6 +rm -f bin/vcsa2txt bin/script bin/cut bin/readlink
     2.7 +if [ -L usr ]; then
     2.8 +	rm usr
     2.9 +	cp -a $1/usr .
    2.10 +fi
    2.11 +packedfs="$1/usr.cromfs"
    2.12 +if [ -f $packedfs ]; then
    2.13 +	rmdir usr
    2.14 +	rm -f bin/unmkcromfs
    2.15 +	cp -a $1/unmkcromfs bin/unmkcromfs
    2.16 +	bin/unmkcromfs $packedfs usr
    2.17 +	[ "${packedfs%%/*]" = ".." ] && rm -f $packedfs
    2.18 +	rm -f bin/cromfs-driver
    2.19 +	cp -a $1/cromfs-driver bin/cromfs-driver
    2.20 +fi
    2.21 +packedfs="$1/usr.sqfs"
    2.22 +if [ -f $packedfs ]; then
    2.23 +	rmdir usr
    2.24 +	sbin/unsquashfs -d usr $packedfs
    2.25 +	[ "${packedfs%%/*]" = ".." ] && rm -f $packedfs
    2.26 +fi
    2.27 +if [ -d usr/.moved ]; then
    2.28 +	( cd usr/.moved ; find * -print ) | \
    2.29 +	while read file; do
    2.30 +		[ -L "$file" ] || continue
    2.31 +		rm -f "$file"
    2.32 +		mv "usr/.moved/$file" "$file"
    2.33 +	done
    2.34 +	rm -rf usr/.moved
    2.35 +fi
     3.1 --- a/slitaz-loram-cdrom/stuff/loram.rootfs	Sat Mar 08 01:10:18 2008 +0000
     3.2 +++ b/slitaz-loram-cdrom/stuff/loram.rootfs	Sat Mar 08 11:30:12 2008 +0000
     3.3 @@ -16,14 +16,32 @@
     3.4    ln -s /usr/.moved$ii .$ii
     3.5  done
     3.6  echo "$(du -hs /usr/.moved | cut -f1) have been moved into /usr"
     3.7 -if [ -x usr/sbin/mksquashfs ]; then
     3.8 +usr=usr
     3.9 +if [ -x bin/funionfs ]; then
    3.10 +  usr=.usr.ro
    3.11 +  mkdir .usr.ro .usr.rw
    3.12 +  ln -s /.usr.ro/lib/$(cd usr/lib ; ls libfuse.so.2.*) lib/libfuse.so.2
    3.13 +fi
    3.14 +if [ -x usr/bin/mkcromfs ]; then
    3.15 +  usr/bin/mkcromfs -qq -f 262144 -b 16384 usr ../rootcd/usr.cromfs
    3.16 +  rm -rf usr
    3.17 +  mkdir usr
    3.18 +  for ii in unmkcromfs cromfs-driver ; do
    3.19 +    mv bin/$ii ../rootcd
    3.20 +    ln -s /cdrom/$ii bin/$ii
    3.21 +  done
    3.22 +elif [ -x usr/sbin/mksquashfs ]; then
    3.23    usr/sbin/mksquashfs usr ../rootcd/usr.sqfs
    3.24    rm -rf usr
    3.25    mkdir usr
    3.26  else
    3.27    mv usr ../rootcd
    3.28 -  ln -s /cdrom/usr usr
    3.29 +  [ "$usr" = "usr" ] || rmdir $usr
    3.30 +  ln -s /cdrom/usr $usr
    3.31    ln -s /bin ../rootcd/bin
    3.32  fi
    3.33 +for ii in bin/vcsa2txt bin/script bin/cut bin/readlink ; do
    3.34 +  ln -s busybox $ii
    3.35 +done
    3.36  mkdir cdrom
    3.37  COMPRESSION="gzip"
     4.1 --- a/slitaz-loram/receipt	Sat Mar 08 01:10:18 2008 +0000
     4.2 +++ b/slitaz-loram/receipt	Sat Mar 08 11:30:12 2008 +0000
     4.3 @@ -11,29 +11,44 @@
     4.4  genpkg_rules()
     4.5  {
     4.6      mkdir -p $fs/etc/tazlito
     4.7 -    cp stuff/loram.rootfs $fs/etc/tazlito
     4.8 +    cp stuff/loram.* $fs/etc/tazlito
     4.9  }
    4.10  
    4.11  get_patch()
    4.12  {
    4.13 +    local tag
    4.14 +    local line
    4.15 +    local i
    4.16 +    tag="Creat /dev/cdrom if needed"
    4.17 +    i=$(grep -n "$tag" /etc/init.d/rcS | cut -d: -f1)
    4.18 +    i=$(($i-1))
    4.19 +    tag=$(grep "$tag" /etc/init.d/rcS)
    4.20 +    if [ "$1" = "-R" ]; then
    4.21 +    	line="-$(($i-13)),15 +$(($i-13)),2"
    4.22 +	i="-"
    4.23 +    else
    4.24 +    	line="-$i,2 +$i,15"
    4.25 +	i="+"
    4.26 +    fi
    4.27      cat <<EOF
    4.28  --- /etc/init.d/rcS
    4.29  +++ /etc/init.d/rcS
    4.30 -@@ -58,2 +58,14 @@
    4.31 +@@ $line @@
    4.32   
    4.33 -+# Mount compressed /usr
    4.34 -+if [ -f /.usr.cromfs ]; then
    4.35 -+	echo -n "Mounting compressed /usr read-only... "
    4.36 -+	if [ -d /.usr.rw ]; then
    4.37 -+		/bin/cromfs-driver /.usr.cromfs /.usr.ro
    4.38 -+		/bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other NONE /usr
    4.39 -+	else
    4.40 -+		/bin/cromfs /.usr.cromfs /usr
    4.41 -+	fi
    4.42 -+	status
    4.43 -+fi
    4.44 -+
    4.45 - # Creat /dev/cdrom if needed (symlink does not exist on LiveCD). Chmod
    4.46 +$i# Mount compressed /usr
    4.47 +$i if [ -f /.usr.cromfs ]; then
    4.48 +$i	if [ -d /.usr.rw ]; then
    4.49 +$i		echo -n "Mounting compressed /usr read-write... "
    4.50 +$i		/bin/cromfs-driver /.usr.cromfs /.usr.ro
    4.51 +$i		/bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other NONE /usr
    4.52 +$i	else
    4.53 +$i		echo -n "Mounting compressed /usr read-only... "
    4.54 +$i		/bin/cromfs /.usr.cromfs /usr
    4.55 +$i	fi
    4.56 +$i	status
    4.57 +$i fi
    4.58 +$i
    4.59 + $tag
    4.60  EOF
    4.61  }
    4.62  
    4.63 @@ -53,5 +68,5 @@
    4.64  # Pre remove commands for Tazpkg.
    4.65  pre_remove()
    4.66  {
    4.67 -    [ -L /usr/bin/patch ] || get_patch | patch -R -p0
    4.68 +    get_patch -R | patch -p0
    4.69  }
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/slitaz-loram/stuff/loram.extract	Sat Mar 08 11:30:12 2008 +0000
     5.3 @@ -0,0 +1,11 @@
     5.4 +cromfs=".usr.cromfs"
     5.5 +rmdir usr
     5.6 +bin/unmkcromfs $cromfs usr
     5.7 +rm -f $cromfs
     5.8 +( cd usr/.moved ; find * -print ) | \
     5.9 +while read file; do
    5.10 +	[ -L "$file" ] || continue
    5.11 +	rm -f "$file"
    5.12 +	mv "usr/.moved/$file" "$file"
    5.13 +done
    5.14 +rm -rf usr/.moved