coreos/stage1_hooks: Add a hook for updating a profile in stage1

This is to make sure that the directory layout wrt. lib directories in
stage1 is correctly set up from the beginning, because it gets
propagated all the way to the final SDK image. It's easier to do it
that way, rather than following the steps described in the deprecation
notice of the 17.0 profile.
This commit is contained in:
Krzesimir Nowak 2023-03-07 17:34:12 +01:00
parent 98668d0281
commit 1ad0ce9964

View File

@ -0,0 +1,25 @@
#!/bin/bash
set -x
set -euo pipefail
stage1_repo="${1}"
new_repo="${2}"
parent_file='profiles/coreos/amd64/parent'
old_parent_line='portage-stable:default/linux/amd64/17.0/no-multilib/hardened'
stage1_parent="${stage1_repo}/${parent_file}"
new_parent="${new_repo}/${parent_file}"
if [[ ! -e "${new_parent}" ]]; then
echo "no file '${parent_file}' in new repo, nothing to do"
exit 0
fi
if [[ ! -e "${stage1_parent}" ]]; then
echo "no file '${parent_file}' in stage1 repo, nothing to do"
exit 0
fi
if grep --quiet --fixed-strings --line-regexp --regexp="${old_parent_line}" -- "${stage1_parent}"; then
rm -f "${stage1_parent}"
cp -a "${new_parent}" "${stage1_parent}"
fi