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

get-pcem-roms: version less
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jul 17 19:56:00 2021 +0000 (2021-07-17)
parents 4aed2b24febc
children
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@22456 83 *) busybox tar xf $(basename $WGET_URL) ;;
pascal@13591 84 esac
pascal@13591 85
pascal@13591 86 # Set dirs
pascal@13591 87 src=/usr/src/$PACKAGE-$VERSION
pascal@13591 88 taz=/tmp/sm$RANDOM$RANDOM$RANDOM.$$
pascal@13591 89 fs=$taz/$PACKAGE-$VERSION/fs
pascal@13591 90 mkdir -p $fs
pascal@13591 91
pascal@13591 92 # Create pseudo package
pascal@13591 93 case "$PACKAGE" in
pascal@13591 94 hsfmodem)
pascal@13591 95 # Rules to configure and make the package.
pascal@13591 96 cd $src
pascal@13591 97 echo "Apply $file..."
pascal@13591 98 patch -p1 < /usr/share/softmodem/$PACKAGE-$VERSION.diff || exit 1
pascal@13591 99 # Build
pascal@13591 100 make all
pascal@13591 101 make ROOT=$fs install
pascal@13591 102 make clean
pascal@13591 103 # Data for automatic region setting
pascal@13591 104 mkdir -p $fs/usr/share/hsfmodem
pascal@13591 105 cp -a /usr/share/softmodem/zone.tab $fs/usr/share/hsfmodem
pascal@13591 106 # src is needed
pascal@13591 107 cd $taz
pascal@13591 108 mkdir -p $fs/usr/src
pascal@13591 109 mv $src $fs/usr/src
pascal@13591 110 ;;
pascal@13591 111 hcfpcimodem)
pascal@13591 112 untested
pascal@13591 113 # Rules to configure and make the package.
pascal@13591 114 cd $src
pascal@13591 115 echo "Apply $file..."
pascal@13591 116 patch -p1 < /usr/share/softmodem/$PACKAGE-$VERSION.diff || exit 1
pascal@13591 117 # Build
pascal@13591 118 make all
pascal@13591 119 make ROOT=$fs install
pascal@13591 120 make clean
pascal@13591 121 # Data for automatic region setting
pascal@13591 122 mkdir -p $fs/usr/share/hcfpcimodem
pascal@13591 123 cp -a /usr/share/softmodem/zone.tab $fs/usr/share/hcfpcimodem
pascal@13591 124 # src is needed
pascal@13591 125 cd $taz
pascal@13591 126 mkdir -p $fs/usr/src
pascal@13591 127 mv $src $fs/usr/src
pascal@13591 128 ;;
pascal@13591 129 martian)
pascal@13591 130 untested
pascal@13591 131 # Build
pascal@13591 132 src=/usr/src/$PACKAGE
pascal@13591 133 cd $src
pascal@13591 134 sed -i 's/uname -i/uname -m/' modem/Makefile
pascal@13591 135 sed -i 's/asm\/page.h/\/usr\/src\/linux\/include\/asm\/page.h/' modem/mport.c
pascal@13591 136 sed -i 's/asm\/page.h/\/usr\/src\/linux\/include\/asm\/page.h/' modem/tweakrelocsdynamic.c
pascal@13591 137 make all
pascal@13591 138 # Install
pascal@13591 139 mkdir -p $fs/usr/sbin
pascal@13591 140 cp -a modem/martian_modem $fs/usr/sbin
pascal@13591 141 mkdir -p $fs/lib/modules/`uname -r`/martian
pascal@13591 142 cp -a kmodule/martian_dev.ko $fs/lib/modules/`uname -r`/martian
pascal@13591 143 mkdir -p $fs/etc/init.d
pascal@13591 144 cp -a /usr/share/softmodem/martian.init $fs/etc/init.d/martian
pascal@13591 145 chmod +x $fs/etc/init.d/martian
pascal@13591 146 # Data for automatic region setting
pascal@13591 147 mkdir -p $fs/usr/share/martian
pascal@13591 148 cp -a /usr/share/softmodem/zone.tab $fs/usr/share/martian
pascal@13591 149 cp -a /usr/share/softmodem/martian.country $fs/usr/share/martian
pascal@13591 150 rm -rf $src
pascal@13591 151 ;;
pascal@13591 152 slmodem)
pascal@13591 153 untested
pascal@13591 154 # build modules
pascal@13591 155 cd $src
pascal@13591 156 make clean
pascal@13591 157 make drivers
pascal@13591 158 # Build slmodemd with ALSA support
pascal@13591 159 cd modem
pascal@13591 160 make clean
pascal@13591 161 make SUPPORT_ALSA=1
pascal@13591 162 # install
pascal@13591 163 cd $src
pascal@13591 164 mkdir -p $fs/lib/modules/`uname -r`/slamr
pascal@13591 165 cp -a drivers/*ko $fs/lib/modules/`uname -r`/slamr
pascal@13591 166 mkdir -p $fs/usr/sbin
pascal@13591 167 cp -a modem/slmodemd $fs/usr/sbin
pascal@13591 168 mkdir -p $fs/etc/init.d
pascal@13591 169 cp -a /usr/share/softmodem/slmodem.init $fs/etc/init.d/slmodem
pascal@13591 170 chmod +x $fs/etc/init.d/slmodem
pascal@13591 171 # Data for automatic region setting
pascal@13591 172 mkdir -p $fs/usr/share/slmodem
pascal@13591 173 cp -a /usr/share/softmodem/zone.tab $fs/usr/share/slmodem
pascal@13591 174 cp -a /usr/share/softmodem/slmodem.country $fs/usr/share/slmodem
pascal@13591 175 rm -rf $src
pascal@13591 176 ;;
pascal@13591 177 esac
pascal@13591 178
pascal@13591 179 # Create receipt
pascal@13591 180 cd $taz
pascal@13591 181 cat /usr/share/softmodem/$PACKAGE.receipt> $PACKAGE-$VERSION/receipt
pascal@13591 182
pascal@13591 183 # Pack
pascal@13591 184 tazpkg pack $PACKAGE-$VERSION
pascal@13591 185
pascal@13591 186 # Install pseudo package
pascal@13591 187 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
pascal@13591 188
pascal@13591 189 # Clean
pascal@13591 190 if [ -e /etc/tazwok.conf ]; then
pascal@13591 191 . /etc/tazwok.conf
pascal@13591 192 mkdir -p $PACKAGES_REPOSITORY
pascal@13591 193 cp -a $PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
pascal@13591 194 fi
pascal@13591 195 rm -rf $taz