From 3397e92b15051be333c59d3f6617d516e2408f3d Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 20 Jun 2022 13:25:05 -0400 Subject: [PATCH 1/3] cmd-init: also create config-git in local subdir mode We want to retain a symlink to the top-level dir itself. Prep for future patch. While we're here, drop `-r`. We want `src/config` to always be exactly a symlink to `config-git/${subdir}`. --- src/cmd-init | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cmd-init b/src/cmd-init index 6547511448..367cda4cac 100755 --- a/src/cmd-init +++ b/src/cmd-init @@ -112,7 +112,7 @@ mkdir -p src (cd src if ! test -e config; then case "${source}" in - /*) ln -s "${source}/${subdir}" config;; + /*) ln -s "${source}" config;; *) git clone ${BRANCH:+--branch=${BRANCH}} --depth=1 --shallow-submodules --recurse-submodules "${source}" config # If a commit was specified then we'll fetch and reset # the specified branch to that commit. This is useful when @@ -124,13 +124,13 @@ mkdir -p src git -C ./config fetch origin "$COMMIT" git -C ./config reset --hard "$COMMIT" fi - if [ -n "${subdir}" ]; then - mv config config-git - ln -sr config-git/"${subdir}" config - fi (set +x; cd config && echo -n "Config commit: " && git describe --tags --always --abbrev=42) ;; esac + if [ -n "${subdir}" ]; then + mv config config-git + ln -s config-git/"${subdir}" config + fi manifest=config/manifest.yaml if ! [ -f "${manifest}" ]; then echo 1>&2 "Failed to find src/${manifest}" From 441bb7c2bfb7755dd24545a5b479a14674d41a75 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 20 Jun 2022 13:51:06 -0400 Subject: [PATCH 2/3] cmdlib: don't canonicalize src/config symlink in subdir mode In those situations, it's expected that `src/config` is a relative symlink to a subdir in `src/config-git`. --- src/cmdlib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmdlib.sh b/src/cmdlib.sh index 2fbd40eaaa..30efd86954 100755 --- a/src/cmdlib.sh +++ b/src/cmdlib.sh @@ -198,7 +198,7 @@ prepare_build() { echo "Using manifest: ${manifest}" # backcompat for local setups that initialized with `ln -sr` - if [ -L "${configdir}" ]; then + if [ -L "${configdir}" ] && [ ! -e "${workdir}/src/config-git" ]; then if [[ $(readlink "${configdir}") != /* ]]; then ln -sfn "$(realpath "${configdir}")" "${configdir}" fi From 28e6c5f5eaa9d709335f52ad46712a48c7f841cf Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 20 Jun 2022 13:55:12 -0400 Subject: [PATCH 3/3] cmdlib: mount `src/config-git` into supermin instead of `src/config` if present The real repo is in `src/config-git` in a subdir setup and `src/config` is just a relative symlink to the subdir in question. This should allow us to use subdirs in the CI of openshift/os for different RHEL/CentOS versions. Long-term, we should probably move away from subdirs into something more structured that doesn't require symlinking everything into the subdirs. --- src/cmdlib.sh | 5 ++++- src/supermin-init-prelude.sh | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cmdlib.sh b/src/cmdlib.sh index 30efd86954..204e5e4e0c 100755 --- a/src/cmdlib.sh +++ b/src/cmdlib.sh @@ -673,7 +673,10 @@ EOF # support local dev cases where src/config is a symlink. Note if you change or extend to this set, # you also need to update supermin-init-prelude.sh to mount it inside the VM. - if [ -L "${workdir}/src/config" ]; then + if [ -L "${workdir}/src/config-git" ]; then + # qemu follows symlinks + base_qemu_args+=("-virtfs" 'local,id=source,path='"${workdir}"'/src/config-git,security_model=none,mount_tag=source') + elif [ -L "${workdir}/src/config" ]; then # qemu follows symlinks base_qemu_args+=("-virtfs" 'local,id=source,path='"${workdir}"'/src/config,security_model=none,mount_tag=source') fi diff --git a/src/supermin-init-prelude.sh b/src/supermin-init-prelude.sh index d8f7b31069..b7b319cc5c 100644 --- a/src/supermin-init-prelude.sh +++ b/src/supermin-init-prelude.sh @@ -37,8 +37,11 @@ umask 002 # https://github.com/coreos/coreos-assembler/issues/2171 mkdir -p "${workdir:?}" mount -t 9p -o rw,trans=virtio,version=9p2000.L,msize=10485760 workdir "${workdir}" -# These two invocations pair with virtfs setups for qemu in cmdlib.sh. Keep them in sync. -if [ -L "${workdir}"/src/config ]; then +# These invocations pair with virtfs setups for qemu in cmdlib.sh. Keep them in sync. +if [ -L "${workdir}"/src/config-git ]; then + mkdir -p "$(readlink "${workdir}"/src/config-git)" + mount -t 9p -o rw,trans=virtio,version=9p2000.L,msize=10485760 source "${workdir}"/src/config-git +elif [ -L "${workdir}"/src/config ]; then mkdir -p "$(readlink "${workdir}"/src/config)" mount -t 9p -o rw,trans=virtio,version=9p2000.L,msize=10485760 source "${workdir}"/src/config fi