From 37ecceb5e21585ffa1bc13be3ec47d6d7220c403 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Fri, 28 Jun 2024 14:45:03 +0200 Subject: [PATCH] overlay coreos/stage1_hooks: Hook for no split-usr for SDK --- ...004-no-split-usr-for-SDK-coreos-overlay.sh | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 sdk_container/src/third_party/coreos-overlay/coreos/stage1_hooks/0004-no-split-usr-for-SDK-coreos-overlay.sh diff --git a/sdk_container/src/third_party/coreos-overlay/coreos/stage1_hooks/0004-no-split-usr-for-SDK-coreos-overlay.sh b/sdk_container/src/third_party/coreos-overlay/coreos/stage1_hooks/0004-no-split-usr-for-SDK-coreos-overlay.sh new file mode 100755 index 00000000000..f5dc13ade35 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/coreos/stage1_hooks/0004-no-split-usr-for-SDK-coreos-overlay.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +set -euo pipefail + +stage1_repo=${1} + +old_use_force="${stage1_repo}/profiles/coreos/targets/generic/use.force" +new_use_force="${stage1_repo}/profiles/coreos/base/use.force" + +old_use_mask="${stage1_repo}/profiles/coreos/targets/generic/use.mask" +new_use_mask="${stage1_repo}/profiles/coreos/base/use.mask" + +make_defaults="${stage1_repo}/profiles/coreos/targets/generic/make.defaults" + +grep_cmd=( + grep + --fixed-strings + --quiet + --line-regexp + --no-messages # swallow errors about nonexistent files +) + +if ! "${grep_cmd[@]}" --regexp '-split-usr' "${old_use_force}"; then + # No unforcing of split-usr in old use.force, not continuing + exit 0 +fi + +if "${grep_cmd[@]}" --regexp '-split-usr' "${new_use_force}"; then + # split-usr already unforced in new use.mask, not continuing + exit 0 +fi + +if ! "${grep_cmd[@]}" 'split-usr' "${old_use_mask}"; then + # No masking of split-usr in old use.mask, not continuing + exit 0 +fi + +if "${grep_cmd[@]}" 'split-usr' "${new_use_mask}"; then + # split-usr already masked in new use.mask, not continuing + exit 0 +fi + +if ! grep --quiet --no-messages '^USE="[^"]*\bsymlink-usr\b' "${make_defaults}"; then + # symlink-usr dropped from make.defaults, not continuing + exit 0 +fi + +sed -i -e '/^-split-usr$/d' "${old_use_force}" +printf '%s\n' '-split-usr' >>"${new_use_force}" +sed -i -e '/^split-usr$/d' "${old_use_mask}" +printf '%s\n' 'split-usr' >>"${new_use_mask}" +sed -i -e 's/\(^USE="[^"]*\)\bsymlink-usr\b\(.*\)/\1\2/' "${make_defaults}" +sed -i -e 's/\(^USE="[^"]*\)\bsymlink-usr\b\(.*\)/\1\2/' "${make_defaults}"