wok view slitaz-loram-cdrom/receipt @ rev 3482
Update: gcc+gcj
author | Matthew Sheets <rcx@zoominternet.net> |
---|---|
date | Wed Jun 17 10:21:48 2009 +0000 (2009-06-17) |
parents | bc8f5b69f71c |
children | 3174fa1fd884 |
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-53)),55 +$(($i-53)),2"
29 i="-"
30 else
31 grep -q 'from slitaz-loram-cdrom package' $1/etc/init.d/rcS && return
32 line="-$i,2 +$i,55"
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 mount -o ro -t iso9660 /dev/cdrom /cdrom
58 $i if [ -d /.usr.rw ]; then
59 $i echo -n "Mounting /usr read-write... "
60 $i usr=.usr.ro
61 $i else
62 $i echo -n "Mounting /usr read-only... "
63 $i usr=usr
64 $i fi
65 $i FS=/cdrom/usr.cromfs
66 $i if [ -f \$FS ]; then
67 $i release_cdrom
68 $i /bin/cromfs-driver \$FS /\$usr -o ro,dev,suid,allow_other
69 $i elif [ -f /cdrom/usr.sqfs ]; then
70 $i FS=/cdrom/usr.sqfs
71 $i release_cdrom
72 $i mount -o loop,ro -t squashfs \$FS /\$usr
73 $i elif [ -L /\$usr ]; then
74 $i FS=/cdrom/usr
75 $i if release_cdrom; then
76 $i rm -f /\$usr
77 $i mv \$FS /usr
78 $i fi
79 $i else
80 $i umount /cdrom
81 $i false
82 $i fi
83 $i status
84 $i if [ -d /.usr.rw ]; then
85 $i if [ -x /bin/funionfs ]; then
86 $i /bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other -o suid,dev NONE /usr
87 $i else
88 $i /bin/mount -t aufs -o br:/.usr.rw:/.usr.ro none /usr
89 $i fi
90 $i fi
91 $i fi
92 $i
93 $tag
94 EOF
95 tag="/var/log/dmesg.log"
96 i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
97 i=$(($i-1))
98 tag=$(grep "$tag" $1/etc/init.d/rcS)
99 if [ "$2" = "-R" ]; then
100 line="-$(($i-7)),9 +$(($i-7)),2"
101 i="-"
102 else
103 line="-$i,2 +$i,9"
104 i="+"
105 fi
106 patch -p0 <<EOF
107 --- $1/etc/init.d/rcS
108 +++ $1/etc/init.d/rcS
109 @@ $line @@
111 $i# Build ramdisk if root=/dev/cdrom (from slitaz-loram-cdrom package)
112 $i if [ -L /root ]; then
113 $i mount -t tmpfs ramdisk /tmp
114 $i mkdir -p /tmp/log/lighttpd /tmp/run /tmp/lock
115 $i chown www.www /tmp/log/lighttpd
116 $i fi
117 $i
118 $tag
119 EOF
120 chmod 0755 $1/etc/init.d/rcS
121 }
123 # Pre and post install commands for Tazpkg.
124 pre_install()
125 {
126 local i
127 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do
128 [ "$i" = "$PACKAGE" ] && continue
129 yes y | tazpkg remove $i
130 . /etc/tazlito/tazlito.conf
131 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null
132 done
133 }
135 post_install()
136 {
137 set_patch "$1"
138 if [ ! -x $1/bin/funionfs -a ! -d $1/var/lib/tazpkg/installed/aufs ]; then
139 cat <<EOF
140 ----
141 You will build a live CD with /usr mounted read-only.
142 You can install aufs or funionfs to have read-write access into /usr with:
144 # tazpkg get-install aufs
145 or
146 # tazpkg get-install funionfs
148 EOF
149 fi
150 }
152 # Pre remove commands for Tazpkg.
153 pre_remove()
154 {
155 set_patch '' -R
156 }