wok-current view slitaz-loram-http/receipt @ rev 4730

slitaz-loram-http: do not transfert unpacked fs
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jan 06 17:56:30 2010 +0100 (2010-01-06)
parents 09c454bea68c
children fa0257184d3c
line source
1 # SliTaz package receipt.
3 PACKAGE="slitaz-loram-http"
4 VERSION="1.5"
5 CATEGORY="misc"
6 SHORT_DESC="Rules to build low ram system using http."
7 MAINTAINER="pascal.bellard@slitaz.org"
8 WEB_SITE="http://www.slitaz.org/"
9 DEPENDS="slitaz-boot-scripts tazlito httpfs-fuse funionfs"
11 # Rules to gen a SliTaz package suitable for Tazpkg.
12 genpkg_rules()
13 {
14 mkdir -p $fs/etc/tazlito
15 cp stuff/loram.* $fs/etc/tazlito
16 }
18 set_patch()
19 {
20 local tag
21 local line
22 local len
23 local i
24 tag="Handle kernel cmdline parameter config"
25 i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
26 i=$(($i-1))
27 len=72
28 tag=$(grep "$tag" $1/etc/init.d/rcS)
29 if [ "$2" = "-R" ]; then
30 line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
31 i="-"
32 else
33 grep -q 'from slitaz-loram-http package' $1/etc/init.d/rcS && return
34 line="-$i,2 +$i,$len"
35 i="+"
36 fi
37 busybox patch -p0 <<EOF
38 --- $1/etc/init.d/rcS
39 +++ $1/etc/init.d/rcS
40 @@ $line @@
42 $i# Try to release http link (from slitaz-loram-http package)
43 $i release_http()
44 $i {
45 $i FREEMEM=\$(free | awk '{ n = \$NF } END { print n }')
46 $i if [ \$FREEMEM -gt \$(du -s \$FS | awk '{ print \$1+40000 }') ]; then
47 $i status
48 $i if ! grep -q " keep-loram" /proc/cmdline &&
49 $i [ -d \$FS -o \$FREEMEM -gt \$(du -s \$FS | \\
50 $i awk '{ print (\$1*4)+40000 }') ]; then
51 $i echo -n "Extracting loram..."
52 $i . /etc/tazlito/loram.extract /cdrom
53 $i if status; then
54 $i umount /cdrom && umount /cdrom
55 $i rmdir /cdrom
56 $i yes y | tazpkg remove slitaz-loram-http > /dev/null
57 $i return 0
58 $i fi
59 $i fi
60 $i echo -n "Loading /usr in memory..."
61 $i cp -a \$FS /.usr.fs
62 $i status
63 $i echo -n "Releasing HTTP link..."
64 $i umount /cdrom && umount /cdrom
65 $i FS=/.usr.fs
66 $i if [ -d \$FS ]; then
67 $i rm -f /\$usr
68 $i mv \$FS /usr
69 $i fi
70 $i fi
71 $i return 1
72 $i }
73 $i
74 $i# Mount /usr (from slitaz-loram-http package)
75 $i while [ -d /cdrom ]; do
76 $i /etc/init.d/network.sh
77 $i RUN_SCRIPTS="\$(echo \$RUN_SCRIPTS | sed 's/network.sh//')"
78 $i URLISO=http://mirror.slitaz.org/iso/\$(cat /etc/slitaz-release)/flavors/slitaz-loram-cdrom.iso,http://download.tuxfamily.org/slitaz/iso/\$(cat /etc/slitaz-release)/flavors/slitaz-loram-cdrom.iso,http://slitaz.c3sl.ufpr.br/iso/\$(cat /etc/slitaz-release)/flavors/slitaz-loram-cdrom.iso
79 $i grep -q " urliso=" /proc/cmdline && URLISO=\$(cat /proc/cmdline | sed 's/.* urliso=\([^ ]*\).*/\1/'),\$URLISO
80 $i for i in \$(echo \$URLISO | sed 's/,/ /g'); do
81 $i /bin/httpfs \$i /cdrom && break
82 $i done
83 $i mount -o loop,ro /cdrom/*.iso /cdrom
84 $i if [ -d /.usr.rw -a -x /bin/funionfs ]; then
85 $i echo -n "Mounting /usr read-write... "
86 $i usr=.usr.ro
87 $i else
88 $i echo -n "Mounting /usr read-only... "
89 $i usr=usr
90 $i fi
91 $i FS=/cdrom/usr.cromfs
92 $i if [ -f \$FS ]; then
93 $i mkdir /\$usr
94 $i release_http && break
95 $i /bin/cromfs-driver \$FS /\$usr -o ro,dev,suid,allow_other
96 $i elif [ -f /cdrom/usr.sqfs ]; then
97 $i FS=/cdrom/usr.sqfs
98 $i mkdir /\$usr
99 $i release_http && break
100 $i mount -o loop,ro -t squashfs \$FS /\$usr
101 $i else
102 $i FS=/cdrom/usr
103 $i ln -s \$FS /\$usr
104 $i fi
105 $i status
106 $i if [ -d /.usr.rw -a -x /bin/funionfs ]; then
107 $i /bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other,nonempty -o suid,dev NONE /usr
108 $i fi
109 $i break
110 $i done
111 $i
112 $tag
113 EOF
114 chmod 0755 $1/etc/init.d/rcS
115 }
117 # Pre and post install commands for Tazpkg.
118 pre_install()
119 {
120 local i
121 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do
122 [ "$i" = "$PACKAGE" ] && continue
123 yes y | tazpkg remove $i
124 . /etc/tazlito/tazlito.conf
125 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null
126 done
127 }
129 post_install()
130 {
131 set_patch "$1"
132 cat <<EOF
133 ----
134 'tazlito gen-distro' will create a loram-http flavor
135 while this package is installed.
136 EOF
137 if [ ! -x $1/bin/funionfs ]; then
138 cat <<EOF
139 ----
140 You will build a live CD with /usr mounted read-only.
141 You can install funionfs to have read-write access into /usr with:
143 # tazpkg get-install funionfs
145 EOF
146 fi
147 }
149 # Pre remove commands for Tazpkg.
150 pre_remove()
151 {
152 set_patch '' -R
153 cat <<EOF
154 ----
155 'tazlito gen-distro' will work as expected now.
156 EOF
157 }