build: Add an option for the migration path for coreos/toolbox users

Commit 6c86cabbe5 changed the command line interface to behave
a lot similar to that of github.com/coreos/toolbox, which makes things
easier for those switching over from it.

However, it makes things confusing for the vast majority of users who
have never used coreos/toolbox. The Toolbox CLI aims to be friendly to
new users by being self-documenting and offering a smooth onboarding
experience. It's jarring to new users when 'toolbox', without any
commands specified, suggests that it needs to perform a big download.

It's difficult to document two different sets of CLIs, and if the
manuals don't mention the second behaviour, then it just leaves the
users even more confused.

Hence, it will be good to keep the migration path for coreos/toolbox
behind a build-time option, so that only those OS distributors who
truly need it may enable it without impacting others. Fortunately,
coreos/toolbox doesn't have any manuals, which means that there's no
need to conditionalize the documentation.

This commit merely adds the build-time option. Subsequent commits will
use this to actually conditionalize the code.

https://github.com/containers/toolbox/pull/951
This commit is contained in:
Debarshi Ray 2021-11-13 13:55:10 +01:00
parent d27cfb4586
commit 04426a04e5
4 changed files with 18 additions and 1 deletions

View file

@ -15,6 +15,7 @@ skopeo = find_program('skopeo', required: false)
bash_completion = dependency('bash-completion', required: false)
migration_path_for_coreos_toolbox = get_option('migration_path_for_coreos_toolbox')
profiledir = get_option('profile_dir')
tmpfilesdir = get_option('tmpfiles_dir')

View file

@ -1,3 +1,10 @@
option(
'migration_path_for_coreos_toolbox',
description: 'Offer a migration path to users of github.com/coreos/toolbox',
type: 'boolean',
value: false
)
option(
'profile_dir',
description: 'Directory for profile.d files to be read by the shell on start-up',

View file

@ -16,13 +16,14 @@
#
if [ "$#" -ne 5 ]; then
if [ "$#" -ne 6 ]; then
echo "go-build-wrapper: wrong arguments" >&2
echo "Usage: go-build-wrapper [SOURCE DIR]" >&2
echo " [OUTPUT DIR]" >&2
echo " [VERSION]" >&2
echo " [C COMPILER]" >&2
echo " [DYNAMIC LINKER]" >&2
echo " [MIGRATION PATH FOR COREOS/TOOLBOX]" >&2
exit 1
fi
@ -31,6 +32,11 @@ if ! cd "$1"; then
exit 1
fi
tags=""
if $6; then
tags="-tags migration_path_for_coreos_toolbox"
fi
if ! libc_dir=$("$4" --print-file-name=libc.so); then
echo "go-build-wrapper: failed to read the path to libc.so" >&2
exit 1
@ -63,7 +69,9 @@ fi
dynamic_linker="/run/host$dynamic_linker_canonical_dirname/$dynamic_linker_basename"
# shellcheck disable=SC2086
go build \
$tags \
-trimpath \
-ldflags "-extldflags '-Wl,-dynamic-linker,$dynamic_linker -Wl,-rpath,/run/host$libc_dir_canonical_dirname' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$3" \
-o "$2/toolbox"

View file

@ -52,6 +52,7 @@ custom_target(
meson.project_version(),
cc.cmd_array().get(-1),
dynamic_linker,
migration_path_for_coreos_toolbox.to_string(),
],
input: sources,
install: true,