wok-current view slitaz-loram-cdrom/receipt @ rev 5118

tazpkg: fix missing doc files
author Christophe Lincoln <pankso@slitaz.org>
date Sat Mar 20 19:13:47 2010 +0100 (2010-03-20)
parents 7ae478e2ad1e
children f7cdbd605b68
line source
1 # SliTaz package receipt.
3 PACKAGE="slitaz-loram-cdrom"
4 VERSION="1.5"
5 CATEGORY="misc"
6 SHORT_DESC="Rules to build low ram system using cdrom."
7 MAINTAINER="pascal.bellard@slitaz.org"
8 WEB_SITE="http://www.slitaz.org/"
9 DEPENDS="slitaz-boot-scripts tazlito"
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=88
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-cdrom 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 the cdrom (from slitaz-loram-cdrom package)
43 $i release_cdrom()
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 if ! grep -q " keep-loram" /proc/cmdline &&
48 $i [ -d \$FS -o \$FREEMEM -gt \$(du -s \$FS | \\
49 $i awk '{ print (\$1*4)+40000 }') ]; then
50 $i echo -n "Extracting loram..."
51 $i . /etc/tazlito/loram.extract /cdrom
52 $i if status; then
53 $i umount /cdrom
54 $i rmdir /cdrom
55 $i yes y | tazpkg remove slitaz-loram-cdrom > /dev/null
56 $i return 0
57 $i fi
58 $i fi
59 $i cp -a \$FS /.usr.fs
60 $i status
61 $i echo -n "Releasing CD-ROM..."
62 $i umount /cdrom
63 $i FS=/.usr.fs
64 $i if [ -d \$FS ]; then
65 $i rm -f /\$usr
66 $i mv \$FS /usr
67 $i fi
68 $i fi
69 $i return 1
70 $i }
71 $i
72 $i# Mount /usr (from slitaz-loram-cdrom package)
73 $i if [ -d /cdrom ]; then
74 $i DEVICE=/dev/cdrom
75 $i DIR=
76 $i if grep -q " loram=" /proc/cmdline; then
77 $i DIR=\`cat /proc/cmdline | sed 's/.* loram=\([^ ]*\).*/\1/'\`
78 $i DEVICE=\${DIR%,*}
79 $i DIR=/\${DIR#*,}
80 $i fi
81 $i if ! /bin/mount -r \$DEVICE /cdrom; then
82 $i if echo \$DEVICE | grep -Eq "/dev/sd|UUID=|LABEL="; then
83 $i USBDELAY=\`cat /sys/module/usb_storage/parameters/delay_use\`
84 $i USBDELAY=\$((1+\$USBDELAY))
85 $i echo "\$DEVICE is potentially a USB device: sleep for \$USBDELAY seconds"
86 $i sleep \$USBDELAY
87 $i fi
88 $i if ! /bin/mount -r \$DEVICE /cdrom; then
89 $i DEVICE=""
90 $i fi
91 $i fi
92 $i while [ -n "\$DEVICE" ]; do
93 $i if [ -d /.usr.rw ]; then
94 $i echo -n "Mounting /usr read-write... "
95 $i usr=.usr.ro
96 $i else
97 $i echo -n "Mounting /usr read-only... "
98 $i usr=usr
99 $i fi
100 $i FS=/cdrom\$DIR/usr.cromfs
101 $i if [ -f \$FS ]; then
102 $i release_cdrom && break
103 $i /bin/cromfs-driver \$FS /\$usr -o ro,dev,suid,allow_other
104 $i elif [ -f /cdrom\$DIR/usr.sqfs ]; then
105 $i FS=/cdrom\$DIR/usr.sqfs
106 $i release_cdrom && break
107 $i mount -o loop,ro -t squashfs \$FS /\$usr
108 $i elif [ -L /\$usr ]; then
109 $i FS=/cdrom\$DIR/usr
110 $i release_cdrom && break
111 $i true
112 $i else
113 $i umount /cdrom
114 $i false
115 $i fi
116 $i status
117 $i if [ -d /.usr.rw ]; then
118 $i if [ -x /bin/funionfs ]; then
119 $i /bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other -o suid,dev NONE /usr
120 $i else
121 $i /bin/mount -t aufs -o br:/.usr.rw:/.usr.ro none /usr
122 $i fi
123 $i fi
124 $i break
125 $i done
126 $i fi
127 $i
128 $tag
129 EOF
130 tag="/var/log/dmesg.log"
131 i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
132 i=$(($i-1))
133 len=9
134 tag=$(grep "$tag" $1/etc/init.d/rcS)
135 if [ "$2" = "-R" ]; then
136 line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
137 i="-"
138 else
139 line="-$i,2 +$i,$len"
140 i="+"
141 fi
142 busybox patch -p0 <<EOF
143 --- $1/etc/init.d/rcS
144 +++ $1/etc/init.d/rcS
145 @@ $line @@
147 $i# Build ramdisk if root=/dev/cdrom (from slitaz-loram-cdrom package)
148 $i if [ -L /root ]; then
149 $i mount -t tmpfs ramdisk /tmp
150 $i mkdir -p /tmp/log/lighttpd /tmp/run /tmp/lock
151 $i chown www.www /tmp/log/lighttpd
152 $i fi
153 $i
154 $tag
155 EOF
156 chmod 0755 $1/etc/init.d/rcS
157 }
159 # Pre and post install commands for Tazpkg.
160 pre_install()
161 {
162 local i
163 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do
164 [ "$i" = "$PACKAGE" ] && continue
165 yes y | tazpkg remove $i
166 . /etc/tazlito/tazlito.conf
167 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null
168 done
169 }
171 post_install()
172 {
173 set_patch "$1"
175 # Don't support FAST_BOOT_X yet
176 sed -i 's/FAST_BOOT_X=.*/FAST_BOOT_X="no"/' $1/etc/rcS.conf
178 cat <<EOF
179 ----
180 'tazlito gen-distro' will create a loram-cdrom flavor
181 while this package is installed.
182 EOF
183 if [ ! -x $1/bin/funionfs -a ! -d $1/var/lib/tazpkg/installed/aufs-utils ]; then
184 cat <<EOF
185 ----
186 You will build a live CD with /usr mounted read-only.
187 You can install aufs or funionfs to have read-write access into /usr with:
189 # tazpkg get-install aufs
190 or
191 # tazpkg get-install funionfs
193 EOF
194 fi
195 }
197 # Pre remove commands for Tazpkg.
198 pre_remove()
199 {
200 set_patch '' -R
201 cat <<EOF
202 ----
203 'tazlito gen-distro' will work as expected now.
204 EOF
205 }