Browse Source

write to apt.conf.new and rename at the end, to avoid trashing apt.conf if we backup part-way through

r31547
tags/0.1
Colin Watson 16 years ago
parent
commit
2b55cb6d8b
4 changed files with 19 additions and 4 deletions
  1. +8
    -0
      apt-setup
  2. +7
    -0
      generators/01setup
  3. +2
    -2
      generators/50mirror
  4. +2
    -2
      generators/90security

+ 8
- 0
apt-setup View File

@@ -15,6 +15,9 @@ else
fi
export ROOT

# generators/01setup will create this
export APT_CONFIG=/etc/apt/apt.conf.new

log() {
logger -t apt-setup "$@"
}
@@ -53,5 +56,10 @@ for generator in $gendir/*; do
db_progress STEP 1
done
mv $ROOT/etc/apt/sources.list.new $ROOT/etc/apt/sources.list
if [ -s $ROOT/etc/apt/apt.conf.new ]; then
mv $ROOT/etc/apt/apt.conf.new $ROOT/etc/apt/apt.conf
else
rm -f $ROOT/etc/apt/apt.conf.new
fi

db_progress STOP

+ 7
- 0
generators/01setup View File

@@ -5,3 +5,10 @@ file="$1"

# add old file as comments
sed 's/^/# /' < $ROOT/etc/apt/sources.list | sed 's/^# # */# /' > $file

# start out with old configuration, if any
if [ -e $ROOT/etc/apt/apt.conf ]; then
cp -a $ROOT/etc/apt/apt.conf $ROOT/etc/apt/apt.conf.new
else
>$ROOT/etc/apt/apt.conf.new
fi

+ 2
- 2
generators/50mirror View File

@@ -67,8 +67,8 @@ if [ "$protocol" = http ]; then
db_get mirror/$protocol/proxy
proxy="$RET"
if [ -n "$proxy" ]; then
if ! grep -iq "Acquire::$protocol::Proxy" $ROOT/etc/apt/apt.conf; then
echo "Acquire::$protocol::Proxy \"$proxy\";" >> $ROOT/etc/apt/apt.conf
if ! grep -iq "Acquire::$protocol::Proxy" $ROOT/etc/apt/apt.conf.new; then
echo "Acquire::$protocol::Proxy \"$proxy\";" >> $ROOT/etc/apt/apt.conf.new
fi
fi
fi


+ 2
- 2
generators/90security View File

@@ -33,8 +33,8 @@ fi
db_fget mirror/http/proxy seen || true
proxy="$RET"
if [ -n "$proxy" ]; then
if ! grep -iq "Acquire::$protocol::Proxy" $ROOT/etc/apt/apt.conf; then
echo "Acquire::$protocol::Proxy \"$proxy\";" >> $ROOT/etc/apt/apt.conf
if ! grep -iq "Acquire::$protocol::Proxy" $ROOT/etc/apt/apt.conf.new; then
echo "Acquire::$protocol::Proxy \"$proxy\";" >> $ROOT/etc/apt/apt.conf.new
fi
fi



Loading…
Cancel
Save