Skip to content

Commit

Permalink
overlay coreos/stage1_hooks: Hook for no split-usr for SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
krnowak committed Jun 28, 2024
1 parent 314a2c9 commit 3e8fbfb
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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' '-split-usr' >>"${new_use_force}"
sed -i -e '/^split-usr$/d' "${old_use_mask}"
printf '%s' 'split-usr' >>"${new_use_mask}"
sed -i -e 's/\(^USE="[^"]*\)\bsymlink-usr\b\(.*\)/\1\2/' "${make_defaults}"
sed -e 's/\(^USE="[^"]*\)\bsymlink-usr\b\(.*\)/\1\2/' "${make_defaults}"

0 comments on commit 3e8fbfb

Please sign in to comment.