Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect apt-cacher on parent #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions retro-home-image
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,17 @@ function nspawn() {
# Create basic resolv.conf for bind mounting inside the container
echo "nameserver 1.1.1.1" > "${R_STAGE_0}/resolv.conf"

if pidof apt-cacher-ng && [ -d "${R}/etc/apt/apt.conf.d" ]; then
# apt-cacher-ng is running here or this is a VM guest and the host
# is running it
if pidof apt-cacher-ng && [ -d "${R}/etc/apt/apt.conf.d" ]; then
echo "Acquire::http { Proxy \"http://${APT_CACHE_IP}:3142\"; }" > "${R}/etc/apt/apt.conf.d/90cache"
else
#or this is a VM guest and the host is running it
if nc -z 10.0.2.2 3142 && [ -d "${R}/etc/apt/apt.conf.d" ]; then
echo "Acquire::http { Proxy \"http://10.0.2.2:3142\"; }" > "${R}/etc/apt/apt.conf.d/90cache"
fi
# TODO ? handle a parameter for external/other apt proxy address if there is one
# in the environment other than the VM or the host it is running on
fi

# Make sure the container has a machine-id
Expand All @@ -92,8 +101,8 @@ function stage_01_bootstrap() {
export B="${B_STAGE_1}"
export R="${R_STAGE_1}"

rm -rf "${B_STAGE_1}"/*
rm -rf "${R_STAGE_1}"/*
rm -rf "${B_STAGE_1:?}"/*
rm -rf "${R_STAGE_1:?}"/*

# Required tools on the host
apt-get -y install binfmt-support debootstrap device-tree-compiler git \
Expand Down Expand Up @@ -477,9 +486,10 @@ function stage_06_clean() {
echo '' > "${R}"/etc/machine-id

# Only required if Connman has been made the default network renderer
cd "${R}/etc"
ln -sf ../run/connman/resolv.conf resolv.conf
cd -
#cd "${R}/etc"
#ln -sf ../run/connman/resolv.conf resolv.conf
#cd -
( cd "${R}/etc" && ln -sf ../run/connman/resolv.conf resolv.conf)
}

function stage_07_image() {
Expand Down