-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: add bottlecap, an optional entry point #182
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/target | ||
**/*.rs.bk | ||
src/__pycache__/* | ||
.gocache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/bin/sh | ||
|
||
# bottlecap, 'cause it's kinda like cork... get it? | ||
|
||
usage() { | ||
echo "usage:" | ||
echo "bottlecap [--dev] [--dry-run] [--runtime $runtime] [--build-dir $build_dir] [--container $container] assemblerargs..." | ||
echo " --dev: rebuild and reinstall mantle, the build scripts, and the ostree-releng-scipts before running coreos-assembler" | ||
echo " --dry-run: do not run CoreOS Assembler; print what commands would be executed instead" | ||
echo " --runtime: (auto) specify whether to use podman or docker. Defaults to podman if it is in \$PATH" | ||
dustymabe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo " --build-dir: Where to put build artifacts, defaults to the current directory" | ||
echo " --container: which coreos-assembler container to use" | ||
echo " --help: print this help message" | ||
} | ||
|
||
dev=0 | ||
dryrun=0 | ||
help=0 | ||
runtime="podman" | ||
command -v podman > /dev/null || runtime="docker" | ||
dustymabe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
build_dir="$(pwd)" | ||
container="quay.io/cgwalters/coreos-assembler" | ||
|
||
rc=0 | ||
TEMP=$(getopt -o 'dr:b:c:h' --long 'dev,dry-run,runtime:,build-dir:,container:,help' -- "$@") || rc=$? | ||
if [ "$rc" -ne 0 ]; then | ||
1>&2 echo "Bad arguments. getopt failed." | ||
usage | ||
exit 1 | ||
fi | ||
|
||
eval set -- "$TEMP" | ||
|
||
while : | ||
dustymabe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
do | ||
case "$1" in | ||
"-d"|"--dev") | ||
dev=1 | ||
shift | ||
;; | ||
"--dry-run") | ||
dryrun=1 | ||
shift | ||
;; | ||
"-r"|"--runtime") | ||
shift | ||
runtime="$1" | ||
shift | ||
;; | ||
"-b"|"--build-dir") | ||
shift | ||
build_dir=$(readlink -f "$1") | ||
shift | ||
;; | ||
"-c"|"--container") | ||
shift | ||
container="$1" | ||
shift | ||
;; | ||
"-h"|"--help") | ||
help=1 | ||
shift | ||
;; | ||
--) | ||
shift | ||
break | ||
;; | ||
*) | ||
1>&2 echo "Error parsing args" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [ "$help" = 1 ]; then | ||
usage | ||
dustymabe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exit 0 | ||
fi | ||
|
||
script_dir=$(dirname "$(readlink -f "$0")") | ||
|
||
volumes="-v $build_dir:/srv " | ||
|
||
entrypoint="" | ||
|
||
if [ "$dev" = 1 ]; then | ||
mkdir -p "$script_dir/.gocache" | ||
volumes="$volumes -v $script_dir:/host/src " | ||
volumes="$volumes -v $script_dir/.gocache:/root/.cache/go-build " | ||
entrypoint="--entrypoint /host/src/bottlecap-shim" | ||
fi | ||
|
||
if [ "$dryrun" = 1 ]; then | ||
# prefix $runtime with `echo` so the command is printed rather than executed | ||
runtime="echo $runtime" | ||
echo "Command to be executed:" | ||
else | ||
set -x | ||
fi | ||
|
||
# we actually want work splitting here since $volumes is multiple args | ||
# shellcheck disable=SC2086 | ||
$runtime run --rm --net=host -ti --privileged --userns=host $volumes --workdir /srv $entrypoint "$container" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
pushd /host/src/ || exit 1 | ||
sudo ./build.sh make_and_makeinstall | ||
popd || exit 1 | ||
|
||
exec /usr/bin/coreos-assembler "$@" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cork
is nice since it's 4 letters :) - I likecass
because it's also 4 letters, but I also like highlighting that this is the script vs an alias that someone has defined on the command line (since I like to define my alias asalias cass=
. Socass.sh
would be my suggestion here, but also takes us back to 7 characters so I'm a hypocrite :)This was mostly just a thought excercise for me. We don't need to change anything unless you want to.