4 echo "Usage: $0 [BuildArch] [LinuxCodeName] [--setproxy=IP] [--skipunmount]"
5 echo "BuildArch can be: arm(default), aarch64"
6 echo "LinuxCodeName - optional, Code name for Linux, can be: bionic, focal(default), jammy"
7 echo "--setproxy=IP - optional, IP is the proxy server IP address or url with portnumber"
8 echo " default no proxy. Example: --setproxy=127.1.2.3:8080"
9 echo "--skipunmount - optional, will skip the unmount of rootfs folder."
13 __CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
15 __UbuntuRepo="http://ports.ubuntu.com/"
23 # base development support
24 # install cmake to find cmake package configuration for target file system
25 __UbuntuPackages="build-essential"
26 __UbuntuPackages+=" cmake"
28 # other development supports
29 __UbuntuPackages+=" ocl-icd-opencl-dev"
30 __UbuntuPackages+=" libhdf5-dev"
31 __UbuntuPackages+=" libboost-all-dev"
32 __UbuntuPackages+=" libglib2.0-dev"
35 __UbuntuPackages+=" symlinks"
37 __UnprocessedBuildArgs=
40 lowerI="$(echo $i | awk '{print tolower($0)}')"
55 __LinuxCodeName=bionic
65 __Apt="Acquire::http::proxy \"http://$proxyip/\";\n"
66 __Apt+="Acquire::https::proxy \"http://$proxyip/\";\n"
67 __Apt+="Acquire::ftp::proxy \"ftp://$proxyip/\";"
74 __UnprocessedBuildArgs="$__UnprocessedBuildArgs $i"
81 __RootfsDir="$__CrossDir/rootfs/$__BuildArch"
83 if [[ -n "$ROOTFS_DIR" ]]; then
84 __RootfsDir=$ROOTFS_DIR
87 if [ -d "$__RootfsDir" ]; then
88 if [ $__SkipUnmount == 0 ]; then
94 if [ $__IsProxySet == 1 ]; then
95 mkdir -p $__RootfsDir/etc/apt/apt.conf.d
96 echo -e "$__Apt" >> $__RootfsDir/etc/apt/apt.conf.d/90proxy
99 if [[ -n $__LinuxCodeName ]]; then
100 qemu-debootstrap --arch $__QemuArch $__LinuxCodeName $__RootfsDir $__UbuntuRepo
101 cp $__CrossDir/$__BuildArch/sources.list.$__LinuxCodeName $__RootfsDir/etc/apt/sources.list
102 chroot $__RootfsDir apt-get update
103 chroot $__RootfsDir apt-get -f -y install
104 chroot $__RootfsDir apt-get -y install $__UbuntuPackages
105 machine=$(chroot $__RootfsDir gcc -dumpmachine)
106 chroot $__RootfsDir ln -s /usr/lib/${machine}/libhdf5_serial.a /usr/lib/${machine}/libhdf5.a
107 chroot $__RootfsDir ln -s /usr/lib/${machine}/libhdf5_serial.so /usr/lib/${machine}/libhdf5.so
108 chroot $__RootfsDir symlinks -cr /usr
110 if [ $__SkipUnmount == 0 ]; then
111 umount $__RootfsDir/*
114 echo "Unsupported target platform."