Obsolete unused backup project such as OK6410
guowenxue
2019-07-29 4816dc1cfe9ae844a61c4c45f384f3d096605d21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/sh
 
#+--------------------------------------------------------------------------------------------
#|Description:  This shell script used to download busybox source code and cross compile it.
#|     Author:  GuoWenxue <guowenxue@gmail.com>
#|  ChangeLog:
#|           1, Initialize 1.0.0 on 2013.03.22
#+--------------------------------------------------------------------------------------------
 
PRJ_PATH=`pwd`
ARCH=arm1176jzfs
 
#APP_NAME="busybox-1.19.3"
APP_NAME="busybox-1.20.2"
PACK_SUFIX="tar.bz2"
DL_ADDR="http://www.busybox.net/downloads/${APP_NAME}.${PACK_SUFIX}"
INST_PATH=
 
if [ -z "$ARCH" -a $# -gt 0 ] ; then
   ARCH=$1
fi
INST_PATH=$PRJ_PATH/../../rootfs/rootfs_tree
 
sup_arch=("" "arm920t" "arm926t" "arm1176jzfs")
function select_arch()
{
   echo "Current support ARCH: "
   i=1
   len=${#sup_arch[*]}
 
   while [ $i -lt $len ]; do
     echo "$i: ${sup_arch[$i]}"
     let i++;
   done
 
   echo "Please select: "
   index=
   read index
   ARCH=${sup_arch[$index]}
}
 
 
function decompress_packet()
(
   echo "+---------------------------------------------+"
   echo "|  Decompress $1 now"  
   echo "+---------------------------------------------+"
 
    ftype=`file "$1"`
    case "$ftype" in
       "$1: Zip archive"*)
           unzip "$1" ;;
       "$1: gzip compressed"*)
           if [ 0 != `expr "$1" : ".*.tar.*" ` ] ; then
               tar -xzf $1
           else
               gzip -d "$1"
           fi ;;
       "$1: bzip2 compressed"*)
           if [ 0 != `expr "$1" : ".*.tar.*" ` ] ; then
               tar -xjf $1
           else
               bunzip2 "$1"
           fi ;;
       "$1: POSIX tar archive"*)
           tar -xf "$1" ;;
       *)
          echo "$1 is unknow compress format";;
    esac
)
 
if [ -z "$CROSS" ] ; then
  if [ -z "$ARCH" ] ; then
    select_arch
  fi
  CROSS="/opt/buildroot-2012.08/${ARCH}/usr/bin/arm-linux-"
fi
 
 
# Download source code packet
if [ ! -s $APP_NAME.$PACK_SUFIX ] ; then
   echo "+------------------------------------------------------------------+"
   echo "|  Download $APP_NAME.$PACK_SUFIX  now "  
   echo "+------------------------------------------------------------------+"
 
   wget $DL_ADDR
fi
 
# Decompress source code packet
if [ ! -d $APP_NAME ] ; then
    tar -xjf $APP_NAME.tar.*
fi
 
#Copy the configure file
if [ ! -s .config ]; then
    cp patch/$APP_NAME.config $APP_NAME/.config
fi
 
if [ ! -s $APP_NAME/.config ]; then
   echo "+------------------------------------------------------------------+"
   echo "| ERROR: Miss default configure file"  
   echo "+------------------------------------------------------------------+"
   exit -2
fi
 
if [ -z $INST_PATH ] ; then
   INST_PATH=$PRJ_PATH/../$ARCH/mnt
fi
 
echo "+------------------------------------------------------------------+"
echo "|          Build $APP_NAME for $ARCH "
echo "| Crosstool:  $CROSS"
echo "+------------------------------------------------------------------+"
 
cd $APP_NAME
 
   #Modify the cross config in the configure file
   line=`sed -n '/CONFIG_CROSS_COMPILER_PREFIX/=' .config`
   sed -i -e ${line}s"|.*|CONFIG_CROSS_COMPILER_PREFIX=\"$CROSS\"|" .config
 
   #Modify the install path in the configure file
   line=`sed -n '/CONFIG_PREFIX=/=' .config`
   sed -i -e ${line}s"|.*|CONFIG_PREFIX=\"$INST_PATH\"|" .config
 
   #Fix strverscmp not define bug
   line=`sed -n '/^#define HAVE_STRVERSCMP/=' include/platform.h `
   sed -i -e ${line}s"|.*|# undef HAVE_STRVERSCMP|" include/platform.h
 
   set -x
   make oldconfig 
   make
   set +x
 
   #install busybox
   if [ -d $INST_PATH ] ; then
     sudo rm -rf $INST_PATH/bin/*
     sudo rm -rf $INST_PATH/sbin/*
     sudo make install 
   fi
   file busybox
cd  -