wok-current rev 4099

slitaz-loram*: add extract-loram
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Sep 18 21:59:40 2009 +0200 (2009-09-18)
parents eda797775988
children 883faa0c43cc
files slitaz-loram-cdrom/receipt slitaz-loram-cdrom/stuff/loram.extract slitaz-loram-cdrom/stuff/loram.rootfs slitaz-loram-http/receipt slitaz-loram-http/stuff/loram.extract slitaz-loram-http/stuff/loram.rootfs slitaz-loram/receipt slitaz-loram/stuff/loram.extract slitaz-loram/stuff/loram.rootfs
line diff
     1.1 --- a/slitaz-loram-cdrom/receipt	Fri Sep 18 13:02:59 2009 +0200
     1.2 +++ b/slitaz-loram-cdrom/receipt	Fri Sep 18 21:59:40 2009 +0200
     1.3 @@ -1,7 +1,7 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="slitaz-loram-cdrom"
     1.7 -VERSION="1.4"
     1.8 +VERSION="1.5"
     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 @@ -19,17 +19,19 @@
    1.13  {
    1.14      local tag
    1.15      local line
    1.16 +    local len
    1.17      local i
    1.18      tag="Handle kernel cmdline parameter config"
    1.19      i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
    1.20      i=$(($i-1))
    1.21 +    len=87
    1.22      tag=$(grep "$tag" $1/etc/init.d/rcS)
    1.23      if [ "$2" = "-R" ]; then
    1.24 -    	line="-$(($i-72)),74 +$(($i-72)),2"
    1.25 +    	line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
    1.26  	i="-"
    1.27      else
    1.28          grep -q 'from slitaz-loram-cdrom package' $1/etc/init.d/rcS && return
    1.29 -    	line="-$i,2 +$i,74"
    1.30 +    	line="-$i,2 +$i,$len"
    1.31  	i="+"
    1.32      fi
    1.33      patch -p0 <<EOF
    1.34 @@ -42,12 +44,27 @@
    1.35  $i {
    1.36  $i	FREEMEM=\$(busybox free | busybox awk '{ n = \$NF } END { print n }')	
    1.37  $i	if [ \$FREEMEM -gt \$(busybox du -s \$FS | busybox awk '{ print \$1+40000 }') ]; then
    1.38 +$i		if grep -q " extract-loram" /proc/cmdline &&
    1.39 +$i		    [ -d \$FS -o \$FREEMEM -gt \$(busybox du -s \$FS | \\
    1.40 +$i			busybox awk '{ print (\$1*4)+40000 }') ]; then
    1.41 +$i			echo -n "Extracting loram..."
    1.42 +$i			. /etc/tazlito/loram.extract /cdrom
    1.43 +$i			if status; then
    1.44 +$i				umount /cdrom
    1.45 +$i				rmdir /cdrom
    1.46 +$i				yes y | tazpkg remove slitaz-loram-cdrom > /dev/null
    1.47 +$i				return 0
    1.48 +$i			fi
    1.49 +$i		fi
    1.50  $i		cp -a \$FS /.usr.fs
    1.51  $i		status
    1.52  $i		echo -n "Releasing CD-ROM..."
    1.53  $i		umount /cdrom
    1.54  $i		FS=/.usr.fs
    1.55 -$i		return 0
    1.56 +$i		if [ -d \$FS ]; then
    1.57 +$i			rm -f /\$usr
    1.58 +$i			mv \$FS /usr
    1.59 +$i		fi
    1.60  $i	fi
    1.61  $i	return 1
    1.62  $i }
    1.63 @@ -72,7 +89,7 @@
    1.64  $i			DEVICE=""
    1.65  $i		fi
    1.66  $i	fi
    1.67 -$i	if [ -n "\$DEVICE" ]; then
    1.68 +$i	while [ -n "\$DEVICE" ]; do
    1.69  $i		if [ -d /.usr.rw ]; then
    1.70  $i			echo -n "Mounting /usr read-write... "
    1.71  $i			usr=.usr.ro
    1.72 @@ -82,18 +99,15 @@
    1.73  $i		fi
    1.74  $i		FS=/cdrom\$DIR/usr.cromfs
    1.75  $i		if [ -f \$FS ]; then
    1.76 -$i			release_cdrom
    1.77 +$i			release_cdrom && break
    1.78  $i			/bin/cromfs-driver \$FS /\$usr -o ro,dev,suid,allow_other
    1.79  $i		elif [ -f /cdrom\$DIR/usr.sqfs ]; then
    1.80  $i			FS=/cdrom\$DIR/usr.sqfs
    1.81 -$i			release_cdrom
    1.82 +$i			release_cdrom && break
    1.83  $i			mount -o loop,ro -t squashfs \$FS /\$usr
    1.84  $i		elif [ -L /\$usr ]; then
    1.85  $i			FS=/cdrom\$DIR/usr
    1.86 -$i			if release_cdrom; then
    1.87 -$i				rm -f /\$usr
    1.88 -$i				mv \$FS /usr
    1.89 -$i			fi
    1.90 +$i			release_cdrom && break
    1.91  $i		else
    1.92  $i			umount /cdrom
    1.93  $i			false
    1.94 @@ -106,7 +120,8 @@
    1.95  $i				/bin/mount -t aufs -o br:/.usr.rw:/.usr.ro none /usr
    1.96  $i			fi
    1.97  $i		fi
    1.98 -$i	fi
    1.99 +$i		break
   1.100 +$i	done
   1.101  $i fi
   1.102  $i
   1.103   $tag
   1.104 @@ -114,12 +129,13 @@
   1.105      tag="/var/log/dmesg.log"
   1.106      i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
   1.107      i=$(($i-1))
   1.108 +    len=9
   1.109      tag=$(grep "$tag" $1/etc/init.d/rcS)
   1.110      if [ "$2" = "-R" ]; then
   1.111 -    	line="-$(($i-7)),9 +$(($i-7)),2"
   1.112 +    	line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
   1.113  	i="-"
   1.114      else
   1.115 -    	line="-$i,2 +$i,9"
   1.116 +    	line="-$i,2 +$i,$len"
   1.117  	i="+"
   1.118      fi
   1.119      patch -p0 <<EOF
     2.1 --- a/slitaz-loram-cdrom/stuff/loram.extract	Fri Sep 18 13:02:59 2009 +0200
     2.2 +++ b/slitaz-loram-cdrom/stuff/loram.extract	Fri Sep 18 21:59:40 2009 +0200
     2.3 @@ -1,5 +1,6 @@
     2.4  # remove link to cdrom
     2.5 -[ -d cdrom ] && rmdir cdrom
     2.6 +[ -d cdrom ] && rmdir cdrom 2> /dev/null
     2.7 +rmdir .usr* 2> /dev/null
     2.8  if [ -L usr ]; then
     2.9  	rm usr
    2.10  	cp -a $1/usr .
    2.11 @@ -9,7 +10,7 @@
    2.12  	rmdir usr
    2.13  	rm -f bin/unmkcromfs
    2.14  	cp -a $1/unmkcromfs bin/unmkcromfs
    2.15 -	bin/unmkcromfs $packedfs usr
    2.16 +	bin/unmkcromfs $packedfs usr > /dev/null
    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 @@ -17,7 +18,7 @@
    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 +	sbin/unsquashfs -d usr $packedfs > /dev/null
    2.26  	[ "${packedfs%%/*}" = ".." ] && rm -f $packedfs
    2.27  fi
    2.28  if [ -d usr/.moved ]; then
     3.1 --- a/slitaz-loram-cdrom/stuff/loram.rootfs	Fri Sep 18 13:02:59 2009 +0200
     3.2 +++ b/slitaz-loram-cdrom/stuff/loram.rootfs	Fri Sep 18 21:59:40 2009 +0200
     3.3 @@ -1,7 +1,9 @@
     3.4  echo "$(du -hs /usr | cut -f1) were used by /usr"
     3.5 -lib/ld-*.so --list ./sbin/insmod | grep /usr/lib | cut -d\  -f3 | \
     3.6 -while read ii; do
     3.7 -  mv .${ii%%.so.*}.so* ./lib
     3.8 +for j in insmod unmkcromfs unsquashfs ; do 
     3.9 +  lib/ld-*.so --list *bin/$j 2> /dev/null | grep /usr/lib | cut -d\  -f3 | \
    3.10 +  while read ii; do
    3.11 +    mv .${ii%%.so.*}.so* ./lib
    3.12 +  done
    3.13  done
    3.14  for ii in /sbin /lib /bin; do
    3.15    mkdir -p ./usr/.moved$ii
     4.1 --- a/slitaz-loram-http/receipt	Fri Sep 18 13:02:59 2009 +0200
     4.2 +++ b/slitaz-loram-http/receipt	Fri Sep 18 21:59:40 2009 +0200
     4.3 @@ -1,7 +1,7 @@
     4.4  # SliTaz package receipt.
     4.5  
     4.6  PACKAGE="slitaz-loram-http"
     4.7 -VERSION="1.1"
     4.8 +VERSION="1.5"
     4.9  CATEGORY="misc"
    4.10  SHORT_DESC="Rules to build low ram system using http."
    4.11  MAINTAINER="pascal.bellard@slitaz.org"
    4.12 @@ -19,17 +19,19 @@
    4.13  {
    4.14      local tag
    4.15      local line
    4.16 +    local len
    4.17      local i
    4.18      tag="Handle kernel cmdline parameter config"
    4.19      i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
    4.20      i=$(($i-1))
    4.21 +    len=71
    4.22      tag=$(grep "$tag" $1/etc/init.d/rcS)
    4.23      if [ "$2" = "-R" ]; then
    4.24 -    	line="-$(($i-52)),54 +$(($i-52)),2"
    4.25 +    	line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
    4.26  	i="-"
    4.27      else
    4.28          grep -q 'from slitaz-loram-http package' $1/etc/init.d/rcS && return
    4.29 -    	line="-$i,2 +$i,54"
    4.30 +    	line="-$i,2 +$i,$len"
    4.31  	i="+"
    4.32      fi
    4.33      patch -p0 <<EOF
    4.34 @@ -43,19 +45,34 @@
    4.35  $i	FREEMEM=\$(busybox free | busybox awk '{ n = \$NF } END { print n }')	
    4.36  $i	if [ \$FREEMEM -gt \$(busybox du -s \$FS | busybox awk '{ print \$1+40000 }') ]; then
    4.37  $i		status
    4.38 +$i		if grep -q " extract-loram" /proc/cmdline &&
    4.39 +$i		    [ -d \$FS -o \$FREEMEM -gt \$(busybox du -s \$FS | \\
    4.40 +$i			busybox awk '{ print (\$1*4)+40000 }') ]; then
    4.41 +$i			echo -n "Extracting loram..."
    4.42 +$i			. /etc/tazlito/loram.extract /cdrom
    4.43 +$i			if status; then
    4.44 +$i				umount /cdrom && umount /cdrom
    4.45 +$i				rmdir /cdrom
    4.46 +$i				yes y | tazpkg remove slitaz-loram-http > /dev/null
    4.47 +$i				return 0
    4.48 +$i			fi
    4.49 +$i		fi
    4.50  $i		echo -n "Loading /usr in memory..."
    4.51  $i		cp -a \$FS /.usr.fs
    4.52  $i		status
    4.53  $i		echo -n "Releasing HTTP link..."
    4.54  $i		umount /cdrom && umount /cdrom
    4.55  $i		FS=/.usr.fs
    4.56 -$i		return 0
    4.57 +$i		if [ -d \$FS ]; then
    4.58 +$i			rm -f /\$usr
    4.59 +$i			mv \$FS /usr
    4.60 +$i		fi
    4.61  $i	fi
    4.62  $i	return 1
    4.63  $i }
    4.64  $i
    4.65  $i# Mount /usr (from slitaz-loram-http package)
    4.66 -$i if [ -d /cdrom ]; then
    4.67 +$i while [ -d /cdrom ]; do
    4.68  $i	/etc/init.d/network.sh
    4.69  $i	RUN_SCRIPTS="\$(echo \$RUN_SCRIPTS | sed 's/network.sh//')"
    4.70  $i	URLISO=http://mirror.slitaz.org/iso/\$(cat /etc/slitaz-release)/flavors/slitaz-loram-cdrom.iso
    4.71 @@ -71,15 +88,16 @@
    4.72  $i	fi
    4.73  $i	FS=/cdrom/usr.cromfs
    4.74  $i	if [ -f \$FS ]; then
    4.75 -$i		release_http
    4.76  $i		mkdir /\$usr
    4.77 +$i		release_http && break
    4.78  $i		/bin/cromfs-driver \$FS /\$usr -o ro,dev,suid,allow_other
    4.79  $i	elif [ -f /cdrom/usr.sqfs ]; then
    4.80  $i		FS=/cdrom/usr.sqfs
    4.81 -$i		release_http
    4.82  $i		mkdir /\$usr
    4.83 +$i		release_http && break
    4.84  $i		mount -o loop,ro -t squashfs \$FS /\$usr
    4.85  $i	else
    4.86 +$i		release_http && break
    4.87  $i		FS=/cdrom/usr
    4.88  $i		ln -s \$FS /\$usr
    4.89  $i	fi
    4.90 @@ -87,7 +105,8 @@
    4.91  $i	if [ -d /.usr.rw -a -x /bin/funionfs ]; then
    4.92  $i		/bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other,nonempty -o suid,dev NONE /usr
    4.93  $i	fi
    4.94 -$i fi
    4.95 +$i	break
    4.96 +$i done
    4.97  $i
    4.98   $tag
    4.99  EOF
     5.1 --- a/slitaz-loram-http/stuff/loram.extract	Fri Sep 18 13:02:59 2009 +0200
     5.2 +++ b/slitaz-loram-http/stuff/loram.extract	Fri Sep 18 21:59:40 2009 +0200
     5.3 @@ -1,5 +1,6 @@
     5.4  # remove link to cdrom
     5.5 -[ -d cdrom ] && rmdir cdrom
     5.6 +[ -d cdrom ] && rmdir cdrom 2> /dev/null
     5.7 +rmdir .usr* 2> /dev/null
     5.8  if [ -L usr ]; then
     5.9  	rm usr
    5.10  	cp -a $1/usr .
    5.11 @@ -9,7 +10,7 @@
    5.12  	rmdir usr
    5.13  	rm -f bin/unmkcromfs
    5.14  	cp -a $1/unmkcromfs bin/unmkcromfs
    5.15 -	bin/unmkcromfs $packedfs usr
    5.16 +	bin/unmkcromfs $packedfs usr > /dev/null
    5.17  	[ "${packedfs%%/*}" = ".." ] && rm -f $packedfs
    5.18  	rm -f bin/cromfs-driver
    5.19  	cp -a $1/cromfs-driver bin/cromfs-driver
    5.20 @@ -17,7 +18,7 @@
    5.21  packedfs="$1/usr.sqfs"
    5.22  if [ -f $packedfs ]; then
    5.23  	rmdir usr
    5.24 -	sbin/unsquashfs -d usr $packedfs
    5.25 +	sbin/unsquashfs -d usr $packedfs > /dev/null
    5.26  	[ "${packedfs%%/*}" = ".." ] && rm -f $packedfs
    5.27  fi
    5.28  if [ -d usr/.moved ]; then
     6.1 --- a/slitaz-loram-http/stuff/loram.rootfs	Fri Sep 18 13:02:59 2009 +0200
     6.2 +++ b/slitaz-loram-http/stuff/loram.rootfs	Fri Sep 18 21:59:40 2009 +0200
     6.3 @@ -1,7 +1,9 @@
     6.4  echo "$(du -hs /usr | cut -f1) were used by /usr"
     6.5 -lib/ld-*.so --list ./sbin/insmod | grep /usr/lib | cut -d\  -f3 | \
     6.6 -while read ii; do
     6.7 -  mv .${ii%%.so.*}.so* ./lib
     6.8 +for j in insmod unmkcromfs unsquashfs ; do
     6.9 +  lib/ld-*.so --list *bin/$j 2> /dev/null | grep /usr/lib | cut -d\  -f3 | \
    6.10 +  while read ii; do
    6.11 +    mv .${ii%%.so.*}.so* ./lib
    6.12 +  done
    6.13  done
    6.14  for ii in /sbin /lib /bin; do
    6.15    mkdir -p ./usr/.moved$ii
     7.1 --- a/slitaz-loram/receipt	Fri Sep 18 13:02:59 2009 +0200
     7.2 +++ b/slitaz-loram/receipt	Fri Sep 18 21:59:40 2009 +0200
     7.3 @@ -1,7 +1,7 @@
     7.4  # SliTaz package receipt.
     7.5  
     7.6  PACKAGE="slitaz-loram"
     7.7 -VERSION="1.4"
     7.8 +VERSION="1.5"
     7.9  CATEGORY="misc"
    7.10  SHORT_DESC="Rules to build low ram rootfs.gz."
    7.11  MAINTAINER="pascal.bellard@slitaz.org"
    7.12 @@ -19,17 +19,19 @@
    7.13  {
    7.14      local tag
    7.15      local line
    7.16 +    local len
    7.17      local i
    7.18      tag="/dev/cdrom if need"
    7.19      i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
    7.20      i=$(($i-1))
    7.21 +    len=38
    7.22      tag=$(grep "$tag" $1/etc/init.d/rcS)
    7.23      if [ "$2" = "-R" ]; then
    7.24 -    	line="-$(($i-25)),27 +$(($i-25)),2"
    7.25 +    	line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
    7.26  	i="-"
    7.27      else
    7.28          grep -q 'from slitaz-loram package' $1/etc/init.d/rcS && return
    7.29 -    	line="-$i,2 +$i,27"
    7.30 +    	line="-$i,2 +$i,$len"
    7.31  	i="+"
    7.32      fi
    7.33      patch -p0 <<EOF
    7.34 @@ -38,7 +40,7 @@
    7.35  @@ $line @@
    7.36   
    7.37  $i# Mount compressed /usr (from slitaz-loram package)
    7.38 -$i if [ -f /.usr.cromfs -o -f /.usr.sqfs ]; then
    7.39 +$i while [ -f /.usr.cromfs -o -f /.usr.sqfs ]; do
    7.40  $i	usr=usr
    7.41  $i	echo -n "Mounting /usr read-"
    7.42  $i	if [ -d /.usr.rw ]; then
    7.43 @@ -47,6 +49,16 @@
    7.44  $i	else
    7.45  $i		echo -n "only... "
    7.46  $i	fi
    7.47 +$i	FREEMEM=\$(busybox free | busybox awk '{ n = \$NF } END { print n }')
    7.48 +$i	if grep -q " extract-loram" /proc/cmdline && [ \$FREEMEM -gt \\
    7.49 +$i	\$(busybox du -s \$FS | busybox awk '{ print (\$1*4)+40000 }') ]; then
    7.50 +$i		echo -n "Extracting loram..."
    7.51 +$i		. /etc/tazlito/loram.extract
    7.52 +$i		if status; then
    7.53 +$i			yes y | tazpkg remove slitaz-loram > /dev/null
    7.54 +$i			break
    7.55 +$i		fi
    7.56 +$i	fi
    7.57  $i	if [ -f /.usr.cromfs ]; then
    7.58  $i		/bin/cromfs-driver /.usr.cromfs /\$usr -o ro,dev,suid,allow_other
    7.59  $i	else
    7.60 @@ -60,7 +72,8 @@
    7.61  $i		fi
    7.62  $i	fi
    7.63  $i	status
    7.64 -$i fi
    7.65 +$i	break
    7.66 +$i done
    7.67  $i
    7.68   $tag
    7.69  EOF
     8.1 --- a/slitaz-loram/stuff/loram.extract	Fri Sep 18 13:02:59 2009 +0200
     8.2 +++ b/slitaz-loram/stuff/loram.extract	Fri Sep 18 21:59:40 2009 +0200
     8.3 @@ -1,12 +1,13 @@
     8.4  rmdir usr
     8.5 +rmdir .usr* 2> /dev/null
     8.6  packedfs=".usr.cromfs"
     8.7  if [ -f $packedfs ]; then
     8.8 -	bin/unmkcromfs $packedfs usr
     8.9 +	bin/unmkcromfs $packedfs usr > /dev/null
    8.10  	rm -f $packedfs
    8.11  fi
    8.12  packedfs=".usr.sqfs"
    8.13  if [ -f $packedfs ]; then
    8.14 -	sbin/unsquashfs -d usr $packedfs
    8.15 +	sbin/unsquashfs -d usr $packedfs > /dev/null
    8.16  	rm -f $packedfs
    8.17  fi
    8.18  ( cd usr/.moved ; find * -print ) | \
     9.1 --- a/slitaz-loram/stuff/loram.rootfs	Fri Sep 18 13:02:59 2009 +0200
     9.2 +++ b/slitaz-loram/stuff/loram.rootfs	Fri Sep 18 21:59:40 2009 +0200
     9.3 @@ -1,7 +1,9 @@
     9.4  echo "$(du -hs ./usr | cut -f1) were used by /usr"
     9.5 -lib/ld-*.so --list ./sbin/insmod | grep /usr/lib | cut -d\  -f3 | \
     9.6 -while read ii; do
     9.7 -  mv .${ii%%.so.*}.so* ./lib
     9.8 +for j in insmod unmkcromfs unsquashfs ; do
     9.9 +  lib/ld-*.so --list *bin/$j 2> /dev/null | grep /usr/lib | cut -d\  -f3 | \
    9.10 +  while read ii; do
    9.11 +    mv .${ii%%.so.*}.so* ./lib
    9.12 +  done
    9.13  done
    9.14  for ii in /sbin /lib /bin; do
    9.15    mkdir -p ./usr/.moved$ii