From: Lars Kurth Date: Fri, 1 Sep 2017 19:27:36 +0000 (+0100) Subject: Renamed file, such that Perl picks it up on Debian X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c9569bcf11c233946570c170a4594ecc5975a2f4;p=people%2Flarsk%2Fxen-release-scripts.git Renamed file, such that Perl picks it up on Debian --- diff --git a/lib/MyOptions.pm b/lib/MyOptions.pm new file mode 100755 index 0000000..ad0c41b --- /dev/null +++ b/lib/MyOptions.pm @@ -0,0 +1,199 @@ +package MyOptions; + +use strict; +use warnings; +use Exporter qw(import); +use Getopt::Long qw(GetOptions); +use Config::Simple; +use File::Spec; + +our @EXPORT= qw(options_matchxsa options_xenreleaselogs options_makewebpage); +our @EXPORT_OK = qw(handleoptions); + +my %o = ( + 'VERSION' => "none", + 'MAJOR' => "none", + 'SINCE' => "none", + 'UNTIL' => "stable", + 'LOGROOT' => "../xen-release-logs", + 'XSALISTDIR' => "../xsa-lists", + 'SMART' => 1, + 'DEBUG' => 1, + 'HTML' => 1, + 'NOTSMART' => 0, + 'NOTDEBUG' => 0, + 'NOTHTML' => 0, +); + +my %optionspec = ( +# Applicable to: match-xsa, xen-release-logs and make-webpage + 'version=s' => \$o{'VERSION'}, + 'major=s' => \$o{'MAJOR'}, + 'since=s' => \$o{'SINCE'}, + 'minor-since=s'=> \$o{'SINCE'}, + 'until=s' => \$o{'UNTIL'}, + 'minor-until=s'=> \$o{'UNTIL'}, + 'logroot=s' => \$o{'LOGROOT'}, + 'outputfile=s' => \$o{'OUTPUTFILE'}, + +# Applicable to: match-xsa + 'xsadir=s' => \$o{'XSADIR'}, + 'xsalist=s' => \$o{'XSALIST'}, # DOCUMENT: Was xsa and $XSALIST + 'xsalistdir=s' => \$o{'XSALISTDIR'}, + + 'not-smart' => \$o{'NOTSMART'}, + 'not-debug' => \$o{'NOTDEBUG'}, + 'not-html' => \$o{'NOTHTML'}, + +# Applicable to: make-webpage + 'xsastart=s' => \$o{'XSASTART'}, + 'xsaend=s' => \$o{'XSAEND'}, + ); + +sub handleoptions { + my $outputfile = shift; + my $usage = shift; + + # Add $outputfile default + $o{'OUTPUTFILE'} = $outputfile; + + # Get Configuration file entries + Config::Simple->import_from('config/config', \%o); + + # Get Options + GetOptions(%optionspec) or die "Usage: $0\n".$usage; + # Error checking + if ($o{'VERSION'} eq "none" ) { + die "Usage: $0\n".$usage."\n". + " --version not specified\n"; + } + if ($o{'MAJOR'} eq "none" ) { + die "Usage: $0\n".$usage."\n". + " --major not specified\n"; + } + + # Normalize Calculate Derived Options and create directories, if needed + # Clean temporary directories such as tmp and debug + $o{'SHORT'} = $o{'VERSION'}.$o{'MAJOR'}.$o{'SINCE'}."-".$o{'UNTIL'}; + $o{'LOGROOT'} = File::Spec->rel2abs($o{'LOGROOT'}); + if (!-d $o{'LOGROOT'}) { + mkdir $o{'LOGROOT'}; + } + $o{'LOGDIR'} = $o{'LOGROOT'}."/logs-".$o{'SHORT'}; + if (!-d $o{'LOGDIR'}) { + mkdir $o{'LOGDIR'}; + } + $o{'OUTPUTFILE'} = $o{'LOGROOT'}."/".$o{'SHORT'}."-".$o{'OUTPUTFILE'}; + $o{'TMPDIR'} = $o{'LOGDIR'}."/tmp"; + system("rm -rf ".$o{'TMPDIR'}); + mkdir $o{'TMPDIR'}; + $o{'DEBUGDIR'} = $o{'LOGDIR'}."/debug"; + system("rm -rf ".$o{'DEBUGDIR'}); + mkdir $o{'DEBUGDIR'}; + $o{'XEN_GIT'} = $o{'LOGDIR'}."/xen"; + $o{'QEMUU_GIT'} = $o{'LOGDIR'}."/qemu-xen"; + $o{'QEMUT_GIT'} = $o{'LOGDIR'}."/qemu-xen-traditional"; + + return %o; +} + +sub options_matchxsa { + my $u = " --version \n". + " --major \n". + " [--since|--minor-since ]\n". + " [--until|--minor-until ]\n". + " [--outputfile filename (relative to logdir)]\n". + " [--logroot directory]\n". + " [--not-smart] [--not-debug] [--not-html]\n". + " [--xsadir xsadir (default=LOGDIR/tmp/xsaweb; files fetched from". + " http://xenbits.xenproject.org/xsa/)]\n". + " [--xsalistdir directory]\n". + " --xsalist xsalistfile\n"; + + my %opt = handleoptions("output_xsamatch", $u); + + # Error checking + if (! defined $o{'XSALIST'}) { + die "Usage: $0\n".$u."\n". + " --xsalist not specified\n"; + } + + # Calculate extra options + $opt{'XSALISTDIR'} = File::Spec->rel2abs($o{'XSALISTDIR'}); + $opt{'XSALISTFILE'} = $opt{'XSALISTDIR'}."/".$o{'XSALIST'}; + + # XSADIR and XSAFETCH SPECIAL CASING + if (!$opt{'XSADIR'}) { + $opt{'XSAFETCH'} = "https://xenbits.xenproject.org/xsa/"; + $opt{'XSADIR'} = $o{'TMPDIR'}."/xsaweb"; + system("rm -rf ".$opt{'XSADIR'}); + mkdir $o{'TMPDIR'}; + } + + # Check whether files/directories exist + if (!-d $opt{'XSALISTDIR'}) { + die "Usage: $0\n".$u."\n". + " directory ".$opt{'XSALISTDIR'}." does not exist.\n"; + } + if (!-f $opt{'XSALISTFILE'}) { + die "Usage: $0\n".$u."\n". + " file ".$opt{'XSALISTFILE'}." does not exist.\n"; + } + + # OVERRIDE 'SMART', 'DEBUG' & 'HTML' if specified + if ( $opt{'NOTSMART'} ) { + $opt{'SMART'} = 0; + } + if ( $opt{'NOTDEBUG'} ) { + $opt{'DEBUG'} = 0; + } + if ( $opt{'NOTHTML'} ) { + $opt{'HTML'} = 0; + $opt{'OUTPUTFILE'} .= ".txt"; + } else { + $opt{'OUTPUTFILE'} .= ".html"; + } + + return %opt; +} + +sub options_xenreleaselogs { + my $u = " --version \n". + " --major \n". + " [--since|--minor-since ]\n". + " [--until|--minor-until ]\n". + " [--outputfile filename (relative to logdir)]\n". + " [--logroot directory]\n"; + + my %opt = handleoptions("output_xenreleaselogs.txt", $u); + + return %opt; +} + +sub options_makewebpage { + my $u = " --version \n". + " --major \n". + " [--since|--minor-since ]\n". + " [--until|--minor-until ]\n". + " [--outputfile filename (relative to logdir)]\n". + " [--logroot directory]\n". + " --xsastart \n". + " --xsasend \n"; + + my %opt = handleoptions("output_webpage.html", $u); + + # Error checking + if (! defined $opt{'XSASTART'}) { + die "Usage: $0\n".$u."\n". + " --xsastart not specified\n"; + } + # Error checking + if (! defined $opt{'XSAEND'}) { + die "Usage: $0\n".$u."\n". + " --xsasend not specified\n"; + } + + return %opt; +} + +1; diff --git a/lib/myoptions.pm b/lib/myoptions.pm deleted file mode 100755 index ad0c41b..0000000 --- a/lib/myoptions.pm +++ /dev/null @@ -1,199 +0,0 @@ -package MyOptions; - -use strict; -use warnings; -use Exporter qw(import); -use Getopt::Long qw(GetOptions); -use Config::Simple; -use File::Spec; - -our @EXPORT= qw(options_matchxsa options_xenreleaselogs options_makewebpage); -our @EXPORT_OK = qw(handleoptions); - -my %o = ( - 'VERSION' => "none", - 'MAJOR' => "none", - 'SINCE' => "none", - 'UNTIL' => "stable", - 'LOGROOT' => "../xen-release-logs", - 'XSALISTDIR' => "../xsa-lists", - 'SMART' => 1, - 'DEBUG' => 1, - 'HTML' => 1, - 'NOTSMART' => 0, - 'NOTDEBUG' => 0, - 'NOTHTML' => 0, -); - -my %optionspec = ( -# Applicable to: match-xsa, xen-release-logs and make-webpage - 'version=s' => \$o{'VERSION'}, - 'major=s' => \$o{'MAJOR'}, - 'since=s' => \$o{'SINCE'}, - 'minor-since=s'=> \$o{'SINCE'}, - 'until=s' => \$o{'UNTIL'}, - 'minor-until=s'=> \$o{'UNTIL'}, - 'logroot=s' => \$o{'LOGROOT'}, - 'outputfile=s' => \$o{'OUTPUTFILE'}, - -# Applicable to: match-xsa - 'xsadir=s' => \$o{'XSADIR'}, - 'xsalist=s' => \$o{'XSALIST'}, # DOCUMENT: Was xsa and $XSALIST - 'xsalistdir=s' => \$o{'XSALISTDIR'}, - - 'not-smart' => \$o{'NOTSMART'}, - 'not-debug' => \$o{'NOTDEBUG'}, - 'not-html' => \$o{'NOTHTML'}, - -# Applicable to: make-webpage - 'xsastart=s' => \$o{'XSASTART'}, - 'xsaend=s' => \$o{'XSAEND'}, - ); - -sub handleoptions { - my $outputfile = shift; - my $usage = shift; - - # Add $outputfile default - $o{'OUTPUTFILE'} = $outputfile; - - # Get Configuration file entries - Config::Simple->import_from('config/config', \%o); - - # Get Options - GetOptions(%optionspec) or die "Usage: $0\n".$usage; - # Error checking - if ($o{'VERSION'} eq "none" ) { - die "Usage: $0\n".$usage."\n". - " --version not specified\n"; - } - if ($o{'MAJOR'} eq "none" ) { - die "Usage: $0\n".$usage."\n". - " --major not specified\n"; - } - - # Normalize Calculate Derived Options and create directories, if needed - # Clean temporary directories such as tmp and debug - $o{'SHORT'} = $o{'VERSION'}.$o{'MAJOR'}.$o{'SINCE'}."-".$o{'UNTIL'}; - $o{'LOGROOT'} = File::Spec->rel2abs($o{'LOGROOT'}); - if (!-d $o{'LOGROOT'}) { - mkdir $o{'LOGROOT'}; - } - $o{'LOGDIR'} = $o{'LOGROOT'}."/logs-".$o{'SHORT'}; - if (!-d $o{'LOGDIR'}) { - mkdir $o{'LOGDIR'}; - } - $o{'OUTPUTFILE'} = $o{'LOGROOT'}."/".$o{'SHORT'}."-".$o{'OUTPUTFILE'}; - $o{'TMPDIR'} = $o{'LOGDIR'}."/tmp"; - system("rm -rf ".$o{'TMPDIR'}); - mkdir $o{'TMPDIR'}; - $o{'DEBUGDIR'} = $o{'LOGDIR'}."/debug"; - system("rm -rf ".$o{'DEBUGDIR'}); - mkdir $o{'DEBUGDIR'}; - $o{'XEN_GIT'} = $o{'LOGDIR'}."/xen"; - $o{'QEMUU_GIT'} = $o{'LOGDIR'}."/qemu-xen"; - $o{'QEMUT_GIT'} = $o{'LOGDIR'}."/qemu-xen-traditional"; - - return %o; -} - -sub options_matchxsa { - my $u = " --version \n". - " --major \n". - " [--since|--minor-since ]\n". - " [--until|--minor-until ]\n". - " [--outputfile filename (relative to logdir)]\n". - " [--logroot directory]\n". - " [--not-smart] [--not-debug] [--not-html]\n". - " [--xsadir xsadir (default=LOGDIR/tmp/xsaweb; files fetched from". - " http://xenbits.xenproject.org/xsa/)]\n". - " [--xsalistdir directory]\n". - " --xsalist xsalistfile\n"; - - my %opt = handleoptions("output_xsamatch", $u); - - # Error checking - if (! defined $o{'XSALIST'}) { - die "Usage: $0\n".$u."\n". - " --xsalist not specified\n"; - } - - # Calculate extra options - $opt{'XSALISTDIR'} = File::Spec->rel2abs($o{'XSALISTDIR'}); - $opt{'XSALISTFILE'} = $opt{'XSALISTDIR'}."/".$o{'XSALIST'}; - - # XSADIR and XSAFETCH SPECIAL CASING - if (!$opt{'XSADIR'}) { - $opt{'XSAFETCH'} = "https://xenbits.xenproject.org/xsa/"; - $opt{'XSADIR'} = $o{'TMPDIR'}."/xsaweb"; - system("rm -rf ".$opt{'XSADIR'}); - mkdir $o{'TMPDIR'}; - } - - # Check whether files/directories exist - if (!-d $opt{'XSALISTDIR'}) { - die "Usage: $0\n".$u."\n". - " directory ".$opt{'XSALISTDIR'}." does not exist.\n"; - } - if (!-f $opt{'XSALISTFILE'}) { - die "Usage: $0\n".$u."\n". - " file ".$opt{'XSALISTFILE'}." does not exist.\n"; - } - - # OVERRIDE 'SMART', 'DEBUG' & 'HTML' if specified - if ( $opt{'NOTSMART'} ) { - $opt{'SMART'} = 0; - } - if ( $opt{'NOTDEBUG'} ) { - $opt{'DEBUG'} = 0; - } - if ( $opt{'NOTHTML'} ) { - $opt{'HTML'} = 0; - $opt{'OUTPUTFILE'} .= ".txt"; - } else { - $opt{'OUTPUTFILE'} .= ".html"; - } - - return %opt; -} - -sub options_xenreleaselogs { - my $u = " --version \n". - " --major \n". - " [--since|--minor-since ]\n". - " [--until|--minor-until ]\n". - " [--outputfile filename (relative to logdir)]\n". - " [--logroot directory]\n"; - - my %opt = handleoptions("output_xenreleaselogs.txt", $u); - - return %opt; -} - -sub options_makewebpage { - my $u = " --version \n". - " --major \n". - " [--since|--minor-since ]\n". - " [--until|--minor-until ]\n". - " [--outputfile filename (relative to logdir)]\n". - " [--logroot directory]\n". - " --xsastart \n". - " --xsasend \n"; - - my %opt = handleoptions("output_webpage.html", $u); - - # Error checking - if (! defined $opt{'XSASTART'}) { - die "Usage: $0\n".$u."\n". - " --xsastart not specified\n"; - } - # Error checking - if (! defined $opt{'XSAEND'}) { - die "Usage: $0\n".$u."\n". - " --xsasend not specified\n"; - } - - return %opt; -} - -1;