Skip to content

Commit

Permalink
Add support to disable features with command line argument
Browse files Browse the repository at this point in the history
The newly added command line argument `--disable-feature` supports removing feature dependencies normally added to an image.

Closes: #17
Signed-off-by: Tobias Wolf <[email protected]>
  • Loading branch information
NotTheEvilOne committed Dec 9, 2024
1 parent b399457 commit f7d61bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ container_run_opts=(
)

container_cmd=()
features_disabled=()

use_kms=0
resolve_cname=0
Expand All @@ -37,6 +38,10 @@ while [ $# -gt 0 ]; do
declare -a "container_run_opts=($2)"
shift 2
;;
--disable-feature)
features_disabled+=("$2")
shift 2
;;
--privileged)
container_run_opts+=(--privileged)
container_cmd=(--second-stage)
Expand Down Expand Up @@ -87,7 +92,6 @@ commit="$(./get_commit)"
timestamp="$(./get_timestamp)"
default_version="$(./get_version)"


if [ "$resolve_cname" = 1 ]; then
arch="$("$container_engine" run --rm "${container_run_opts[@]}" "${container_mount_opts[@]}" "$container_image" dpkg --print-architecture)"
cname="$("$container_engine" run --rm "${container_run_opts[@]}" "${container_mount_opts[@]}" "$container_image" /builder/parse_features --feature-dir /builder/features --default-arch "$arch" --default-version "$default_version" --cname "$1")"
Expand All @@ -101,6 +105,7 @@ make_opts=(
COMMIT="$commit"
TIMESTAMP="$timestamp"
DEFAULT_VERSION="$default_version"
FEATURES_DISABLED="$(IFS="," ; echo "${features_disabled[*]}")"
)

if [ "$use_kms" = 1 ]; then
Expand Down
3 changes: 2 additions & 1 deletion builder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ endef
required_vars := REPO COMMIT TIMESTAMP DEFAULT_VERSION TEMPFS_SIZE
$(foreach var,$(required_vars),$(eval $(call require_var,$(var))))

FEATURES_DISABLED ?= ''
SHORT_COMMIT := $(shell head -c 8 <<< '$(COMMIT)')

NATIVE_ARCH := $(shell dpkg --print-architecture)
Expand Down Expand Up @@ -54,7 +55,7 @@ clean:
.build/%-$(SHORT_COMMIT).tar: .build/bootstrap-$$(call cname_arch,$$*)-$$(call cname_version,$$*)-$(SHORT_COMMIT).tar .build/native_bin-$$(call cname_version,$$*)-$(SHORT_COMMIT).tar $(shell ./make_directory_sentinel features) $(shell ./make_directory_sentinel cert)
target '$@' '$<'
info 'configuring rootfs $*-$(SHORT_COMMIT)'
features="$$(./parse_features --feature-dir features --cname '$*' features)"
features="$$(./parse_features --feature-dir features --ignore '$(FEATURES_DISABLED)' --cname '$*' features)"
BUILDER_CNAME='$*'
BUILDER_VERSION='$(call cname_version,$*)'
BUILDER_ARCH='$(call cname_arch,$*)'
Expand Down

0 comments on commit f7d61bd

Please sign in to comment.