wok-next view slitaz-loram-http/receipt @ rev 9006
linphone: update BUILD_DEPENDS
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Mar 03 18:02:13 2011 +0100 (2011-03-03) |
parents | fa0257184d3c |
children | a40a0eb643ba |
line source
1 # SliTaz package receipt.
3 PACKAGE="slitaz-loram-http"
4 VERSION="1.6"
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=89
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 release=\$(cat /etc/slitaz-release)
79 $i iso1=iso/\$release/flavors/slitaz-\$release-loram-cdrom.iso
80 $i iso2=iso/\$release/flavors/slitaz-loram-cdrom.iso
81 $i URLISO=http://mirror.slitaz.org/\$iso1,http://mirror.slitaz.org/\$iso2,http://download.tuxfamily.org/slitaz/\$iso1,http://download.tuxfamily.org/slitaz/\$iso2,http://slitaz.c3sl.ufpr.br/\$iso1,http://slitaz.c3sl.ufpr.br/\$iso2
82 $i grep -q " urliso=" /proc/cmdline && URLISO=\$(cat /proc/cmdline | sed 's/.* urliso=\([^ ]*\).*/\1/'),\$URLISO
83 $i for i in \$(echo \$URLISO | sed 's/,/ /g'); do
84 $i /bin/httpfs \$i /cdrom && break
85 $i done
86 $i mount -o loop,ro /cdrom/*.iso /cdrom
87 $i if [ -d /.usr.rw -a -x /bin/funionfs ]; then
88 $i echo -n "Mounting /usr read-write... "
89 $i usr=.usr.ro
90 $i else
91 $i echo -n "Mounting /usr read-only... "
92 $i usr=usr
93 $i fi
94 $i FS=/cdrom/usr.cromfs
95 $i if [ -f \$FS ]; then
96 $i mkdir /\$usr
97 $i ln -s /usr/.moved /.moved
98 $i release_http && break
99 $i /bin/cromfs-driver \$FS /\$usr -o ro,dev,suid,allow_other
100 $i elif grep -q squashfs /etc/filesystems && [ -f /cdrom/usr.sqfs ]; then
101 $i FS=/cdrom/usr.sqfs
102 $i ln -s /usr/.moved /.moved
103 $i mkdir /\$usr
104 $i release_http && break
105 $i mount -o loop,ro -t squashfs \$FS /\$usr
106 $i elif grep -q squashfs /etc/filesystems && [ -f /cdrom/rootfs.gz ]; then
107 $i FS=/cdrom/rootfs.gz
108 $i ln -s /.rootfs /.moved
109 $i mkdir /.rootfs
110 $i release_http && break
111 $i mount -o loop,ro -t squashfs \$FS /.rootfs
112 $i ln -s /.rootfs/usr /\$usr
113 $i elif [ -d /cdrom/usr ]; then
114 $i FS=/cdrom/usr
115 $i ln -s /usr/.moved /.moved
116 $i rm -rf /\$usr && ln -s \$FS /\$usr
117 $i else
118 $i FS=/cdrom/fs/usr
119 $i ln -s /cdrom/fs /.moved
120 $i rm -rf /\$usr && ln -s \$FS /\$usr
121 $i fi
122 $i status
123 $i if [ -d /.usr.rw -a -x /bin/funionfs ]; then
124 $i /bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other,nonempty -o suid,dev NONE /usr
125 $i fi
126 $i break
127 $i done
128 $i
129 $tag
130 EOF
131 chmod 0755 $1/etc/init.d/rcS
132 }
134 # Pre and post install commands for Tazpkg.
135 pre_install()
136 {
137 local i
138 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do
139 [ "$i" = "$PACKAGE" ] && continue
140 yes y | tazpkg remove $i
141 . /etc/tazlito/tazlito.conf
142 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null
143 done
144 }
146 post_install()
147 {
148 set_patch "$1"
150 # Don't support FAST_BOOT_X yet
151 sed -i 's/FAST_BOOT_X=.*/FAST_BOOT_X="no"/' $1/etc/rcS.conf
153 cat <<EOF
154 ----
155 'tazlito gen-distro' will create a loram-http flavor
156 while this package is installed.
157 EOF
158 if [ ! -x $1/bin/funionfs ]; then
159 cat <<EOF
160 ----
161 You will build a live CD with /usr mounted read-only.
162 You can install funionfs to have read-write access into /usr with:
164 # tazpkg get-install funionfs
166 EOF
167 fi
168 }
170 # Pre remove commands for Tazpkg.
171 pre_remove()
172 {
173 set_patch '' -R
174 cat <<EOF
175 ----
176 'tazlito gen-distro' will work as expected now.
177 EOF
178 }