-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·47 lines (40 loc) · 1.46 KB
/
build
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
#!/bin/bash
goversion=$(go version)
arch="$1"
if [ "x$(echo $goversion | grep devel | wc -l)" != "x1" -a "x$(echo $goversion | grep -E "1\.5|1\.6" | wc -l)" != "x1" ]; then
export GOROOT=$(pwd)/goroot/go
wget https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz -O go.tar.gz
mkdir -p ${GOROOT}; tar -C $(pwd)/goroot/ -xf go.tar.gz
rm -f go.tar.gz
export PATH=${GOROOT}/bin:$PATH
fi
export GOPATH=$(pwd)/gopath
export ORG_PATH=github.com/yoctocloud
export REPO_PATH=${ORG_PATH}/cloudinstall
rm -rf ${GOPATH}
mkdir -p ${GOPATH}/src/${ORG_PATH}
ln -s ../../../.. ${GOPATH}/src/${REPO_PATH}
export GOOS=linux
if [ "x${arch}" = "xx86_64" ]; then
export GOARCH=amd64
elif [ "x${arch}" = "xx86_32" ]; then
export GOARCH=386
fi
curdir=$(pwd)
tmp=$(mktemp --tmpdir -d)
rm -f "${curdir}/output/*-${arch}"
mkdir -p "${tmp}/etc" "${tmp}/bin" "${curdir}/output"
touch "${tmp}/etc/resolv.conf"
cp -v "${curdir}/data/busybox-${arch}" "${tmp}/bin/busybox"
cp -v "${curdir}/data/resize2fs-${arch}" "${tmp}/bin/resize2fs"
cp -v "${curdir}/data/init" "${tmp}/init"
go build -v -tags netgo -o "${tmp}/init2" ${REPO_PATH}
if [ "x${arch}" = "xx86_64" ]; then
cp -f "${curdir}"/data/vmlinuz-4.4.3-${arch} "${curdir}/output/kernel-${arch}"
else
cp -f "${curdir}"/data/vmlinuz-3.18.3-${arch} "${curdir}/output/kernel-${arch}"
fi
pushd "${tmp}/" >/dev/null
find . | cpio -H newc -o 2>/dev/null | gzip > "${curdir}/output/initrd-${arch}"
popd >/dev/null
#rm -rf "${tmp}"