From: Lars Kurth Date: Tue, 18 Jul 2017 19:14:47 +0000 (+0100) Subject: Added support for fetching *.patch files from xenbits when --xsadir is not specified X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=6d371d6adccc36eeeb5d2acd412ba0f3424a4a15;p=people%2Flarsk%2Fxen-release-scripts.git Added support for fetching *.patch files from xenbits when --xsadir is not specified --- diff --git a/README b/README index e15d4b9..a772620 100644 --- a/README +++ b/README @@ -7,7 +7,7 @@ To keep things clean, I use the following directory structure - xen-release-logs [output/input directory] - xen-release-scripts [git repo] - xsa-lists [output/input directory, see steps 1-5 in match-xsa] - - xsa [git repo] + - xsa [git repo, optional] xen-release-logs ================ diff --git a/match-xsa b/match-xsa index b9f77e8..b65cb79 100755 --- a/match-xsa +++ b/match-xsa @@ -22,7 +22,8 @@ my $MAJOR; my $SINCE="none"; my $UNTIL="stable"; my $XSAFILE; -my $XSADIR = File::Spec->canonpath(cwd()."/../xsa" ); +my $XSADIR; +my $XSAFETCH; my $LOGROOT = File::Spec->canonpath(cwd()."/../xen-release-logs" ); GetOptions( @@ -44,8 +45,8 @@ die "Usage: $0 --version ". " [--until ]". " [--smart] [--debug] [--html]". " [--getlogs]". - " [--xsadir xsadir(default=../xsa)]". - " [--logroot directory(default=../xen_release_logs)]". + " [--xsadir xsadir (default=../xsaweb; files fetched from http://xenbits.xenproject.org/xsa/)]". + " [--logroot directory (default=../xen_release_logs)]". " --xsa xsafile\n"; if ($GETLOGS) { @@ -55,6 +56,14 @@ if ($GETLOGS) { # Calculate log file names my $short="$VERSION$MAJOR$SINCE-$UNTIL"; +# Set up XSADIR and XSAFETCH, if not set +if (!$XSADIR && $SMART!=0) { + $XSAFETCH = "https://xenbits.xenproject.org/xsa/"; + $XSADIR = File::Spec->canonpath(cwd()."/../xsaweb" ); + system("rm -rf $XSADIR"); + mkdir $XSADIR; +} + # Directories if (! -e $LOGROOT) { mkdir $LOGROOT; @@ -331,6 +340,20 @@ sub matchsmart { chdir($git_dir); my $git_command="git show ".@$loghash_ref[$index].' --format=""'; my $diff_git = `$git_command`; + + if ($XSAFETCH) { + my $path=""; + # Check whether $XSA_PATCH[$i] contains a path + my $index = rindex($XSA_PATCH[$i], "/"); + if ($index != -1) { + $path = "/".substr($XSA_PATCH[$i], 0, $index); + } + if (! -d "$xsa_dir$path") { + system("mkdir $xsa_dir$path"); + } + system("wget --quiet --no-check-certificate -P $xsa_dir$path $XSAFETCH/$XSA_PATCH[$i]"); + } + my $patch = read_file("$xsa_dir/$XSA_PATCH[$i]"); my $diff_git_n = normalize_diff($diff_git); @@ -445,4 +468,4 @@ sub normalize_diff { } return join "\n", @newlines; -} +} \ No newline at end of file