Skip to content

Commit 26c2e93

Browse files
committed
Drop cros-workon.eclass and replace with git-r3.eclass
The cros_workon tool has been replaced with a simpler flatcar_workon tool based around git-r3. Signed-off-by: James Le Cuirot <[email protected]>
1 parent 7f151af commit 26c2e93

File tree

29 files changed

+269
-835
lines changed

29 files changed

+269
-835
lines changed

bash_completion

+9-106
Original file line numberDiff line numberDiff line change
@@ -106,124 +106,28 @@ _autotest_complete() {
106106
_complete_board_sysroot_flag && return 0
107107
}
108108

109-
# Complete cros_workon's <command> argument.
109+
# Complete flatcar_workon's <command> argument.
110110
#
111111
# TODO(petkov): We should probably extract the list of commands from
112-
# cros_workon --help, just like we do for flags (see _flag_complete).
112+
# flatcar_workon --help, just like we do for flags (see _flag_complete).
113113
#
114114
# TODO(petkov): Currently, this assumes that the command is the first
115115
# argument. In practice, the command is the first non-flag
116116
# argument. I.e., this should be fixed to support something like
117-
# "cros_workon --all list".
118-
_complete_cros_workon_command() {
117+
# "flatcar_workon --all list".
118+
_complete_flatcar_workon_command() {
119119
[ ${COMP_CWORD} -eq 1 ] || return 1
120120
local command="${COMP_WORDS[1]}"
121-
COMPREPLY=($(compgen -W "start stop list iterate" -- "$command"))
121+
COMPREPLY=($(compgen -W "start stop list" -- "$command"))
122122
return 0
123123
}
124124

125-
# Prints the full path to the cros_workon executable, handling tilde
126-
# expansion for the current user.
127-
_cros_workon_executable() {
128-
local cros_workon="${COMP_WORDS[0]}"
129-
if [[ "$cros_workon" == '~/'* ]]; then
130-
cros_workon="$HOME/${cros_workon#'~/'}"
131-
fi
132-
echo "$cros_workon"
133-
}
134-
135-
# Lists the workon (or live, if --all is passed in) ebuilds. Lists
136-
# both the full names (e.g., chromeos-base/metrics) as well as just
137-
# the ebuild names (e.g., metrics).
138-
_cros_workon_list() {
139-
local cros_workon=$(_cros_workon_executable)
140-
${cros_workon} list $1 | sed 's,\(.\+\)/\(.\+\),\1/\2 \2,'
141-
}
142-
143-
# Completes the current cros_workon argument assuming it's a
144-
# package/ebuild name.
145-
_complete_cros_workon_package() {
146-
[ ${COMP_CWORD} -gt 1 ] || return 1
147-
local package="${COMP_WORDS[COMP_CWORD]}"
148-
local command="${COMP_WORDS[1]}"
149-
# If "start", complete based on all workon packages.
150-
if [[ ${command} == "start" ]]; then
151-
COMPREPLY=($(compgen -W "$(_cros_workon_list --all)" -- "$package"))
152-
return 0
153-
fi
154-
# If "stop" or "iterate", complete based on all live packages.
155-
if [[ ${command} == "stop" ]] || [[ ${command} == "iterate" ]]; then
156-
COMPREPLY=($(compgen -W "$(_cros_workon_list)" -- "$package"))
157-
return 0
158-
fi
159-
return 1
160-
}
161-
162-
# Complete cros_workon arguments.
163-
_cros_workon() {
125+
# Complete flatcar_workon arguments.
126+
_flatcar_workon() {
164127
COMPREPLY=()
165128
_flag_complete && return 0
166129
_complete_board_sysroot_flag && return 0
167-
_complete_cros_workon_command && return 0
168-
_complete_cros_workon_package && return 0
169-
return 0
170-
}
171-
172-
_list_repo_commands() {
173-
local repo=${COMP_WORDS[0]}
174-
"$repo" help --all | grep -E '^ ' | sed 's/ \([^ ]\+\) .\+/\1/'
175-
}
176-
177-
_list_repo_branches() {
178-
local repo=${COMP_WORDS[0]}
179-
"$repo" branches 2>&1 | grep \| | sed 's/[ *][Pp ] *\([^ ]\+\) .*/\1/'
180-
}
181-
182-
_list_repo_projects() {
183-
local repo=${COMP_WORDS[0]}
184-
"$repo" manifest -o /dev/stdout 2> /dev/null \
185-
| grep 'project name=' \
186-
| sed 's/.\+name="\([^"]\+\)".\+/\1/'
187-
}
188-
189-
# Complete repo's <command> argument.
190-
_complete_repo_command() {
191-
[ ${COMP_CWORD} -eq 1 ] || return 1
192-
local command=${COMP_WORDS[1]}
193-
COMPREPLY=($(compgen -W "$(_list_repo_commands)" -- "$command"))
194-
return 0
195-
}
196-
197-
_complete_repo_arg() {
198-
[ ${COMP_CWORD} -gt 1 ] || return 1
199-
local command=${COMP_WORDS[1]}
200-
local current=${COMP_WORDS[COMP_CWORD]}
201-
if [[ ${command} == "abandon" ]]; then
202-
if [[ ${COMP_CWORD} -eq 2 ]]; then
203-
COMPREPLY=($(compgen -W "$(_list_repo_branches)" -- "$current"))
204-
else
205-
COMPREPLY=($(compgen -W "$(_list_repo_projects)" -- "$current"))
206-
fi
207-
return 0
208-
fi
209-
if [[ ${command} == "help" ]]; then
210-
[ ${COMP_CWORD} -eq 2 ] && \
211-
COMPREPLY=($(compgen -W "$(_list_repo_commands)" -- "$current"))
212-
return 0
213-
fi
214-
if [[ ${command} == "start" ]]; then
215-
[ ${COMP_CWORD} -gt 2 ] && \
216-
COMPREPLY=($(compgen -W "$(_list_repo_projects)" -- "$current"))
217-
return 0
218-
fi
219-
return 1
220-
}
221-
222-
# Complete repo arguments.
223-
_complete_repo() {
224-
COMPREPLY=()
225-
_complete_repo_command && return 0
226-
_complete_repo_arg && return 0
130+
_complete_flatcar_workon_command && return 0
227131
return 0
228132
}
229133

@@ -234,8 +138,7 @@ complete -o bashdefault -o default -F _board_sysroot \
234138
image_to_usb.sh \
235139
mod_image_for_test.sh
236140
complete -o bashdefault -o default -o nospace -F _autotest_complete autotest
237-
complete -F _cros_workon cros_workon
238-
complete -F _complete_repo repo
141+
complete -F _flatcar_workon flatcar_workon
239142

240143
### Local Variables:
241144
### mode: shell-script

build_library/build_image_util.sh

+4-5
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,13 @@ get_metadata() {
340340
if [ -z "${val}" ]; then
341341
# The grep invocation gives errors when the ebuild file is not present.
342342
# This can happen when the binary packages from ./build_packages are outdated.
343-
val="$(grep "CROS_WORKON_PROJECT=" "${ebuild_path}" | cut -d '"' -f 2)"
343+
val="$(grep "EGIT_REPO_URI=" "${ebuild_path}" | cut -d '"' -f 2)"
344344
if [ -n "${val}" ]; then
345-
val="https://github.com/${val}"
346345
# All github.com/flatcar projects specify their commit
347346
local commit=""
348-
commit="$(grep "CROS_WORKON_COMMIT=" "${ebuild_path}" | cut -d '"' -f 2)"
347+
commit="$(grep "EGIT_COMMIT=" "${ebuild_path}" | cut -d '"' -f 2)"
349348
if [ -n "${commit}" ]; then
350-
val="${val}/commit/${commit}"
349+
val="${val%.git}/commit/${commit}"
351350
fi
352351
fi
353352
fi
@@ -539,7 +538,7 @@ insert_extra_slsa() {
539538

540539
# Add an entry to the image's package.provided
541540
package_provided() {
542-
local p profile="${BUILD_DIR}/configroot/etc/portage/profile"
541+
local p profile="${BUILD_DIR}/configroot/etc/portage/profile"
543542
for p in "$@"; do
544543
info "Writing $p to package.provided and soname.provided"
545544
echo "$p" >> "${profile}/package.provided"

build_packages

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ DEFINE_string getbinpkgver "" \
2727
DEFINE_boolean toolchainpkgonly "${FLAGS_FALSE}" \
2828
"Use binary packages only for the board toolchain."
2929
DEFINE_boolean workon "${FLAGS_TRUE}" \
30-
"Automatically rebuild updated cros-workon packages."
30+
"Automatically rebuild updated flatcar-workon packages."
3131
DEFINE_boolean fetchonly "${FLAGS_FALSE}" \
3232
"Don't build anything, instead only fetch what is needed."
3333
DEFINE_boolean rebuild "${FLAGS_FALSE}" \
@@ -169,16 +169,16 @@ if [[ "${FLAGS_debug_emerge}" -eq "${FLAGS_TRUE}" ]]; then
169169
EMERGE_FLAGS+=( --debug )
170170
fi
171171

172-
# Build cros_workon packages when they are changed.
173-
CROS_WORKON_PKGS=()
174-
if [ "${FLAGS_workon}" -eq "${FLAGS_TRUE}" ]; then
175-
CROS_WORKON_PKGS+=( $("${SRC_ROOT}/scripts/cros_workon" list --board=${FLAGS_board}) )
172+
# Build flatcar_workon packages when they are changed.
173+
WORKON_PKGS=()
174+
if [[ ${FLAGS_workon} -eq "${FLAGS_TRUE}" ]]; then
175+
mapfile -t WORKON_PKGS < <("${SRC_ROOT}"/scripts/flatcar_workon list --board="${FLAGS_board}")
176176
fi
177177

178-
if [[ ${#CROS_WORKON_PKGS[@]} -gt 0 ]]; then
178+
if [[ ${#WORKON_PKGS[@]} -gt 0 ]]; then
179179
EMERGE_FLAGS+=(
180-
--reinstall-atoms="${CROS_WORKON_PKGS[*]}"
181-
--usepkg-exclude="${CROS_WORKON_PKGS[*]}"
180+
--reinstall-atoms="${WORKON_PKGS[*]}"
181+
--usepkg-exclude="${WORKON_PKGS[*]}"
182182
)
183183
fi
184184

0 commit comments

Comments
 (0)