wok-current annotate slitaz-loram-cdrom/receipt @ rev 7176

Up: libupnp-dev to 1.6.9. I forgot to commit this.
author Christopher Rogers <slaxemulator@gmail.com>
date Sun Nov 07 23:39:20 2010 +0000 (2010-11-07)
parents 7ae478e2ad1e
children f7cdbd605b68
rev   line source
pascal@251 1 # SliTaz package receipt.
pascal@251 2
pascal@251 3 PACKAGE="slitaz-loram-cdrom"
pascal@4099 4 VERSION="1.5"
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@1964 9 DEPENDS="slitaz-boot-scripts tazlito"
pascal@251 10
pascal@251 11 # Rules to gen a SliTaz package suitable for Tazpkg.
pascal@251 12 genpkg_rules()
pascal@251 13 {
pascal@251 14 mkdir -p $fs/etc/tazlito
pascal@370 15 cp stuff/loram.* $fs/etc/tazlito
pascal@251 16 }
pascal@251 17
pascal@377 18 set_patch()
pascal@251 19 {
pascal@370 20 local tag
pascal@370 21 local line
pascal@4099 22 local len
pascal@370 23 local i
pascal@370 24 tag="Handle kernel cmdline parameter config"
pascal@375 25 i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
pascal@370 26 i=$(($i-1))
pascal@4726 27 len=88
pascal@375 28 tag=$(grep "$tag" $1/etc/init.d/rcS)
pascal@375 29 if [ "$2" = "-R" ]; then
pascal@4099 30 line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
pascal@370 31 i="-"
pascal@370 32 else
pascal@390 33 grep -q 'from slitaz-loram-cdrom package' $1/etc/init.d/rcS && return
pascal@4099 34 line="-$i,2 +$i,$len"
pascal@370 35 i="+"
pascal@370 36 fi
pascal@4186 37 busybox patch -p0 <<EOF
pascal@375 38 --- $1/etc/init.d/rcS
pascal@375 39 +++ $1/etc/init.d/rcS
pascal@370 40 @@ $line @@
pascal@309 41
pascal@768 42 $i# Try to release the cdrom (from slitaz-loram-cdrom package)
pascal@768 43 $i release_cdrom()
pascal@768 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@4503 47 $i if ! grep -q " keep-loram" /proc/cmdline &&
pascal@4454 48 $i [ -d \$FS -o \$FREEMEM -gt \$(du -s \$FS | \\
pascal@4454 49 $i awk '{ print (\$1*4)+40000 }') ]; then
pascal@4099 50 $i echo -n "Extracting loram..."
pascal@4099 51 $i . /etc/tazlito/loram.extract /cdrom
pascal@4099 52 $i if status; then
pascal@4099 53 $i umount /cdrom
pascal@4099 54 $i rmdir /cdrom
pascal@4099 55 $i yes y | tazpkg remove slitaz-loram-cdrom > /dev/null
pascal@4099 56 $i return 0
pascal@4099 57 $i fi
pascal@4099 58 $i fi
pascal@768 59 $i cp -a \$FS /.usr.fs
pascal@768 60 $i status
pascal@768 61 $i echo -n "Releasing CD-ROM..."
pascal@768 62 $i umount /cdrom
pascal@768 63 $i FS=/.usr.fs
pascal@4099 64 $i if [ -d \$FS ]; then
pascal@4099 65 $i rm -f /\$usr
pascal@4099 66 $i mv \$FS /usr
pascal@4099 67 $i fi
pascal@768 68 $i fi
pascal@768 69 $i return 1
pascal@768 70 $i }
pascal@768 71 $i
pascal@390 72 $i# Mount /usr (from slitaz-loram-cdrom package)
pascal@370 73 $i if [ -d /cdrom ]; then
pascal@3898 74 $i DEVICE=/dev/cdrom
pascal@3898 75 $i DIR=
pascal@3898 76 $i if grep -q " loram=" /proc/cmdline; then
pascal@3898 77 $i DIR=\`cat /proc/cmdline | sed 's/.* loram=\([^ ]*\).*/\1/'\`
pascal@3898 78 $i DEVICE=\${DIR%,*}
pascal@3898 79 $i DIR=/\${DIR#*,}
pascal@3898 80 $i fi
pascal@4082 81 $i if ! /bin/mount -r \$DEVICE /cdrom; then
pascal@4082 82 $i if echo \$DEVICE | grep -Eq "/dev/sd|UUID=|LABEL="; then
pascal@4082 83 $i USBDELAY=\`cat /sys/module/usb_storage/parameters/delay_use\`
pascal@4082 84 $i USBDELAY=\$((1+\$USBDELAY))
pascal@4082 85 $i echo "\$DEVICE is potentially a USB device: sleep for \$USBDELAY seconds"
pascal@4082 86 $i sleep \$USBDELAY
pascal@4082 87 $i fi
pascal@4082 88 $i if ! /bin/mount -r \$DEVICE /cdrom; then
pascal@4082 89 $i DEVICE=""
pascal@4082 90 $i fi
pascal@4082 91 $i fi
pascal@4099 92 $i while [ -n "\$DEVICE" ]; do
pascal@3915 93 $i if [ -d /.usr.rw ]; then
pascal@3915 94 $i echo -n "Mounting /usr read-write... "
pascal@3915 95 $i usr=.usr.ro
pascal@3915 96 $i else
pascal@3915 97 $i echo -n "Mounting /usr read-only... "
pascal@3915 98 $i usr=usr
pascal@768 99 $i fi
pascal@3915 100 $i FS=/cdrom\$DIR/usr.cromfs
pascal@3915 101 $i if [ -f \$FS ]; then
pascal@4099 102 $i release_cdrom && break
pascal@3915 103 $i /bin/cromfs-driver \$FS /\$usr -o ro,dev,suid,allow_other
pascal@3915 104 $i elif [ -f /cdrom\$DIR/usr.sqfs ]; then
pascal@3915 105 $i FS=/cdrom\$DIR/usr.sqfs
pascal@4099 106 $i release_cdrom && break
pascal@3915 107 $i mount -o loop,ro -t squashfs \$FS /\$usr
pascal@3915 108 $i elif [ -L /\$usr ]; then
pascal@3915 109 $i FS=/cdrom\$DIR/usr
pascal@4099 110 $i release_cdrom && break
pascal@4726 111 $i true
pascal@1884 112 $i else
pascal@3915 113 $i umount /cdrom
pascal@3915 114 $i false
pascal@3915 115 $i fi
pascal@3915 116 $i status
pascal@3915 117 $i if [ -d /.usr.rw ]; then
pascal@3915 118 $i if [ -x /bin/funionfs ]; then
pascal@3915 119 $i /bin/funionfs -o dirs=/.usr.ro=RO:/.usr.rw -o allow_other -o suid,dev NONE /usr
pascal@3915 120 $i else
pascal@3915 121 $i /bin/mount -t aufs -o br:/.usr.rw:/.usr.ro none /usr
pascal@3915 122 $i fi
pascal@1884 123 $i fi
pascal@4099 124 $i break
pascal@4099 125 $i done
pascal@370 126 $i fi
pascal@370 127 $i
pascal@370 128 $tag
pascal@251 129 EOF
pascal@780 130 tag="/var/log/dmesg.log"
pascal@780 131 i=$(grep -n "$tag" $1/etc/init.d/rcS | cut -d: -f1)
pascal@780 132 i=$(($i-1))
pascal@4099 133 len=9
pascal@780 134 tag=$(grep "$tag" $1/etc/init.d/rcS)
pascal@780 135 if [ "$2" = "-R" ]; then
pascal@4099 136 line="-$(($i-$len+2)),$len +$(($i-$len+2)),2"
pascal@780 137 i="-"
pascal@780 138 else
pascal@4099 139 line="-$i,2 +$i,$len"
pascal@780 140 i="+"
pascal@780 141 fi
pascal@4186 142 busybox patch -p0 <<EOF
pascal@780 143 --- $1/etc/init.d/rcS
pascal@780 144 +++ $1/etc/init.d/rcS
pascal@780 145 @@ $line @@
pascal@780 146
pascal@780 147 $i# Build ramdisk if root=/dev/cdrom (from slitaz-loram-cdrom package)
pascal@780 148 $i if [ -L /root ]; then
pascal@780 149 $i mount -t tmpfs ramdisk /tmp
pascal@780 150 $i mkdir -p /tmp/log/lighttpd /tmp/run /tmp/lock
pascal@780 151 $i chown www.www /tmp/log/lighttpd
pascal@780 152 $i fi
pascal@780 153 $i
pascal@780 154 $tag
pascal@780 155 EOF
pascal@375 156 chmod 0755 $1/etc/init.d/rcS
pascal@251 157 }
pascal@251 158
pascal@251 159 # Pre and post install commands for Tazpkg.
pascal@251 160 pre_install()
pascal@251 161 {
pascal@380 162 local i
pascal@380 163 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do
pascal@380 164 [ "$i" = "$PACKAGE" ] && continue
pascal@380 165 yes y | tazpkg remove $i
pascal@1285 166 . /etc/tazlito/tazlito.conf
pascal@390 167 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null
pascal@380 168 done
pascal@251 169 }
pascal@251 170
pascal@251 171 post_install()
pascal@251 172 {
pascal@380 173 set_patch "$1"
pascal@5048 174
pascal@5048 175 # Don't support FAST_BOOT_X yet
pascal@5048 176 sed -i 's/FAST_BOOT_X=.*/FAST_BOOT_X="no"/' $1/etc/rcS.conf
pascal@5048 177
pascal@4503 178 cat <<EOF
pascal@4503 179 ----
pascal@4503 180 'tazlito gen-distro' will create a loram-cdrom flavor
pascal@4503 181 while this package is installed.
pascal@4503 182 EOF
pascal@5048 183 if [ ! -x $1/bin/funionfs -a ! -d $1/var/lib/tazpkg/installed/aufs-utils ]; then
pascal@371 184 cat <<EOF
pascal@390 185 ----
pascal@371 186 You will build a live CD with /usr mounted read-only.
pascal@1884 187 You can install aufs or funionfs to have read-write access into /usr with:
pascal@390 188
pascal@1884 189 # tazpkg get-install aufs
pascal@1884 190 or
pascal@371 191 # tazpkg get-install funionfs
pascal@390 192
pascal@371 193 EOF
pascal@371 194 fi
pascal@251 195 }
pascal@251 196
pascal@251 197 # Pre remove commands for Tazpkg.
pascal@251 198 pre_remove()
pascal@251 199 {
pascal@377 200 set_patch '' -R
pascal@4503 201 cat <<EOF
pascal@4503 202 ----
pascal@4503 203 'tazlito gen-distro' will work as expected now.
pascal@4503 204 EOF
pascal@251 205 }