-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·121 lines (100 loc) · 3.02 KB
/
build.sh
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
#!/bin/sh
#########################################
### Author: Yuanjun.Li
### Email: [email protected]
### Created Time: 2014-10-14
### Tested OS : Linux Mint 17 Qiana (Ubuntu 14.10)
#########################################
export PATH=/opt/FriendlyARM/toolschain/4.4.3/bin:$PATH
export HOST=arm-unknown-linux-gnueabi
cdir=`pwd`
#clean
rm -rf ssh_*
rm -rf openssh
rm -rf target_board
rm -rf zlib-1.2.8
rm -rf openssl-1.0.1i
rm -rf openssh-6.7p1
mkdir -p openssh
mkdir -p target_board/lib
mkdir -p target_board/usr/sbin
mkdir -p target_board/usr/local/bin
mkdir -p target_board/usr/libexec
mkdir -p target_board/usr/local/etc
#download package
#wget http://www.zlib.net/zlib-1.2.8.tar.gz
#wget http://www.openssl.org/source/openssl-1.0.1i.tar.gz
#wget http://mirror.mcs.anl.gov/openssh/portable/openssh-6.7p1.tar.gz
#unzip
tar xvfz zlib-1.2.8.tar.gz
tar xvfz openssl-1.0.1i.tar.gz
tar xvfz openssh-6.7p1.tar.gz
#set env for building zlib
export CC=arm-linux-gcc
export AR=ar
#build zlib
cd zlib-1.2.8
make clean
./configure --prefix=$cdir/openssh/zlib
make
if [ "XX$?" != "XX0" ]; then
echo "zlib make error!"
fi
make install
if [ "XX$?" != "XX0" ]; then
echo "zlib make install error!"
fi
cd -
#build openssl
cd openssl-1.0.1i
make clean
./config no-asm shared --prefix=$cdir/openssh/openssl os/compiler:arm-linux-gcc
#set env for building openssl
export CC=arm-linux-gcc
export CFLAG="-fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAV E_DLFCN_H -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall"
export DEPFLAG="-DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_R C5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_STORE"
export PEX_LIBS=
export EX_LIBS="-ldl"
export EXE_EXT=
export ARFLAGS=
#AR= ar $(ARFLAGS) r
export AR="arm-linux-ar $ARFLAGS r"
#RANLIB=/usr/bin/ranlib
export RANLIB=arm-linux-ranlib
#NM=nm
export NM=arm-linux-nm
export PERL="/usr/bin/perl"
export TAR=tar
export TARFLAGS="--no-recursion"
export MAKEDEPPROG=gcc
export LIBDIR=lib
make
if [ "XX$?" != "XX0" ]; then
echo "openssl make error!"
fi
make install
if [ "XX$?" != "XX0" ]; then
echo "openssl make install error!"
fi
cd -
#build openssh
cd openssh-6.7p1
make clean
./configure --host=arm-linux --with-libs --with-zlib=$cdir/openssh/zlib --with-ssl-dir=$cdir/openssh/openssl --disable-etc-default-login CC=arm-linux-gcc AR=arm-linux-ar
make
if [ "XX$?" != "XX0" ]; then
echo "openssh make error!"
fi
cd -
#generate ssh-key
ssh-keygen -t rsa1 -f ssh_host_key -N ""
ssh-keygen -t rsa -f ssh_host_rsa_key -N ""
ssh-keygen -t dsa -f ssh_host_dsa_key -N ""
#install
sleep 1
cp $cdir/openssh/zlib/lib/libz.so.1.2.8 $cdir/target_board/lib/
cp $cdir/openssh-6.7p1/sshd $cdir/target_board/usr/sbin/
cp $cdir/openssh-6.7p1/{scp,sftp,ssh,ssh-add,ssh-agent,ssh-keygen,ssh-keyscan} $cdir/target_board/usr/local/bin/
cp $cdir/openssh-6.7p1/{sftp-server,ssh-keysign,moduli} $cdir/target_board/usr/libexec/
cp $cdir/openssh-6.7p1/{sshd_config,ssh_config} $cdir/target_board/usr/local/etc/
cp $cdir/ssh_host_* $cdir/target_board/usr/local/etc/