blob: 11e5eff764fbc64f413f56d53cf0d1ed0de7c44a (
plain)
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
|
#!/usr/bin/env bash
set -x
usage()
{
echo "Usage: $0 [BuildArch] [LinuxCodeName] [--setproxy=IP] [--skipunmount]"
echo "BuildArch can be: arm(default), arm64 and armel"
echo "LinuxCodeName - optional, Code name for Linux, can be: xenial(default), trusty"
echo " If BuildArch is armel, this can be tizen(default)"
echo "--setproxy=IP - optional, IP is the proxy server IP address or url with portnumber"
echo " default no proxy. Example: --setproxy=127.1.2.3:8080"
echo "--skipunmount - optional, will skip the unmount of rootfs folder."
exit 1
}
__CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
__InitialDir=$PWD
__UbuntuRepo="http://ports.ubuntu.com/"
__BuildArch=arm
__UbuntuArch=armhf
__LinuxCodeName=xenial
__SkipUnmount=0
__IsProxySet=0
__Apt=""
# base development support
__UbuntuPackages="build-essential"
# other development supports
__UbuntuPackages+=" libboost-all-dev ocl-icd-opencl-dev"
# symlinks fixer
__UbuntuPackages+=" symlinks"
__UnprocessedBuildArgs=
for i in "$@" ; do
lowerI="$(echo $i | awk '{print tolower($0)}')"
case $lowerI in
-?|-h|--help)
usage
exit 1
;;
arm)
__BuildArch=arm
__UbuntuArch=armhf
;;
arm64)
__BuildArch=arm64
__UbuntuArch=arm64
;;
armel)
__BuildArch=armel
__Tizen=tizen
__UbuntuArch=
__UbuntuRepo=
__LinuxCodeName=
;;
tizen)
if [ "$__BuildArch" != "armel" ]; then
echo "Tizen is available only for armel."
usage;
exit 1;
fi
__Tizen=tizen
__UbuntuArch=
__UbuntuRepo=
__LinuxCodeName=
;;
trusty)
__LinuxCodeName=trusty
;;
xenial)
__LinuxCodeName=xenial
;;
--setproxy*)
proxyip="${i#*=}"
__Apt="Acquire::http::proxy \"http://$proxyip/\";\n"
__Apt+="Acquire::https::proxy \"http://$proxyip/\";\n"
__Apt+="Acquire::ftp::proxy \"ftp://$proxyip/\";"
__IsProxySet=1
;;
--skipunmount)
__SkipUnmount=1
;;
*)
__UnprocessedBuildArgs="$__UnprocessedBuildArgs $i"
;;
esac
done
__RootfsDir="$__CrossDir/rootfs/$__BuildArch"
if [[ -n "$ROOTFS_DIR" ]]; then
__RootfsDir=$ROOTFS_DIR
fi
if [ -d "$__RootfsDir" ]; then
if [ $__SkipUnmount == 0 ]; then
umount $__RootfsDir/*
fi
rm -rf $__RootfsDir
fi
if [ $__IsProxySet == 1 ] && [ "$__Tizen" != "tizen" ]; then
mkdir -p $__RootfsDir/etc/apt/apt.conf.d
echo -e "$__Apt" >> $__RootfsDir/etc/apt/apt.conf.d/90proxy
fi
if [[ -n $__LinuxCodeName ]]; then
qemu-debootstrap --arch $__UbuntuArch $__LinuxCodeName $__RootfsDir $__UbuntuRepo
cp $__CrossDir/$__BuildArch/sources.list.$__LinuxCodeName $__RootfsDir/etc/apt/sources.list
chroot $__RootfsDir apt-get update
chroot $__RootfsDir apt-get -f -y install
chroot $__RootfsDir apt-get -y install $__UbuntuPackages
chroot $__RootfsDir symlinks -cr /usr
if [ $__SkipUnmount == 0 ]; then
umount $__RootfsDir/*
fi
elif [ "$__Tizen" == "tizen" ]; then
ROOTFS_DIR=$__RootfsDir $__CrossDir/$__BuildArch/tizen-build-rootfs.sh
else
echo "Unsupported target platform."
usage;
exit 1
fi
|