-
Notifications
You must be signed in to change notification settings - Fork 50
/
set_version
executable file
·128 lines (119 loc) · 5.5 KB
/
set_version
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
128
#!/bin/bash
set -euo pipefail
. "$(dirname ${BASH_SOURCE[0]})/settings.env" || exit 1
DEFAULT_BASE_URL="${SETTING_BINPKG_SERVER_PROD}"
DEV_BOARD_URL="${DEFAULT_BASE_URL}/developer"
DEFAULT_SDK_URL="${DEFAULT_BASE_URL}/sdk"
DEV_SDK_URL="${DEFAULT_BASE_URL}/developer/sdk"
FILE=~/trunk/.repo/manifests/version.txt
FLATCAR_DEV_BUILDS_SDK=""
FLATCAR_SDK_VERSION=""
FLATCAR_DEV_BUILDS=""
FLATCAR_VERSION=""
FLATCAR_VERSION_ID=""
# To keep this script usable outside of the SDK chroot, do not include common.sh here.
if [[ $# = 0 ]] || [[ "$1" = "-h" ]] || [[ "$1" = "--help" ]]; then
echo "Updates ${FILE} with new values to specify which binary packages to use
Usage: $0 FLAGS...
--board-version (VERSION|BOARD/BRANCH-nightly): Set FLATCAR_VERSION=VERSION and
FLATCAR_VERSION_ID=VERSION where VERSION can
be resolved by looking up the latest build
referenced by
${DEV_BOARD_URL}/boards/BOARD/BRANCH-nightly.txt
where BRANCH can be flatcar-MAJOR for the maintenance
branch of a release with the version MAJOR.MINOR.PATCH,
or the Alpha/Edge development branch
--dev-board: Set FLATCAR_DEV_BUILDS=${DEV_BOARD_URL}
which also selects --dev-sdk unless you specify
--no-dev-sdk
--no-dev-board: Remove existing FLATCAR_DEV_BUILDS
--sdk-version (VERSION|sdk-BRANCH-nightly): Set FLATCAR_SDK_VERSION=VERSION where VERSION can
be resolved by looking up the latest SDK build
referenced by
${DEV_BOARD_URL}/sdk/amd64/sdk-BRANCH-nightly.txt
where BRANCH is currently only main, and requires
the --dev-sdk option if --no-dev-board is used
--dev-sdk: Set FLATCAR_DEV_BUILDS_SDK=${DEV_SDK_URL}
--no-dev-sdk: Use a release SDK even if --dev-board is specified
--file FILE: Modify another file than ${FILE}, useful if run
outside of the SDK chroot. If /dev/stdout or
/dev/stderr is used, only new values are printed.
--binhost Use a custom binhost (defaults to '${DEFAULT_BASE_URL}'),
e.g., '${SETTING_BINPKG_SERVER_DEV}'.
This will update BOARD and SDK URLs accordingly.
"
exit 1
fi
# --binhost needs to be evaluated first since it impacts other variables set below
custom_binhost="false"
for arg in "${@}" ; do
if $custom_binhost; then
echo "Using custom binhost '${arg}'"
DEFAULT_BASE_URL="${arg}"
DEV_BOARD_URL="${DEFAULT_BASE_URL}/developer"
DEFAULT_SDK_URL="${DEFAULT_BASE_URL}/sdk"
DEV_SDK_URL="${DEFAULT_BASE_URL}/developer/sdk"
break
fi
if [ "$arg" = "--binhost" ] ; then
custom_binhost="true"
fi
done
while [[ $# -gt 0 ]]; do
ARG="$1"
shift
case "${ARG}" in
--binhost) # handled separately above, pass
shift;;
--board-version)
VAL="$1"
shift
if [[ "${VAL}" == */*-nightly ]]; then
VAL=$(curl -s -S -f -L "${DEV_BOARD_URL}/boards/${VAL}.txt")
fi
FLATCAR_VERSION="${VAL}"
FLATCAR_VERSION_ID="${VAL}"
;;
--dev-board)
FLATCAR_DEV_BUILDS="${DEV_BOARD_URL}"
;;
--no-dev-board)
FLATCAR_DEV_BUILDS=no
;;
--sdk-version)
FLATCAR_SDK_VERSION="$1"
if [[ "${FLATCAR_SDK_VERSION}" == sdk-*-nightly ]]; then
FLATCAR_SDK_VERSION=$(curl -s -S -f -L "${DEV_BOARD_URL}/sdk/amd64/${FLATCAR_SDK_VERSION}.txt")
fi
shift
;;
--dev-sdk)
FLATCAR_DEV_BUILDS_SDK="${DEV_SDK_URL}"
;;
--no-dev-sdk)
FLATCAR_DEV_BUILDS_SDK="${DEFAULT_SDK_URL}"
;;
--file)
FILE="$1"
shift
;;
*)
echo "Unkown argument ${ARG}"
exit 1
;;
esac
done
if [[ "${FILE}" != "/dev/stdout" ]] && [[ "${FILE}" != "/dev/stderr" ]]; then
[[ -n "${FLATCAR_VERSION}" ]] && sed -i "/FLATCAR_VERSION=.*/d" "${FILE}"
[[ -n "${FLATCAR_VERSION_ID}" ]] && sed -i "/FLATCAR_VERSION_ID=.*/d" "${FILE}"
[[ -n "${FLATCAR_DEV_BUILDS}" ]] && sed -i "/FLATCAR_DEV_BUILDS=.*/d" "${FILE}"
[[ -n "${FLATCAR_SDK_VERSION}" ]] && sed -i "/FLATCAR_SDK_VERSION=.*/d" "${FILE}"
[[ -n "${FLATCAR_DEV_BUILDS_SDK}" ]] && sed -i "/FLATCAR_DEV_BUILDS_SDK=.*/d" "${FILE}"
fi
{
[[ -n "${FLATCAR_VERSION}" ]] && echo "FLATCAR_VERSION=${FLATCAR_VERSION}"
[[ -n "${FLATCAR_VERSION_ID}" ]] && echo "FLATCAR_VERSION_ID=${FLATCAR_VERSION_ID}"
[[ -n "${FLATCAR_DEV_BUILDS}" ]] && [[ "${FLATCAR_DEV_BUILDS}" != no ]] && echo "FLATCAR_DEV_BUILDS=${FLATCAR_DEV_BUILDS}"
[[ -n "${FLATCAR_SDK_VERSION}" ]] && echo "FLATCAR_SDK_VERSION=${FLATCAR_SDK_VERSION}"
[[ -n "${FLATCAR_DEV_BUILDS_SDK}" ]] && echo "FLATCAR_DEV_BUILDS_SDK=${FLATCAR_DEV_BUILDS_SDK}"
} >> "${FILE}"