From 7f874e491eac8911aec46cc81ae309162006b4e8 Mon Sep 17 00:00:00 2001 From: flatcar-ci Date: Fri, 5 Nov 2021 09:17:30 +0100 Subject: [PATCH] sdk-container: address feedback from @krnowak review Signed-off-by: flatcar-ci --- .gitignore | 1 - README.md | 4 ++-- bootstrap_sdk_container | 8 +++++--- sdk_lib/Dockerfile.sdk-import | 1 + sdk_lib/sdk_container_common.sh | 5 +++-- sdk_lib/sdk_init_selfcontained.sh | 9 +++------ 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 9036cd3235..a62ac41ee1 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,3 @@ sdk_container/.sdkenv __build__/ sdk_container/.cache sdk_container/.config -sdk_container/.lock diff --git a/README.md b/README.md index 4c2e6df021..e007677365 100644 --- a/README.md +++ b/README.md @@ -92,11 +92,11 @@ The wrapper scripts will re-use existing containers instead of creating new ones To clone the scripts repo and pick a version: * Clone the scripts repo: `git clone https://github.com/flatcar-linux/scripts.git` - * Make sure to initialise and fetch git submodules - Flatcar's ebuilds are in 2 separate repositories, connected to `scripts` via submodules. - * `git submodule init; git submodule update` * Optionally, check out a release tag to base your work on * list releases (e.g. all Alpha releases): `git tag -l alpha-*` * check out the release version, e.g. `3033.0.0`: `git checkout 3033.0.0` +* Make sure to initialise and fetch git submodules - Flatcar's ebuilds are in 2 separate repositories, connected to `scripts` via submodules. + * `git submodule init; git submodule update` To use the SDK container: * Fetch image and start the SDK container: `./run_sdk_container -t` diff --git a/bootstrap_sdk_container b/bootstrap_sdk_container index eb41be258c..93629938b7 100755 --- a/bootstrap_sdk_container +++ b/bootstrap_sdk_container @@ -17,7 +17,9 @@ if is_official "$vernum" ; then else official="false" fi -cleanup="" + +declare -a cleanup + # -- usage() { @@ -42,7 +44,7 @@ usage() { while [ 0 -lt $# ] ; do case "$1" in -h) usage; exit 0;; - -x) cleanup="-x $2"; shift; shift;; + -x) cleanup=("-x" "$2"); shift; shift;; *) if [ -z "$seed_version" ] ; then seed_version="$1" elif [ -z "$target_version" ] ; then @@ -69,7 +71,7 @@ if $official; then fi # bootstrap_sdk needs FLATCAR_SDK_VERSION set to the seed version -./run_sdk_container $cleanup -V "$seed_version" -v "$target_version" \ +./run_sdk_container "${cleanup[@]}" -V "$seed_version" -v "$target_version" \ sudo -E ./bootstrap_sdk # Update versionfile to the actual SDK version diff --git a/sdk_lib/Dockerfile.sdk-import b/sdk_lib/Dockerfile.sdk-import index 7cec2c724f..59b517366e 100644 --- a/sdk_lib/Dockerfile.sdk-import +++ b/sdk_lib/Dockerfile.sdk-import @@ -1,6 +1,7 @@ ARG VERSION FROM flatcar-sdk-tarball:${VERSION} +# Make build scripts believe we're in the SDK chroot (which technically, we are) RUN touch /etc/debian_chroot RUN chmod 644 /etc/passwd RUN chmod 644 /etc/group diff --git a/sdk_lib/sdk_container_common.sh b/sdk_lib/sdk_container_common.sh index bdba23456b..f22e30dcf4 100644 --- a/sdk_lib/sdk_container_common.sh +++ b/sdk_lib/sdk_container_common.sh @@ -40,7 +40,7 @@ function get_sdk_version_from_versionfile() { function is_official() { local vernum="$1" - official="$(echo "$vernum" | sed -n 's/^[0-9]\+\.[0-9]\+\.[0-9]\+$/true/p')" + local official="$(echo "$vernum" | sed -n 's/^[0-9]\+\.[0-9]\+\.[0-9]\+$/true/p')" test -n "$official" } @@ -67,7 +67,8 @@ function vernum_from_version() { # -- # Strip prefix from version string if present ("alpha-3233.0.0[-...]" => "3233.0.0[-...]") -# +# and add a "+[build suffix]" if this is a non-official build. The "+" matches the version +# string generation in the build scripts. function strip_version_prefix() { local version="$1" diff --git a/sdk_lib/sdk_init_selfcontained.sh b/sdk_lib/sdk_init_selfcontained.sh index cb437d24d9..4b7f3fcbea 100755 --- a/sdk_lib/sdk_init_selfcontained.sh +++ b/sdk_lib/sdk_init_selfcontained.sh @@ -19,12 +19,9 @@ function clone_version() { local version="$3" git clone https://github.com/flatcar-linux/$repo "$dest" - ( - cd "$dest" - git fetch --all - local tag=$(git tag -l | grep "${version}") - git checkout "$tag" - ) + git -C "${dest}" fetch --all + local tag=$(git -C "${dest}" tag -l | grep "${version}") + git -C "${dest}" checkout "$tag" } # --