pf-tools commit: r619 [ccaillet-guest] - /trunk/sbin/mk_sourceslist

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Fri Aug 1 13:27:09 UTC 2008


Author: ccaillet-guest
Date: Fri Aug  1 13:27:09 2008
New Revision: 619

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=619
Log:
Fix some typo and syntax errors and adding usage for mk_sourceslist

Modified:
    trunk/sbin/mk_sourceslist

Modified: trunk/sbin/mk_sourceslist
URL: http://svn.debian.org/wsvn/pf-tools/trunk/sbin/mk_sourceslist?rev=619&op=diff
==============================================================================
--- trunk/sbin/mk_sourceslist (original)
+++ trunk/sbin/mk_sourceslist Fri Aug  1 13:27:09 2008
@@ -31,11 +31,57 @@
 use File::Copy ;
 use Getopt::Long qw( :config ignore_case_always bundling ) ;
 
+my $HELP	= 0 ;
 my $SRC 	= "" ;
 my $DST 	= "" ;
 my $TPL		= "/usr/share/pf-tools/templates/sources.list.tpl" ;
 my $SECTIONS	= "common" ;
-my $HOST	= chomp ( `/bin/hostname -s 2>>/dev/null` ) ;
+my $HOST	= `/bin/hostname -s 2>>/dev/null` ;
+chomp ( $HOST ) ;
+
+my $program = $0;
+$program =~ s%.*/%%; # cheap basename
+
+my $version = sprintf("svn-r%s", q$Revision$ =~ /([\d.]+)/);
+
+
+sub Usage () {
+
+print <<EOF
+
+$program - version $version
+
+Synopsis : $program [-h|--help] [-s|--src <private-network source] [-d|--dst <sources.list dest>]
+		[ -t|--tpl <sources.list template>] [--host <hostname>] [[section] [section]]
+
+	This tool permits to build the sources.list file according to distribution defined
+	in private-network file from PF-Tools configuration. It can also add some sections
+	to custom repository
+
+	-h | --help	Displays this message and exits
+
+	-s | --src	Defines here where to find the private-network file
+
+	-d | --dst	Defines here where to build the sources.list file
+
+	-t | --tpl	Defines here where to find the sources.list template. If not defined
+			the program will use /usr/share/pf-tools/templates/sources.list.tpl
+
+	--host		Defines for which hostname you want to build the sources.list. This
+			option is mainly for debugging
+
+
+	You can add on CLI some sections to add to the "common" section for custom repository
+	
+	Sample use :
+	
+	$program -s GLOBAL:private-network -d /tmp/sources.list -h stream-tv00 stream
+
+	This command generate the sources.list file on /tmp for stream-tv00 host and adds the
+	section stream to the custom packages repository
+
+EOF
+}
 
 sub Mk_sourceslist ($$$$) {
 	my ( $ref_srv, $dst, $tpl, $sections ) = @_ ;
@@ -67,11 +113,17 @@
 }
 
 GetOptions (
-	'h|host=s'	=> \$HOST,
+	'h|help'	=> \$HELP,
+	'host=s'	=> \$HOST,
 	's|src=s'	=> \$SRC,
 	'd|dst=s'	=> \$DST,
 	't|tpl=s'	=> \$TPL
 ) || die "Didn't grok options on CLI\n" ;
+
+if ( $HELP ) {
+	Usage () ;
+	exit 0 ;
+}
 
 if ( $SRC eq "" || $DST eq "" ) {
 	warn "Source or/and destination are not defined : cannot build sources.list file\n" ;
@@ -83,6 +135,6 @@
 
 my $PF_NET	= Init_lib_net ( Get_source ( $SRC ) ) ;
 $HOST		=~ /^(([^\-]{4})-)?([^\d\-]+)-([\d]+)$/ ;
-my $SRV		= $PF_NET->{$Z->{'SERVERS'}->{'BY_NAME'}->{$3}->{'SRVLIST'}->{$HOST} ;
+my $SRV		= $PF_NET->{'SERVERS'}->{'BY_NAME'}->{$3}->{'SRVLIST'}->{$HOST} ;
 
 Mk_sourceslist ( $SRV, $DST, $TPL, $SECTIONS ) ;




More information about the pf-tools-commits mailing list