http://downloads.netgear.com/files/GPL/DM111P(B)_v3.29u_src.tar.gz
[bcm963xx.git] / targets / buildFS
1 #!/bin/bash
2
3 #****************************************************************************
4 #
5 # <:copyright-gpl 
6 # Copyright 2004 Broadcom Corp. All Rights Reserved. 
7 # This program is free software; you can distribute it and/or modify it 
8 # under the terms of the GNU General Public License (Version 2) as 
9 # published by the Free Software Foundation. 
10 # This program is distributed in the hope it will be useful, but WITHOUT 
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
13 # for more details. 
14 # You should have received a copy of the GNU General Public License along 
15 # with this program; if not, write to the Free Software Foundation, Inc., 
16 # 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
17 # :>
18 #
19 #****************************************************************************
20
21 TOP_DIR=`pwd`
22
23 if [ "$MOD_DIR" == "" ] ; then
24     MOD_DIR=$PROFILE/modules
25 fi
26
27 if [ "$FSSRC_DIR" == "" ]; then
28     FSSRC_DIR=./fs.src
29 fi
30
31 ROOTFS=$PROFILE/fs
32
33 rm -rf $ROOTFS
34 # Create file system dir
35 mkdir $ROOTFS
36 chmod 777 $ROOTFS
37 # Copy files onto root file system
38 echo "Creating target root file system..."
39 cp -av $FSSRC_DIR/* $ROOTFS
40 # Create directories as needed
41 mkdir $ROOTFS/dev
42 mkdir $ROOTFS/mnt
43 mkdir $ROOTFS/proc
44 mkdir $ROOTFS/var
45 mkdir $ROOTFS/etc/adsl
46 cp -av $BRCMDRIVERS_DIR/broadcom/char/adsl/bcm9$BRCM_CHIP/*.bin  $ROOTFS/etc/adsl
47 DEFAULTCFG=`echo $DEFAULTCFG_DIR/$BRCM_DEFAULTCFG|sed -e 's/\"//g'`
48 if [ -f "$DEFAULTCFG" ]; then
49    cp -v $DEFAULTCFG $ROOTFS/etc/default.cfg; chmod a+r $ROOTFS/etc/default.cfg
50 elif [ $BRCM_DEFAULTCFG != '""' ]; then
51    echo
52    echo "        No default run-time config file called $BRCM_DEFAULTCFG in $DEFAULTCFG_DIR"
53    echo "        Check your profile setting!"
54    exit 1
55 else
56    echo
57 fi
58 # Create devices
59 ./makeDevs
60 # Create symbolic links
61 ln -s /var/log/log $ROOTFS/dev/log
62 ln -s /var/sysmsg $ROOTFS/etc/sysmsg
63 ln -s /var/passwd $ROOTFS/etc/passwd
64 ln -s /var/group $ROOTFS/etc/group
65 ln -s /var/ppp/pppmsg $ROOTFS/etc/pppmsg
66 ln -s /var/fyi/sys/dns $ROOTFS/etc/resolv.conf
67 ln -s /var/fyi/sys/gateway $ROOTFS/etc/gateway.conf
68 ln -s /var/udhcpd/udhcpd.conf $ROOTFS/etc/udhcpd.conf
69 ln -s /var/udhcpd/udhcpd.leases $ROOTFS/etc/udhcpd.leases
70
71 if [ -x $PROFILE/special-buildFS ]; then
72    $PROFILE/special-buildFS
73 fi
74
75 # Copy proprietary binaries if any
76 FSBIN=`ls $TOP_DIR/fs.bin|wc -l`
77 if [ $FSBIN != 0 ]; then
78    echo "Copying proprietary binaries..."
79    cd $TOP_DIR
80    cp -avf fs.bin/* $ROOTFS
81 fi
82
83 # Stripping unneeded module symbols
84 cd $MOD_DIR
85 cp -a lib $TOP_DIR/$ROOTFS/.
86 chown -R root:root $TOP_DIR/$ROOTFS/lib
87 echo "Stripping kernel modules..."
88 find $TOP_DIR/$ROOTFS/lib/modules -name "*.ko"
89 #Modules that need parameters cannot be stripped
90 #MODS_KEEPSYM='! -name "ip_conntrack_pt.ko" ! -name "ip_nat_pt.ko"'
91 MODS_KEEPSYM='! -name "ip*.ko"'
92 eval "find $TOP_DIR/$ROOTFS/lib/modules -name '*.ko' $MODS_KEEPSYM |xargs $STRIP --strip-unneeded"
93
94 # Continue to strip user apps and shared libraries using sstrip
95 echo "Stripping userapps and shared libraries more..."
96 $SSTRIP $TOP_DIR/$ROOTFS/bin/* $TOP_DIR/$ROOTFS/lib/*.so*
97
98