diff options
author | Mikaël Barbero | 2014-01-24 09:07:22 +0000 |
---|---|---|
committer | Mikaël Barbero | 2014-01-24 09:07:22 +0000 |
commit | a3daf0b777c280448a3082f7b04f20091c64f84c (patch) | |
tree | 044178b1cfacca528732784c69b6e95b1d1dc00b | |
parent | 1aa5096099377cb8e34c93ee4740cc5c2a4caa17 (diff) | |
download | org.eclipse.emf.compare-a3daf0b777c280448a3082f7b04f20091c64f84c.tar.gz org.eclipse.emf.compare-a3daf0b777c280448a3082f7b04f20091c64f84c.tar.xz org.eclipse.emf.compare-a3daf0b777c280448a3082f7b04f20091c64f84c.zip |
Parameterized build and fix issues in "latest" publication
Change-Id: Id58eb8e7bee180a6eae547e32829694d556f6ace
-rw-r--r-- | org.eclipse.emf.compare-parent/releng/common.sh | 86 | ||||
-rwxr-xr-x | org.eclipse.emf.compare-parent/releng/publish-nightly.sh | 263 |
2 files changed, 223 insertions, 126 deletions
diff --git a/org.eclipse.emf.compare-parent/releng/common.sh b/org.eclipse.emf.compare-parent/releng/common.sh index 26461f51b..eabd21ac4 100644 --- a/org.eclipse.emf.compare-parent/releng/common.sh +++ b/org.eclipse.emf.compare-parent/releng/common.sh @@ -10,9 +10,6 @@ # Obeo - initial API and implementation # ==================================================================== -# For testing -#export BUILD_ID=$(date "+%Y-%m-%d_%H-%M-%S") - # The path to the p2-admin executable export P2_ADMIN_PATH="/jobs/genie.modeling.emfcompare/p2-admin/lastStable/archive/org.eclipselabs.equinox.p2.admin.product/target/products/org.eclipse.equinox.p2.admin.rcp.product/linux/gtk/x86_64/p2admin" @@ -46,6 +43,7 @@ chmod u+x $P2_ADMIN_PATH alias p2-admin="$P2_ADMIN_PATH" alias composite-repository="p2-admin -application org.eclipselabs.equinox.p2.composite.repository -compressed" +# Create a p2 index file for composite repositories createP2Index() { cat > "$1/p2.index" <<EOF version = 1 @@ -57,9 +55,9 @@ EOF # Remove any previous file from the $1 path and create a composite repository with a single # child ($2). The composite will be name $3. createRedirect() { - local from=$1 - local to=$2 - local name=$3 + local from="$1" + local to="$2" + local name="$3" mkdir -p "$from" rm -f "$from/compositeArtifacts."* @@ -71,8 +69,8 @@ createRedirect() { # Echo a negative integer, zero, or a positive integer if $1 version is less than, equal to, # or greater than the specified $2 version. compareOSGIVersions() { - local this=$1 - local that=$2 + local this="$1" + local that="$2" thisMajor=`echo $this | cut -d . -f1` thisMinor=`echo $this | cut -d . -f2` thisMicro=`echo $this | cut -d . -f3` @@ -95,43 +93,46 @@ compareOSGIVersions() { # print all major versions (sorted) in the $1 path on the standard output # the output will be a list of integer allMajors() { - local path=$1 + local path="$1" find-regex "$path" -regex '^'"$path"'/?[0-9]+\.[0-9]+\.[0-9]+-[NIR][0-9]{8}-[0-9]{6}$' -type d \ | sed-regex -e 's#^'"$path"'/?([0-9]+)\.([0-9]+)\.([0-9]+)-([NIR])([0-9]{8})-([0-9]{6})$#\1#' \ - | sort -t . -un -k1,1 -k2,2 -k3,3 + | sort -un } # print all minor versions (sorted) for the given $2 major version in the $1 path on the standard output # $2 must be an integer # the output will be a list of the form X.Y allMinors() { - local path=$1 - local major=$2 + local path="$1" + local major="$2" find-regex "$path" -regex '^'"$path"'/?'"$major"'\.[0-9]+\.[0-9]+-[NIR][0-9]{8}-[0-9]{6}$' -type d \ - | sed-regex -e 's#^'"$path"'/?([0-9]+)\.([0-9]+)\.([0-9]+)-([NIR])([0-9]{8})-([0-9]{6})$#\1.\2#' \ - | sort -t . -un -k2,2 -k3,3 + | sed-regex -e 's#^'"$path"'/?([0-9]+)\.([0-9]+)\.([0-9]+)-([NIR])([0-9]{8})-([0-9]{6})$#\2#' \ + | sort -un } # print all micro versions (sorted) for the given $2 minor version in the $1 path on the standard output # $2 must be of the form x.y where x and y are integer # the output will be a list of the form X.Y.Z allMicros() { - local path=$1 - local minor=$2 - find-regex "$path" -regex '^'"$path"'/?'"$minor"'\.[0-9]+-[NIR][0-9]{8}-[0-9]{6}$' -type d \ - | sed-regex -e 's#^'"$path"'/?([0-9]+)\.([0-9]+)\.([0-9]+)-([NIR])([0-9]{8})-([0-9]{6})$#\1.\2.\3#' \ - | sort -t . -un -k3,3 + local path="$1" + local major="$2" + local minor="$3" + find-regex "$path" -regex '^'"$path"'/?'"$major"'\.'"$minor"'\.[0-9]+-[NIR][0-9]{8}-[0-9]{6}$' -type d \ + | sed-regex -e 's#^'"$path"'/?([0-9]+)\.([0-9]+)\.([0-9]+)-([NIR])([0-9]{8})-([0-9]{6})$#\3#' \ + | sort -un } # print all builds (sorted) for the given $2 micro version in the $1 path on the standard output # $2 must be of the form x.y.z where x, y and z are integer # the output will be a list of the form X.Y.Z-NYYYYMMDD-HHMMSS allBuilds() { - local path=$1 - local micro=$2 - find-regex "$path" -regex '^'"$path"'/?'"$micro"'+-[NIR][0-9]{8}-[0-9]{6}$' -type d \ - | sed-regex -e 's#^'"$path"'/?([0-9]+)\.([0-9]+)\.([0-9]+)-([NIR])([0-9]{8})-([0-9]{6})$#\1.\2.\3-\4\5-\6#' \ - | sort + local path="$1" + local major="$2" + local minor="$3" + local micro="$4" + find-regex "$path" -regex '^'"$path"'/?'"$major"'\.'"$minor"'\.'"$micro"'-[NIR][0-9]{8}-[0-9]{6}$' -type d \ + | sed-regex -e 's#'"$path"'/?##' \ + | sort -u } # visit all the builds in $1 path and call the $2 callback for each. @@ -150,10 +151,10 @@ allBuilds() { # 9/ the most recent build version in the currently visited micro version (format x.y.z-TYYYYMMDD-HHMM, where x, y and z # are integer, T is N for nightly, I for integration or R for release and YYYYMMDD-HHMM is a timestamp) visitVersions() { - local path=$1 - local callback=$2 - local version=$3 - + local path="$1" + local callback="$2" + local version="$3" + allMajors=$(allMajors "$path") latestMajor=$(echo "$allMajors" | tail -1) for major in $allMajors @@ -162,15 +163,36 @@ visitVersions() { latestMinor=$(echo "$allMinors" | tail -1) for minor in $allMinors do - allMicros=$(allMicros "$path" "$minor") + allMicros=$(allMicros "$path" "$major" "$minor") latestMicro=$(echo "$allMicros" | tail -1) for micro in $allMicros do - allBuilds=$(allBuilds "$path" "$micro") + allBuilds=$(allBuilds "$path" "$major" "$minor" "$micro") latestBuild=$(echo "$allBuilds" | tail -1) $callback "$path" "$version" "$major" "$minor" "$micro" "$latestMajor" "$latestMinor" "$latestMicro" "$latestBuild" - done + done done done -}
\ No newline at end of file +} + +# Get the name of the minor stream from the $1 full version X.Y.Z. +# Example: majorStream 2.3.2 => 2.3.x +minorStream() { + local version="$1" + echo "$version" | sed-regex -e 's/^([0-9]+\.[0-9]+\.).*$/\1x/' +} + +# Get the name of the major stream from the $1 full version X.Y.Z. +# Example: majorStream 2.3.2 => 2.x +majorStream() { + local version="$1" + echo "$version" | sed-regex -e 's/^([0-9]+\.).*$/\1x/' +} + +# Converts the Hudson build id $1 (e.g. 2013-10-15_07-07-07) into the +# syntax we want for our update-sites (e.g. 20131015-070707) +buildTimestamp() { + local buildId="$1" + echo "$buildId" | sed -e 's/-//g' -e 's/_/-/' +} diff --git a/org.eclipse.emf.compare-parent/releng/publish-nightly.sh b/org.eclipse.emf.compare-parent/releng/publish-nightly.sh index de73ef333..864804736 100755 --- a/org.eclipse.emf.compare-parent/releng/publish-nightly.sh +++ b/org.eclipse.emf.compare-parent/releng/publish-nightly.sh @@ -10,158 +10,233 @@ # Obeo - initial API and implementation # ==================================================================== +# Get common function and values source common.sh -usage() { - echo "Usage: "$0" version" -} +###################################################################### +# Constants +###################################################################### -[ -z "$WORKSPACE" -o -z "$GIT_BRANCH" -o -z "$BUILD_ID" ] && { - echo "Execution aborted. +# The type of build being published +BUILD_TYPE="nightly" +BUILD_TYPE_PREFIX="N" +PROG=`basename $0` +REPOSITORY_PATH="packaging/org.eclipse.emf.compare.update/target/repository" -One or more of the required variables is not set. They are normally -provided by the Hudson build. +###################################################################### +# Arguments processing +###################################################################### -- WORKSPACE : the build workspace root. -- BUILD_ID : the Hudson build ID (e.g. 2013-10-15_07-07-07). -- GIT_BRANCH : the name fo the Git branch being build/published. -" - exit 1 +usage() { + echo "Usage: "$PROG" [-h] -v version -i build-id -w workspace" + echo " Options:" + echo " -v, --version The version to be published. Format is X.Y.Z where X, Y and Z are integer" + echo " -i, --build-id The build ID. Format is YYYY-MM-DD_HH-MM-SS" + echo " -w, --workspace The folder where the artifacts have been built" + echo " -h, --help Display this help message" } -if [ $# -le 0 ]; then - echo "$0: version argument not found" - usage - exit 1 +SHORT_OPT_STRING="hw:i:v:" +getopt -T > /dev/null +if [ $? -eq 4 ]; then + # GNU enhanced getopt is available + ARGS=`getopt --name "$PROG" --long help,workspace:,build-id:,version: --options "$SHORT_OPT_STRING" -- "$@"` else - echo $1 | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' > /dev/null - if [ $? -eq 0 ]; then - export VERSION=$1 - else - echo "$0: bad version format -- $1" - usage - exit 1 - fi + # Original getopt is available (no long option names, no whitespace, no sorting) + ARGS=`getopt "$SHORT_OPT_STRING" "$@"` +fi +if [ $? -ne 0 ]; then + usage >&2 + exit 2 +fi +eval set -- $ARGS + +while [ $# -gt 0 ]; do + case "$1" in + -h | --help) HELP=true;; + -w | --workspace) WORKSPACE="$2"; shift;; + -i | --build-id) BUILD_ID="$2"; shift;; + -v | --version) VERSION=$2; shift;; + --) shift; break;; # end of options + esac + shift +done + +if [ "$HELP" = true ]; then + usage + exit 0 fi -###################################################################### -# Setup -###################################################################### - -# Exit on error -set -e - -# The type of build being published -export BUILD_TYPE="nightly" -export BUILD_TYPE_PREFIX="N" - -# MINOR_STREAMs are of the form 1.0.x: only keep major and minor version number parts -export MINOR_STREAM=$(echo "$VERSION" | sed-regex -e 's/^([0-9]+\.[0-9]+\.).*$/\1x/') - -# MINOR_STREAMs are of the form 1.x: only keep major version number parts -export MAJOR_STREAM=$(echo "$VERSION" | sed-regex -e 's/^([0-9]+\.).*$/\1x/') +if [ -z "$WORKSPACE" ]; then + echo "$0: workspace argument is mandatory" >&2 + exit 1 +fi -# The short version, common to all versions in that MINOR_STREAM (e.g. 2.1) -export SHORT_VERSION=$(echo "$VERSION" | sed-regex -e 's/^([0-9]+\.[0-9]+)\..*$/\1/') +if [ ! -d "$WORKSPACE" ]; then + echo "$0: workspace does not exist or is not a directory -- $WORKSPACE" >&2 + exit 1 +fi -# Converts the Hudson BUILD_ID (e.g. 2013-10-15_07-07-07) into the -# syntax we want for our update-sites (e.g. 20131015-070707) -export BUILD_TIMESTAMP=$(echo "$BUILD_ID" | sed -e 's/-//g' -e 's/_/-/') +if [ -z "$BUILD_ID" ]; then + echo "$0: build-id argument is mandatory" >&2 + exit 1 +fi -# The full version for this build, e.g. 0.9.0-N20131015-070707 -export FULL_VERSION="${VERSION}-${BUILD_TYPE_PREFIX}${BUILD_TIMESTAMP}" +echo $BUILD_ID | grep -E '^[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}$' > /dev/null +if [ ! $? -eq 0 ]; then + echo "$0: bad build-id format -- $BUILD_ID" >&2 + exit 1 +fi -# The root folder where all the builds of the same type as this one -# are published -export NIGHTLY_PATH="$EMF_COMPARE_UPDATES_ROOT/$BUILD_TYPE" +if [ -z "$VERSION" ]; then + echo "$0: version argument is mandatory" >&2 + exit 1 +fi -# The folder for this particular build -export UPDATE_SITE_PATH="$NIGHTLY_PATH/$FULL_VERSION" +echo $VERSION | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' > /dev/null +if [ ! $? -eq 0 ]; then + echo "$0: bad version format -- $VERSION" >&2 + exit 1 +fi -# The URL on which this particular build will be made available -export UPDATE_SITE_URL="$EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/$FULL_VERSION" +# Exit on error +set -e # update the "latest" repositories to the new build. Should be used as a callback in # function visitVersions +# 1/ the path +# 2/ the version of interrest +# 3/ the currently visited major version (format x, where x is an integer) +# 4/ the currently visited minor version (format x.y, where x and y are integer) +# 5/ the currently visited micro version (format x.y.z, where x, y and z are integer) +# 6/ the most recent major version in the given $1 path (format x, where x is an integer) +# 7/ the most recent minor version in the currently visited major version (format x.y, where x and y are integer) +# 8/ the most recent micro version in the currently visited minor version (format x.y.z, where x, y and z are integer) +# 9/ the most recent build version in the currently visited micro version (format x.y.z-TYYYYMMDD-HHMM, where x, y and z +# are integer, T is N for nightly, I for integration or R for release and YYYYMMDD-HHMM is a timestamp) updateLatestRedirections() { local path=$1 local versionToPublish=$2 - local major=$3 - local minor=$4 - local micro=$5 + local visitedMajor=$3 + local visitedMinor=$4 + local visitedMicro=$5 local latestMajor=$6 local latestMinor=$7 local latestMicro=$8 local latestBuild=$9 local updateSiteURL="$EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/$latestBuild" - local diff=$(compareOSGIVersions $versionToPublish $micro) - - if [ $diff -le 0 ]; then - if [ "$major" = "$latestMajor" -a "$minor" = "$latestMinor" -a "$micro" = "$latestMicro" ]; then - echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/latest" - createRedirect "$path/latest" "$updateSiteURL" "EMF Compare latest $BUILD_TYPE build" - fi - echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/$micro/latest" - createRedirect "$path/$micro/latest" "$updateSiteURL" "EMF Compare latest $micro $BUILD_TYPE build" - - if [ "$micro" = "$latestMicro" ]; then - echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/$minor.x/latest" - createRedirect "$path/$minor.x/latest" "$updateSiteURL" "EMF Compare latest $minor.x $BUILD_TYPE build" - fi - if [ "$minor" = "$latestMinor" -a "$micro" = "$latestMicro" ]; then - echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/$major.x/latest" - createRedirect "$path/$major.x/latest" "$updateSiteURL" "EMF Compare latest $major.x $BUILD_TYPE build" + local nextMajor="$(($visitedMajor+1)).0.0" + local nextMinor="$visitedMajor.$(($visitedMinor+1)).0" + local nextMicro="$visitedMajor.$visitedMinor.$(($visitedMicro+1)).0" + + if [ $(compareOSGIVersions $versionToPublish "$visitedMajor.$visitedMinor.$visitedMicro") -ge 0 ]; then + if [ $(compareOSGIVersions $versionToPublish $nextMicro) -lt 0 ]; then + local stream="$visitedMajor.$visitedMinor.$visitedMicro" + echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/$stream/latest" + createRedirect "$path/$stream/latest" "$updateSiteURL" "EMF Compare latest $stream $BUILD_TYPE build" + fi + + if [ $visitedMicro = $latestMicro ]; then + if [ $(compareOSGIVersions $versionToPublish $nextMinor) -lt 0 ]; then + local stream="$visitedMajor.$visitedMinor.x" + echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/$stream/latest" + createRedirect "$path/$stream/latest" "$updateSiteURL" "EMF Compare latest $stream $BUILD_TYPE build" + fi + + if [ $visitedMinor = $latestMinor ]; then + if [ $(compareOSGIVersions $versionToPublish $nextMajor) -lt 0 ]; then + local stream="$visitedMajor.x" + echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/$stream/latest" + createRedirect "$path/$stream/latest" "$updateSiteURL" "EMF Compare latest $stream $BUILD_TYPE build" + fi + + if [ $visitedMajor = $latestMajor ]; then + echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/latest" + createRedirect "$path/latest" "$updateSiteURL" "EMF Compare latest $BUILD_TYPE build" + fi + fi fi - fi - + return 0 } ###################################################################### +# Setup +###################################################################### + +# MINOR_STREAMs are of the form 1.0.x: only keep major and minor version number parts +export MINOR_STREAM=$(minorStream "$VERSION") + +# MINOR_STREAMs are of the form 1.x: only keep major version number parts +export MAJOR_STREAM=$(majorStream "$VERSION") + +# Converts the Hudson BUILD_ID (e.g. 2013-10-15_07-07-07) into the +# syntax we want for our update-sites (e.g. 20131015-070707) +export BUILD_TIMESTAMP=$(buildTimestamp "$BUILD_ID") + +# The full version for this build, e.g. 0.9.0-N20131015-070707 +export FULL_VERSION="${VERSION}-${BUILD_TYPE_PREFIX}${BUILD_TIMESTAMP}" + +# The root folder where all the builds of the same type as this one +# are published +export NIGHTLY_PATH="$EMF_COMPARE_UPDATES_ROOT/$BUILD_TYPE" + +# The folder for this particular build +export UPDATE_SITE_PATH= + +# The URL on which this particular build will be made available +export UPDATE_SITE_URL="$EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/$FULL_VERSION" + +###################################################################### # Publish the build ###################################################################### -echo "Publishing build $UPDATE_SITE_PATH to $UPDATE_SITE_URL" +echo "Publishing build $NIGHTLY_PATH/$FULL_VERSION to $UPDATE_SITE_URL" # Ensure the target folder exists -mkdir -p "$UPDATE_SITE_PATH" +mkdir -p "$NIGHTLY_PATH/$FULL_VERSION" # The actual publication of the p2 repo produced by the build -cp -a "$WORKSPACE"/packaging/org.eclipse.emf.compare.update/target/repository/* "$UPDATE_SITE_PATH" +cp -a "$WORKSPACE/$REPOSITORY_PATH/"* "$NIGHTLY_PATH/$FULL_VERSION" # Also publish a dump of the build environment, may be useful to debug -env | sort > "$UPDATE_SITE_PATH/build_env.txt" - -###################################################################### -# Setup or update the redirects (implemented as composite repos) -###################################################################### +env | sort > "$NIGHTLY_PATH/$FULL_VERSION/build_env.txt" echo "Adding $UPDATE_SITE_URL to composites repositories:" -# add a link for all nightly list -echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE" -composite-repository -location "$NIGHTLY_PATH" -add "$UPDATE_SITE_URL" \ - -repositoryName "EMF Compare $BUILD_TYPE builds" -createP2Index "$NIGHTLY_PATH" - # add a link for the $VERSION (e.g. "1.2.0" => "1.2.0-NYYYYMMDD-HHMM") echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/$VERSION" -composite-repository -location "$NIGHTLY_PATH/$VERSION" -add "$UPDATE_SITE_URL" \ +composite-repository \ + -location "$NIGHTLY_PATH/$VERSION" \ + -add "$UPDATE_SITE_URL" \ -repositoryName "EMF Compare $VERSION $BUILD_TYPE builds" createP2Index "$NIGHTLY_PATH/$VERSION" # add a link for the $MINOR_STREAM (e.g. "1.2.x" => "1.2.0-NYYYYMMDD-HHMM") echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/$MINOR_STREAM" -composite-repository -location "$NIGHTLY_PATH/$MINOR_STREAM" -add "$UPDATE_SITE_URL" \ +composite-repository \ + -location "$NIGHTLY_PATH/$MINOR_STREAM" \ + -add "$UPDATE_SITE_URL" \ -repositoryName "EMF Compare $MINOR_STREAM $BUILD_TYPE builds" createP2Index "$NIGHTLY_PATH/$MINOR_STREAM" # add a link for the $MAJOR_STREAM (e.g. "1.x" => "1.2.0-NYYYYMMDD-HHMM") echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE/$MAJOR_STREAM" -composite-repository -location "$NIGHTLY_PATH/$MAJOR_STREAM" -add "$UPDATE_SITE_URL" \ +composite-repository \ + -location "$NIGHTLY_PATH/$MAJOR_STREAM" \ + -add "$UPDATE_SITE_URL" \ -repositoryName "EMF Compare $MAJOR_STREAM $BUILD_TYPE builds" createP2Index "$NIGHTLY_PATH/$MAJOR_STREAM" +# add a link for all nightly list +echo " $EMF_COMPARE_UPDATES_BASE_URL/$BUILD_TYPE" +composite-repository \ + -location "$NIGHTLY_PATH" \ + -add "$UPDATE_SITE_URL" \ + -repositoryName "EMF Compare $BUILD_TYPE builds" +createP2Index "$NIGHTLY_PATH" + +# Setup or update the redirects (implemented as composite repos) echo "Redirecting 'latest' repositories to $UPDATE_SITE_URL:" -visitVersions $NIGHTLY_PATH "updateLatestRedirections" $VERSION +visitVersions "$NIGHTLY_PATH" "updateLatestRedirections" $VERSION |