try to keep comments in /etc/network/interfaces

This commit is contained in:
Dietmar Maurer 2012-03-01 09:52:12 +01:00
parent 9934cd0bd1
commit 72ca652054
3 changed files with 55 additions and 36 deletions

View File

@ -1,7 +1,7 @@
RELEASE=2.0
VERSION=1.0
PKGREL=15
PKGREL=16
PACKAGE=libpve-common-perl

View File

@ -722,7 +722,11 @@ sub read_etc_network_interfaces {
$ifaces->{$i}->{method} = $2;
my $d = $ifaces->{$i};
while (defined ($line = <$fh>) && ($line =~ m/^\s+((\S+)\s+(.+))$/)) {
while (defined ($line = <$fh>)) {
if ($line =~ m/^#(.*)\s*$/) {
$d->{comment} = '' if !$d->{comment};
$d->{comment} .= PVE::Tools::decode_text($1) . "\n";
} elsif ($line =~ m/^\s+((\S+)\s+(.+))$/) {
my $option = $1;
my ($id, $value) = ($2, $3);
if (($id eq 'address') || ($id eq 'netmask') || ($id eq 'broadcast')) {
@ -761,6 +765,9 @@ sub read_etc_network_interfaces {
} else {
push @{$d->{options}}, $option;
}
} else {
last;
}
}
}
}
@ -864,6 +871,12 @@ sub __interface_to_string {
$raw .= "\t$option\n";
}
# add comments
my $comment = $d->{comment} || '';
foreach my $cl (split(/\n/, $comment)) {
$raw .= '#' . PVE::Tools::encode_text($cl) . "\n";
}
$raw .= "\n";
return $raw;

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
libpve-common-perl (1.0-16) unstable; urgency=low
* try to keep comments in /etc/network/interfaces
-- Proxmox Support Team <support@proxmox.com> Thu, 01 Mar 2012 09:49:22 +0100
libpve-common-perl (1.0-15) unstable; urgency=low
* add Swedish keymap