Author: sebb Date: Mon Apr 25 23:33:41 2016 New Revision: 1740926 URL: http://svn.apache.org/viewvc?rev=1740926&view=rev Log: Add some developer scripts
Added: commons/scripts/AAREADME.txt (with props) commons/scripts/Nexus2DistDev.sh (with props) commons/scripts/create_RC_tag.sh (with props) Added: commons/scripts/AAREADME.txt URL: http://svn.apache.org/viewvc/commons/scripts/AAREADME.txt?rev=1740926&view=auto ============================================================================== --- commons/scripts/AAREADME.txt (added) +++ commons/scripts/AAREADME.txt Mon Apr 25 23:33:41 2016 @@ -0,0 +1,3 @@ +A collection of scripts that may be useful for Commons Developers. + +These are not not intended to be formally released. \ No newline at end of file Propchange: commons/scripts/AAREADME.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/scripts/Nexus2DistDev.sh URL: http://svn.apache.org/viewvc/commons/scripts/Nexus2DistDev.sh?rev=1740926&view=auto ============================================================================== --- commons/scripts/Nexus2DistDev.sh (added) +++ commons/scripts/Nexus2DistDev.sh Mon Apr 25 23:33:41 2016 @@ -0,0 +1,141 @@ +#!/bin/bash + +# @(#) Extract files from Nexus and add to dist/dev SVN tree + +# This script is intended to be run from the tag directory where the release was built +# The Nexus staging area should still be open. + +# Parameters: +# 1: the NEXUS number of the directory +# 2: optional password; if provided the artifacts and sigs/hashes are deleted from Nexus +# +# Required environment variables: +# COMMONS_TAGS - pathname of work directory where tags are created +# Defaults to $HOME/CommonsTags if that exists +# USER - LDAP login name to be used for Nexus + +# Usage: +# Initially the script is run with just the Nexus number. +# This creates a workspace from https://dist.apache.org/repos/dist/dev/commons/<component> +# and populates it from Nexus. +# If necessary this can be repeated (delete the workspace first) +# Once the workspace has been successfully populated it can be committed (the script does not currently do this) +# The script can be run again, this time with the password, and it will delete the downloaded artifacts from Nexus +# N.B. *** Since the password is passed on the command-line, this should not be run on a shared system. *** +# The Nexus staging area can then be closed. + +# What it does: +# - extracts GID/AID/VER from POM +# - extracts SVNDIR from developerConnection +# - checks that the Nexus directory exists +# - changes to the Tags dir +# - extracts the current dist/dev tree +# - Creates a new subdir <version>_RC +# - copies RELEASE-NOTES.txt if present in the original directory +# - downloads the source and binary zip and tar.gz archives +# - runs gpg --verify on the asc files +# - SVN adds the files +# +# Does not commit the updated workspace + +# TODO: +# Consider using svnmucc put instead of SVN checkout/update workspace/checkin +# Nexus returns an XML doc instead of an HTML index for the parent doc. +# The XML could be used to provide the actual file names instead of assuming them; +# would be easier to do that in Java in which case this could be converted into a Maven plugin + +cleanup() { + rv=$? + echo Currently working in $(pwd) + exit $rv +} + +trap "cleanup" EXIT + +STARTDIR=$(pwd) + +NEXUS=${1:?Need Nexus id, e.g. 11nn} +PASS=$2 + +BASEDIR=https://repository.apache.org/service/local/repositories/orgapachecommons-${NEXUS}/content + + +# Work area for tags +TAGS=${COMMONS_TAGS:-${HOME}/CommonsTags} + +# Extract a property value from the pom +function scrapePom() { + sed -n -e "s!.*<$1>\(.*\)</$1>.*!\1!p" pom.xml +} + +# Assume the gid/aid/ver are second in the file (i.e. after the parent) +GID=$(scrapePom groupId | sed -n -e '2p' | tr '.' '/') +AID=$(scrapePom artifactId | sed -n -e 2p) +VER=$(scrapePom version | sed -n -e 2p) + +echo $VER | fgrep -q -- '-SNAPSHOT' && { echo "Invalid (SNAPSHOT) version: $VER"; exit 1; } + +# Extract the SVN dir name - this is also used for dist/dev tree +# TODO How to get this for Git-based projects? +SVNDIR=$(scrapePom developerConnection | sed -n -e 's!.*/proper/\(.*\)/tags.*!\1!p') + +test -z "$SVNDIR" && { echo Could not extract SVNDIR; exit 1; } + +NEXUSDIR=${BASEDIR}/$GID/$AID/$VER + +echo Checking $NEXUSDIR +curl --head -f -sS $NEXUSDIR >/dev/null || exit + +if [ "$PASS" == '' ] +then + + RC=$(scrapePom commons.rc.version) + + TAGNAMERC="${VER}_$RC" + + cd ${TAGS} || exit + + svn co https://dist.apache.org/repos/dist/dev/commons/${SVNDIR}/ ${SVNDIR}-dev-dist || exit + + cd ${SVNDIR}-dev-dist || exit + + mkdir $TAGNAMERC #|| exit + + svn add $TAGNAMERC || exit + + cd $TAGNAMERC || exit + + if [ -r $STARTDIR/RELEASE-NOTES.txt ] + then + cp $STARTDIR/RELEASE-NOTES.txt . + svn add RELEASE-NOTES.txt + fi + +fi + +handle() { + FILE=$NEXUSDIR/${AID}-${VER}-$1$2 + if [ "$PASS" == '' ] + then + echo Getting ${AID}-${VER}-$1$2 + wget -nv -q $FILE || { echo Failed to download $FILE; exit 1; } + if [ "$2" == ".asc" ] + then + gpg --verify ${AID}-${VER}-$1$2 ${AID}-${VER}-$1 || exit + fi + svn add ${AID}-${VER}-$1$2 || exit + else + curl --user $USER:$PASS --request DELETE $FILE || exit + fi +} + +for t in src bin +do + for a in zip tar.gz + do + for x in '' .asc .sha1 .md5 + do + handle $t.$a $x || exit + done + done +done Propchange: commons/scripts/Nexus2DistDev.sh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: commons/scripts/Nexus2DistDev.sh ------------------------------------------------------------------------------ svn:executable = * Added: commons/scripts/create_RC_tag.sh URL: http://svn.apache.org/viewvc/commons/scripts/create_RC_tag.sh?rev=1740926&view=auto ============================================================================== --- commons/scripts/create_RC_tag.sh (added) +++ commons/scripts/create_RC_tag.sh Mon Apr 25 23:33:41 2016 @@ -0,0 +1,61 @@ +# @(#) create a Commons Tag for an RC vote + +TAGS=${COMMONS_TAGS:-${HOME}/CommonsTags} + +svn -u st # is the workspace clean? + +function scrapePom() { + sed -n -e "s!.*<$1>\(.*\)</$1>.*!\1!p" pom.xml +} + +developerConnection=$(scrapePom developerConnection | sed -e s'!scm:svn:!!') +tagURL=$(echo $developerConnection | sed -e 's!/trunk/*.*!/tags!') + +# Extract the SVN dir name - also used for dist/dev tree +SVNDIR=$(echo $developerConnection | sed -n -e 's!.*/proper/\(.*\)/trunk.*!\1!p') + +if [ "$SVNDIR" == 'commons-parent' ] +then + PFX=$SVNDIR +else + # Other prefixes use upper case + PFX=$(echo $SVNDIR | tr '[a-z]' '[A-Z]') +fi + +# There should only be one version with SNAPSHOT suffix in the pom +VER=$(scrapePom version | sed -n -e '2p') + +echo $VER | fgrep -q -- '-SNAPSHOT' || { echo "Invalid (non-SNAPSHOT) version: $VER"; exit 1; } + +VERUN=$(echo $VER | sed -e 's!-SNAPSHOT!!'| tr '.' '_') + +RC=$(scrapePom commons.rc.version) + +TAGNAME="${PFX}_${VERUN}" +TAGNAMERC="${TAGNAME}_$RC" + +cd ${TAGS} || exit + +if [ -r ${TAGNAMERC}_TEMP ] +then + echo "${TAGNAMERC}_TEMP already exists!" + exit 1 +fi + +svn co ${developerConnection} ${TAGNAMERC}_TEMP || exit + +cd ${TAGNAMERC}_TEMP || exit + +mvn versions:set -DnewVersion=$VER -DgenerateBackupPoms=false + +sed -e "s!/trunk/*<!/tags/$TAGNAME<!" pom.xml >pom.xml.tmp +mv pom.xml.tmp pom.xml || exit + +svn diff + +cd ${TAGS} || exit + +svn copy ${TAGNAMERC}_TEMP -m "Creating $TAGNAMERC tag" ${tagURL}/$TAGNAMERC + +svn co ${tagURL}/$TAGNAMERC + Propchange: commons/scripts/create_RC_tag.sh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: commons/scripts/create_RC_tag.sh ------------------------------------------------------------------------------ svn:executable = *