rev |
line source |
pascal@251
|
1 # SliTaz package receipt.
|
pascal@251
|
2
|
pascal@251
|
3 PACKAGE="slitaz-loram-cdrom"
|
pascal@4099
|
4 VERSION="1.5"
|
pascal@251
|
5 CATEGORY="misc"
|
pascal@251
|
6 SHORT_DESC="Rules to build low ram system using cdrom."
|
pascal@251
|
7 MAINTAINER="pascal.bellard@slitaz.org"
|
pankso@422
|
8 WEB_SITE="http://www.slitaz.org/"
|
pascal@1964
|
9 DEPENDS="slitaz-boot-scripts tazlito"
|
pascal@251
|
10
|
pascal@251
|
11 # Rules to gen a SliTaz package suitable for Tazpkg.
|
pascal@251
|
12 genpkg_rules()
|
pascal@251
|
13 {
|
pascal@251
|
14 mkdir -p $fs/etc/tazlito
|
pascal@370
|
15 cp stuff/loram.* $fs/etc/tazlito
|
pascal@251
|
16 }
|
pascal@251
|
17
|
pascal@377
|
18 set_patch()
|
pascal@251
|
19 {
|
pascal@370
|
20 local tag
|
pascal@370
|
21 local line
|
pascal@4099
|
22 local len
|
pascal@370
|
23 local i
|
pascal@370
|
24 tag="Handle kernel cmdline parameter config"
|
pascal@375
|
25 i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
|
pascal@370
|
26 i=$(($i-1))
|
pascal@4099
|
27 len=87
|
pascal@375
|
28 tag=$(grep "$tag" $1/etc/init.d/rcS)
|
pascal@375
|
29 if [ "$2" = "-R" ]; then
|
pascal@4099
|
30 line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
|
pascal@370
|
31 i="-"
|
pascal@370
|
32 else
|
pascal@390
|
33 grep -q 'from slitaz-loram-cdrom package' $1/etc/init.d/rcS && return
|
pascal@4099
|
34 line="-$i,2 +$i,$len"
|
pascal@370
|
35 i="+"
|
pascal@370
|
36 fi
|
pascal@377
|
37 patch -p0 <<EOF
|
pascal@375
|
38 --- $1/etc/init.d/rcS
|
pascal@375
|
39 +++ $1/etc/init.d/rcS
|
pascal@370
|
40 @@ $line @@
|
pascal@309
|
41
|
pascal@768
|
42 $i# Try to release the cdrom (from slitaz-loram-cdrom package)
|
pascal@768
|
43 $i release_cdrom()
|
pascal@768
|
44 $i {
|
pascal@4046
|
45 $i FREEMEM=\$(busybox free | busybox awk '{ n = \$NF } END { print n }')
|
pascal@4046
|
46 $i if [ \$FREEMEM -gt \$(busybox du -s \$FS | busybox awk '{ print \$1+40000 }') ]; then
|
pascal@4099
|
47 $i if grep -q " extract-loram" /proc/cmdline &&
|
pascal@4099
|
48 $i [ -d \$FS -o \$FREEMEM -gt \$(busybox du -s \$FS | \\
|
pascal@4099
|
49 $i busybox awk '{ print (\$1*4)+40000 }') ]; then
|
pascal@4099
|
50 $i echo -n "Extracting loram..."
|
pascal@4099
|
51 $i . /etc/tazlito/loram.extract /cdrom
|
pascal@4099
|
52 $i if status; then
|
pascal@4099
|
53 $i umount /cdrom
|
pascal@4099
|
54 $i rmdir /cdrom
|
pascal@4099
|
55 $i yes y | tazpkg remove slitaz-loram-cdrom > /dev/null
|
pascal@4099
|
56 $i return 0
|
pascal@4099
|
57 $i fi
|
pascal@4099
|
58 $i fi
|
pascal@768
|
59 $i cp -a \$FS /.usr.fs
|
pascal@768
|
60 $i status
|
pascal@768
|
61 $i echo -n "Releasing CD-ROM..."
|
pascal@768
|
62 $i umount /cdrom
|
pascal@768
|
63 $i FS=/.usr.fs
|
pascal@4099
|
64 $i if [ -d \$FS ]; then
|
pascal@4099
|
65 $i rm -f /\$usr
|
pascal@4099
|
66 $i mv \$FS /usr
|
pascal@4099
|
67 $i fi
|
pascal@768
|
68 $i fi
|
pascal@768
|
69 $i return 1
|
pascal@768
|
70 $i }
|
pascal@768
|
71 $i
|
pascal@390
|
72 $i# Mount /usr (from slitaz-loram-cdrom package)
|
pascal@370
|
73 $i if [ -d /cdrom ]; then
|
pascal@3898
|
74 $i DEVICE=/dev/cdrom
|
pascal@3898
|
75 $i DIR=
|
pascal@3898
|
76 $i if grep -q " loram=" /proc/cmdline; then
|
pascal@3898
|
77 $i DIR=\`cat /proc/cmdline | sed 's/.* loram=\([^ ]*\).*/\1/'\`
|
pascal@3898
|
78 $i DEVICE=\${DIR%,*}
|
pascal@3898
|
79 $i DIR=/\${DIR#*,}
|
pascal@3898
|
80 $i fi
|
pascal@4082
|
81 $i if ! /bin/mount -r \$DEVICE /cdrom; then
|
pascal@4082
|
82 $i if echo \$DEVICE | grep -Eq "/dev/sd|UUID=|LABEL="; then
|
pascal@4082
|
83 $i USBDELAY=\`cat /sys/module/usb_storage/parameters/delay_use\`
|
pascal@4082
|
84 $i USBDELAY=\$((1+\$USBDELAY))
|
pascal@4082
|
85 $i echo "\$DEVICE is potentially a USB device: sleep for \$USBDELAY seconds"
|
pascal@4082
|
86 $i sleep \$USBDELAY
|
pascal@4082
|
87 $i fi
|
pascal@4082
|
88 $i if ! /bin/mount -r \$DEVICE /cdrom; then
|
pascal@4082
|
89 $i DEVICE=""
|
pascal@4082
|
90 $i fi
|
pascal@4082
|
91 $i fi
|
pascal@4099
|
92 $i while [ -n "\$DEVICE" ]; do
|
pascal@3915
|
93 $i if [ -d /.usr.rw ]; then
|
pascal@3915
|
94 $i echo -n "Mounting /usr read-write... "
|
pascal@3915
|
95 $i usr=.usr.ro
|
pascal@3915
|
96 $i else
|
pascal@3915
|
97 $i echo -n "Mounting /usr read-only... "
|
pascal@3915
|
98 $i usr=usr
|
pascal@768
|
99 $i fi
|
pascal@3915
|
100 $i FS=/cdrom\$DIR/usr.cromfs
|
pascal@3915
|
101 $i if [ -f \$FS ]; then
|
pascal@4099
|
102 $i release_cdrom && break
|
pascal@3915
|
103 $i /bin/cromfs-driver \$FS /\$usr -o ro,dev,suid,allow_other
|
pascal@3915
|
104 $i elif [ -f /cdrom\$DIR/usr.sqfs ]; then
|
pascal@3915
|
105 $i FS=/cdrom\$DIR/usr.sqfs
|
pascal@4099
|
106 $i release_cdrom && break
|
pascal@3915
|
107 $i mount -o loop,ro -t squashfs \$FS /\$usr
|
pascal@3915
|
108 $i elif [ -L /\$usr ]; then
|
pascal@3915
|
109 $i FS=/cdrom\$DIR/usr
|
pascal@4099
|
110 $i release_cdrom && break
|
pascal@1884
|
111 $i else
|
pascal@3915
|
112 $i umount /cdrom
|
pascal@3915
|
113 $i false
|
pascal@3915
|
114 $i fi
|
pascal@3915
|
115 $i status
|
pascal@3915
|
116 $i if [ -d /.usr.rw ]; then
|
pascal@3915
|
117 $i if [ -x /bin/funionfs ]; then
|
pascal@3915
|
118 $i /bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other -o suid,dev NONE /usr
|
pascal@3915
|
119 $i else
|
pascal@3915
|
120 $i /bin/mount -t aufs -o br:/.usr.rw:/.usr.ro none /usr
|
pascal@3915
|
121 $i fi
|
pascal@1884
|
122 $i fi
|
pascal@4099
|
123 $i break
|
pascal@4099
|
124 $i done
|
pascal@370
|
125 $i fi
|
pascal@370
|
126 $i
|
pascal@370
|
127 $tag
|
pascal@251
|
128 EOF
|
pascal@780
|
129 tag="/var/log/dmesg.log"
|
pascal@780
|
130 i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
|
pascal@780
|
131 i=$(($i-1))
|
pascal@4099
|
132 len=9
|
pascal@780
|
133 tag=$(grep "$tag" $1/etc/init.d/rcS)
|
pascal@780
|
134 if [ "$2" = "-R" ]; then
|
pascal@4099
|
135 line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
|
pascal@780
|
136 i="-"
|
pascal@780
|
137 else
|
pascal@4099
|
138 line="-$i,2 +$i,$len"
|
pascal@780
|
139 i="+"
|
pascal@780
|
140 fi
|
pascal@780
|
141 patch -p0 <<EOF
|
pascal@780
|
142 --- $1/etc/init.d/rcS
|
pascal@780
|
143 +++ $1/etc/init.d/rcS
|
pascal@780
|
144 @@ $line @@
|
pascal@780
|
145
|
pascal@780
|
146 $i# Build ramdisk if root=/dev/cdrom (from slitaz-loram-cdrom package)
|
pascal@780
|
147 $i if [ -L /root ]; then
|
pascal@780
|
148 $i mount -t tmpfs ramdisk /tmp
|
pascal@780
|
149 $i mkdir -p /tmp/log/lighttpd /tmp/run /tmp/lock
|
pascal@780
|
150 $i chown www.www /tmp/log/lighttpd
|
pascal@780
|
151 $i fi
|
pascal@780
|
152 $i
|
pascal@780
|
153 $tag
|
pascal@780
|
154 EOF
|
pascal@375
|
155 chmod 0755 $1/etc/init.d/rcS
|
pascal@251
|
156 }
|
pascal@251
|
157
|
pascal@251
|
158 # Pre and post install commands for Tazpkg.
|
pascal@251
|
159 pre_install()
|
pascal@251
|
160 {
|
pascal@380
|
161 local i
|
pascal@380
|
162 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do
|
pascal@380
|
163 [ "$i" = "$PACKAGE" ] && continue
|
pascal@380
|
164 yes y | tazpkg remove $i
|
pascal@1285
|
165 . /etc/tazlito/tazlito.conf
|
pascal@390
|
166 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null
|
pascal@380
|
167 done
|
pascal@251
|
168 }
|
pascal@251
|
169
|
pascal@251
|
170 post_install()
|
pascal@251
|
171 {
|
pascal@380
|
172 set_patch "$1"
|
pascal@1884
|
173 if [ ! -x $1/bin/funionfs -a ! -d $1/var/lib/tazpkg/installed/aufs ]; then
|
pascal@371
|
174 cat <<EOF
|
pascal@390
|
175 ----
|
pascal@371
|
176 You will build a live CD with /usr mounted read-only.
|
pascal@1884
|
177 You can install aufs or funionfs to have read-write access into /usr with:
|
pascal@390
|
178
|
pascal@1884
|
179 # tazpkg get-install aufs
|
pascal@1884
|
180 or
|
pascal@371
|
181 # tazpkg get-install funionfs
|
pascal@390
|
182
|
pascal@371
|
183 EOF
|
pascal@371
|
184 fi
|
pascal@251
|
185 }
|
pascal@251
|
186
|
pascal@251
|
187 # Pre remove commands for Tazpkg.
|
pascal@251
|
188 pre_remove()
|
pascal@251
|
189 {
|
pascal@377
|
190 set_patch '' -R
|
pascal@251
|
191 }
|