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 <jlecuirot@microsoft.com>
This commit is contained in:
James Le Cuirot 2024-06-14 16:49:03 +01:00
parent 7f151af41d
commit 26c2e935c1
No known key found for this signature in database
GPG Key ID: 1226415D00DD3137
29 changed files with 269 additions and 835 deletions

View File

@ -106,124 +106,28 @@ _autotest_complete() {
_complete_board_sysroot_flag && return 0 _complete_board_sysroot_flag && return 0
} }
# Complete cros_workon's <command> argument. # Complete flatcar_workon's <command> argument.
# #
# TODO(petkov): We should probably extract the list of commands from # TODO(petkov): We should probably extract the list of commands from
# cros_workon --help, just like we do for flags (see _flag_complete). # flatcar_workon --help, just like we do for flags (see _flag_complete).
# #
# TODO(petkov): Currently, this assumes that the command is the first # TODO(petkov): Currently, this assumes that the command is the first
# argument. In practice, the command is the first non-flag # argument. In practice, the command is the first non-flag
# argument. I.e., this should be fixed to support something like # argument. I.e., this should be fixed to support something like
# "cros_workon --all list". # "flatcar_workon --all list".
_complete_cros_workon_command() { _complete_flatcar_workon_command() {
[ ${COMP_CWORD} -eq 1 ] || return 1 [ ${COMP_CWORD} -eq 1 ] || return 1
local command="${COMP_WORDS[1]}" local command="${COMP_WORDS[1]}"
COMPREPLY=($(compgen -W "start stop list iterate" -- "$command")) COMPREPLY=($(compgen -W "start stop list" -- "$command"))
return 0 return 0
} }
# Prints the full path to the cros_workon executable, handling tilde # Complete flatcar_workon arguments.
# expansion for the current user. _flatcar_workon() {
_cros_workon_executable() {
local cros_workon="${COMP_WORDS[0]}"
if [[ "$cros_workon" == '~/'* ]]; then
cros_workon="$HOME/${cros_workon#'~/'}"
fi
echo "$cros_workon"
}
# Lists the workon (or live, if --all is passed in) ebuilds. Lists
# both the full names (e.g., chromeos-base/metrics) as well as just
# the ebuild names (e.g., metrics).
_cros_workon_list() {
local cros_workon=$(_cros_workon_executable)
${cros_workon} list $1 | sed 's,\(.\+\)/\(.\+\),\1/\2 \2,'
}
# Completes the current cros_workon argument assuming it's a
# package/ebuild name.
_complete_cros_workon_package() {
[ ${COMP_CWORD} -gt 1 ] || return 1
local package="${COMP_WORDS[COMP_CWORD]}"
local command="${COMP_WORDS[1]}"
# If "start", complete based on all workon packages.
if [[ ${command} == "start" ]]; then
COMPREPLY=($(compgen -W "$(_cros_workon_list --all)" -- "$package"))
return 0
fi
# If "stop" or "iterate", complete based on all live packages.
if [[ ${command} == "stop" ]] || [[ ${command} == "iterate" ]]; then
COMPREPLY=($(compgen -W "$(_cros_workon_list)" -- "$package"))
return 0
fi
return 1
}
# Complete cros_workon arguments.
_cros_workon() {
COMPREPLY=() COMPREPLY=()
_flag_complete && return 0 _flag_complete && return 0
_complete_board_sysroot_flag && return 0 _complete_board_sysroot_flag && return 0
_complete_cros_workon_command && return 0 _complete_flatcar_workon_command && return 0
_complete_cros_workon_package && return 0
return 0
}
_list_repo_commands() {
local repo=${COMP_WORDS[0]}
"$repo" help --all | grep -E '^ ' | sed 's/ \([^ ]\+\) .\+/\1/'
}
_list_repo_branches() {
local repo=${COMP_WORDS[0]}
"$repo" branches 2>&1 | grep \| | sed 's/[ *][Pp ] *\([^ ]\+\) .*/\1/'
}
_list_repo_projects() {
local repo=${COMP_WORDS[0]}
"$repo" manifest -o /dev/stdout 2> /dev/null \
| grep 'project name=' \
| sed 's/.\+name="\([^"]\+\)".\+/\1/'
}
# Complete repo's <command> argument.
_complete_repo_command() {
[ ${COMP_CWORD} -eq 1 ] || return 1
local command=${COMP_WORDS[1]}
COMPREPLY=($(compgen -W "$(_list_repo_commands)" -- "$command"))
return 0
}
_complete_repo_arg() {
[ ${COMP_CWORD} -gt 1 ] || return 1
local command=${COMP_WORDS[1]}
local current=${COMP_WORDS[COMP_CWORD]}
if [[ ${command} == "abandon" ]]; then
if [[ ${COMP_CWORD} -eq 2 ]]; then
COMPREPLY=($(compgen -W "$(_list_repo_branches)" -- "$current"))
else
COMPREPLY=($(compgen -W "$(_list_repo_projects)" -- "$current"))
fi
return 0
fi
if [[ ${command} == "help" ]]; then
[ ${COMP_CWORD} -eq 2 ] && \
COMPREPLY=($(compgen -W "$(_list_repo_commands)" -- "$current"))
return 0
fi
if [[ ${command} == "start" ]]; then
[ ${COMP_CWORD} -gt 2 ] && \
COMPREPLY=($(compgen -W "$(_list_repo_projects)" -- "$current"))
return 0
fi
return 1
}
# Complete repo arguments.
_complete_repo() {
COMPREPLY=()
_complete_repo_command && return 0
_complete_repo_arg && return 0
return 0 return 0
} }
@ -234,8 +138,7 @@ complete -o bashdefault -o default -F _board_sysroot \
image_to_usb.sh \ image_to_usb.sh \
mod_image_for_test.sh mod_image_for_test.sh
complete -o bashdefault -o default -o nospace -F _autotest_complete autotest complete -o bashdefault -o default -o nospace -F _autotest_complete autotest
complete -F _cros_workon cros_workon complete -F _flatcar_workon flatcar_workon
complete -F _complete_repo repo
### Local Variables: ### Local Variables:
### mode: shell-script ### mode: shell-script

View File

@ -340,14 +340,13 @@ get_metadata() {
if [ -z "${val}" ]; then if [ -z "${val}" ]; then
# The grep invocation gives errors when the ebuild file is not present. # The grep invocation gives errors when the ebuild file is not present.
# This can happen when the binary packages from ./build_packages are outdated. # This can happen when the binary packages from ./build_packages are outdated.
val="$(grep "CROS_WORKON_PROJECT=" "${ebuild_path}" | cut -d '"' -f 2)" val="$(grep "EGIT_REPO_URI=" "${ebuild_path}" | cut -d '"' -f 2)"
if [ -n "${val}" ]; then if [ -n "${val}" ]; then
val="https://github.com/${val}"
# All github.com/flatcar projects specify their commit # All github.com/flatcar projects specify their commit
local commit="" local commit=""
commit="$(grep "CROS_WORKON_COMMIT=" "${ebuild_path}" | cut -d '"' -f 2)" commit="$(grep "EGIT_COMMIT=" "${ebuild_path}" | cut -d '"' -f 2)"
if [ -n "${commit}" ]; then if [ -n "${commit}" ]; then
val="${val}/commit/${commit}" val="${val%.git}/commit/${commit}"
fi fi
fi fi
fi fi

View File

@ -27,7 +27,7 @@ DEFINE_string getbinpkgver "" \
DEFINE_boolean toolchainpkgonly "${FLAGS_FALSE}" \ DEFINE_boolean toolchainpkgonly "${FLAGS_FALSE}" \
"Use binary packages only for the board toolchain." "Use binary packages only for the board toolchain."
DEFINE_boolean workon "${FLAGS_TRUE}" \ DEFINE_boolean workon "${FLAGS_TRUE}" \
"Automatically rebuild updated cros-workon packages." "Automatically rebuild updated flatcar-workon packages."
DEFINE_boolean fetchonly "${FLAGS_FALSE}" \ DEFINE_boolean fetchonly "${FLAGS_FALSE}" \
"Don't build anything, instead only fetch what is needed." "Don't build anything, instead only fetch what is needed."
DEFINE_boolean rebuild "${FLAGS_FALSE}" \ DEFINE_boolean rebuild "${FLAGS_FALSE}" \
@ -169,16 +169,16 @@ if [[ "${FLAGS_debug_emerge}" -eq "${FLAGS_TRUE}" ]]; then
EMERGE_FLAGS+=( --debug ) EMERGE_FLAGS+=( --debug )
fi fi
# Build cros_workon packages when they are changed. # Build flatcar_workon packages when they are changed.
CROS_WORKON_PKGS=() WORKON_PKGS=()
if [ "${FLAGS_workon}" -eq "${FLAGS_TRUE}" ]; then if [[ ${FLAGS_workon} -eq "${FLAGS_TRUE}" ]]; then
CROS_WORKON_PKGS+=( $("${SRC_ROOT}/scripts/cros_workon" list --board=${FLAGS_board}) ) mapfile -t WORKON_PKGS < <("${SRC_ROOT}"/scripts/flatcar_workon list --board="${FLAGS_board}")
fi fi
if [[ ${#CROS_WORKON_PKGS[@]} -gt 0 ]]; then if [[ ${#WORKON_PKGS[@]} -gt 0 ]]; then
EMERGE_FLAGS+=( EMERGE_FLAGS+=(
--reinstall-atoms="${CROS_WORKON_PKGS[*]}" --reinstall-atoms="${WORKON_PKGS[*]}"
--usepkg-exclude="${CROS_WORKON_PKGS[*]}" --usepkg-exclude="${WORKON_PKGS[*]}"
) )
fi fi

View File

@ -1,420 +0,0 @@
#!/bin/bash
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This script moves ebuilds between 'stable' and 'live' states.
# By default 'stable' ebuilds point at and build from source at the
# last known good commit. Moving an ebuild to 'live' (via cros_workon start)
# is intended to support development. The current source tip is fetched,
# source modified and built using the unstable 'live' (9999) ebuild.
. "$(dirname "$0")/common.sh" || exit 1
assert_not_root_user
# Script must be run inside the chroot
DEFINE_string board "${DEFAULT_BOARD}" \
"The board to set package keywords for."
DEFINE_boolean host "${FLAGS_FALSE}" \
"Uses the host instead of board"
DEFINE_string remote "" \
"For non-workon projects, the git remote to use."
DEFINE_string revision "" \
"Use to override the manifest defined default revision used for a project"
DEFINE_string command "git status" \
"The command to be run by forall."
DEFINE_boolean all "${FLAGS_FALSE}" \
"Apply to all possible packages for the given command"
FLAGS_HELP="usage: $0 <command> [flags] [<list of packages>|.|--all]
commands:
start: Moves an ebuild to live (intended to support development)
stop: Moves an ebuild to stable (use last known good)
info: Print package name, repo name, and source directory.
list: List of live ebuilds (workon ebuilds if --all)
list-all: List all of the live ebuilds for all setup boards
iterate: For each ebuild, cd to the source dir and run a command"
FLAGS "$@" || { [ "${FLAGS_help}" = "${FLAGS_TRUE}" ] && exit 0; } || exit 1
eval set -- "${FLAGS_ARGV}"
# eat the workon command keywords: start, stop or list.
WORKON_CMD=$1
shift
# Board dir config
# If both are specified, just use host, because board does not
# have to be specified and may come from default, in which case
# there's no way to override.
[ -n "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_TRUE} ] && \
FLAGS_board="" # kill board
if [ -z "${FLAGS_board}" ] && \
[ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \
[ "${WORKON_CMD}" != "list-all" ]; then
flags_help
die "You must specify either --host or --board="
fi
if [ -n "${FLAGS_board}" ]; then
BOARD_DIR=/build/"${FLAGS_board}" # --board specified
EQUERYCMD=equery-"${FLAGS_board}"
EBUILDCMD=ebuild-"${FLAGS_board}"
PORTAGEQCMD=portageq-"${FLAGS_board}"
BOARD_STR="${FLAGS_board}"
else
BOARD_DIR="" # --host specified
EQUERYCMD=equery
EBUILDCMD=ebuild
PORTAGEQCMD=portageq
BOARD_STR="host"
fi
WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon
CONFIG_DIR=${BOARD_DIR}/etc/portage
KEYWORDS_DIR=${CONFIG_DIR}/package.keywords
MASK_DIR=${CONFIG_DIR}/package.mask
UNMASK_DIR=${CONFIG_DIR}/package.unmask
WORKON_FILE=${WORKON_DIR}/${FLAGS_board:-host}
MASK_WORKON_FILE=${WORKON_FILE}.mask
KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon
MASK_FILE=${MASK_DIR}/cros-workon
UNMASK_FILE=${UNMASK_DIR}/cros-workon
CHROME_ATOM=chromeos-base/chromeos-chrome
mkdir -p "${WORKON_DIR}" || die "mkdir -p ${WORKON_DIR}"
touch "${WORKON_FILE}" "${MASK_WORKON_FILE}" || \
die "touch ${WORKON_FILE} ${MASK_WORKON_FILE}"
cmds=(
"mkdir -p '${KEYWORDS_DIR}' '${MASK_DIR}' '${UNMASK_DIR}'"
# Clobber and re-create the WORKON_FILE symlinks every time. This
# is a trivial operation and eliminates all kinds of corner cases
# as well as any possible future renames of WORKON_FILE.
# In particular, chroot is usually built as "amd64-host" but becomes
# just "host" after installation. crosbug.com/23096
"ln -sf '${WORKON_FILE}' '${KEYWORDS_FILE}'"
"ln -sf '${MASK_WORKON_FILE}' '${MASK_FILE}'"
"ln -sf '${WORKON_FILE}' '${UNMASK_FILE}'"
)
# If the board dir doesn't exist yet, we don't want to create it as
# that'll screw up ./setup_board later on.
if [[ -d ${BOARD_DIR:-/} ]] ; then
sudo_multi "${cmds[@]}"
else
die "${BOARD_STR} has not been setup yet"
fi
find_keyword_workon_ebuilds() {
local keyword="${1}"
local overlay
# NOTE: overlay may be a symlink, and we have to use ${overlay}/
for overlay in ${PORTDIR_OVERLAY}; do
# only look up ebuilds named 9999 to eliminate duplicates
find ${overlay}/*-* -maxdepth 2 -type f -name '*9999.ebuild' \
-exec grep -l 'inherit.*cros-workon' {} + 2>/dev/null | \
xargs grep -l "KEYWORDS=.*${keyword}.*"
done
}
ebuild_to_package() {
# This changes the absolute path to ebuilds into category/package.
sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/'
}
show_project_ebuild_map() {
local keyword="$1"
# Column 1: Repo name
# Column 2: Package name
for EBUILD in $(find_keyword_workon_ebuilds ${keyword}); do
(
eval $(grep -E '^CROS_WORKON' "${EBUILD}")
CP=$(echo "$EBUILD" | ebuild_to_package)
echo "${CROS_WORKON_PROJECT}" "${CP}"
)
done
}
show_project_path_map() {
# Column 1: Repo name
# Column 2: Source directory
repo list | awk -F ' : ' '{ print $2, $1 }'
}
show_workon_ebuilds() {
local keyword="$1"
find_keyword_workon_ebuilds "${keyword}" | ebuild_to_package | sort -u
}
show_workon_info() {
local atoms="$1"
local keyword="$2"
local sort="sort -k1b,1"
# Column 1: Package name
# Column 2: Repo name
# Column 3: Source directory (if present locally)
join \
<(echo "${atoms}" | sed -e 's/ /\n/g' | ${sort}) \
<(join -a 1 -e - -o 1.2,1.1,2.2 \
<(show_project_ebuild_map "${keyword}" | ${sort}) \
<(show_project_path_map | ${sort}) \
| ${sort})
}
# Canonicalize package name to category/package.
canonicalize_name () {
local pkgfile
local pkgname
if grep -qx "=$1-9999" "${WORKON_FILE}" ; then
echo $1
return 0
fi
if ! pkgfile=$(ACCEPT_KEYWORDS="~${ARCH}" ${EQUERYCMD} \
which --include-masked $1); then
warn "error looking up package $1" 1>&2
return 1
fi
pkgname=$(echo "${pkgfile}" |awk -F '/' '{ print $(NF-2) "/" $(NF-1) }')
# TODO(rcui): remove special casing of chromeos-chrome here when we make it
# inherit from cros-workon class. Tracked in chromium-os:19259.
if [ "${pkgname}" != "${CHROME_ATOM}" ] && \
! grep -q "cros-workon" ${pkgfile}; then
warn "${pkgname} is not a cros-workon package" 1>&2
return 1
fi
echo "${pkgname}"
return 0
}
# Canonicalize a list of names.
canonicalize_names () {
local atoms=$1
local names=""
local atom
for atom in ${atoms}; do
local name=$(canonicalize_name "${atom}")
[ -n "${name}" ] || return 1
names+=" ${name}"
done
echo "${names}"
}
# Locate the package name based on the current directory
locate_package () {
local projectname=$(git config --get remote.cros.projectname ||
git config --get remote.cros-internal.projectname)
if [ -z "${projectname}" ]; then
die "No project in git config: Can not cros_workon . here"
fi
local reponame=$(show_project_ebuild_map |
grep "^${projectname} " | cut -d" " -f2)
if [ -z "${reponame}" ]; then
die "No matching package for ${projectname}: Can not cros_workon . here"
else
echo "${reponame}"
fi
}
# Display ebuilds currently part of the live branch and open for development.
show_live_ebuilds () {
sed -n 's/^=\(.*\)-9999$/\1/p' "${WORKON_FILE}"
}
# Display ebuilds currently part of the live branch and open for development
# for any board that currently has live ebuilds.
show_all_live_ebuilds () {
local workon_file
for workon_file in ${WORKON_DIR}/*; do
if [[ -s ${workon_file} && ${workon_file} != *.mask ]] ; then
echo -e "${V_BOLD_GREEN}$(basename ${workon_file}):${V_VIDOFF}"
sed -n 's/^=\(.*\)-9999$/ \1/p' "${workon_file}"
echo ""
fi
done
}
# This is called only for "cros-workon start". We dont handle the
# "stop" case since the local changes are ignored anyway since the
# 9999.ebuild is masked and we dont want to deal with what to do with
# the user's local changes.
regen_manifest_and_sync() {
# Nothing to do unless you are working on the minilayout
local manifest=${CHROOT_TRUNK_DIR}/.repo/manifest.xml
if [ $(basename $(readlink -f ${manifest})) != "minilayout.xml" ]; then
if [ -z "$(git config -f "${CHROOT_TRUNK_DIR}/.repo/manifests.git/config" \
--get manifest.groups)" ]; then
# Reaching here means that it's a full manifest w/out any groups set-
# literal full manifest.
return
fi
fi
local need_repo_sync=
local pkgname
for pkgname in $(show_live_ebuilds); do
local pkgpath="$(${EQUERYCMD} which "${pkgname}")"
local pkginfo="$(${EBUILDCMD} "${pkgpath}" info |
grep -v 'pkg_info() is not defined')"
if [ -z "${pkginfo}" ]; then
continue # No package information available
fi
eval "${pkginfo}"
local trunkdir=$(readlink -m "${CHROOT_TRUNK_DIR}")
local i=0
need_repo_sync='yes'
for S in "${CROS_WORKON_SRCDIR[@]}"; do
local srcdir=$(readlink -m "${S}")
local revision="${FLAGS_revision:+--revision=${FLAGS_revision}}"
if [ -z "${FLAGS_remote}" ]; then
loman add --workon "${CROS_WORKON_PROJECT[i]}" ${revision}
else
loman add --remote "${FLAGS_remote}" ${revision} \
"${CROS_WORKON_PROJECT[i]}" "${srcdir#${trunkdir}/}"
fi
: $(( ++i ))
done
done
if [ -n "${need_repo_sync}" ]; then
echo "Please run \"repo sync\" now."
fi
}
chrome_to_live () {
# Switch to using repo manifest checkout of chromium src.
# Run chrome_set_ver to set DEPS
# No chromium/src.git project checked out, meaning user not using
# gerrit_source.xml
if [ ! -d "${CHROOT_TRUNK_DIR}/chromium/src/.git" ]; then
return
fi
info "Setting Chrome dependencies to the correct revision."
chrome_set_ver
if [ -n "${CHROME_ORIGIN}" ] && [ "${CHROME_ORIGIN}" != GERRIT_SOURCE ]; then
warn "CHROME_ORIGIN is already set to ${CHROME_ORIGIN}"
warn "To use the new GERRIT_SOURCE workflow, please unset it."
warn "Run 'unset CHROME_ORIGIN' to reset to the default source location."
fi
}
# Move a stable ebuild to the live development catgeory. The ebuild
# src_unpack step fetches the package source for local development.
ebuild_to_live () {
local atoms=$1
local atoms_success=()
local atom
for atom in ${atoms}; do
if ! grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then
echo "=${atom}-9999" >> "${WORKON_FILE}" || \
die "Could not update ${WORKON_FILE} with ${atom}"
echo "<${atom}-9999" >> "${MASK_WORKON_FILE}" || \
die "Could not update ${MASK_WORKON_FILE} with ${atom}"
atoms_success+=( ${atom} )
if [ "${atom}" = "${CHROME_ATOM}" ]; then
chrome_to_live
fi
else
warn "Already working on ${atom}"
fi
done
[ ${#atoms_success[@]} -gt 0 ] && regen_manifest_and_sync && \
info "Started working on '${atoms_success[*]}' for '${BOARD_STR}'"
}
# Move a live development ebuild back to stable.
ebuild_to_stable () {
local atoms=$1
local atoms_success=()
local atom
for atom in ${atoms}; do
if grep -qx "=${atom}-9999" "${WORKON_FILE}" "${MASK_WORKON_FILE}" ; then
sed -i -e "/^=${atom/\//\\/}-9999\$/d" "${WORKON_FILE}" || \
die "Could not update ${WORKON_FILE} with ${atom}"
sed -i -e "/^<${atom/\//\\/}-9999\$/d" "${MASK_WORKON_FILE}" || \
die "Could not update ${WORKON_FILE} with ${atom}"
atoms_success+=( ${atom} )
else
warn "Not working on ${atom}"
fi
done
[ ${#atoms_success[@]} -gt 0 ] && \
info "Stopped working on '${atoms_success[*]}' for '${BOARD_STR}'"
}
# Run a command on all or a set of repos.
ebuild_iterate() {
local atoms=$1
local atom
for atom in ${atoms}; do
info "Running \"${FLAGS_command}\" on ${atom}"
eval $(${EBUILDCMD} $(${EQUERYCMD} which ${atom}) info)
for S in "${CROS_WORKON_SRCDIR[@]}"; do
(cd "${S}" && bash -c "${FLAGS_command}")
done
done
}
# Only call portageq when absolutely required, and when we do, only run it
# once -- it's a slow beast and can easily take hundreds of milliseconds :(.
if [[ ${WORKON_CMD} != "list" || ${FLAGS_all} != ${FLAGS_FALSE} ]] ; then
portageq_vars="ARCH PORTDIR_OVERLAY"
unset ${portageq_vars}
eval $(${PORTAGEQCMD} envvar -v ${portageq_vars})
fi
# --all makes commands operate on different lists
if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then
case ${WORKON_CMD} in
start|info) ATOM_LIST=$(show_workon_ebuilds ${ARCH});;
stop|iterate) ATOM_LIST=$(show_live_ebuilds);;
list) ;;
*) die "--all is invalid for the given command";;
esac
else # not selected --all
case ${WORKON_CMD} in
start|stop|info|iterate)
ATOM_LIST=$@
if [ -z "${ATOM_LIST}" ]; then
die "${WORKON_CMD}: No packages specified"
fi
if [ "${ATOM_LIST}" = "." ]; then
ATOM_LIST=$(locate_package)
fi
if ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then
die "Error parsing package list"
fi;;
*) ;;
esac
fi
case ${WORKON_CMD} in
start) ebuild_to_live "${ATOM_LIST}" ;;
stop) ebuild_to_stable "${ATOM_LIST}" ;;
info) show_workon_info "${ATOM_LIST}" "${ARCH}" ;;
list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || \
show_workon_ebuilds ${ARCH} ;;
list-all) show_all_live_ebuilds ;;
iterate) ebuild_iterate "${ATOM_LIST}" ;;
*)
flags_help
die "$(basename $0): command '${WORKON_CMD}' not recognized"
;;
esac

172
flatcar_workon Executable file
View File

@ -0,0 +1,172 @@
#!/bin/bash
# Copyright (c) 2024 The Flatcar Maintainers.
# Distributed under the terms of the GNU General Public License v2
. "${0%/*}"/common.sh || exit 1
DEFINE_string board "${DEFAULT_BOARD}" \
"The board to set package keywords for."
FLAGS_HELP="usage: $0 <command> [flags] <atom>
commands:
start: Moves an ebuild to live (intended to support development)
stop: Moves an ebuild to stable (use last known good)
list: List of live ebuilds"
FLAGS "$@" || { [[ ${FLAGS_help} = "${FLAGS_TRUE}" ]] && exit 0; } || exit 1
eval set -- "${FLAGS_ARGV}"
set -euo pipefail
# /etc/portage under either / or /build/<board>.
ETC_PORTAGE=${FLAGS_board+/build/${FLAGS_board}}/etc/portage
# If the board dir doesn't exist yet, we don't want to create it as that'll
# screw up ./setup_board later on.
[[ -d ${ETC_PORTAGE} ]] ||
die "${FLAGS_board} has not been setup yet"
find_ebuild() {
if [[ -z ${1-} ]]; then
flags_help
exit 1
fi
# Exact atom does not need to be given. Resolve to an ebuild with equery.
EBUILD=$(equery which --include-masked "$1")
[[ -n ${EBUILD} ]] ||
die "Package matching \"$1\" could not be found."
PN=${EBUILD%/*}
PN=${PN##*/}
CAT=${EBUILD%/*/*}
CAT=${CAT##*/}
CP=${CAT}/${PN}
}
add_if_needed() {
grep -Fxq "$1" "$2" 2>/dev/null || sudo tee -a "$2" >/dev/null <<< "$1"
}
start() {
export PORTAGE_TMPDIR
PORTAGE_TMPDIR=$(mktemp -d)
trap 'rm -rf -- "${PORTAGE_TMPDIR}"' EXIT
# Load the ebuild environment to reliably pull out variables.
"ebuild${FLAGS_board+-}${FLAGS_board-}" "${EBUILD}" setup
# shellcheck disable=SC1090
. "${PORTAGE_TMPDIR}"/portage/*/*/temp/environment
[[ -n ${EGIT_REPO_URI-} ]] ||
die "${EBUILD} is not live because it does not set EGIT_REPO_URI."
[[ -z ${EGIT_COMMIT-} ]] ||
die "${EBUILD} is not live because it sets EGIT_COMMIT."
### v--- Taken from git-r3.eclass ---v
if [[ $(declare -p EGIT_REPO_URI) == "declare -a"* ]]; then
repos=( "${EGIT_REPO_URI[@]}" )
else
# shellcheck disable=SC2206
repos=( ${EGIT_REPO_URI} )
fi
repo_name=${repos[0]#*://*/}
# strip the trailing slash
repo_name=${repo_name%/}
# strip common prefixes to make paths more likely to match
# e.g. git://X/Y.git vs https://X/git/Y.git
# (but just one of the prefixes)
case "${repo_name}" in
# gnome.org... who else?
browse/*) repo_name=${repo_name#browse/};;
# cgit can proxy requests to git
cgit/*) repo_name=${repo_name#cgit/};;
# pretty common
git/*) repo_name=${repo_name#git/};;
# gentoo.org
gitroot/*) repo_name=${repo_name#gitroot/};;
# sourceforge
p/*) repo_name=${repo_name#p/};;
# kernel.org
pub/scm/*) repo_name=${repo_name#pub/scm/};;
esac
# ensure a .git suffix, same reason
repo_name=${repo_name%.git}.git
# now replace all the slashes
repo_name=${repo_name//\//_}
# get the name and do some more processing:
# 1) kill .git suffix,
# 2) underscore (remaining) non-variable characters,
# 3) add preceding underscore if it starts with a digit,
# 4) uppercase.
override_name=${repo_name##*/}
override_name=${override_name%.git}
override_name=${override_name//[^a-zA-Z0-9_]/_}
override_name=${override_name^^}
### ^--- Taken from git-r3.eclass ---^
GIT_WORKTREE=/home/sdk/trunk/src/scripts/workon/${repo_name}
sudo mkdir -p "${ETC_PORTAGE}"/{env,package.accept_keywords,package.env}
add_if_needed \
"EGIT_OVERRIDE_REPO_${override_name}=\"${GIT_WORKTREE}\" # ${CP}" \
"${ETC_PORTAGE}"/env/workon.conf
add_if_needed \
"${CP} workon.conf" \
"${ETC_PORTAGE}"/package.env/workon.conf
add_if_needed \
"${CP} **" \
"${ETC_PORTAGE}"/package.accept_keywords/workon.conf
if [[ ! -e ${GIT_WORKTREE} ]]; then
mkdir -p "${GIT_WORKTREE%/*}"
git clone "${repos[0]}" "${GIT_WORKTREE}"
fi
return 0
}
stop() {
[[ -e ${ETC_PORTAGE}/env/workon.conf ]] &&
sudo sed -i "/# ${CP//\//\\/}\$/d" "${ETC_PORTAGE}"/env/workon.conf
[[ -e ${ETC_PORTAGE}/package.accept_keywords/workon.conf ]] &&
sudo sed -i "/^${CP//\//\\/} /d" "${ETC_PORTAGE}"/package.accept_keywords/workon.conf
[[ -e ${ETC_PORTAGE}/package.env/workon.conf ]] &&
sudo sed -i "/^${CP//\//\\/} /d" "${ETC_PORTAGE}"/package.env/workon.conf
return 0
}
list() {
[[ -e ${ETC_PORTAGE}/package.env/workon.conf ]] &&
sed '/\bworkon\.conf\b/s:\s.*::' "${ETC_PORTAGE}"/package.env/workon.conf
return 0
}
case "$1" in
start)
find_ebuild "${2-}"
start ;;
stop)
find_ebuild "${2-}"
stop ;;
list)
list ;;
*)
flags_help
die "$0: command \"$1\" not recognized" ;;
esac

View File

@ -2,16 +2,14 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="flatcar/locksmith" EGIT_REPO_URI="https://github.com/flatcar/locksmith.git"
CROS_WORKON_LOCALNAME="locksmith"
CROS_WORKON_REPO="https://github.com"
COREOS_GO_PACKAGE="github.com/flatcar/locksmith" COREOS_GO_PACKAGE="github.com/flatcar/locksmith"
inherit cros-workon systemd coreos-go inherit git-r3 systemd coreos-go
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm64" KEYWORDS="~amd64 ~arm64"
else else
CROS_WORKON_COMMIT="439d44f24b24f679d08f309399f6bb2f82614637" # flatcar-master EGIT_COMMIT="439d44f24b24f679d08f309399f6bb2f82614637" # flatcar-master
KEYWORDS="amd64 arm64" KEYWORDS="amd64 arm64"
fi fi

View File

@ -2,16 +2,14 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="flatcar/mayday" EGIT_REPO_URI="https://github.com/flatcar/mayday.git"
CROS_WORKON_LOCALNAME="mayday"
CROS_WORKON_REPO="https://github.com"
COREOS_GO_PACKAGE="github.com/flatcar/mayday" COREOS_GO_PACKAGE="github.com/flatcar/mayday"
inherit coreos-go cros-workon inherit coreos-go git-r3
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm64" KEYWORDS="~amd64 ~arm64"
else else
CROS_WORKON_COMMIT="9de08c8f9f4360fe52cb3a56a7fb8f4bc4e75dcc" # flatcar-master EGIT_COMMIT="9de08c8f9f4360fe52cb3a56a7fb8f4bc4e75dcc" # flatcar-master
KEYWORDS="amd64 arm64" KEYWORDS="amd64 arm64"
fi fi

View File

@ -2,22 +2,20 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="kinvolk/sdnotify-proxy" EGIT_REPO_URI="https://github.com/flatcar/sdnotify-proxy.git"
CROS_WORKON_LOCALNAME="sdnotify-proxy" COREOS_GO_PACKAGE="github.com/flatcar/sdnotify-proxy"
CROS_WORKON_REPO="https://github.com"
COREOS_GO_PACKAGE="github.com/coreos/sdnotify-proxy"
COREOS_GO_GO111MODULE="off" COREOS_GO_GO111MODULE="off"
inherit coreos-go cros-workon inherit coreos-go git-r3
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm64" KEYWORDS="~amd64 ~arm64"
else else
CROS_WORKON_COMMIT="0f8ef1aa86c59fc6d54eadaffb248feaccd1018b" # master EGIT_COMMIT="0f8ef1aa86c59fc6d54eadaffb248feaccd1018b" # master
KEYWORDS="amd64 arm64" KEYWORDS="amd64 arm64"
fi fi
DESCRIPTION="sdnotify-proxy" DESCRIPTION="sdnotify-proxy"
HOMEPAGE="https://github.com/coreos/sdnotify-proxy" HOMEPAGE="https://github.com/flatcar/sdnotify-proxy"
SRC_URI="" SRC_URI=""
LICENSE="Apache-2.0" LICENSE="Apache-2.0"

View File

@ -2,18 +2,16 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="flatcar/toolbox" EGIT_REPO_URI="https://github.com/flatcar/toolbox.git"
CROS_WORKON_LOCALNAME="toolbox"
CROS_WORKON_REPO="https://github.com"
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm64" KEYWORDS="~amd64 ~arm64"
else else
CROS_WORKON_COMMIT="fce9ba2bbd55e1835af72952bfbb7aed6be75606" # flatcar-master EGIT_COMMIT="fce9ba2bbd55e1835af72952bfbb7aed6be75606" # flatcar-master
KEYWORDS="amd64 arm64" KEYWORDS="amd64 arm64"
fi fi
inherit cros-workon inherit git-r3
DESCRIPTION="toolbox" DESCRIPTION="toolbox"
HOMEPAGE="https://github.com/flatcar/toolbox" HOMEPAGE="https://github.com/flatcar/toolbox"

View File

@ -2,17 +2,15 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="flatcar/updateservicectl" EGIT_REPO_URI="https://github.com/flatcar/updateservicectl.git"
CROS_WORKON_LOCALNAME="updateservicectl"
CROS_WORKON_REPO="https://github.com"
COREOS_GO_PACKAGE="github.com/flatcar/updateservicectl" COREOS_GO_PACKAGE="github.com/flatcar/updateservicectl"
COREOS_GO_GO111MODULE="on" COREOS_GO_GO111MODULE="on"
inherit cros-workon coreos-go inherit git-r3 coreos-go
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm64" KEYWORDS="~amd64 ~arm64"
else else
CROS_WORKON_COMMIT="446f13594465503a3fdfc9106fd8a0c3123249c2" # main EGIT_COMMIT="446f13594465503a3fdfc9106fd8a0c3123249c2" # main
KEYWORDS="amd64 arm64" KEYWORDS="amd64 arm64"
fi fi

View File

@ -3,14 +3,12 @@
EAPI=8 EAPI=8
CROS_WORKON_PROJECT="coreos/afterburn" EGIT_REPO_URI="https://github.com/coreos/afterburn.git"
CROS_WORKON_LOCALNAME="afterburn"
CROS_WORKON_REPO="https://github.com"
if [[ ${PV} == 9999 ]]; then if [[ ${PV} == 9999 ]]; then
KEYWORDS="~amd64 ~arm64" KEYWORDS="~amd64 ~arm64"
else else
CROS_WORKON_COMMIT="aa1be7dba724403457dee0fabed16e15be3ef4e0" # v5.6.0 EGIT_COMMIT="aa1be7dba724403457dee0fabed16e15be3ef4e0" # v5.6.0
KEYWORDS="amd64 arm64" KEYWORDS="amd64 arm64"
fi fi
@ -349,7 +347,7 @@ CRATES="
zvariant_utils@1.0.1 zvariant_utils@1.0.1
" "
inherit cargo cros-workon systemd inherit cargo git-r3 systemd
DESCRIPTION="A tool for collecting instance metadata from various providers" DESCRIPTION="A tool for collecting instance metadata from various providers"
HOMEPAGE="https://github.com/coreos/afterburn" HOMEPAGE="https://github.com/coreos/afterburn"
@ -372,7 +370,7 @@ PATCHES=(
) )
src_unpack() { src_unpack() {
cros-workon_src_unpack git-r3_src_unpack
cargo_src_unpack cargo_src_unpack
} }

View File

@ -2,17 +2,15 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="flatcar/coreos-cloudinit" EGIT_REPO_URI="https://github.com/flatcar/coreos-cloudinit.git"
CROS_WORKON_LOCALNAME="coreos-cloudinit"
CROS_WORKON_REPO="https://github.com"
COREOS_GO_PACKAGE="github.com/flatcar/coreos-cloudinit" COREOS_GO_PACKAGE="github.com/flatcar/coreos-cloudinit"
COREOS_GO_GO111MODULE="on" COREOS_GO_GO111MODULE="on"
inherit cros-workon systemd toolchain-funcs udev coreos-go inherit git-r3 systemd toolchain-funcs udev coreos-go
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm64" KEYWORDS="~amd64 ~arm64"
else else
CROS_WORKON_COMMIT="f78b9f7b484497c610c8a159aa971234d384d215" # flatcar-master EGIT_COMMIT="f78b9f7b484497c610c8a159aa971234d384d215" # flatcar-master
KEYWORDS="amd64 arm64" KEYWORDS="amd64 arm64"
fi fi

View File

@ -3,20 +3,18 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="flatcar/init" EGIT_REPO_URI="https://github.com/flatcar/init.git"
CROS_WORKON_LOCALNAME="init"
CROS_WORKON_REPO="https://github.com"
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm ~arm64 ~x86" KEYWORDS="~amd64 ~arm ~arm64 ~x86"
else else
CROS_WORKON_COMMIT="05e3d8b9c0f8e95d5044db5133b3e75d205f6d91" # flatcar-master EGIT_COMMIT="05e3d8b9c0f8e95d5044db5133b3e75d205f6d91" # flatcar-master
KEYWORDS="amd64 arm arm64 x86" KEYWORDS="amd64 arm arm64 x86"
fi fi
PYTHON_COMPAT=( python3_{9..11} ) PYTHON_COMPAT=( python3_{9..11} )
inherit cros-workon systemd python-any-r1 inherit git-r3 systemd python-any-r1
DESCRIPTION="Init scripts for CoreOS" DESCRIPTION="Init scripts for CoreOS"
HOMEPAGE="http://www.coreos.com/" HOMEPAGE="http://www.coreos.com/"

View File

@ -2,21 +2,18 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="flatcar/flatcar-dev-util" EGIT_REPO_URI="https://github.com/flatcar/flatcar-dev-util.git"
CROS_WORKON_REPO="https://github.com"
CROS_WORKON_LOCALNAME="dev"
CROS_WORKON_LOCALDIR="src/platform"
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm ~arm64 ~x86" KEYWORDS="~amd64 ~arm ~arm64 ~x86"
else else
CROS_WORKON_COMMIT="00396595376d8d6a3c4b9251ba94e9de2d7a9e39" # flatcar-master EGIT_COMMIT="00396595376d8d6a3c4b9251ba94e9de2d7a9e39" # flatcar-master
KEYWORDS="amd64 arm arm64 x86" KEYWORDS="amd64 arm arm64 x86"
fi fi
PYTHON_COMPAT=( python3_{6..11} ) PYTHON_COMPAT=( python3_{6..11} )
inherit cros-workon python-single-r1 inherit git-r3 python-single-r1
DESCRIPTION="emerge utilities for Flatcar developer images" DESCRIPTION="emerge utilities for Flatcar developer images"
HOMEPAGE="https://github.com/flatcar/flatcar-dev-util/" HOMEPAGE="https://github.com/flatcar/flatcar-dev-util/"

View File

@ -2,17 +2,15 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="coreos/nova-agent-watcher" EGIT_REPO_URI="https://github.com/coreos/nova-agent-watcher.git"
CROS_WORKON_LOCALNAME="nova-agent-watcher"
CROS_WORKON_REPO="https://github.com"
COREOS_GO_PACKAGE="github.com/coreos/nova-agent-watcher" COREOS_GO_PACKAGE="github.com/coreos/nova-agent-watcher"
COREOS_GO_GO111MODULE="off" COREOS_GO_GO111MODULE="off"
inherit cros-workon systemd coreos-go inherit git-r3 systemd coreos-go
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm64" KEYWORDS="~amd64 ~arm64"
else else
CROS_WORKON_COMMIT="2262401fe363cfdcc4c6f02144622466d506de43" EGIT_COMMIT="2262401fe363cfdcc4c6f02144622466d506de43"
KEYWORDS="amd64 arm64" KEYWORDS="amd64 arm64"
fi fi

View File

@ -3,14 +3,12 @@
EAPI=8 EAPI=8
CROS_WORKON_PROJECT="flatcar/ue-rs" EGIT_REPO_URI="https://github.com/flatcar/ue-rs.git"
CROS_WORKON_LOCALNAME="ue-rs"
CROS_WORKON_REPO="https://github.com"
if [[ ${PV} == 9999 ]]; then if [[ ${PV} == 9999 ]]; then
KEYWORDS="~amd64 ~arm64" KEYWORDS="~amd64 ~arm64"
else else
CROS_WORKON_COMMIT="9b6ddb0226208450bcef9da4ac5ba8bc2a47a87c" # trunk EGIT_COMMIT="9b6ddb0226208450bcef9da4ac5ba8bc2a47a87c" # trunk
KEYWORDS="amd64 arm64" KEYWORDS="amd64 arm64"
fi fi
@ -197,7 +195,7 @@ CRATES="
zeroize@1.6.0 zeroize@1.6.0
" "
inherit cargo cros-workon inherit cargo git-r3
DESCRIPTION="Prototype Omaha Rust implementation" DESCRIPTION="Prototype Omaha Rust implementation"
HOMEPAGE="https://github.com/flatcar/ue-rs" HOMEPAGE="https://github.com/flatcar/ue-rs"
@ -214,7 +212,7 @@ RDEPEND="
" "
src_unpack() { src_unpack() {
cros-workon_src_unpack git-r3_src_unpack
cargo_src_unpack cargo_src_unpack
} }

View File

@ -3,14 +3,12 @@
EAPI=8 EAPI=8
CROS_WORKON_PROJECT="flatcar/update-ssh-keys" EGIT_REPO_URI="https://github.com/flatcar/update-ssh-keys.git"
CROS_WORKON_LOCALNAME="update-ssh-keys"
CROS_WORKON_REPO="https://github.com"
if [[ ${PV} == 9999 ]]; then if [[ ${PV} == 9999 ]]; then
KEYWORDS="~amd64 ~arm64" KEYWORDS="~amd64 ~arm64"
else else
CROS_WORKON_COMMIT="2a2aa89cd6eda6202de62b8870ca50945c836c54" # flatcar-master EGIT_COMMIT="2a2aa89cd6eda6202de62b8870ca50945c836c54" # flatcar-master
KEYWORDS="amd64 arm64" KEYWORDS="amd64 arm64"
fi fi
@ -65,7 +63,7 @@ CRATES="
windows_x86_64_msvc@0.48.5 windows_x86_64_msvc@0.48.5
" "
inherit cargo cros-workon inherit cargo git-r3
DESCRIPTION="Utility for managing OpenSSH authorized public keys" DESCRIPTION="Utility for managing OpenSSH authorized public keys"
HOMEPAGE="https://github.com/flatcar/update-ssh-keys" HOMEPAGE="https://github.com/flatcar/update-ssh-keys"
@ -80,6 +78,6 @@ SLOT="0"
RDEPEND="!<coreos-base/coreos-init-0.0.1-r152" RDEPEND="!<coreos-base/coreos-init-0.0.1-r152"
src_unpack() { src_unpack() {
cros-workon_src_unpack git-r3_src_unpack
cargo_src_unpack cargo_src_unpack
} }

View File

@ -2,18 +2,17 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="flatcar/update_engine" EGIT_REPO_URI="https://github.com/flatcar/update_engine.git"
CROS_WORKON_REPO="https://github.com"
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm ~arm64 ~x86" KEYWORDS="~amd64 ~arm ~arm64 ~x86"
else else
CROS_WORKON_COMMIT="541576a4dcd56397597abef7d9ce4c539631ed65" # flatcar-master EGIT_COMMIT="541576a4dcd56397597abef7d9ce4c539631ed65" # flatcar-master
KEYWORDS="amd64 arm64" KEYWORDS="amd64 arm64"
fi fi
TMPFILES_OPTIONAL=1 TMPFILES_OPTIONAL=1
inherit autotools flag-o-matic toolchain-funcs cros-workon systemd tmpfiles inherit autotools flag-o-matic toolchain-funcs git-r3 systemd tmpfiles
DESCRIPTION="CoreOS OS Update Engine" DESCRIPTION="CoreOS OS Update Engine"
HOMEPAGE="https://github.com/coreos/update_engine" HOMEPAGE="https://github.com/coreos/update_engine"

View File

@ -5,5 +5,4 @@
[[ -f ~/.bashrc ]] && . ~/.bashrc [[ -f ~/.bashrc ]] && . ~/.bashrc
# Chromium OS build environment settings # Chromium OS build environment settings
export CROS_WORKON_SRCROOT="/home/${USER}/trunk"
export PORTAGE_USERNAME="${USER}" export PORTAGE_USERNAME="${USER}"

View File

@ -1,185 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: cros-workon.eclass
# @BLURB: helper eclass for building CoreOS SDK provided source
# @DESCRIPTION:
# Instead of cloning git trees directly from github ebuilds can fetch
# from the local cache maintained by repo. Additionally live builds can
# build directly from the source checked out in the repo tree.
# @ECLASS-VARIABLE: CROS_WORKON_REPO
# @DESCRIPTION:
# Git URL which is prefixed to CROS_WORKON_PROJECT
: "${CROS_WORKON_REPO:=https://chromium.googlesource.com}"
# @ECLASS-VARIABLE: CROS_WORKON_PROJECT
# @DESCRIPTION:
# Git project name which is suffixed to CROS_WORKON_REPO
: "${CROS_WORKON_PROJECT:=${PN}}"
# @ECLASS-VARIABLE: CROS_WORKON_LOCALDIR
# @DESCRIPTION:
# Repo checkout directory which is prefixed to CROS_WORKON_LOCALNAME
# Generally is either src/third_party or src/platform
: "${CROS_WORKON_LOCALDIR:=src/third_party}"
# @ECLASS-VARIABLE: CROS_WORKON_LOCALNAME
# @DESCRIPTION:
# Directory name which is suffixed to CROS_WORKON_LOCALDIR
: "${CROS_WORKON_LOCALNAME:=${PN}}"
# @ECLASS-VARIABLE: CROS_WORKON_COMMIT
# @DESCRIPTION:
# Git commit to checkout to
: "${CROS_WORKON_COMMIT:=}"
# @ECLASS-VARIABLE: CROS_WORKON_TREE
# @DESCRIPTION:
# SHA1 of the contents of the repository. This is used for verifying the
# correctness of prebuilts. Unlike the commit hash, this SHA1 is unaffected
# by the history of the repository, or by commit messages.
: "${CROS_WORKON_TREE:=}"
# @ECLASS-VARIABLE: CROS_WORKON_SRCROOT
# @DESCRIPTION:
# Directory where chrome third party and platform sources are located (formerly CHROMEOS_ROOT)
: "${CROS_WORKON_SRCROOT:=}"
# TODO(marineam): Remove profiling and cros_workon_tree_* use flags.
# These have never been used in CoreOS.
IUSE="cros_workon_tree_$CROS_WORKON_TREE profiling"
inherit git-r3
# Calculate path where code should be cloned from.
get_path() {
local pathbase
if [[ -n "${CROS_WORKON_SRCROOT}" ]]; then
pathbase="${CROS_WORKON_SRCROOT}"
elif [[ -n "${CHROMEOS_ROOT}" ]]; then
pathbase="${CHROMEOS_ROOT}"
else
# HACK: Figure out the missing legacy path for now
# this only happens in amd64 chroot with sudo emerge.
pathbase="/mnt/host/source"
fi
echo "${pathbase}/${CROS_WORKON_LOCALDIR}/${CROS_WORKON_LOCALNAME}"
}
local_copy() {
debug-print-function ${FUNCNAME} "$@"
local path="$(get_path)"
einfo "Cloning ${path}"
git clone -sn "${path}" "${S}" || die "Can't clone ${path}"
einfo "Copying source from ${path}"
rsync -a --exclude=.git "${path}/" "${S}" || return 1
}
local_clone() {
debug-print-function ${FUNCNAME} "$@"
local path="$(get_path)"
if [[ ! -d "${path}/.git" ]]; then
return 1
fi
einfo "Cloning ${path}"
einfo "Checking out ${CROS_WORKON_COMMIT}"
# Looks like we already have a local copy of the repository.
# Let's use these and checkout ${CROS_WORKON_COMMIT}.
# -s: For speed, share objects between ${path} and ${S}.
# -n: Don't checkout any files from the repository yet. We'll
# checkout the source separately.
#
# We don't use git clone to checkout the source because the -b
# option for clone defaults to HEAD if it can't find the
# revision you requested. On the other hand, git checkout fails
# if it can't find the revision you requested, so we use that
# instead.
git clone -sn "${path}" "${S}" || die "Can't clone ${path}"
if ! git -C "${S}" checkout -q "${CROS_WORKON_COMMIT}"; then
ewarn "Cannot run git checkout ${CROS_WORKON_COMMIT} in ${S}."
ewarn "Is ${path} up to date? Try running repo sync."
rm -rf "${S}" || die
return 1
fi
}
cros-workon_src_unpack() {
debug-print-function ${FUNCNAME} "$@"
# Sanity check. We cannot have S set to WORKDIR because if/when we try
# to check out repos, git will die if it tries to check out into a dir
# that already exists. Some packages might try this when out-of-tree
# builds are enabled, and they'll work fine most of the time because
# they'll be using a full manifest and will just re-use the existing
# checkout in src/platform/*. But if the code detects that it has to
# make its own checkout, things fall apart. For out-of-tree builds,
# the initial $S doesn't even matter because it resets it below to the
# repo in src/platform/.
if [[ ${S} == "${WORKDIR}" ]]; then
die "Sorry, but \$S cannot be set to \$WORKDIR"
fi
# Hack
# TODO(msb): remove once we've resolved the include path issue
# http://groups.google.com/a/chromium.org/group/chromium-os-dev/browse_thread/thread/5e85f28f551eeda/3ae57db97ae327ae
ln -s "${S}" "${WORKDIR}/${CROS_WORKON_LOCALNAME}" &> /dev/null
if [[ "${PV}" == "9999" ]]; then
local_copy || die "Cannot create a local copy"
else
if [[ -z "${CROS_WORKON_COMMIT}" ]]; then
die "CROS_WORKON_COMMIT is unset"
fi
# Try cloning from a local repo first
local_clone && return
# There is no good way to ensure repo-maintained git trees
# always have exactly what ebuilds need so fall back gracefully
# to fetching remotely. Also, when ebuilds only specify a git
# hash there isn't a way to know which branch that is on. To be
# safe use git-r3's "mirror" mode to fetch all remote branches.
ewarn "Falling back to fetching from remote git repository..."
EGIT_CLONE_TYPE=mirror
EGIT_REPO_URI="${CROS_WORKON_REPO}/${CROS_WORKON_PROJECT}.git"
EGIT_CHECKOUT_DIR="${S}"
EGIT_COMMIT="${CROS_WORKON_COMMIT}"
git-r3_src_unpack
fi
}
# TODO(marineam): This is used by cros_workon to deal manage
# 'minilayout' manifests but we don't bother with that in CoreOS.
# Do a pass on the cros_workon tool to give it a freshening too...
cros-workon_pkg_info() {
echo "CROS_WORKON_SRCDIR=(\"$(get_path)\")"
echo "CROS_WORKON_PROJECT=(\"${CROS_WORKON_PROJECT}\")"
}
# get the semver of the git repo that is being built
get_semver() {
# get git tag/sha
local v
v=$(git describe --long --dirty) || die
# strip a leading v from the tag
v=${v#v}
# replace first - with +, to attach git sha/dirty as semver metadata
v=${v/-/+}
echo ${v}
}
EXPORT_FUNCTIONS src_unpack pkg_info

View File

@ -1,10 +1,8 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
# ChromeOS-specific: CROS_WORKON_TREE for cros-workon # ChromeOS-specific: TESTS USE_EXPAND for autotest
# TESTS USE_EXPAND for autotest USE_EXPAND="${USE_EXPAND} TESTS"
USE_EXPAND="${USE_EXPAND} CROS_WORKON_TREE TESTS"
USE_EXPAND_HIDDEN="${USE_EXPAND_HIDDEN} CROS_WORKON_TREE"
# Use go_version_* flags to indicate which major version was used. # Use go_version_* flags to indicate which major version was used.
# For now this is only informational and set by coreos-go.eclass # For now this is only informational and set by coreos-go.eclass

View File

@ -2,19 +2,17 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="flatcar/baselayout" EGIT_REPO_URI="https://github.com/flatcar/baselayout.git"
CROS_WORKON_LOCALNAME="baselayout"
CROS_WORKON_REPO="https://github.com"
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm ~arm64 ~x86" KEYWORDS="~amd64 ~arm ~arm64 ~x86"
else else
CROS_WORKON_COMMIT="937a45faef0f7fa88d3d2c3f7ba60a7f3e2e82f7" # flatcar-master EGIT_COMMIT="937a45faef0f7fa88d3d2c3f7ba60a7f3e2e82f7" # flatcar-master
KEYWORDS="amd64 arm arm64 x86" KEYWORDS="amd64 arm arm64 x86"
fi fi
TMPFILES_OPTIONAL=1 TMPFILES_OPTIONAL=1
inherit cros-workon multilib systemd tmpfiles inherit git-r3 multilib systemd tmpfiles
DESCRIPTION="Filesystem baselayout for CoreOS" DESCRIPTION="Filesystem baselayout for CoreOS"
HOMEPAGE="http://www.coreos.com/" HOMEPAGE="http://www.coreos.com/"

View File

@ -2,17 +2,15 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="coreos/ignition" EGIT_REPO_URI="https://github.com/coreos/ignition.git"
CROS_WORKON_LOCALNAME="ignition"
CROS_WORKON_REPO="https://github.com"
COREOS_GO_PACKAGE="github.com/flatcar/ignition/v2" COREOS_GO_PACKAGE="github.com/flatcar/ignition/v2"
COREOS_GO_GO111MODULE="off" COREOS_GO_GO111MODULE="off"
inherit coreos-go cros-workon systemd udev inherit coreos-go git-r3 systemd udev
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm64" KEYWORDS="~amd64 ~arm64"
else else
CROS_WORKON_COMMIT="09c99e0305adc1377b87964a39ad2d009aec9b12" # v2.19.0 EGIT_COMMIT="09c99e0305adc1377b87964a39ad2d009aec9b12" # v2.19.0
KEYWORDS="amd64 arm64" KEYWORDS="amd64 arm64"
fi fi

View File

@ -2,17 +2,16 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="flatcar/seismograph" EGIT_REPO_URI="https://github.com/flatcar/seismograph.git"
CROS_WORKON_REPO="https://github.com"
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm ~arm64 ~x86" KEYWORDS="~amd64 ~arm ~arm64 ~x86"
else else
CROS_WORKON_COMMIT="0d57463de18df81741375d628852c521542b6836" # flatcar-master EGIT_COMMIT="0d57463de18df81741375d628852c521542b6836" # flatcar-master
KEYWORDS="amd64 arm arm64 x86" KEYWORDS="amd64 arm arm64 x86"
fi fi
inherit autotools cros-workon inherit autotools git-r3
DESCRIPTION="CoreOS Disk Utilities (e.g. cgpt)" DESCRIPTION="CoreOS Disk Utilities (e.g. cgpt)"
LICENSE="BSD" LICENSE="BSD"

View File

@ -2,19 +2,16 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="flatcar/bootengine" EGIT_REPO_URI="https://github.com/flatcar/bootengine.git"
CROS_WORKON_LOCALNAME="bootengine"
CROS_WORKON_OUTOFTREE_BUILD=1
CROS_WORKON_REPO="https://github.com"
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm ~arm64 ~x86" KEYWORDS="~amd64 ~arm ~arm64 ~x86"
else else
CROS_WORKON_COMMIT="fb2631ce5e6a21d044c8dca73f59db01f9d5abcf" # flatcar-master EGIT_COMMIT="fb2631ce5e6a21d044c8dca73f59db01f9d5abcf" # flatcar-master
KEYWORDS="amd64 arm arm64 x86" KEYWORDS="amd64 arm arm64 x86"
fi fi
inherit cros-workon inherit git-r3
DESCRIPTION="CoreOS Bootengine" DESCRIPTION="CoreOS Bootengine"
SRC_URI="" SRC_URI=""

View File

@ -2,18 +2,16 @@
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=7
CROS_WORKON_PROJECT="flatcar/nss-altfiles" EGIT_REPO_URI="https://github.com/flatcar/nss-altfiles.git"
CROS_WORKON_LOCALNAME="nss-altfiles"
CROS_WORKON_REPO="https://github.com"
if [[ "${PV}" == 9999 ]]; then if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm ~arm64 ~x86" KEYWORDS="~amd64 ~arm ~arm64 ~x86"
else else
CROS_WORKON_COMMIT="c8e05a08a2e28eb48c6c788e3007d94f8d8de5cd" # flatcar-master EGIT_COMMIT="c8e05a08a2e28eb48c6c788e3007d94f8d8de5cd" # flatcar-master
KEYWORDS="amd64 arm arm64 x86" KEYWORDS="amd64 arm arm64 x86"
fi fi
inherit cros-workon toolchain-funcs inherit git-r3 toolchain-funcs
DESCRIPTION="NSS module for data sources under /usr on for CoreOS" DESCRIPTION="NSS module for data sources under /usr on for CoreOS"
HOMEPAGE="https://github.com/coreos/nss-altfiles" HOMEPAGE="https://github.com/coreos/nss-altfiles"

View File

@ -97,10 +97,10 @@ generate_all_wrappers() {
_generate_wrapper ${wrapper} _generate_wrapper ${wrapper}
done done
wrapper="/usr/local/bin/cros_workon-${BOARD_VARIANT}" wrapper="/usr/local/bin/flatcar_workon-${BOARD_VARIANT}"
sudo_clobber "${wrapper}" <<EOF sudo_clobber "${wrapper}" <<EOF
#!/bin/bash #!/bin/bash
exec "${SRC_ROOT}/scripts/cros_workon" --board ${BOARD_VARIANT} "\$@" exec "${SRC_ROOT}/scripts/flatcar_workon" --board ${BOARD_VARIANT} "\$@"
EOF EOF
wrappers+=( "${wrapper}" ) wrappers+=( "${wrapper}" )
@ -349,10 +349,7 @@ fi
command_completed command_completed
info "The SYSROOT is: ${BOARD_ROOT}" info "The SYSROOT is: ${BOARD_ROOT}"
# NOTE: Printing the working-on ebuilds does not only serve the informative WORKING_ON=$("${SRC_ROOT}"/scripts/flatcar_workon list --board="${FLAGS_board}")
# purpose. It also causes the ${BOARD_ROOT}/etc/portage/package.* files to be
# regenerated.
WORKING_ON=$("${SRC_ROOT}/scripts/cros_workon" --board=${FLAGS_board} list)
if [ -n "${WORKING_ON}" ]; then if [ -n "${WORKING_ON}" ]; then
info info
info "Currently working on the following ebuilds for this board:" info "Currently working on the following ebuilds for this board:"

View File

@ -232,11 +232,17 @@ if [[ "${FLAGS_skip_toolchain_update}" -eq "${FLAGS_FALSE}" && \
done done
fi fi
# Build cros_workon packages when they are changed. # Build flatcar_workon packages when they are changed.
if [ "${FLAGS_workon}" -eq "${FLAGS_TRUE}" ]; then WORKON_PKGS=()
for pkg in $("${SRC_ROOT}/scripts/cros_workon" list --host); do if [[ ${FLAGS_workon} -eq "${FLAGS_TRUE}" ]]; then
EMERGE_FLAGS+=( "--reinstall-atoms=${pkg}" "--usepkg-exclude=${pkg}" ) mapfile -t WORKON_PKGS < <("${SRC_ROOT}"/scripts/flatcar_workon list)
done fi
if [[ ${#WORKON_PKGS[@]} -gt 0 ]]; then
EMERGE_FLAGS+=(
--reinstall-atoms="${WORKON_PKGS[*]}"
--usepkg-exclude="${WORKON_PKGS[*]}"
)
fi fi
sudo_e_emerge() { sudo_e_emerge() {

1
workon/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*