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