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