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