]> git.proxmox.com Git - pve-common.git/commitdiff
try to keep comments in /etc/network/interfaces
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 1 Mar 2012 08:52:12 +0000 (09:52 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 1 Mar 2012 08:52:12 +0000 (09:52 +0100)
Makefile
data/PVE/INotify.pm
debian/changelog

index 581d757cc044615885e8ce90fae35e713a2182f6..01f1e2af28d26629fcfffbf28d517fee62bf2022 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 RELEASE=2.0
 
 VERSION=1.0
-PKGREL=15
+PKGREL=16
 
 PACKAGE=libpve-common-perl
 
index abc8aeb6777ebaa97be3239c40dd00425e3a5594..0c4da4cae0111d9ecb8a9318a6d92d6df8bcfbc8 100644 (file)
@@ -722,44 +722,51 @@ sub read_etc_network_interfaces {
            $ifaces->{$i}->{method} = $2;
 
            my $d = $ifaces->{$i};
-           while (defined ($line = <$fh>) && ($line =~ m/^\s+((\S+)\s+(.+))$/)) {
-               my $option = $1;
-               my ($id, $value) = ($2, $3);
-               if (($id eq 'address') || ($id eq 'netmask') || ($id eq 'broadcast')) {
-                   $d->{$id} = $value;
-               } elsif ($id eq 'gateway') {
-                   $d->{$id} = $value;
-                   $gateway = 1;
-               } elsif ($id eq 'slaves' || $id eq 'bridge_ports') {
-                   my $devs = {};
-                   foreach my $p (split (/\s+/, $value)) {
-                       next if $p eq 'none';
-                       $devs->{$p} = 1;
-                   }
-                   my $str = join (' ', sort keys %{$devs});
-                   $d->{$id} = $str || '';
-               } elsif ($id eq 'bridge_stp') {
-                   if ($value =~ m/^\s*(on|yes)\s*$/i) {
-                       $d->{$id} = 'on';
-                   } else {
-                       $d->{$id} = 'off';
-                   }
-               } elsif ($id eq 'bridge_fd') {
-                   $d->{$id} = $value;
-               } elsif ($id eq 'bond_miimon') {
-                   $d->{$id} = $value;
-               } elsif ($id eq 'bond_mode') {
-                   # always use names
-                   foreach my $bm (keys %$bond_modes) {
-                       my $id = $bond_modes->{$bm};
-                       if ($id eq $value) {
-                           $value = $bm;
-                           last;
+           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')) {
+                       $d->{$id} = $value;
+                   } elsif ($id eq 'gateway') {
+                       $d->{$id} = $value;
+                       $gateway = 1;
+                   } elsif ($id eq 'slaves' || $id eq 'bridge_ports') {
+                       my $devs = {};
+                       foreach my $p (split (/\s+/, $value)) {
+                           next if $p eq 'none';
+                           $devs->{$p} = 1;
                        }
+                       my $str = join (' ', sort keys %{$devs});
+                       $d->{$id} = $str || '';
+                   } elsif ($id eq 'bridge_stp') {
+                       if ($value =~ m/^\s*(on|yes)\s*$/i) {
+                           $d->{$id} = 'on';
+                       } else {
+                           $d->{$id} = 'off';
+                       }
+                   } elsif ($id eq 'bridge_fd') {
+                       $d->{$id} = $value;
+                   } elsif ($id eq 'bond_miimon') {
+                       $d->{$id} = $value;
+                   } elsif ($id eq 'bond_mode') {
+                       # always use names
+                       foreach my $bm (keys %$bond_modes) {
+                           my $id = $bond_modes->{$bm};
+                           if ($id eq $value) {
+                               $value = $bm;
+                               last;
+                           }
+                       }
+                       $d->{$id} = $value;
+                   } else {
+                       push @{$d->{options}}, $option;
                    }
-                   $d->{$id} = $value;
                } else {
-                   push @{$d->{options}}, $option;
+                   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;
index 32ccec03feeafbfb9f6c722409c4d2a7860e9703..92a93b4ab57bd3e80fe17aa821f89cabfc7750fd 100644 (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