wok-6.x view slitaz-loram-cdrom/receipt @ rev 1404

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