fix(rootfs): unset GIT_FIXED_WORKDIR after debootstrap/mmdebstrap clone (#9132)

* fix(rootfs): pass GIT_FIXED_WORKDIR inline to fetch_from_repo

Instead of using 'export GIT_FIXED_WORKDIR' and then 'unset' after,
pass the variable inline to the fetch_from_repo call. This ensures
the variable only exists in the context of that specific command
and doesn't leak into subsequent calls.

This follows the same pattern used in uboot-git.sh and kernel-git.sh.
---------

Co-authored-by: Viacheslav Bocharov <adeep@lexina.in>
This commit is contained in:
Nikita Maslo 2025-12-27 08:15:36 +03:00 committed by GitHub
parent 810ff67c90
commit 1e7ef9d064
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -100,35 +100,38 @@ function create_new_rootfs_cache_via_debootstrap() {
case "${DISTRIBUTION}" in
Ubuntu)
if [[ "${LEGACY_DEBOOTSTRAP,,}" == "yes" ]]; then
export GIT_FIXED_WORKDIR="debootstrap-ubuntu-devel"
fetch_from_repo "https://git.launchpad.net/ubuntu/+source/debootstrap" "debootstrap-ubuntu-devel" "tag:import/1.0.118ubuntu1.13"
debootstrap_wanted_dir="${SRC}/cache/sources/${GIT_FIXED_WORKDIR}"
declare debootstrap_name="debootstrap-ubuntu-devel"
GIT_FIXED_WORKDIR="${debootstrap_name}" \
fetch_from_repo "https://git.launchpad.net/ubuntu/+source/debootstrap" "${debootstrap_name}" "tag:import/1.0.118ubuntu1.13"
debootstrap_wanted_dir="${SRC}/cache/sources/${debootstrap_name}"
debootstrap_default_script="gutsy"
debootstrap_version="$(sed 's/.*(\(.*\)).*/\1/; q' "${debootstrap_wanted_dir}/debian/changelog")"
debootstrap_bin="${debootstrap_wanted_dir}/debootstrap"
else
export GIT_FIXED_WORKDIR="mmdebstrap-ubuntu-devel"
declare debootstrap_name="mmdebstrap-ubuntu-devel"
#FIXME: branch should be a variable eventually
fetch_from_repo "https://git.launchpad.net/ubuntu/+source/mmdebstrap" "${GIT_FIXED_WORKDIR}" "branch:ubuntu/noble"
debootstrap_wanted_dir="${SRC}/cache/sources/${GIT_FIXED_WORKDIR}"
GIT_FIXED_WORKDIR="${debootstrap_name}" \
fetch_from_repo "https://git.launchpad.net/ubuntu/+source/mmdebstrap" "${debootstrap_name}" "branch:ubuntu/noble"
debootstrap_wanted_dir="${SRC}/cache/sources/${debootstrap_name}"
debootstrap_version="$(sed 's/.*(\(.*\)).*/\1/; q' "${debootstrap_wanted_dir}/debian/changelog")"
debootstrap_bin="${debootstrap_wanted_dir}/mmdebstrap"
fi
;;
Debian)
if [[ "${LEGACY_DEBOOTSTRAP,,}" == "yes" ]]; then
export GIT_FIXED_WORKDIR="debootstrap-debian-devel"
fetch_from_repo "https://salsa.debian.org/installer-team/debootstrap.git" "debootstrap-debian-devel" "branch:master"
debootstrap_wanted_dir="${SRC}/cache/sources/${GIT_FIXED_WORKDIR}"
declare debootstrap_name="debootstrap-debian-devel"
GIT_FIXED_WORKDIR="${debootstrap_name}" \
fetch_from_repo "https://salsa.debian.org/installer-team/debootstrap.git" "${debootstrap_name}" "branch:master"
debootstrap_wanted_dir="${SRC}/cache/sources/${debootstrap_name}"
debootstrap_default_script="sid"
debootstrap_version="$(sed 's/.*(\(.*\)).*/\1/; q' "${debootstrap_wanted_dir}/debian/changelog")"
debootstrap_bin="${debootstrap_wanted_dir}/debootstrap"
else
export GIT_FIXED_WORKDIR="mmdebstrap-debian-devel"
declare debootstrap_name="mmdebstrap-debian-devel"
#FIXME: branch should be a variable eventually
fetch_from_repo "https://gitlab.mister-muffin.de/josch/mmdebstrap" "${GIT_FIXED_WORKDIR}" "branch:main"
debootstrap_wanted_dir="${SRC}/cache/sources/${GIT_FIXED_WORKDIR}"
debootstrap_default_script="sid"
GIT_FIXED_WORKDIR="${debootstrap_name}" \
fetch_from_repo "https://gitlab.mister-muffin.de/josch/mmdebstrap" "${debootstrap_name}" "branch:main"
debootstrap_wanted_dir="${SRC}/cache/sources/${debootstrap_name}"
debootstrap_version="$(sed 's/^## \[\([^]]*\)\].*/\1/; q' "${debootstrap_wanted_dir}/CHANGELOG.md")"
debootstrap_bin="${debootstrap_wanted_dir}/mmdebstrap"
fi