wok view slitaz-loram-cdrom/receipt @ rev 4314

Up: libogg, libtheora, *vorbis* to last stable release
author Christophe Lincoln <pankso@slitaz.org>
date Mon Sep 28 21:13:27 2009 +0200 (2009-09-28)
parents 6509db5aa948
children d9ddcc6d973c
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=87
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=\$(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 if grep -q " extract-loram" /proc/cmdline &&
48 $i [ -d \$FS -o \$FREEMEM -gt \$(busybox du -s \$FS | \\
49 $i busybox 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 else
112 $i umount /cdrom
113 $i false
114 $i fi
115 $i status
116 $i if [ -d /.usr.rw ]; then
117 $i if [ -x /bin/funionfs ]; then
118 $i /bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other -o suid,dev NONE /usr
119 $i else
120 $i /bin/mount -t aufs -o br:/.usr.rw:/.usr.ro none /usr
121 $i fi
122 $i fi
123 $i break
124 $i done
125 $i fi
126 $i
127 $tag
128 EOF
129 tag="/var/log/dmesg.log"
130 i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
131 i=$(($i-1))
132 len=9
133 tag=$(grep "$tag" $1/etc/init.d/rcS)
134 if [ "$2" = "-R" ]; then
135 line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
136 i="-"
137 else
138 line="-$i,2 +$i,$len"
139 i="+"
140 fi
141 busybox patch -p0 <<EOF
142 --- $1/etc/init.d/rcS
143 +++ $1/etc/init.d/rcS
144 @@ $line @@
146 $i# Build ramdisk if root=/dev/cdrom (from slitaz-loram-cdrom package)
147 $i if [ -L /root ]; then
148 $i mount -t tmpfs ramdisk /tmp
149 $i mkdir -p /tmp/log/lighttpd /tmp/run /tmp/lock
150 $i chown www.www /tmp/log/lighttpd
151 $i fi
152 $i
153 $tag
154 EOF
155 chmod 0755 $1/etc/init.d/rcS
156 }
158 # Pre and post install commands for Tazpkg.
159 pre_install()
160 {
161 local i
162 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do
163 [ "$i" = "$PACKAGE" ] && continue
164 yes y | tazpkg remove $i
165 . /etc/tazlito/tazlito.conf
166 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null
167 done
168 }
170 post_install()
171 {
172 set_patch "$1"
173 if [ ! -x $1/bin/funionfs -a ! -d $1/var/lib/tazpkg/installed/aufs ]; then
174 cat <<EOF
175 ----
176 You will build a live CD with /usr mounted read-only.
177 You can install aufs or funionfs to have read-write access into /usr with:
179 # tazpkg get-install aufs
180 or
181 # tazpkg get-install funionfs
183 EOF
184 fi
185 }
187 # Pre remove commands for Tazpkg.
188 pre_remove()
189 {
190 set_patch '' -R
191 }