pf-tools commit: r744 [ccaillet-guest] - in /branches/0.33-stable: debian/changelog debian/control sbin/mk_grub2opt

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Fri May 14 13:06:45 UTC 2010


Author: ccaillet-guest
Date: Fri May 14 13:06:45 2010
New Revision: 744

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=744
Log:
* sbin/mk_grub2opt : tool for generating GRUB2 configuration option according to
  cmdline defined into host definition
* debian/control : fixing deps for libmd5-perl which is included in perl >= 5.10

Added:
    branches/0.33-stable/sbin/mk_grub2opt
Modified:
    branches/0.33-stable/debian/changelog
    branches/0.33-stable/debian/control

Modified: branches/0.33-stable/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.33-stable/debian/changelog?rev=744&op=diff
==============================================================================
--- branches/0.33-stable/debian/changelog (original)
+++ branches/0.33-stable/debian/changelog Fri May 14 13:06:45 2010
@@ -18,7 +18,12 @@
   * tools/kvmlaunch:
     - correctly handle bonding / slaves / eth remapping.
 
- -- Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>  Thu, 29 Apr 2010 14:40:46 +0200
+  [ Thierry Magnien ]
+  * sbin/mk_grub2opt : tool for generating GRUB2 configuration option according to
+    cmdline defined into host definition
+  * debian/control : fixing deps for libmd5-perl which is included in perl >= 5.10
+
+ -- Christophe Caillet <quadchris at free.fr>  Fri, 14 May 2010 15:03:07 +0200
 
 pf-tools (0.33.19-1) unstable; urgency=low
 

Modified: branches/0.33-stable/debian/control
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.33-stable/debian/control?rev=744&op=diff
==============================================================================
--- branches/0.33-stable/debian/control (original)
+++ branches/0.33-stable/debian/control Fri May 14 13:06:45 2010
@@ -8,7 +8,7 @@
 
 Package: pf-tools
 Architecture: all
-Depends: perl, libmd5-perl, cvs, ssh, iproute, debconf, psmisc
+Depends: perl, perl (>= 5.10.0) | libmd5-perl, cvs, ssh, iproute, debconf, psmisc
 Recommends: vlan, bridge-utils, uml-utilities (>= 20030605-2), screen
 Description: Outils de gestion de la plateforme
  Mise a jour automatique et generation de conf.
@@ -16,7 +16,7 @@
 
 Package: pf-host
 Architecture: all
-Depends: perl, libmd5-perl, libdigest-crc-perl, libexpect-perl, libnetwork-ipv4addr-perl, cvs, ssh, iproute, debconf, psmisc, vlan, bridge-utils, uml-utilities, screen, pf-tools (>= 0.30-1), sitalibs-config-perl (>= 0.7.2), libnet-ip-perl
+Depends: perl, perl (>= 5.10.0) | libmd5-perl, libdigest-crc-perl, libexpect-perl, libnetwork-ipv4addr-perl, cvs, ssh, iproute, debconf, psmisc, vlan, bridge-utils, uml-utilities, screen, pf-tools (>= 0.30-1), sitalibs-config-perl (>= 0.7.2), libnet-ip-perl
 Description: Outils de gestion d'une plateforme, partie host 
  Deploiement de machines virtuelles.
 

Added: branches/0.33-stable/sbin/mk_grub2opt
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.33-stable/sbin/mk_grub2opt?rev=744&op=file
==============================================================================
--- branches/0.33-stable/sbin/mk_grub2opt (added)
+++ branches/0.33-stable/sbin/mk_grub2opt Fri May 14 13:06:45 2010
@@ -1,0 +1,137 @@
+#!/usr/bin/perl
+##
+##  $Id: mk_grub2opt 714 2009-07-22 11:38:04Z ccaillet-guest $
+##
+##  Copyright (C) 2007-2008 Christophe Caillet <quadchris at free.fr>
+##  Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
+##  Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
+##
+##  This program is free software; you can redistribute it and/or
+##  modify it under the terms of the GNU General Public License
+##  as published by the Free Software Foundation; either version 2
+##  of the License, or (at your option) any later version.
+##
+##  This program is distributed in the hope that it will be useful,
+##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+##  GNU General Public License for more details.
+##
+##  You should have received a copy of the GNU General Public License
+##  along with this program; if not, write to the Free Software
+##  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+##
+
+use strict;
+use warnings;
+
+use Sys::Hostname ;
+use Digest::MD5;
+use PFTools::Net;
+use PFTools::Update;
+use File::Compare ;
+use File::Copy ;
+use Getopt::Long qw( :config ignore_case_always bundling );
+
+my $program = $0;
+$program =~ s%.*/%%; # cheap basename
+
+my $version = sprintf( "svn-r%s", q$Revision: 714 $ =~ /([\d.]+)/ );
+
+my $MENU_GRUB	= "/etc/default/grub" ;
+my $HOSTNAME	= hostname ;
+my $DEST	= "-" ;
+my $NET		= "GLOBAL:private-network" ;
+my $HELP	= 0 ;
+my $DEBUG	= 0 ;
+my $VERBOSE	= 0 ;
+
+sub Display_usage () {
+print STDERR << "# ENDHELP";
+    $program - version $version
+
+Usage:	$0 [options]
+	-h --help:	print help and exit
+	-v --verbose:	be more verbose
+	-s --src	source for GRUB configuration (default: /boot/grub/menu.lst)
+	-d --dst	destination for modified GRUB configuration (default: /boot/grub/menu.lst)
+	--host		hostname on which GRUB configuration applied
+	-n --net	Possiblitiy for defining an alternate PATH for private-network file (default GLOBAL:private-network)
+# ENDHELP
+}
+
+
+sub Change_kopt ($$$) {
+	my ( $cmd_line, $menulst, $dst ) = @_ ;
+
+	unless ( open ( MENU, $menulst ) ) {
+		warn "Unable top open ".$menulst."\n" ;
+		return 0 ;
+	}
+	my @tmp_grub = <MENU> ;
+	foreach ( @tmp_grub ) {
+		chomp ;
+		next if ( ! /^GRUB_CMDLINE_LINUX_DEFAULT=".*"$/ ) ;
+		s/\"$/ $cmd_line\"/ if ( defined $cmd_line && ! /\Q$cmd_line\E$/ ) ;
+	}
+	
+	if ( $dst eq '-' ) {
+		foreach ( @tmp_grub ) {
+			print $_."\n" ;
+		}
+		return 1 ;
+	}
+	else {
+		unless ( open ( TMPDST, ">/tmp/menulst" ) ) {
+			warn "Unable to open temporary destination file /tmp/menulst\n" ;
+			return 0 ;
+		}
+		foreach ( @tmp_grub ) {
+			print TMPDST $_."\n" ;
+		}
+		close ( TMPDST ) ;
+		if ( compare ( '/tmp/menulst', $dst ) ) {
+			return move ( '/tmp/menulst', $dst) ;
+		} else {
+			if ( $DEBUG ) {
+				warn "No need to move /tmp/menulst to ".$dst." they are equals\n" ;
+				warn "Unlinking source file /tmp/menulst\n" ;
+			}
+			if ( ! unlink ( '/tmp/menulst' ) ) {
+				warn "Unable to unlink source file /tmp/menulst\n" ;
+				warn "Please clean it manually\n" ;
+			}
+		}
+		return 1 ;
+	}
+}
+
+##### MAIN
+GetOptions(
+    'src|s=s'	=> \$MENU_GRUB,
+    'dst|d=s'	=> \$DEST,
+    'host=s'	=> \$HOSTNAME,
+    'net|n=s'	=> \$NET,
+    'debug'	=> \$DEBUG,
+    'help|h'	=> \$HELP,
+    'verbose|v'	=> \$VERBOSE
+) or die "GetOptions error, try --help: $!\n";
+
+if ( $HELP ) {
+	Display_usage () ;
+	exit 0 ;
+}
+elsif ( ! -e $MENU_GRUB ) {
+	die "Unexistant GRUB configuration ".$MENU_GRUB."\n" ;
+}
+elsif ( -z $MENU_GRUB ) {
+	die "Empty configuration file for GRUB ".$MENU_GRUB."\n" ;
+}
+
+$DEST = "-" if ( $DEBUG ) ;
+$VERBOSE = 1 if ( $DEBUG ) ;
+
+my $NETWORK = Init_lib_net ( Get_source ( $NET ) ) ;
+if ( ! Change_kopt ( Get_Cmdline ( $NETWORK, $HOSTNAME ), $MENU_GRUB, $DEST ) ) {
+	die "Unable to change kernel options(s) into file ".$MENU_GRUB."\n" ;
+}
+




More information about the pf-tools-commits mailing list