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