wok annotate slitaz-loram-cdrom/receipt @ rev 1216

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