Articles

[SCRIPT] for creating martian_modem(Agere LT Modem) module

Note: This script has been written for Porteus V1.0

How to make the script executable before use:

chmod +x martian.pbuild

How to run the script after making executable:

./path/to/martian.pbuild

Copy the text below and paste it into a text file, saving it as 'martian.pbuild'

NOTE: If you receive a stdin error from gunzip, try removing this line, near the end of the script: "find $TMP | grep .gz |xargs gunzip". Delete all of the associated files and try again.

 

#!/bin/bash

PKG=martian-full-20100123
TMP=/tmp/martian$
# uncomment if you want wget to download source
#wget http://linmodems.technion.ac.il/packages/ltmodem/kernel-2.6/martian/martian-full-20100123.tar.gz

#set -e

tar -zxvf $PKG*
mkdir -p $TMP/etc/rc.d/
cd $PKG/scripts/
sed -i '25 s|DEVICE="/dev/ttySM0"|DEVICE="/dev/modem"|g' martian
sed -i '25 a /sbin/depmod -a\' martian
sed -i '26 a sleep 3\' martian
sed -i '27 a /sbin/modprobe martian_dev' martian
#sed -i '28 s|echo "kernel module is not loaded!"|/sbin/modprobe martian_dev|g' martian
cp martian $TMP/etc/rc.d/rc.martian
chmod +x $TMP/etc/rc.d/rc.martian
cd ../
#cd $PKG
make all
make install

mkdir -p $TMP/lib/modules/`uname -r`/extra/
cp -ra /lib/modules/`uname -r`/extra/martian_dev.ko $TMP/lib/modules/`uname -r`/extra/
mkdir -p $TMP/usr/sbin/
cp -ra /usr/sbin/martian_modem $TMP/usr/sbin/
mkdir -p $TMP/usr/lib/debug/usr/sbin/
cp -ra /usr/lib/debug/usr/sbin/martian_modem.debug $TMP/usr/lib/debug/usr/sbin/

rm -rf /lib/modules/`uname -r`/extra/martian_dev.ko

# copy build script
cd ..
mkdir -p $TMP/usr/src/pbuilds/
cp $0 $TMP/usr/src/pbuilds/
find $TMP -type d | xargs chmod -v 755
find $TMP | grep .gz | xargs gunzip
find $TMP | xargs file | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded

dir2xzm $TMP $PKG.xzm
rm -Rf $TMP
rm -Rf $PKG