summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLyndon Brown <jnqnfe@gmail.com>2020-04-04 20:20:07 +0100
committerRaphaƫl Hertzog <hertzog@debian.org>2020-04-23 10:05:51 +0000
commit1a0c813c46e274970d6f7ad87b9f04084a8d24f3 (patch)
treeb3830182d16efdeacf861edcceeb2847681367c9 /scripts
parentaffcbb95d14037db43a13548a61fc2a6d14cce42 (diff)
downloadvyos-live-build-1a0c813c46e274970d6f7ad87b9f04084a8d24f3.tar.gz
vyos-live-build-1a0c813c46e274970d6f7ad87b9f04084a8d24f3.zip
chroot_apt: fix broken removal
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build/chroot_apt42
1 files changed, 12 insertions, 30 deletions
diff --git a/scripts/build/chroot_apt b/scripts/build/chroot_apt
index d21a1e92b..f7f2326f2 100755
--- a/scripts/build/chroot_apt
+++ b/scripts/build/chroot_apt
@@ -173,11 +173,7 @@ case "${1}" in
CONFIG_FILE="config/apt/apt.conf"
CHROOT_FILE="chroot/etc/apt/apt.conf"
if [ -f ${CONFIG_FILE} ]; then
- if [ -f ${CHROOT_FILE} ]; then
- mv ${CHROOT_FILE} ${CHROOT_FILE}.orig
- fi
-
- cp ${CONFIG_FILE} ${CHROOT_FILE}
+ rm -f ${CHROOT_FILE}
if [ -f ${CHROOT_FILE}.orig ]; then
mv ${CHROOT_FILE}.orig ${CHROOT_FILE}
@@ -188,25 +184,27 @@ case "${1}" in
CONFIG_FILE="config/apt/preferences"
CHROOT_FILE="chroot/etc/apt/preferences"
if [ -f ${CONFIG_FILE} ]; then
- if [ -f ${CHROOT_FILE} ]; then
- mv ${CHROOT_FILE} ${CHROOT_FILE}.orig
- fi
-
- cp ${CONFIG_FILE} ${CHROOT_FILE}
+ rm -f ${CHROOT_FILE}
if [ -f ${CHROOT_FILE}.orig ]; then
mv ${CHROOT_FILE}.orig ${CHROOT_FILE}
fi
+ elif [ -f ${CHROOT_FILE} ]; then
+ # delete additions from lb_chroot_apt install|install-binary to preferences
+ sed -i '/# Added by lb_chroot_apt/,$d' ${CHROOT_FILE}
+ # delete the last empty line
+ sed -i '${/^[[:blank:]]*$/d;}' ${CHROOT_FILE}
+ # if the resulting preferences file is empty, we must have created it, remove it
+ if [ ! -s ${CHROOT_FILE} ]; then
+ rm -f ${CHROOT_FILE}
+ fi
fi
if Find_files config/apt/*.pref; then
for CONFIG_FILE in config/apt/*.pref; do
CHROOT_FILE="chroot/etc/apt/preferences.d/$(basename ${CONFIG_FILE})"
- if [ -f ${CHROOT_FILE} ]; then
- mv ${CHROOT_FILE} ${CHROOT_FILE}.orig
- fi
- cp -aL ${CONFIG_FILE} chroot/etc/apt/preferences.d
+ rm -f ${CHROOT_FILE}
if [ -f ${CHROOT_FILE}.orig ]; then
mv ${CHROOT_FILE}.orig ${CHROOT_FILE}
@@ -214,22 +212,6 @@ case "${1}" in
done
fi
- if Find_files config/packages.chroot/*.deb || Find_files config/packages/*.deb
- then
- CHROOT_FILE="chroot/etc/apt/preferences"
- if [ -f ${CHROOT_FILE} ]; then
- # delete additions from lb_chroot_apt install|install-binary to preferences
- sed -i '/# Added by lb_chroot_apt/,$d' ${CHROOT_FILE}
- # delete the last empty line
- sed -i '${/^[[:blank:]]*$/d;}' ${CHROOT_FILE}
- # if the resulting preferences file is empty there was no user additions, remove it
- if [ ! -s ${CHROOT_FILE} ]; then
- rm -rf ${CHROOT_FILE}
- fi
- fi
-
- fi
-
# Removing stage file
Remove_stagefile
;;