wok-stable annotate 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 |
rev | line source |
---|---|
pascal@251 | 1 # SliTaz package receipt. |
pascal@251 | 2 |
pascal@251 | 3 PACKAGE="slitaz-loram-cdrom" |
pascal@768 | 4 VERSION="1.2" |
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@768 | 68 $i FS=/cdrom/usr.sqfs |
pascal@768 | 69 $i elif [ -f \$FS ]; then |
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@375 | 90 chmod 0755 $1/etc/init.d/rcS |
pascal@251 | 91 } |
pascal@251 | 92 |
pascal@251 | 93 # Pre and post install commands for Tazpkg. |
pascal@251 | 94 pre_install() |
pascal@251 | 95 { |
pascal@380 | 96 local i |
pascal@390 | 97 . /etc/tazlito/tazlito.conf |
pascal@380 | 98 for i in $(cd /var/lib/tazpkg/installed ; ls -d slitaz-loram* 2> /dev/null); do |
pascal@380 | 99 [ "$i" = "$PACKAGE" ] && continue |
pascal@380 | 100 yes y | tazpkg remove $i |
pascal@390 | 101 rm -f $PACKAGES_REPOSITORY/slitaz-boot-scripts-*.tazpkg 2> /dev/null |
pascal@380 | 102 done |
pascal@251 | 103 } |
pascal@251 | 104 |
pascal@251 | 105 post_install() |
pascal@251 | 106 { |
pascal@380 | 107 set_patch "$1" |
pascal@371 | 108 if [ ! -x /bin/funionfs ]; then |
pascal@371 | 109 cat <<EOF |
pascal@390 | 110 ---- |
pascal@371 | 111 You will build a live CD with /usr mounted read-only. |
pascal@390 | 112 You can install funionfs to have read-write access into /usr with: |
pascal@390 | 113 |
pascal@371 | 114 # tazpkg get-install funionfs |
pascal@390 | 115 |
pascal@371 | 116 EOF |
pascal@371 | 117 fi |
pascal@251 | 118 } |
pascal@251 | 119 |
pascal@251 | 120 # Pre remove commands for Tazpkg. |
pascal@251 | 121 pre_remove() |
pascal@251 | 122 { |
pascal@377 | 123 set_patch '' -R |
pascal@251 | 124 } |