tags 530024 + patch thanks Hi,
please find attached a patch based on what Ubuntu has done with a few improvements: - a single backup per run but the correct one - disable with a special prefix (to allow the next feature) - re-enable on removal It's still somewhat crude, i.e. it's not something I would like to have on my own package but it works for now. You might also want to tweak the name of the backup files and maybe remove them on purge... Cheers, -- Raphaël Hertzog ◈ Debian Developer ◈ [Flattr=20693] Follow my Debian News ▶ http://RaphaelHertzog.com (English) ▶ http://RaphaelHertzog.fr (Français)
diff -Nru network-manager-0.8.1/debian/changelog network-manager-0.8.1/debian/changelog --- network-manager-0.8.1/debian/changelog 2010-09-22 03:31:51.000000000 +0200 +++ network-manager-0.8.1/debian/changelog 2010-10-03 22:24:19.000000000 +0200 @@ -1,3 +1,13 @@ +network-manager (0.8.1-3.1) unstable; urgency=low + + * Non-maintainer upload. + * Integrate debian/ifblacklist_migrate.sh from Ubuntu and install + it in /usr/lib/NetworkManager. Improve it to disable the interfaces + with a #NetworkManager# prefix and re-enable them when the package is + removed. Closes: #530024 + + -- Raphaël Hertzog <hert...@debian.org> Sun, 03 Oct 2010 10:11:22 +0200 + network-manager (0.8.1-3) unstable; urgency=low * debian/control diff -Nru network-manager-0.8.1/debian/ifblacklist_migrate.sh network-manager-0.8.1/debian/ifblacklist_migrate.sh --- network-manager-0.8.1/debian/ifblacklist_migrate.sh 1970-01-01 01:00:00.000000000 +0100 +++ network-manager-0.8.1/debian/ifblacklist_migrate.sh 2010-10-03 22:03:41.000000000 +0200 @@ -0,0 +1,66 @@ +#!/bin/sh + +# (C) 2007 Canonical Ltd. +# Author: Alexander Sack <a...@jwsdot.com> +# License: GNU General Public License, version 2 or any later version + +if test x$NIF_FILE = x; then + NIF_FILE=/etc/network/interfaces +fi + +auto_ifs=$(cat $NIF_FILE | \ + egrep "^auto|^allow-" | \ + sed -e 's/auto//' | \ + sed -e 's/allow-[^ ].* //') + +ifaces_to_disable="" + +echo Auto interfaces found: $auto_ifs + +# iterate over all auto interfaces +for i in $auto_ifs; do + IFS_old=$IFS; IFS="" + + NIF_FILE_content=$(cat $NIF_FILE | \ + sed -e 's/^[ \t]*auto.*$//' | \ + sed -e 's/^[ \t]*allow-.*$//' | \ + sed -e 's/^[ \t]*#.*$//' | grep -v ^$) + + # '--' is inserted by grep -A1 if there are multiple iface blocks + lines=$(echo $NIF_FILE_content | grep -A1 "^iface.*$i.*dhcp" | grep -v '\--') + IFS=" +" + + # if there is no iface line for that interface, we would still get a line + # count of 1 ... so use word_count 0 below to exclude ifaces that have no + # configuration at all. + word_count=$(echo $lines | wc -w) + line_count=0 + for line in $lines; do + nulled_line=$(echo "$line" | sed -e 's/[# ]//' | grep -v ^iface) + if test x$nulled_line != x; then + line_count=$(expr $line_count + 1) + fi + done + + if test $line_count -eq 0 -a $word_count -gt 0; then + ifaces_to_disable="$ifaces_to_disable $i" + echo iface to disable = $i + fi + IFS=$IFS_old +done + +backup_suffix=0 +while test -e ${NIF_FILE}.bak-${backup_suffix}; do + backup_suffix=$(expr $backup_suffix + 1) +done + +if [ -n "$ifaces_to_disable" ]; then + cp $NIF_FILE "$NIF_FILE.bak-${backup_suffix}" + for i in $ifaces_to_disable; do + echo -n "Disabling interface: $i ... " + sed -i -e "s/^\([ \t]*iface.*$i.*\)$/#NetworkManager#\1/" $NIF_FILE + echo done. + done +fi + diff -Nru network-manager-0.8.1/debian/network-manager.install network-manager-0.8.1/debian/network-manager.install --- network-manager-0.8.1/debian/network-manager.install 2010-07-29 03:32:17.000000000 +0200 +++ network-manager-0.8.1/debian/network-manager.install 2010-10-03 10:14:03.000000000 +0200 @@ -18,4 +18,5 @@ debian/tmp/etc/NetworkManager/dispatcher.d/ debian/tmp/etc/NetworkManager/system-connections/ debian/tmp/lib/udev/rules.d/*.rules +debian/ifblacklist_migrate.sh /usr/lib/NetworkManager debian/NetworkManager.conf etc/NetworkManager/ diff -Nru network-manager-0.8.1/debian/network-manager.postinst network-manager-0.8.1/debian/network-manager.postinst --- network-manager-0.8.1/debian/network-manager.postinst 2010-07-30 02:14:01.000000000 +0200 +++ network-manager-0.8.1/debian/network-manager.postinst 2010-10-03 22:12:03.000000000 +0200 @@ -66,6 +66,11 @@ if dpkg --compare-versions "$2" lt "0.8.1-2"; then mv_conffile "/etc/NetworkManager/nm-system-settings.conf" "/etc/NetworkManager/NetworkManager.conf" fi + + if [ -z "$2" ] || dpkg --compare-versions "$2" lt-nl "0.8.1-3.1"; then + echo "Disabling interfaces configured with plain DHCP in /etc/network/interfaces so that NetworkManager can take them over" + sh /usr/lib/NetworkManager/ifblacklist_migrate.sh + fi ;; abort-upgrade|abort-deconfigure|abort-remove) diff -Nru network-manager-0.8.1/debian/network-manager.postrm network-manager-0.8.1/debian/network-manager.postrm --- network-manager-0.8.1/debian/network-manager.postrm 2010-08-06 04:06:33.000000000 +0200 +++ network-manager-0.8.1/debian/network-manager.postrm 2010-10-03 22:07:43.000000000 +0200 @@ -24,7 +24,15 @@ rmdir --ignore-fail-on-non-empty /var/lib/NetworkManager fi ;; - remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + remove) + # Restore the ifupdown configuration that were disabled at installation + backup_suffix=0 + while test -e /etc/network/interfaces.bak-${backup_suffix}; do + backup_suffix=$(($backup_suffix + 1)) + done + sed -i.bak-${backup_suffix} -e "s/^#NetworkManager#//g" /etc/network/interfaces + ;; + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) ;; *)