-
Notifications
You must be signed in to change notification settings - Fork 4
/
linuxboot-bin-build.sh
executable file
·65 lines (56 loc) · 1.95 KB
/
linuxboot-bin-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
#!/bin/bash
# @file
#
# Copyright (c) 2020, Ampere Computing LLC.
#
# SPDX-License-Identifier: ISC
#
# LinuxBoot Binary Build
#
GOLANG_VER=1.20.4
TOOLS_DIR="`dirname $0`"
TOOLS_DIR="`readlink -f \"$TOOLS_DIR\"`"
export TOOLS_DIR
. "$TOOLS_DIR"/common-functions
PLATFORM_LOWER="jade"
if uname -m | grep -q "x86_64"; then
CROSS_COMPILE=${CROSS_COMPILE:-aarch64-linux-gnu-}
fi
check_golang ${GOLANG_VER}
export GOPATH=${TOOLS_DIR}/toolchain/gosource
export GOFLAGS=-modcacherw
export GO111MODULE=auto
mkdir -p ${GOPATH}
export PATH=${GOPATH}/bin:${TOOLS_DIR}/toolchain/go/bin:$PATH
LINUBOOT_DIR="`readlink -f $PWD/linuxboot`"
if [ ! -d "$LINUBOOT_DIR" ]; then
git clone --single-branch --branch main https://github.com/linuxboot/linuxboot.git
fi
check_lzma_tool ${TOOLS_DIR}
RESULT=$?
if [ $RESULT -ne 0 ]; then
exit 1
fi
echo "Clean up LinuxBoot binaries..."
rm -rf ${LINUBOOT_DIR}/mainboards/ampere/${PLATFORM_LOWER}/{flashkernel,flashinitramfs.*}
if [ -d ${LINUBOOT_DIR}/mainboards/ampere/${PLATFORM_LOWER}/linux ]; then
make -C ${LINUBOOT_DIR}/mainboards/ampere/${PLATFORM_LOWER}/linux distclean
fi
LINUBOOT_MAKEFILE=${LINUBOOT_DIR}/mainboards/ampere/${PLATFORM_LOWER}/Makefile
if ! grep -q "uroot-source" "${LINUBOOT_MAKEFILE}"; then
sed -i "s;uinitcmd=systemboot;uinitcmd=systemboot -uroot-source \$\{GOPATH\}/src/github.com/u-root/u-root;" ${LINUBOOT_MAKEFILE}
fi
if grep -q "GO111MODULE=off" "${LINUBOOT_MAKEFILE}"; then
sed -i "s;GO111MODULE=off;;" ${LINUBOOT_MAKEFILE}
fi
go get -d github.com/u-root/u-root
go get -d github.com/u-root/cpu/...
go install github.com/u-root/u-root@v0.9.0
make -C $LINUBOOT_DIR/mainboards/ampere/${PLATFORM_LOWER} getkernel flashkernel ARCH=arm64 CROSS_COMPILE=${CROSS_COMPILE}
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "ERROR: compile LinuxBoot binaries issue" >&2
exit 1
fi
echo "Results: $LINUBOOT_DIR/mainboards/ampere/${PLATFORM_LOWER}/flashkernel"
ls -l $LINUBOOT_DIR/mainboards/ampere/${PLATFORM_LOWER}/flashkernel