stage_4 support

Signed-off-by: Mike Marchetti <mmarchetti@sandvine.com>
Change-Id: Ic997b0baf6ad9cedf486a506f050e016a0c5796a
diff --git a/tools/.gitignore b/tools/.gitignore
new file mode 100644
index 0000000..d250963
--- /dev/null
+++ b/tools/.gitignore
@@ -0,0 +1 @@
+repos/*
diff --git a/tools/gen-repo.sh b/tools/gen-repo.sh
index 6fb2ad8..502b941 100755
--- a/tools/gen-repo.sh
+++ b/tools/gen-repo.sh
@@ -14,6 +14,7 @@
     echo -e "  -h  <rsync user@host>    "
     echo -e "  -R  <rsync options>      "
     echo -e "  -P  <public key file>    "
+    echo -e "  -c  <changelogfile>      "
     exit 1
 }
 
@@ -46,8 +47,9 @@
 RSYNC_USER_HOST=osmusers@osm-download.etsi.org
 CURR_DIR=$(pwd)
 PUBLIC_KEY_FILE=~/OSM\ ETSI\ Release\ Key.gpg
+CHANGE_LOG_FILE=
 
-while getopts ":p:i:o:k:j::d:b:r:h:R:P:" o; do
+while getopts ":p:i:o:k:j::d:b:r:h:R:P:c:" o; do
     case "${o}" in
         p)
             PASSPHRASE_FILE=${OPTARG}
@@ -82,6 +84,9 @@
         P)
             PUBLIC_KEY_FILE=${OPTARG}
             ;;
+        c)
+            CHANGE_LOG_FILE=${OPTARG}
+            ;;
         *)
             usage
             exit 1
@@ -139,4 +144,7 @@
 # copy over the public key file
 [ "$PUBLIC_KEY_FILE" ] && cp "$PUBLIC_KEY_FILE" osm/debian/$RELEASE_DIR
 
+# copy over the changelog file
+[ "$CHANGE_LOG_FILE" ] && cp "$CHANGE_LOG_FILE" osm/debian/$RELEASE_DIR
+
 rsync -avR $RSYNC_OPTIONS osm/debian/$RELEASE_DIR rsync://$RSYNC_USER_HOST/repos
diff --git a/tools/generatechangelog.sh b/tools/generatechangelog.sh
new file mode 100755
index 0000000..33a5302
--- /dev/null
+++ b/tools/generatechangelog.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+if [ $# -ne 2 ]; then
+    echo "Usage $0 <repo> <outfile>"
+    exit 1
+fi
+
+REPO="$1"
+OUTFILE=$2
+
+modules="devops openvim RO SO UI IM osmclient"
+list=""
+for i in $modules; do
+    if [ $REPO == "$i" -o $REPO == "all" ]; then
+        list=$REPO
+        break
+    fi
+done
+
+[ $REPO == "all" ] && list=$modules
+
+if [ -z "$list" ]; then
+    echo "Repo must be one of these: $modules all"
+    exit 1
+fi
+
+echo "<h1>OSM Changelog</h1>" >> $OUTFILE
+for i in $list; do
+    echo
+    echo $i
+    if [ ! -d $i ]; then
+        git clone https://osm.etsi.org/gerrit/osm/$i
+    fi
+    git -C $i checkout master
+    git -C $i pull --rebase
+    git -C $i fetch --tags
+    TAG_START=$(git -C $i tag | sort -Vr | head -2 | sort -V | head -1)
+    TAG_END=$(git -C $i tag | sort -Vr | head -1)
+    echo "<h2>Changes for $i tag: ${TAG_START}..${TAG_END}</h2>" >> $OUTFILE
+    #git -C $i log --pretty=format:"* %h; author: %cn; date: %ci; subject:%s" ${TAG_START}..${TAG_END} >> $OUTFILE
+    git -C $i log --pretty=format:"<li> <a href=https://osm.etsi.org/gitweb/?p=osm/$i.git;a=commitdiff;h=%H>%h &bull;</a> %s</li> " --reverse  ${TAG_START}..${TAG_END} >> $OUTFILE
+    echo "" >> $OUTFILE
+done
+
+exit 0