wok view slitaz-loram-cdrom/receipt @ rev 768

slitaz-loram-cdrom: version 1.2, may release cdrom
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun May 11 00:32:32 2008 +0000 (2008-05-11)
parents e0ad9f116fca
children 2857e33d1bb6
line source
1 # SliTaz package receipt.
3 PACKAGE="slitaz-loram-cdrom"
4 VERSION="1.2"
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
68 $i FS=/cdrom/usr.sqfs
69 $i elif [ -f \$FS ]; then
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 NONE /usr
85 $i fi
86 $i fi
87 $i
88 $tag
89 EOF
90 chmod 0755 $1/etc/init.d/rcS
91 }
93 # Pre and post install commands for Tazpkg.
94 pre_install()
95 {
96 local i
97 . /etc/tazlito/tazlito.conf
98 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do
99 [ "$i" = "$PACKAGE" ] && continue
100 yes y | tazpkg remove $i
101 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null
102 done
103 }
105 post_install()
106 {
107 set_patch "$1"
108 if [ ! -x /bin/funionfs ]; then
109 cat <<EOF
110 ----
111 You will build a live CD with /usr mounted read-only.
112 You can install funionfs to have read-write access into /usr with:
114 # tazpkg get-install funionfs
116 EOF
117 fi
118 }
120 # Pre remove commands for Tazpkg.
121 pre_remove()
122 {
123 set_patch '' -R
124 }