]> xenbits.xensource.com Git - people/larsk/xen-release-scripts.git/commitdiff
Re-wrote xen-release-logs in perl such that it works on Mac and Linux
authorLars Kurth <lars.kurth@citrix.com>
Wed, 19 Jul 2017 12:23:45 +0000 (13:23 +0100)
committerLars Kurth <lars.kurth@citrix.com>
Wed, 19 Jul 2017 12:23:45 +0000 (13:23 +0100)
README
xen-release-logs

diff --git a/README b/README
index e5e8911ec8ae2a92d420625528fe65003f7bed0c..9e19d864df880210fed41482d4283a764d1bded4 100644 (file)
--- a/README
+++ b/README
@@ -11,7 +11,7 @@ To keep things clean, I use the following directory structure
 
 prerequisites
 =============
-match-xsa, requires perl and the following perl libraries
+match-xsa and xen-release-logs, require perl and the following perl libraries
 
     libfile-slurp-perl  
     libfile-spec-perl  
index c8a297a3c7aca5e2ceaea38480af797928662965..ecae9565a42184a3029633fc262c28c38eefd142 100755 (executable)
-#!/bin/sh
-# Usage
-# xen-release-logs --version 4 --major 7 --since 0
-# xen-release-logs --version 4 --major 7 --since 0 --until 1
-# xen-release-logs --version 4 --major 7 (for new major releases)
-# xen-release-logs --version 4 --major 7 --until 0 (for new major releases)
-# xen-release-logs --nocheckout (does not check out tree)
-# xen-release-logs --logroot <directory> (needs to exist)
-
-USAGE="Usage: xen-release-logs --version v --major m [--since s] [--until u] [--nocheckout] [--logroot directory]\n"
-
-VERSION="none"
-MAJOR="none"
-UNTIL="stable"
-SINCE="none"
-NOCHECKOUT="false"
-LOGROOT=".";
-
-while [[ $# -gt 1 ]]
-do
-key="$1"
-
-case $key in
-    -v|--version)
-    VERSION="$2"
-    shift # past argument
-    ;;
-    -m|--major)
-    MAJOR="$2"
-    MAJOR_LAST=$(($2-1))
-    shift # past argument
-    ;;
-    -s|--since)
-    SINCE="$2"
-    shift # past argument
-    ;;
-    -u|--until)
-    UNTIL="$2"
-    shift # past argument
-    ;;  
-    -l|--logroot)
-    LOGROOT="$2"
-    if [ ! -d $LOGROOT ]; then
-       echo ${USAGE}
-       echo "Log directory '${LOGROOT}' does not exist"
-       exit 1;
-    fi
-    shift # past argument
-    ;;  
-    -n|--nocheckout)
-    NOCHECKOUT="true"
-    ;;      
-    *)
-    # unknown option
-    echo ${USAGE}
-    exit 1;
-    ;;
-esac
-shift # past argument or value
-done
+#!/usr/bin/perl
 
+# Usage
+#
+# For new minor releases: use --until ONLY when tree is tagged
+#   xen-release-logs --version 4 --major 7 --since 0
+#   xen-release-logs --version 4 --major 7 --since 0 --until 1
+#
+# For new major releases: use --until ONLY when tree tagged
+#   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 
+
+use strict;
+use warnings;
+use 5.010;
+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 == "none" ]; then
-   echo ${USAGE}
-   echo "--version not specified"
-   exit 1;
-fi
-if [ $MAJOR == "none" ]; then
-   echo ${USAGE}
-   echo "--major not specified"
-   exit 1;
-fi
+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";
+}
 
 # Set up variables
-SHORT="${VERSION}${MAJOR}${SINCE}-${UNTIL}"
-DIR="${LOGROOT}/logs-${SHORT}"
-SERIES="${VERSION}.${MAJOR}"
-SERIES_LAST="${VERSION}.${MAJOR_LAST}"
-
-if [ $NOCHECKOUT == "false" ]; then
-rm -rf $DIR
-mkdir $DIR
-fi
-cd $DIR
-
-echo
-echo "Fetching Git trees"
-echo "=================="
-echo
-
-if [ $NOCHECKOUT == "false" ]; then
-git clone git://xenbits.xen.org/qemu-xen-traditional.git
-git clone git://xenbits.xen.org/qemu-xen.git
-git clone git://xenbits.xen.org/xen.git
-fi
-
-echo
-echo "Getting xen.git logs"
-echo "===================="
-echo ""
-
-cd xen
-git checkout stable-$SERIES
-
-if [ $SINCE == "none" ]; then
-   S=RELEASE-$SERIES_LAST.0
-else
-   S=RELEASE-$SERIES.$SINCE
-fi
-if [ $UNTIL == "stable" ]; then
-   U=stable-$SERIES
-else
-   U=RELEASE-$SERIES.$UNTIL
-fi
-L=xen_$SHORT
-
-echo ""
-echo "START TAG: $S"
-echo "END TAG: $U"
-echo ""
-
-git log $S..$U --format=format:"<li><a href=%x22http://xenbits.xenproject.org/gitweb/?p=xen.git;a=commit;h=%H%x22>%h</a>: %s [%an]</li>" > ../$L-pretty.log
-git log $S..$U --format=format:"* [http://xenbits.xenproject.org/gitweb/?p=xen.git;a=commit;h=%H %h]: %s [%an]" > ../$L-wiki.log
-git log $S..$U --format=format:"* %h: %s [%an]" > ../$L-raw.log
-git log $S..$U --format=format:"%s" > ../$L.log
-git log $S..$U --format=format:"%H" > ../$L-hash.log
-
-echo
-echo "Getting qemu-xen.git (qemu upstream) logs"
-echo "========================================="
-echo ""
-
-cd ../qemu-xen
-git checkout stable-$SERIES
-
-if [ $SINCE == "none" ]; then
-   S=qemu-xen-$SERIES_LAST.0
-else
-   S=qemu-xen-$SERIES.$SINCE
-fi
-if [ $UNTIL == "stable" ]; then
-   U=stable-$SERIES
-else
-   U=qemu-xen-$SERIES.$UNTIL
-fi
-L=qemuu_$SHORT
-
-echo ""
-echo "START TAG: $S"
-echo "END TAG: $U"
-echo ""
-
-git log $S..$U --format=format:"<li><a href=%x22http://xenbits.xen.org/gitweb/?p=qemu-xen.git;a=commit;h=%H%x22>%h</a>: %s [%an]</li>" > ../$L-pretty.log
-git log $S..$U --format=format:"* [http://xenbits.xenproject.org/gitweb/?p=qemu-xen.git;a=commit;h=%H %h]: %s [%an]" > ../$L-wiki.log
-git log $S..$U --format=format:"* %h: %s [%an]" > ../$L-raw.log
-git log $S..$U --format=format:"%s" > ../$L.log
-git log $S..$U --format=format:"%H" > ../$L-hash.log
-
-echo
-echo "Getting qemu-xen-traditional.git (qemu traditional) logs"
-echo "========================================================"
-echo ""
-
-cd ../qemu-xen-traditional
-git checkout stable-$SERIES
-
-if [ $SINCE == "none" ]; then
-   S=xen-$SERIES_LAST.0
-else
-   S=xen-$SERIES.$SINCE
-fi
-if [ $UNTIL == "stable" ]; then
-   U=stable-$SERIES
-else
-   U=xen-$SERIES.$UNTIL
-fi
-L=qemut_$SHORT
-
-echo ""
-echo "START TAG: $S"
-echo "END TAG: $U"
-echo ""
-
-git log $S..$U --format=format:"<li><a href=%x22http://xenbits.xen.org/gitweb/?p=qemu-xen-traditional.git;a=commit;h=%H%x22>%h</a>: %s [%an]</li>" > ../$L-pretty.log
-git log $S..$U --format=format:"* [http://xenbits.xenproject.org/gitweb/?p=qemu-xen-traditional.git;a=commit;h=%H %h]: %s [%an]" > ../$L-wiki.log
-git log $S..$U --format=format:"* %h: %s [%an]" > ../$L-raw.log
-git log $S..$U --format=format:"%s" > ../$L.log
-git log $S..$U --format=format:"%H" > ../$L-hash.log
-
-echo
-echo "Log files"
-echo "========="
-echo ""
-cd ..
-ls *.log
-cd ..
\ No newline at end of file
+my $MAJOR_LAST=$MAJOR-1;
+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;
+}
+chdir $DIR;
+
+if (!$NOCHECKOUT) {
+  print "\n";
+  print "Fetching Git trees\n";
+  print "==================\n";
+  print "\n";
+
+  system("git clone git://xenbits.xen.org/qemu-xen-traditional.git");
+  system("git clone git://xenbits.xen.org/qemu-xen.git");
+  system("git clone git://xenbits.xen.org/xen.git");
+}
+
+print "\n";
+print "Getting xen.git logs\n";
+print "====================\n";
+print "\n";
+
+chdir "xen" 
+      or die "ERROR: repo xen does not exist: do not use --nocheckout\n";
+system("git checkout stable-$SERIES");
+
+if ( $SINCE eq "none" ) {
+  $S="RELEASE-".$SERIES_LAST.".0";
+} else {
+  $S="RELEASE-".$SERIES.".".$SINCE;
+}
+if ( $UNTIL eq "stable" ) {
+  $U="stable-".$SERIES;
+} else {
+  $U="RELEASE-".$SERIES.".".$UNTIL;
+}
+$L="xen_".$SHORT;
+
+getlogs($S, $U, $L, "xen.git");
+
+print "\n";
+print "Getting qemu-xen.git (qemu upstream) logs\n";
+print "=========================================\n";
+print "\n";
+
+chdir "../qemu-xen" 
+      or die "ERROR: repo qemu-xen does not exist: do not use --nocheckout\n";;
+system("git checkout stable-$SERIES");
+
+if ( $SINCE eq "none" ) {
+  $S="qemu-xen-".$SERIES_LAST.".0";
+} else {
+  $S="qemu-xen-".$SERIES.".".$SINCE;
+}
+if ( $UNTIL eq "stable" ) {
+  $U="stable-".$SERIES;
+} else {
+  $U="qemu-xen-".$SERIES.".".$UNTIL;
+}
+$L="qemuu_".$SHORT;
+
+getlogs($S, $U, $L, "qemu-xen.git");
+
+print "\n";
+print "Getting qemu-xen-traditional.git (qemu traditional) logs\n";
+print "========================================================\n";
+print "\n";
+
+chdir "../qemu-xen-traditional" 
+      or die "ERROR: repo qemu-xen-traditional does not exist: do not use --nocheckout\n";;
+system("git checkout stable-$SERIES");
+
+if ( $SINCE eq "none" ) {
+  $S="xen-".$SERIES_LAST.".0";
+} else {
+  $S="xen-".$SERIES.".".$SINCE;
+}
+if ( $UNTIL eq "stable" ) {
+  $U="stable-".$SERIES;
+} else {
+  $U="xen-".$SERIES.".".$UNTIL;
+}
+$L="qemut_".$SHORT;
+
+getlogs($S, $U, $L, "qemu-xen-traditional.git");
+
+print "\n";
+print "Log files\n";
+print "=========\n";
+print "\n";
+
+chdir "..";
+system("ls *.log");
+chdir "..";
+
+sub getlogs {
+  my $S = shift; 
+  my $U = shift;
+  my $L = shift;
+  my $P = shift;
+  
+  my $Q = '"';
+
+  print "\n";
+  print "START TAG: $S\n";
+  print "END TAG: $U\n";
+  print "\n";
+
+  system("git log $S..$U --format=format:$Q<li><a href=%x22http://xenbits.xen.org/gitweb/?p=$P;".
+         "a=commit;h=%H%x22>%h</a>: %s [%an]</li>$Q > ../$L-pretty.log");         
+  system("git log $S..$U --format=format:$Q* [https://xenbits.xenproject.org/gitweb/?p=$P;".
+         "a=commit;h=%H %h]: %s [%an]$Q > ../$L-wiki.log");    
+  system("git log $S..$U --format=format:$Q* %h: %s [%an]$Q > ../$L-raw.log");    
+  system("git log $S..$U --format=format:$Q%s$Q > ../$L.log");  
+  system("git log $S..$U --format=format:$Q%H$Q > ../$L-hash.log");
+}