]> xenbits.xensource.com Git - people/larsk/xen-release-scripts.git/commitdiff
Ported the scripts to use lib/myoptions.pm
authorLars Kurth <lars.kurth@citrix.com>
Fri, 1 Sep 2017 17:02:51 +0000 (18:02 +0100)
committerLars Kurth <lars.kurth@citrix.com>
Fri, 1 Sep 2017 17:02:51 +0000 (18:02 +0100)
README
make-webpage
match-xsa
xen-release-logs

diff --git a/README b/README
index eaaac920da00c73ebd7b1d8a1307acaa31d80d3b..e255c52e1916f6cf4cc68afad110f62ffda182e9 100644 (file)
--- a/README
+++ b/README
@@ -13,6 +13,8 @@ To keep things clean, use the following directory structure
                             see steps 1-5 in match-xsa]
     - xsa                  [git repo, optional]
 
+This is set up as the default. You can also set defaults for all scripts
+in the config/config file
 
 Prerequisites
 -------------
@@ -20,7 +22,10 @@ match-xsa and xen-release-logs, require perl and the following perl libraries
 
     libfile-slurp-perl  
     libfile-spec-perl
+    libfile-config-simple
 
+On Mac: see https://stackoverflow.com/questions/12027327/
+            how-to-install-json-pm-perl-module-on-osx
 
 Tested on
 ---------
@@ -54,6 +59,10 @@ This document is written for specific users
 Logfiles, --version, --major, --since, --until and --logroot
 ------------------------------------------------------------
 
+Note:
+* You can also use --minor-since instead of --since
+* You can also use --minor-until instead of --until
+
 The tools xen-release-logs, match-xsa and make-webpage use the following
 common options:
 
index 9fbf3705f149e7bc0138eccc96a73fd77d208921..0bfcb5afb66c528b484b61013c78ba6dc73c9cd6 100755 (executable)
@@ -1,54 +1,39 @@
 #!/usr/bin/perl
 # Usage
-# $0 --version 4 --major 7 --since 0 --until 1 [--getlogs] [--logroot dir] --xsastart start --xsaend end
-# Logs will be put into the log directory under "webpage.html"
+# See lib/myoptions.pl
 
 use strict;
 use warnings;
-use 5.010;
-use Getopt::Long qw(GetOptions);
 use Cwd;
 use File::Slurp;
 use Text::Diff;
 use File::Spec;
 
-my $GETLOGS=0;
-my $VERSION;
-my $MAJOR;
-my $SINCE="none";
-my $UNTIL="stable";
-my $XSASTART;
-my $XSAEND;
-my $LOGROOT = File::Spec->canonpath(cwd()."/../xen-release-logs" );
-
-GetOptions(
-    'getlogs'    => \$GETLOGS,
-    'version=s'  => \$VERSION,
-    'major=s'    => \$MAJOR,
-    'since=s'    => \$SINCE,
-    'until=s'    => \$UNTIL,
-    'xsastart=s' => \$XSASTART,
-    'xsaend=s'   => \$XSAEND,
-    'logroot=s'  => \$LOGROOT,
-) or 
-die "Usage: $0 --version 4 --major 7 --since 0 --until 1 [--getlogs] [--logroot dir] --xsastart start --xsaend end\n";
-if ($GETLOGS) {
-    system("./xen-release-logs --version $VERSION --major $MAJOR --since $SINCE --until $UNTIL --logroot $LOGROOT");
-}
+use FindBin;
+use lib $FindBin::Bin.'/lib';
+
+use MyOptions;
 
-# Calculate log file names
-my $short="$VERSION$MAJOR$SINCE-$UNTIL";
+my %opt = options_makewebpage();
 
-# Directories
+# Copy Variables from Options
+my $GETLOGS     = $opt{'GETLOGS'};
+my $VERSION     = $opt{'VERSION'};
+my $MAJOR       = $opt{'MAJOR'};
+my $SINCE       = $opt{'SINCE'};
+my $UNTIL       = $opt{'UNTIL'};
+my $LOGDIR      = $opt{'LOGDIR'};
+my $SHORT       = $opt{'SHORT'};
+my $XSASTART    = $opt{'XSASTART'};
+my $XSAEND      = $opt{'XSAEND'};
+my $LOGROOT     = $opt{'LOGROOT'};
 # Output
-my $dir=$LOGROOT;
-my $output="$dir/logs-$short/webpage.html";
+my $OUTPUTFILE  = $opt{'OUTPUTFILE'};
 
 # Input
-my $xen_log="$dir/logs-$short/xen_$short-pretty.log";
-my $qemuu_log="$dir/logs-$short/qemuu_$short-pretty.log";
-my $qemut_log="$dir/logs-$short/qemut_$short-pretty.log";
+my $xen_log     = "$LOGDIR/xen_$SHORT-pretty.log";
+my $qemuu_log   = "$LOGDIR/qemuu_$SHORT-pretty.log";
+my $qemut_log   = "$LOGDIR/qemut_$SHORT-pretty.log";
 
 my $s;
 my $releaseshort=$VERSION.".".$MAJOR;
@@ -117,4 +102,4 @@ $s .= 'for details related to Xen Project security advisories.</p>'."\n";
 $s .= '<p>We recommend all users of the '.$releaseshort.' stable series to update to this latest point release.</p>'."\n";
 
 # WRITE REPORT
-write_file($output, $s);     
\ No newline at end of file
+write_file($OUTPUTFILE, $s);
index 1b4c1d19d4b7eccdfb562a252543139e679cb8ec..986caa8d256bdf20e573e5dad22be09b10c510b9 100755 (executable)
--- a/match-xsa
+++ b/match-xsa
@@ -1,92 +1,44 @@
 #!/usr/bin/perl
 # Usage
-# $0 --version 4 --major 7 --since 0 [--until 1] 
-#   [--getlogs] [--smart] [--debug] [--html] 
-#   [--logroot directory]
-#   [--xsadir xsadir] --xsa xsafile
+# See lib/myoptions.pl
 
 use strict;
 use warnings;
-use 5.010;
-use Getopt::Long qw(GetOptions);
 use Cwd;
 use File::Slurp;
 use File::Spec;
 
-my $GETLOGS=0;
-my $SMART=0;
-my $DEBUG=0;
-my $HTML=0;
-my $VERSION;
-my $MAJOR;
-my $SINCE="none";
-my $UNTIL="stable";
-my $XSAFILE;
-my $XSADIR;
-my $XSAFETCH;
-my $LOGROOT = "../xen-release-logs";
-
-GetOptions(
-    'version=s' => \$VERSION,
-    'major=s'   => \$MAJOR,
-    'since=s'   => \$SINCE,
-    'until=s'   => \$UNTIL,
-    'xsa=s'     => \$XSAFILE,
-    'xsadir=s'  => \$XSADIR,  
-    'logroot=s' => \$LOGROOT,      
-    'getlogs'   => \$GETLOGS,
-    'smart'     => \$SMART,
-    'debug'     => \$DEBUG,
-    'html'      => \$HTML,
-) or 
-die "Usage: $0 --version <xen version, e.g. 4>".
-             " --major <major version>".
-             " [--since <minor version start>]".
-             " [--until <minor version end>]".
-             " [--smart] [--debug] [--html]".
-             " [--getlogs]".
-             " [--xsadir xsadir (default=../xsaweb; files fetched from".
-             " http://xenbits.xenproject.org/xsa/)]".
-             " [--logroot directory (default=../xen_release_logs)]".
-             " --xsa xsafile\n";
-if ($GETLOGS) {
-    system("./xen-release-logs --version $VERSION --major $MAJOR --since ".
-           "$SINCE --until $UNTIL --logroot $LOGROOT");
-}
-
-# Calculate log file names
-my $short="$VERSION$MAJOR$SINCE-$UNTIL";
-
-# Set up XSADIR and XSAFETCH, if not set
-if (!$XSADIR) {
-   $XSAFETCH = "https://xenbits.xenproject.org/xsa/";
-   $XSADIR = "../xsaweb";
-   system("rm -rf $XSADIR");
-   mkdir $XSADIR;
-}
-
-# Make relative paths absolute
-$LOGROOT = File::Spec->rel2abs($LOGROOT);
-$XSADIR = File::Spec->rel2abs($XSADIR);
-
-# Directories
-if (! -e $LOGROOT) {
-    mkdir $LOGROOT;
-}
-
-my $debug="$LOGROOT/logs-$short/debug";
-my $xen_git="$LOGROOT/logs-$short/xen";
-my $qemuu_git="$LOGROOT/logs-$short/qemu-xen";
-my $qemut_git="$LOGROOT/logs-$short/qemu-xen-traditional";
-my $xsa=$XSADIR;
-
-if ($DEBUG != 0) { 
-    system("rm -rf $debug");
-    mkdir $debug;
-}
-
-# Get the xsafile
+use FindBin;
+use lib $FindBin::Bin.'/lib';
+
+use MyOptions;
+
+my %opt = options_matchxsa();
+
+# Copy Variables from Options
+my $GETLOGS     = $opt{'GETLOGS'};
+my $SMART       = $opt{'SMART'};
+my $DEBUG       = $opt{'DEBUG'};
+my $HTML        = $opt{'HTML'};
+my $VERSION     = $opt{'VERSION'};
+my $MAJOR       = $opt{'MAJOR'};
+my $SINCE       = $opt{'SINCE'};
+my $UNTIL       = $opt{'UNTIL'};
+my $LOGDIR      = $opt{'LOGDIR'};
+my $SHORT       = $opt{'SHORT'};
+my $XSALISTFILE = $opt{'XSALISTFILE'};
+my $XSADIR      = $opt{'XSADIR'};
+my $XSAFETCH    = $opt{'XSAFETCH'};
+my $LOGROOT     = $opt{'LOGROOT'};
+
+my $debug       = $opt{'DEBUGDIR'};
+my $xen_git     = $opt{'XEN_GIT'} ;
+my $qemuu_git   = $opt{'QEMUU_GIT'};
+my $qemut_git   = $opt{'QEMUT_GIT'};
+my $xsa         = $XSADIR;
+
+
+# Get the xsa list file
 my @XSA;
 my $XSAs;
 my @XSA_PATCH;
@@ -97,7 +49,7 @@ my @XSA_REPO;
 
 my $i=0;
 
-open(my $data, '<', $XSAFILE) or die "Could not open '$XSAFILE' $!\n";
+open(my $data, '<', $XSALISTFILE) or die "Could not open '$XSALISTFILE' $!\n";
 while (my $line = <$data>) {
   chomp $line;
  
@@ -137,13 +89,13 @@ my @LOGQEMUU_hash;
 my @LOGQEMUT;
 my @LOGQEMUT_hash;
 
-getlogs("$LOGROOT/logs-$short/xen_$short", \@LOGXEN, \@LOGXEN_hash);
-getlogs("$LOGROOT/logs-$short/qemuu_$short", \@LOGQEMUU, \@LOGQEMUU_hash);
-getlogs("$LOGROOT/logs-$short/qemut_$short", \@LOGQEMUT, \@LOGQEMUT_hash);
+getlogs("$LOGDIR/xen_$SHORT", \@LOGXEN, \@LOGXEN_hash);
+getlogs("$LOGDIR/qemuu_$SHORT", \@LOGQEMUU, \@LOGQEMUU_hash);
+getlogs("$LOGDIR/qemut_$SHORT", \@LOGQEMUT, \@LOGQEMUT_hash);
 
 # Do the actual matching
-print "CHECKING '$XSAFILE' against 'xen_$short.log', 'qemuu_$short.log' ".
-      "and 'qemut_$short.log'.\n";
+print "CHECKING '$XSALISTFILE' against 'xen_$SHORT.log', 'qemuu_$SHORT.log' ".
+      "and 'qemut_$SHORT.log'.\n";
 print "\n";
 for ($i=0; $i <= $XSAs; $i++) {
    my $j=0;
index 8736462a6b31fa79f06a503830995e456aed5357..068e088e1e5bfae9dc815b8743879a5eef1b790a 100755 (executable)
 #   xen-release-logs --version 4 --major 7 
 #   xen-release-logs --version 4 --major 7 --until 0 
 #
-# Additional Options:
-#   specify EXISTING  log root directory, e.g. ../xen-release-logs
-#   xen-release-logs ... --logroot <directory> 
-#
-# DEBUG OPTIONS
-#   xen-release-logs ... --nocheckout 
-#
-# Note: Git repos are checked out in directories specific to options
-#       This option is mainly useful for debugging the script or when changes
-#       to the script are made
+# Further Usage
+# See lib/myoptions.pl
 
 use strict;
 use warnings;
-use 5.010;
+use FindBin;
+use lib $FindBin::Bin.'/lib';
+
+use MyOptions;
 use Cwd;
-use Getopt::Long qw(GetOptions);
-
-my $USAGE="--version v --major m [--since s] [--until u] [--nocheckout] [--logroot directory]\n";
-
-my $VERSION="none";
-my $MAJOR="none";
-my $UNTIL="stable";
-my $SINCE="none";
-my $NOCHECKOUT=0;
-my $LOGROOT=".";
-
-GetOptions(
-    'version=s'  => \$VERSION,
-    'major=s'    => \$MAJOR,
-    'since=s'    => \$SINCE,
-    'until=s'    => \$UNTIL,
-    'logroot=s'  => \$LOGROOT,      
-    'nocheckout' => \$NOCHECKOUT,
-) or die "Usage: ".$0." ".$USAGE."\n";
-             
-# Error checking
-if ($VERSION eq "none" ) {
-  die "Usage: ".$0." ".$USAGE."\n".
-      "       --version not specified\n";
-}
-if ($MAJOR eq "none" ) {
-  die "Usage: ".$0." ".$USAGE."\n".
-      "       --major not specified\n";
-}
+
+my %opt = options_xenreleaselogs();
+
+# Copy Variables from Options
+my $VERSION    = $opt{'VERSION'};
+my $MAJOR      = $opt{'MAJOR'};
+my $SINCE      = $opt{'SINCE'};
+my $UNTIL      = $opt{'UNTIL'};
+my $LOGDIR     = $opt{'LOGDIR'};
+my $SHORT      = $opt{'SHORT'};
+my $NOCHECKOUT = $opt{'NOCHECKOUT'};
 
 # Set up variables
 my $MAJOR_LAST=$MAJOR-1;
@@ -61,16 +38,14 @@ my $S;
 my $U;
 my $L;
 
-my $SHORT=$VERSION.$MAJOR.$SINCE."-".$UNTIL;
-my $DIR=$LOGROOT."/logs-".$SHORT;
 my $SERIES=$VERSION.".".$MAJOR;
 my $SERIES_LAST=$VERSION.".".$MAJOR_LAST;
 
 if (!$NOCHECKOUT) {
-  system("rm -rf $DIR");
-  mkdir $DIR;
+  system("rm -rf $LOGDIR");
+  mkdir $LOGDIR;
 }
-chdir $DIR;
+chdir $LOGDIR;
 
 if (!$NOCHECKOUT) {
   print "\n";