wok-stable annotate slitaz-loram-http/receipt @ rev 5048

slitaz-loram*: be FAST_BOOT_X aware
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Mar 05 17:52:43 2010 +0100 (2010-03-05)
parents 81178a538337
children 3cdfaefe3387
rev   line source
pascal@1290 1 # SliTaz package receipt.
pascal@1290 2
pascal@1290 3 PACKAGE="slitaz-loram-http"
pascal@4099 4 VERSION="1.5"
pascal@1290 5 CATEGORY="misc"
pascal@1290 6 SHORT_DESC="Rules to build low ram system using http."
pascal@1290 7 MAINTAINER="pascal.bellard@slitaz.org"
pascal@1290 8 WEB_SITE="http://www.slitaz.org/"
pascal@1964 9 DEPENDS="slitaz-boot-scripts tazlito httpfs-fuse funionfs"
pascal@1290 10
pascal@1290 11 # Rules to gen a SliTaz package suitable for Tazpkg.
pascal@1290 12 genpkg_rules()
pascal@1290 13 {
pascal@1290 14 mkdir -p $fs/etc/tazlito
pascal@1290 15 cp stuff/loram.* $fs/etc/tazlito
pascal@1290 16 }
pascal@1290 17
pascal@1290 18 set_patch()
pascal@1290 19 {
pascal@1290 20 local tag
pascal@1290 21 local line
pascal@4099 22 local len
pascal@1290 23 local i
pascal@1290 24 tag="Handle kernel cmdline parameter config"
pascal@1290 25 i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
pascal@1290 26 i=$(($i-1))
pascal@4730 27 len=72
pascal@1290 28 tag=$(grep "$tag" $1/etc/init.d/rcS)
pascal@1290 29 if [ "$2" = "-R" ]; then
pascal@4099 30 line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
pascal@1290 31 i="-"
pascal@1290 32 else
pascal@1290 33 grep -q 'from slitaz-loram-http package' $1/etc/init.d/rcS && return
pascal@4099 34 line="-$i,2 +$i,$len"
pascal@1290 35 i="+"
pascal@1290 36 fi
pascal@4186 37 busybox patch -p0 <<EOF
pascal@1290 38 --- $1/etc/init.d/rcS
pascal@1290 39 +++ $1/etc/init.d/rcS
pascal@1290 40 @@ $line @@
pascal@1290 41
pascal@1290 42 $i# Try to release http link (from slitaz-loram-http package)
pascal@1290 43 $i release_http()
pascal@1290 44 $i {
pascal@4454 45 $i FREEMEM=\$(free | awk '{ n = \$NF } END { print n }')
pascal@4454 46 $i if [ \$FREEMEM -gt \$(du -s \$FS | awk '{ print \$1+40000 }') ]; then
pascal@1290 47 $i status
pascal@4503 48 $i if ! grep -q " keep-loram" /proc/cmdline &&
pascal@4454 49 $i [ -d \$FS -o \$FREEMEM -gt \$(du -s \$FS | \\
pascal@4454 50 $i awk '{ print (\$1*4)+40000 }') ]; then
pascal@4099 51 $i echo -n "Extracting loram..."
pascal@4099 52 $i . /etc/tazlito/loram.extract /cdrom
pascal@4099 53 $i if status; then
pascal@4099 54 $i umount /cdrom && umount /cdrom
pascal@4099 55 $i rmdir /cdrom
pascal@4099 56 $i yes y | tazpkg remove slitaz-loram-http > /dev/null
pascal@4099 57 $i return 0
pascal@4099 58 $i fi
pascal@4099 59 $i fi
pascal@1290 60 $i echo -n "Loading /usr in memory..."
pascal@1290 61 $i cp -a \$FS /.usr.fs
pascal@1290 62 $i status
pascal@1290 63 $i echo -n "Releasing HTTP link..."
pascal@1290 64 $i umount /cdrom && umount /cdrom
pascal@1290 65 $i FS=/.usr.fs
pascal@4099 66 $i if [ -d \$FS ]; then
pascal@4099 67 $i rm -f /\$usr
pascal@4099 68 $i mv \$FS /usr
pascal@4099 69 $i fi
pascal@1290 70 $i fi
pascal@1290 71 $i return 1
pascal@1290 72 $i }
pascal@1290 73 $i
pascal@1290 74 $i# Mount /usr (from slitaz-loram-http package)
pascal@4099 75 $i while [ -d /cdrom ]; do
pascal@1290 76 $i /etc/init.d/network.sh
pascal@1290 77 $i RUN_SCRIPTS="\$(echo \$RUN_SCRIPTS | sed 's/network.sh//')"
pascal@4397 78 $i URLISO=http://mirror.slitaz.org/iso/\$(cat /etc/slitaz-release)/flavors/slitaz-loram-cdrom.iso,http://download.tuxfamily.org/slitaz/iso/\$(cat /etc/slitaz-release)/flavors/slitaz-loram-cdrom.iso,http://slitaz.c3sl.ufpr.br/iso/\$(cat /etc/slitaz-release)/flavors/slitaz-loram-cdrom.iso
pascal@4397 79 $i grep -q " urliso=" /proc/cmdline && URLISO=\$(cat /proc/cmdline | sed 's/.* urliso=\([^ ]*\).*/\1/'),\$URLISO
pascal@4397 80 $i for i in \$(echo \$URLISO | sed 's/,/ /g'); do
pascal@4728 81 $i /bin/httpfs \$i /cdrom && break
pascal@4397 82 $i done
pascal@1290 83 $i mount -o loop,ro /cdrom/*.iso /cdrom
pascal@1290 84 $i if [ -d /.usr.rw -a -x /bin/funionfs ]; then
pascal@1290 85 $i echo -n "Mounting /usr read-write... "
pascal@1290 86 $i usr=.usr.ro
pascal@1290 87 $i else
pascal@1290 88 $i echo -n "Mounting /usr read-only... "
pascal@1290 89 $i usr=usr
pascal@1290 90 $i fi
pascal@1290 91 $i FS=/cdrom/usr.cromfs
pascal@1290 92 $i if [ -f \$FS ]; then
pascal@1290 93 $i mkdir /\$usr
pascal@4099 94 $i release_http && break
pascal@1339 95 $i /bin/cromfs-driver \$FS /\$usr -o ro,dev,suid,allow_other
pascal@1290 96 $i elif [ -f /cdrom/usr.sqfs ]; then
pascal@1290 97 $i FS=/cdrom/usr.sqfs
pascal@1290 98 $i mkdir /\$usr
pascal@4099 99 $i release_http && break
pascal@1290 100 $i mount -o loop,ro -t squashfs \$FS /\$usr
pascal@1290 101 $i else
pascal@1290 102 $i FS=/cdrom/usr
pascal@1290 103 $i ln -s \$FS /\$usr
pascal@1290 104 $i fi
pascal@1290 105 $i status
pascal@1290 106 $i if [ -d /.usr.rw -a -x /bin/funionfs ]; then
pascal@1339 107 $i /bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other,nonempty -o suid,dev NONE /usr
pascal@1290 108 $i fi
pascal@4099 109 $i break
pascal@4099 110 $i done
pascal@1290 111 $i
pascal@1290 112 $tag
pascal@1290 113 EOF
pascal@1290 114 chmod 0755 $1/etc/init.d/rcS
pascal@1290 115 }
pascal@1290 116
pascal@1290 117 # Pre and post install commands for Tazpkg.
pascal@1290 118 pre_install()
pascal@1290 119 {
pascal@1290 120 local i
pascal@1290 121 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do
pascal@1290 122 [ "$i" = "$PACKAGE" ] && continue
pascal@1290 123 yes y | tazpkg remove $i
pascal@1290 124 . /etc/tazlito/tazlito.conf
pascal@1290 125 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null
pascal@1290 126 done
pascal@1290 127 }
pascal@1290 128
pascal@1290 129 post_install()
pascal@1290 130 {
pascal@1290 131 set_patch "$1"
pascal@5048 132
pascal@5048 133 # Don't support FAST_BOOT_X yet
pascal@5048 134 sed -i 's/FAST_BOOT_X=.*/FAST_BOOT_X="no"/' $1/etc/rcS.conf
pascal@5048 135
pascal@4503 136 cat <<EOF
pascal@4503 137 ----
pascal@4503 138 'tazlito gen-distro' will create a loram-http flavor
pascal@4503 139 while this package is installed.
pascal@4503 140 EOF
pascal@1290 141 if [ ! -x $1/bin/funionfs ]; then
pascal@1290 142 cat <<EOF
pascal@1290 143 ----
pascal@1290 144 You will build a live CD with /usr mounted read-only.
pascal@1290 145 You can install funionfs to have read-write access into /usr with:
pascal@1290 146
pascal@1290 147 # tazpkg get-install funionfs
pascal@1290 148
pascal@1290 149 EOF
pascal@1290 150 fi
pascal@1290 151 }
pascal@1290 152
pascal@1290 153 # Pre remove commands for Tazpkg.
pascal@1290 154 pre_remove()
pascal@1290 155 {
pascal@1290 156 set_patch '' -R
pascal@4503 157 cat <<EOF
pascal@4503 158 ----
pascal@4503 159 'tazlito gen-distro' will work as expected now.
pascal@4503 160 EOF
pascal@1290 161 }