wok-next view slitaz-loram/receipt @ rev 11620

Up slitaz-boot-scripts (4.6)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Jan 24 11:48:19 2012 +0100 (2012-01-24)
parents fd85055f79db
children f7cdbd605b68
line source
1 # SliTaz package receipt.
3 PACKAGE="slitaz-loram"
4 VERSION="1.6"
5 CATEGORY="misc"
6 SHORT_DESC="Rules to build low ram rootfs.gz."
7 MAINTAINER="pascal.bellard@slitaz.org"
8 DEPENDS="slitaz-boot-scripts tazlito cromfs-or-squashfs"
9 WEB_SITE="http://www.slitaz.org/"
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 len
23 local i
24 tag="Fast boot into X"
25 i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
26 i=$(($i-1))
27 len=38
28 tag=$(grep "$tag" $1/etc/init.d/rcS)
29 if [ "$2" = "-R" ]; then
30 line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
31 i="-"
32 else
33 grep -q 'from slitaz-loram package' $1/etc/init.d/rcS && return
34 line="-$i,2 +$i,$len"
35 i="+"
36 fi
37 busybox patch -p0 <<EOF
38 --- $1/etc/init.d/rcS
39 +++ $1/etc/init.d/rcS
40 @@ $line @@
42 $i# Mount compressed /usr (from slitaz-loram package)
43 $i while [ -f /.usr.cromfs -o -f /.usr.sqfs ]; do
44 $i usr=usr
45 $i echo -n "Mounting /usr read-"
46 $i if [ -d /.usr.rw ]; then
47 $i usr=.usr.ro
48 $i echo -n "write... "
49 $i else
50 $i echo -n "only... "
51 $i fi
52 $i FREEMEM=\$(free | awk '{ n = \$NF } END { print n }')
53 $i if ! grep -q " keep-loram" /proc/cmdline && [ \$FREEMEM -gt \\
54 $i \$(du -s \$FS | awk '{ print (\$1*4)+40000 }') ]; then
55 $i echo -n "Extracting loram..."
56 $i . /etc/tazlito/loram.extract
57 $i if status; then
58 $i yes y | tazpkg remove slitaz-loram > /dev/null
59 $i break
60 $i fi
61 $i fi
62 $i if [ -f /.usr.cromfs ]; then
63 $i /bin/cromfs-driver /.usr.cromfs /\$usr -o ro,dev,suid,allow_other
64 $i else
65 $i /bin/mount -o loop,ro -t squashfs /.usr.sqfs /\$usr
66 $i fi
67 $i if [ -d /.usr.rw ]; then
68 $i if [ -x bin/funionfs ]; then
69 $i /bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other -o suid,dev NONE /usr
70 $i else
71 $i /bin/mount -t aufs -o br:/.usr.rw:/.usr.ro none /usr
72 $i fi
73 $i fi
74 $i status
75 $i break
76 $i done
77 $i
78 $tag
79 EOF
80 chmod 0755 $1/etc/init.d/rcS
81 }
83 # Pre and post install commands for Tazpkg.
84 pre_install()
85 {
86 local i
87 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do
88 [ "$i" = "$PACKAGE" ] && continue
89 yes y | tazpkg remove $i
90 . /etc/tazlito/tazlito.conf
91 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null
92 done
93 }
95 post_install()
96 {
97 set_patch "$1"
98 cat <<EOF
99 ----
100 'tazlito gen-distro' will create a loram flavor while this package is installed.
101 EOF
102 if [ ! -x $1/bin/funionfs -a ! -d $1/var/lib/tazpkg/installed/aufs-utils ]; then
103 cat <<EOF
104 ----
105 You will build a live CD with /usr mounted read-only.
106 You can install aufs or funionfs to have read-write access into /usr with:
108 # tazpkg get-install aufs
109 or
110 # tazpkg get-install funionfs
112 EOF
113 fi
114 }
116 # Pre remove commands for Tazpkg.
117 pre_remove()
118 {
119 set_patch '' -R
120 cat <<EOF
121 ----
122 'tazlito gen-distro' will work as expected now.
123 EOF
124 }