wok-stable view slitaz-loram-cdrom/receipt @ rev 3899
Add scribus
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Aug 15 10:41:17 2009 +0200 (2009-08-15) |
parents | d37cb8649ac6 |
children | 0e169dcb3f73 |
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-60)),62 +$(($i-60)),2"
29 i="-"
30 else
31 grep -q 'from slitaz-loram-cdrom package' $1/etc/init.d/rcS && return
32 line="-$i,2 +$i,62"
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=\$(free | awk '{ n = \$NF } END { print n }')
44 $i if [ \$FREEMEM -gt \$(du -s \$FS | 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 mount -o ro \$DEVICE /cdrom
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
100 $tag
101 EOF
102 tag="/var/log/dmesg.log"
103 i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
104 i=$(($i-1))
105 tag=$(grep "$tag" $1/etc/init.d/rcS)
106 if [ "$2" = "-R" ]; then
107 line="-$(($i-7)),9 +$(($i-7)),2"
108 i="-"
109 else
110 line="-$i,2 +$i,9"
111 i="+"
112 fi
113 patch -p0 <<EOF
114 --- $1/etc/init.d/rcS
115 +++ $1/etc/init.d/rcS
116 @@ $line @@
118 $i# Build ramdisk if root=/dev/cdrom (from slitaz-loram-cdrom package)
119 $i if [ -L /root ]; then
120 $i mount -t tmpfs ramdisk /tmp
121 $i mkdir -p /tmp/log/lighttpd /tmp/run /tmp/lock
122 $i chown www.www /tmp/log/lighttpd
123 $i fi
124 $i
125 $tag
126 EOF
127 chmod 0755 $1/etc/init.d/rcS
128 }
130 # Pre and post install commands for Tazpkg.
131 pre_install()
132 {
133 local i
134 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do
135 [ "$i" = "$PACKAGE" ] && continue
136 yes y | tazpkg remove $i
137 . /etc/tazlito/tazlito.conf
138 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null
139 done
140 }
142 post_install()
143 {
144 set_patch "$1"
145 if [ ! -x $1/bin/funionfs -a ! -d $1/var/lib/tazpkg/installed/aufs ]; then
146 cat <<EOF
147 ----
148 You will build a live CD with /usr mounted read-only.
149 You can install aufs or funionfs to have read-write access into /usr with:
151 # tazpkg get-install aufs
152 or
153 # tazpkg get-install funionfs
155 EOF
156 fi
157 }
159 # Pre remove commands for Tazpkg.
160 pre_remove()
161 {
162 set_patch '' -R
163 }