wok-6.x view slitaz-loram-http/receipt @ rev 4317

Codeblocks: hack for new glib
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Sep 29 10:37:40 2009 +0200 (2009-09-29)
parents 6509db5aa948
children b78e1aa035a3
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=71
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=\$(busybox free | busybox awk '{ n = \$NF } END { print n }')
46 $i if [ \$FREEMEM -gt \$(busybox du -s \$FS | busybox awk '{ print \$1+40000 }') ]; then
47 $i status
48 $i if grep -q " extract-loram" /proc/cmdline &&
49 $i [ -d \$FS -o \$FREEMEM -gt \$(busybox du -s \$FS | \\
50 $i busybox 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
79 $i grep -q " urliso=" /proc/cmdline && URLISO=\$(cat /proc/cmdline | sed 's/.* urliso=\([^ ]*\).*/\1/')
80 $i /bin/httpfs \$URLISO /cdrom
81 $i mount -o loop,ro /cdrom/*.iso /cdrom
82 $i if [ -d /.usr.rw -a -x /bin/funionfs ]; then
83 $i echo -n "Mounting /usr read-write... "
84 $i usr=.usr.ro
85 $i else
86 $i echo -n "Mounting /usr read-only... "
87 $i usr=usr
88 $i fi
89 $i FS=/cdrom/usr.cromfs
90 $i if [ -f \$FS ]; then
91 $i mkdir /\$usr
92 $i release_http && break
93 $i /bin/cromfs-driver \$FS /\$usr -o ro,dev,suid,allow_other
94 $i elif [ -f /cdrom/usr.sqfs ]; then
95 $i FS=/cdrom/usr.sqfs
96 $i mkdir /\$usr
97 $i release_http && break
98 $i mount -o loop,ro -t squashfs \$FS /\$usr
99 $i else
100 $i release_http && break
101 $i FS=/cdrom/usr
102 $i ln -s \$FS /\$usr
103 $i fi
104 $i status
105 $i if [ -d /.usr.rw -a -x /bin/funionfs ]; then
106 $i /bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other,nonempty -o suid,dev NONE /usr
107 $i fi
108 $i break
109 $i done
110 $i
111 $tag
112 EOF
113 chmod 0755 $1/etc/init.d/rcS
114 }
116 # Pre and post install commands for Tazpkg.
117 pre_install()
118 {
119 local i
120 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do
121 [ "$i" = "$PACKAGE" ] && continue
122 yes y | tazpkg remove $i
123 . /etc/tazlito/tazlito.conf
124 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null
125 done
126 }
128 post_install()
129 {
130 set_patch "$1"
131 if [ ! -x $1/bin/funionfs ]; then
132 cat <<EOF
133 ----
134 You will build a live CD with /usr mounted read-only.
135 You can install funionfs to have read-write access into /usr with:
137 # tazpkg get-install funionfs
139 EOF
140 fi
141 }
143 # Pre remove commands for Tazpkg.
144 pre_remove()
145 {
146 set_patch '' -R
147 }