wok annotate get-softmodem-driver/stuff/get-softmodem-driver @ rev 11830

U: phpmyadmin(3.4.10.1)
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Mon Feb 27 00:22:36 2012 +0100 (2012-02-27)
parents 8fc90d8b565b
children
rev   line source
domcox@3446 1 #!/bin/sh
domcox@3446 2 # install softmodems drivers if needed.
domcox@3446 3
domcox@3452 4 PACKAGE=$(echo $0 | sed 's/.*get-\(.*\)-driver/\1/')
domcox@3446 5 ROOT="$1"
domcox@3446 6 DEPENDS=""
domcox@3446 7
domcox@3464 8 untested()
domcox@3464 9 {
domcox@3464 10 echo "--------------------------------------------------------"
domcox@3464 11 echo "Due to a lack of compatible hardware for troubleshooting,"
domcox@3498 12 echo "this $PACKAGE package has not been tested. Please report"
domcox@3498 13 echo "any success, failure, bug to SliTaz Labs or SliTaz Forum."
domcox@3464 14 echo "--------------------------------------------------------"
domcox@3464 15 sleep 1
domcox@3464 16 }
domcox@3464 17
domcox@3452 18 case "$PACKAGE" in
domcox@3446 19 hsfmodem)
domcox@3498 20 . /usr/share/softmodem/hsfmodem.receipt ;;
domcox@3462 21 hcfpcimodem)
domcox@3498 22 . /usr/share/softmodem/hcfpcimodem.receipt ;;
domcox@3464 23 martian)
domcox@3498 24 . /usr/share/softmodem/martian.receipt ;;
domcox@3473 25 slmodem)
domcox@3498 26 . /usr/share/softmodem/slmodem.receipt ;;
domcox@3464 27 *)
domcox@3464 28 echo "Unknown modem driver. Please run one of the following commands:"
domcox@3446 29 for i in $(cd $(dirname $0); ls get-*-driver); do
domcox@3446 30 [ -L $i ] || continue
domcox@3446 31 [ "$(readlink $i)" = "get-modem-driver" ] || continue
domcox@3446 32 echo " $i"
domcox@3446 33 done
domcox@3446 34 exit 1;;
domcox@3446 35 esac
domcox@3446 36
domcox@3498 37 # Report
domcox@3498 38 echo "Installing $SHORT_DESC.."
domcox@3498 39
domcox@3446 40 # Check if user is root to install.
domcox@3446 41 if test $(id -u) != 0 ; then
domcox@3446 42 echo -e "\nYou must be root to run `basename $0`."
domcox@3446 43 echo -e "Please use 'su' and root password to become super-user.\n"
domcox@3446 44 exit 0
domcox@3446 45 fi
domcox@3446 46
domcox@3446 47 # Avoid reinstall
domcox@3452 48 if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ]; then
domcox@3452 49 echo -e "\n$PACKAGE-$VERSION package is already installed.\n"
domcox@3446 50 exit 0
domcox@3446 51 fi
domcox@3446 52
domcox@3446 53 # Check linux-source
domcox@3446 54 cp /proc/config.gz . && gunzip config.gz
domcox@3446 55 DIFF=$(diff /usr/src/linux/.config config | awk 'BEGIN{i=0}/^[-+]/{ i++} END{print i}')
domcox@3446 56 rm -f config config.gz
domcox@3446 57 if [ $DIFF -gt 2 ]; then
domcox@3452 58 echo "Warning: Linux source .config file and currently installed kernel don't match."
domcox@3452 59 echo "Please rebuild Linux source with the proper .config file."
domcox@3452 60 echo "Otherwise you may not be able to load the generated drivers."
domcox@3452 61 sleep 2
domcox@3446 62 fi
domcox@3446 63
domcox@3446 64 # Get files
domcox@3446 65 cd /usr/src
domcox@3473 66 echo "Checking for source tarball... $WGET_URL"
domcox@3446 67 if [ ! -f "$TARBALL" ]; then
domcox@3446 68 wget $WGET_URL
domcox@3446 69 # Exit if download failed to avoid errors.
domcox@3446 70 if [ ! -f "$TARBALL" ]; then
domcox@3446 71 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n"
domcox@3446 72 exit 1
domcox@3446 73 fi
domcox@3446 74 fi
domcox@3446 75
domcox@3446 76 case "$WGET_URL" in
domcox@3446 77 *rpm) rpm2cpio < $(basename $WGET_URL) | cpio -id;;
domcox@3446 78 *deb) dpkg-deb -x $(basename $WGET_URL) . ;;
domcox@3446 79 *bz2) tar xjf $(basename $WGET_URL) ;;
domcox@3462 80 *tar.gz|*tgz) tar xzf $(basename $WGET_URL) || exit 1 ;;
domcox@3446 81 *zip) unzip $(basename $WGET_URL);;
domcox@3446 82 *o) ;;
domcox@3446 83 esac
domcox@3446 84
domcox@3446 85 # Set dirs
domcox@3452 86 src=/usr/src/$PACKAGE-$VERSION
domcox@3446 87 taz=/tmp/sm$RANDOM$RANDOM$RANDOM.$$
domcox@3452 88 fs=$taz/$PACKAGE-$VERSION/fs
domcox@3446 89 mkdir -p $fs
domcox@3446 90
domcox@3446 91 # Create pseudo package
domcox@3452 92 case "$PACKAGE" in
domcox@3446 93 hsfmodem)
domcox@3446 94 # Rules to configure and make the package.
domcox@3446 95 cd $src
domcox@3453 96 echo "Apply $file..."
domcox@3459 97 patch -p1 < /usr/share/softmodem/$PACKAGE-$VERSION.diff || exit 1
domcox@3446 98 # Build
domcox@3459 99 make all
domcox@3459 100 make ROOT=$fs install
domcox@3459 101 make clean
domcox@3459 102 # Data for automatic region setting
domcox@3494 103 mkdir -p $fs/usr/share/hsfmodem
domcox@3494 104 cp -a /usr/share/softmodem/zone.tab $fs/usr/share/hsfmodem
domcox@3459 105 # src is needed
domcox@3453 106 cd $taz
domcox@3453 107 mkdir -p $fs/usr/src
domcox@3453 108 mv $src $fs/usr/src
domcox@3446 109 ;;
domcox@3462 110 hcfpcimodem)
domcox@3473 111 untested
domcox@3462 112 # Rules to configure and make the package.
domcox@3462 113 cd $src
domcox@3462 114 echo "Apply $file..."
domcox@3462 115 patch -p1 < /usr/share/softmodem/$PACKAGE-$VERSION.diff || exit 1
domcox@3462 116 # Build
domcox@3462 117 make all
domcox@3462 118 make ROOT=$fs install
domcox@3462 119 make clean
domcox@3462 120 # Data for automatic region setting
domcox@3494 121 mkdir -p $fs/usr/share/hcfpcimodem
domcox@3494 122 cp -a /usr/share/softmodem/zone.tab $fs/usr/share/hcfpcimodem
domcox@3462 123 # src is needed
domcox@3462 124 cd $taz
domcox@3462 125 mkdir -p $fs/usr/src
domcox@3462 126 mv $src $fs/usr/src
domcox@3462 127 ;;
domcox@3464 128 martian)
domcox@3464 129 untested
domcox@3464 130 # Build
domcox@3464 131 src=/usr/src/$PACKAGE
domcox@3464 132 cd $src
domcox@3464 133 sed -i 's/uname -i/uname -m/' modem/Makefile
domcox@3464 134 sed -i 's/asm\/page.h/\/usr\/src\/linux\/include\/asm\/page.h/' modem/mport.c
domcox@3464 135 sed -i 's/asm\/page.h/\/usr\/src\/linux\/include\/asm\/page.h/' modem/tweakrelocsdynamic.c
domcox@3464 136 make all
domcox@3464 137 # Install
domcox@3464 138 mkdir -p $fs/usr/sbin
domcox@3464 139 cp -a modem/martian_modem $fs/usr/sbin
domcox@3464 140 mkdir -p $fs/lib/modules/`uname -r`/martian
domcox@3464 141 cp -a kmodule/martian_dev.ko $fs/lib/modules/`uname -r`/martian
domcox@3464 142 mkdir -p $fs/etc/init.d
domcox@3464 143 cp -a /usr/share/softmodem/martian.init $fs/etc/init.d/martian
domcox@3498 144 chmod +x $fs/etc/init.d/martian
domcox@3498 145 # Data for automatic region setting
domcox@3498 146 mkdir -p $fs/usr/share/martian
domcox@3498 147 cp -a /usr/share/softmodem/zone.tab $fs/usr/share/martian
domcox@3498 148 cp -a /usr/share/softmodem/martian.country $fs/usr/share/martian
domcox@3473 149 rm -rf $src
domcox@3473 150 ;;
domcox@3473 151 slmodem)
domcox@3473 152 untested
domcox@3473 153 # build modules
domcox@3473 154 cd $src
domcox@3473 155 make clean
domcox@3473 156 make drivers
domcox@3473 157 # Build slmodemd with ALSA support
domcox@3473 158 cd modem
domcox@3473 159 make clean
domcox@3473 160 make SUPPORT_ALSA=1
domcox@3473 161 # install
domcox@3473 162 cd $src
domcox@3473 163 mkdir -p $fs/lib/modules/`uname -r`/slamr
domcox@3473 164 cp -a drivers/*ko $fs/lib/modules/`uname -r`/slamr
domcox@3473 165 mkdir -p $fs/usr/sbin
domcox@3473 166 cp -a modem/slmodemd $fs/usr/sbin
domcox@3473 167 mkdir -p $fs/etc/init.d
domcox@3473 168 cp -a /usr/share/softmodem/slmodem.init $fs/etc/init.d/slmodem
domcox@3494 169 chmod +x $fs/etc/init.d/slmodem
domcox@3494 170 # Data for automatic region setting
domcox@3494 171 mkdir -p $fs/usr/share/slmodem
domcox@3494 172 cp -a /usr/share/softmodem/zone.tab $fs/usr/share/slmodem
domcox@3494 173 cp -a /usr/share/softmodem/slmodem.country $fs/usr/share/slmodem
domcox@3473 174 rm -rf $src
domcox@3473 175 ;;
domcox@3446 176 esac
domcox@3446 177
domcox@3446 178 # Create receipt
domcox@3446 179 cd $taz
domcox@3462 180 cat /usr/share/softmodem/$PACKAGE.receipt> $PACKAGE-$VERSION/receipt
domcox@3446 181
domcox@3446 182 # Pack
domcox@3452 183 tazpkg pack $PACKAGE-$VERSION
domcox@3446 184
domcox@3446 185 # Install pseudo package
domcox@3452 186 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
domcox@3446 187
domcox@3446 188 # Clean
domcox@3478 189 if [ -e /etc/tazwok.conf ]; then
domcox@3478 190 . /etc/tazwok.conf
domcox@3478 191 mkdir -p $PACKAGES_REPOSITORY
domcox@3478 192 cp -a $PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
domcox@3478 193 fi
domcox@3446 194 rm -rf $taz