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