-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_whaleos.sh
executable file
·128 lines (114 loc) · 3.65 KB
/
build_whaleos.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
122
123
124
125
126
127
#!/bin/bash
# Copyright (c) 2021 NAVER Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -e
if [[ -z "$BOARD" ]]; then
echo "BOARD should be defined"
exit -1
fi
echo_help() {
echo "Usage: path/to/manifest> ./build_whaleos.sh [args...]"
echo "* Optional parameters:"
echo " @No parameter: Build packages only"
echo " @Available param 1: base, dev, test"
echo " base: Build base image after building packages"
echo " dev: Build dev image after building packages"
echo " test: Build test image after building packages"
exit 0
}
if [[ $1 == "-h" ]]; then
echo_help
fi
if [[ ! -z $1 && ! $1 =~ ^(base|dev|test)$ ]]; then
echo_help
fi
if [[ ${CHROME_REV} == "" ]]; then
CHROME_REV="R120"
fi
WHALEOS_ROOT_PATH="$PWD/.."
DEV_UPDATE_SERVER=""
UPDATE_SERVER=""
DEV_SERVER=""
WHALEOS_VERSION=$(head -n 1 VERSION)
IMAGE_DIR_PREFIX=${CHROME_REV}-${WHALEOS_VERSION}
# MUST add package as full name.
WORKON_PACKAGES=(
'app-i18n/chromeos-hangul'
'chromeos-base/chaps'
'chromeos-base/chrome-icu'
'chromeos-base/chromeos-chrome'
'chromeos-base/chromeos-init'
'chromeos-base/chromeos-installer'
'chromeos-base/chromeos-login'
'chromeos-base/chromiumos-assets'
'chromeos-base/common-assets'
'chromeos-base/crash-reporter'
'chromeos-base/crosh'
'chromeos-base/crosh-extension'
'chromeos-base/cryptohome'
'chromeos-base/device_management'
'chromeos-base/diagnostics'
'chromeos-base/iioservice'
'chromeos-base/libbrillo'
'chromeos-base/libec'
'chromeos-base/libhwsec'
'chromeos-base/libmems'
'chromeos-base/missive'
'chromeos-base/tpm_manager'
'chromeos-base/tpm_manager-client'
'chromeos-base/userfeedback'
'media-libs/cros-camera-hal-usb'
'sys-apps/flashrom'
'sys-apps/frecon'
'virtual/target-chromium-os'
'chromeos-base/os_install_service'
'chromeos-base/power_manager'
'chromeos-base/vpd'
'net-misc/tlsdate'
'media-libs/mesa-llvmpipe'
'sys-kernel/chromeos-kernel-5_15'
'sys-kernel/linux-firmware'
)
echo "** Setup for image building **"
cd $WHALEOS_ROOT_PATH
cros_sdk -- setup_board --board=${BOARD}
cros_sdk -- sudo sysctl -w vm.max_map_count=262144
PACKAGES_WORKON_STARTED=$(cros_sdk -- cros_workon --board=${BOARD} list)
# https://unix.stackexchange.com/a/104848
TO_STOP=($(comm -13 <(printf '%s\n' "${WORKON_PACKAGES[@]}" | LC_ALL=C sort) \
<(printf '%s\n' "${PACKAGES_WORKON_STARTED[@]}" | LC_ALL=C sort)))
TO_START=($(comm -23 <(printf '%s\n' "${WORKON_PACKAGES[@]}" | LC_ALL=C sort) \
<(printf '%s\n' "${PACKAGES_WORKON_STARTED[@]}" | LC_ALL=C sort)))
if [[ ${#TO_STOP[@]} -gt 0 ]]; then
cros_sdk -- cros_workon --board=${BOARD} stop ${TO_STOP[@]}
fi
if [[ ${#TO_START[@]} -gt 0 ]]; then
cros_sdk -- cros_workon --board=${BOARD} start ${TO_START[@]}
fi
echo "** Build packages **"
sudo mkdir -p out/build/amd64-generic/usr/lib64
LIBRT_PATH="out/build/amd64-generic/usr/lib64/librt.so"
if [ ! -f $LIBRT_PATH ]; then
sudo ln -s "../../../${BOARD}/lib64/librt.so.1" $LIBRT_PATH
fi
cros_sdk -- build_packages --board=${BOARD}
cros_sdk -- emerge-${BOARD} ${WORKON_PACKAGES[@]}
if [[ $1 == "jenkins" ]]; then
cros_sdk BOARD=${BOARD} -- emerge-${BOARD} grub
fi
if [[ -z "$1" ]]; then
echo "Build packages only done."
exit 0
fi
if [[ $1 =~ ^(base|dev|test)$ ]]; then
echo "** Make $1 image **"
if [[ $1 == "test" ]]; then
EXTRA_COMMANDS="--noenable_rootfs_verification"
fi
cros_sdk CHROMEOS_VERSION_DEVSERVER=${DEV_SERVER} \
CHROMEOS_VERSION_AUSERVER=${UPDATE_SERVER} \
-- build_image --board=${BOARD} ${EXTRA_COMMANDS} \
--version=${WHALEOS_VERSION} $1 --replace
exit 0
fi