]> xenbits.xensource.com Git - people/larsk/xen-release-scripts.git/commitdiff
Moved more common functionality into myoptions.pm
authorLars Kurth <lars.kurth@citrix.com>
Fri, 1 Sep 2017 16:59:30 +0000 (17:59 +0100)
committerLars Kurth <lars.kurth@citrix.com>
Fri, 1 Sep 2017 16:59:30 +0000 (17:59 +0100)
lib/myoptions.pm

index db01409d687a3a86a54aa05ae12c95cfb39f0368..c2ec0f017799bac4cdd4a805a6fe720c4232749d 100755 (executable)
@@ -19,6 +19,10 @@ my %o = (
     'XSALISTDIR' => "../xsa-lists",
 # LATER: Remove these
     'NOCHECKOUT' => 0,
+    'GETLOGS'    => 0,
+    'SMART'      => 0,
+    'DEBUG'      => 0,
+    'HTML'       => 0,
 );
 
 my %optionspec = (
@@ -75,8 +79,6 @@ sub handleoptions {
         "       --major not specified\n";
     }
     
-    # XSADIR SPECIAL CASING?
-    
     # Normalize Calculate Derived Options
     $o{'SHORT'}       = $o{'VERSION'}.$o{'MAJOR'}.$o{'SINCE'}."-".$o{'UNTIL'};
     $o{'LOGROOT'}     = File::Spec->rel2abs($o{'LOGROOT'});
@@ -84,9 +86,13 @@ sub handleoptions {
         mkdir $o{'LOGROOT'};
     }
     $o{'LOGDIR'}      = $o{'LOGROOT'}."/logs-".$o{'SHORT'};
-    $o{'OUTPUTFILE'}  = $o{'LOGDIR'}."/".$o{'OUTPUTFILE'};
+    $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";
@@ -102,7 +108,7 @@ sub options_matchxsa {
             " [--outputfile filename (relative to logdir)]".
 #           " [--smart] [--debug] [--html]".
 #           " [--getlogs]".
-            " [--xsadir xsadir (default=../xsaweb; files fetched from".
+            " [--xsadir xsadir (default=LOGDIR/tmp/xsaweb; files fetched from".
             " http://xenbits.xenproject.org/xsa/)]".
             " [--logroot directory]".
             " [--xsalistdir directory]".
@@ -117,17 +123,25 @@ sub options_matchxsa {
     }
     
     # Calculate extra options
-    $o{'XSALISTDIR'}  = File::Spec->rel2abs($o{'XSALISTDIR'});
-    $o{'XSALISTFILE'} = $o{'XSALISTDIR'}."/".$o{'XSALIST'};
+    $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 $o{'XSALISTDIR'}) {
+    if (!-d $opt{'XSALISTDIR'}) {
         die "Usage: $0".$u."\n".
-        "       directory ".$o{'XSALISTDIR'}." does not exist.\n";
+        "       directory ".$opt{'XSALISTDIR'}." does not exist.\n";
     }
-    if (!-f $o{'XSALISTFILE'}) {
+    if (!-f $opt{'XSALISTFILE'}) {
         die "Usage: $0".$u."\n".
-        "       file ".$o{'XSALISTFILE'}." does not exist.\n";
+        "       file ".$opt{'XSALISTFILE'}." does not exist.\n";
     }
     
     return %opt;
@@ -161,12 +175,12 @@ sub options_makewebpage {
     my %opt = handleoptions("output_webpage.html", $u);
 
     # Error checking
-    if (! defined $o{'XSASTART'}) {
+    if (! defined $opt{'XSASTART'}) {
         die "Usage: $0".$u."\n".
         "       --xsastart not specified\n";
     }
     # Error checking
-    if (! defined $o{'XSAEND'}) {
+    if (! defined $opt{'XSAEND'}) {
         die "Usage: $0".$u."\n".
         "       --xsasend not specified\n";
     }