From 56bff085af91000c3f230ccd95d499ba825a5b8a Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 16 Jul 2011 12:59:50 -0400 Subject: [PATCH] Added code to use remote versions files. --- bin_ppa_script.sh | 14 ++++- ppa_script.sh | 14 ++++- tarball_script.sh | 117 ++++++++++++++++++++++++++++++++++++++---- tarball_script.sh-new | 113 ---------------------------------------- 4 files changed, 134 insertions(+), 124 deletions(-) delete mode 100755 tarball_script.sh-new diff --git a/bin_ppa_script.sh b/bin_ppa_script.sh index 1e1ebb37..98c417f8 100755 --- a/bin_ppa_script.sh +++ b/bin_ppa_script.sh @@ -9,12 +9,20 @@ then fi HUDSON=http://localhost:8080/ -PKGRECORDFILE=$HOME/binpkgversions +VERSIONDIR=$HOME/versions +PKGRECORDFILE=$VERSIONDIR/binpkgversions JENKINS_TARBALL_JOB=${JENKINS_TARBALL_JOB:-$PROJECT-tarball} BZR_BRANCH=${BZR_BRANCH:-lp:~openstack-ubuntu-packagers/$PROJECT/ubuntu} PPAS=${PPAS:-ppa:$PROJECT-core/trunk} PACKAGING_REVNO=${PACKAGING_REVNO:--1} +if [ ! -d "$VERSIONDIR" ] +then + bzr co bzr://jenkins.openstack.org/ "$VERSIONDIR" +else + ( cd $VERSIONDIR ; bzr up ) +fi + # Clean up after previous build rm -rf build dist.zip mkdir build @@ -64,6 +72,10 @@ do buildno=$(($buildno + 1)) else echo "$PROJECT $pkgversion" >> "$PKGRECORDFILE" + cat "$PKGRECORDFILE" | sort > "$PKGRECORDFILE" + ( cd $VERSIONDIR ; + bzr up ; + bzr commit -m"Added $PROJECT $snapshotversion" ) break fi done diff --git a/ppa_script.sh b/ppa_script.sh index 125a6c1c..f2effb23 100755 --- a/ppa_script.sh +++ b/ppa_script.sh @@ -9,12 +9,20 @@ then fi HUDSON=http://localhost:8080/ -PKGRECORDFILE=$HOME/pkgversions +VERSIONDIR=$HOME/versions +PKGRECORDFILE=$VERSIONDIR/pkgversions BZR_BRANCH=${BZR_BRANCH:-lp:~openstack-ubuntu-packagers/$PROJECT/ubuntu} PPAS=${PPAS:-ppa:$PROJECT-core/trunk} PACKAGING_REVNO=${PACKAGING_REVNO:--1} series=${series:-lucid} +if [ ! -d "$VERSIONDIR" ] +then + bzr co bzr://jenkins.openstack.org/ "$VERSIONDIR" +else + ( cd $VERSIONDIR ; bzr up ) +fi + cd build tarball="$(echo dist/$PROJECT*.tar.gz)" @@ -56,6 +64,10 @@ do buildno=$(($buildno + 1)) else echo "$PROJECT $pkgversion" >> "$PKGRECORDFILE" + cat "$PKGRECORDFILE" | sort > "$PKGRECORDFILE" + ( cd $VERSIONDIR ; + bzr up ; + bzr commit -m"Added $PROJECT $snapshotversion" ) break fi done diff --git a/tarball_script.sh b/tarball_script.sh index b1981209..644e5f85 100755 --- a/tarball_script.sh +++ b/tarball_script.sh @@ -2,24 +2,123 @@ set -e +find_next_version() { + datestamp="${datestamp:-$(date +%Y%m%d)}" + index=1 + MILESTONEDIR="${MILESTONEDIR:-$HOME/milestone}" + BRANCH=${BRANCH:-trunk} + + milestonefile="${MILESTONEDIR}/${PROJECT}-${BRANCH}" + + if [ ! -e "${milestonefile}" ] + then + if [ "$NOMILESTONE" = "true" ] + then + milestonever="" + else + echo "Milestone file ${milestonefile} not found. Bailing out." >&2 + exit 1 + fi + else + milestonever="$(cat ${milestonefile})" + fi + + if false # Because we only need this madness if we're using git, that's why! + then + while true + do + version="$milestonever" + if [ -n "$version" ] + then + version="${version}~" + fi + version="$(printf %s%s.%s%d "${version}" "$datestamp" "$REVNOPREFIX" "$index")" + if grep -q "^$PROJECT $version$" "$RECORDFILE" + then + echo "$version of $PROJECT already exists. Bumping index." >&2 + index="$(($index + 1))" + else + break + fi + done + else + version="$milestonever" + if [ -n "$version" ] + then + version="${version}~" + fi + revno="${revno:-$(bzr revno)}" + version="$(printf %s%s.%s%d "$version" "$datestamp" "$REVNOPREFIX" "$revno")" + if grep -q "^$PROJECT $version$" "$RECORDFILE" + then + echo "$version of $PROJECT already exists. Bailing out." >&2 + exit 1 + fi + fi + + printf "%s" "$version" +} + +if [ "$1" = "test" ] +then + PROJECT="testproj" + datestamp="12345678" + RECORDFILE=$(mktemp) + MILESTONEDIR=$(mktemp -d) + BRANCH=foo + revno="99923" + REVNOPREFIX="r" + + # Verify that we skip already built versions + echo "d2" > "${MILESTONEDIR}/$PROJECT-${BRANCH}" + echo "$PROJECT d2~$datestamp.001" > $RECORDFILE + expected_version="d2~12345678.r99923" + actual_version="$(find_next_version)" + test "${actual_version}" = "${expected_version}" || (echo Got ${actual_version}, expected ${expected_version} ; exit 1) + echo "For a milestoned project, we'd get: ${expected_version}" + + PROJECT="testproj2" + NOMILESTONE=true + expected_version="12345678.r99923" + actual_version="$(find_next_version)" + test "${actual_version}" = "${expected_version}" || (echo Got ${actual_version}, expected ${expected_version} ; exit 1) + echo "For a non-milestoned project, we'd get: ${expected_version}" + + echo All tests passed + exit 0 +fi + if [ -z "$PROJECT" ] then echo '$PROJECT not set.' exit 1 fi -RECORDFILE=$HOME/tarballversions -SEPARATOR=${SEPARATOR:-'~'} -revno=$(bzr revno) -datestamp="$(date +%Y%m%d)" +VERSIONSDIR="$HOME/versions" +RECORDFILE="$VERSIONSDIR/tarballversions" -if grep "^$PROJECT $revno$" "$RECORDFILE"; +if [ ! -d "$VERSIONDIR" ] then - echo "Tarball already built. Not rebuilding." - exit 0 + bzr co bzr://jenkins.openstack.org/ "$VERSIONDIR" +else + ( cd $VERSIONDIR ; bzr up ) fi -echo "$PROJECT $revno" '>>' "$RECORDFILE" + +snapshotversion=$(find_next_version) +echo "$PROJECT $snapshotversion" >> "$RECORDFILE" +cat "$RECORDFILE" | sort > "$RECORDFILE" +( cd $VERSIONDIR ; bzr up ; bzr commit -m"Added $PROJECT $snapshotversion" ) + +# Should be ~ if tarball version is the one we're working *toward*. (By far preferred!) +# Should be + if tarball version is already released and we're moving forward after it. +SEPARATOR=${SEPARATOR:-'~'} + +rm -f dist/*.tar.gz python setup.py sdist + +# There should only be one, so this should be safe. tarball=$(echo dist/*.tar.gz) -mv "$tarball" "dist/$(basename $tarball .tar.gz)${SEPARATOR}bzr${revno}.tar.gz" + +echo mv "$tarball" "dist/$(basename $tarball .tar.gz)${SEPARATOR}${snapshotversion}.tar.gz" +mv "$tarball" "dist/$(basename $tarball .tar.gz)${SEPARATOR}${snapshotversion}.tar.gz" diff --git a/tarball_script.sh-new b/tarball_script.sh-new deleted file mode 100755 index 33a132df..00000000 --- a/tarball_script.sh-new +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/sh - -set -e - -find_next_version() { - datestamp="${datestamp:-$(date +%Y%m%d)}" - index=1 - MILESTONEDIR="${MILESTONEDIR:-$HOME/milestone}" - BRANCH=${BRANCH:-trunk} - - milestonefile="${MILESTONEDIR}/${PROJECT}-${BRANCH}" - - if [ ! -e "${milestonefile}" ] - then - if [ "$NOMILESTONE" = "true" ] - then - milestonever="" - else - echo "Milestone file ${milestonefile} not found. Bailing out." >&2 - exit 1 - fi - else - milestonever="$(cat ${milestonefile})" - fi - - if false # Because we only need this madness if we're using git, that's why! - then - while true - do - version="$milestonever" - if [ -n "$version" ] - then - version="${version}~" - fi - version="$(printf %s%s.%s%d "${version}" "$datestamp" "$REVNOPREFIX" "$index")" - if grep -q "^$PROJECT $version$" "$RECORDFILE" - then - echo "$version of $PROJECT already exists. Bumping index." >&2 - index="$(($index + 1))" - else - break - fi - done - else - version="$milestonever" - if [ -n "$version" ] - then - version="${version}~" - fi - revno="${revno:-$(bzr revno)}" - version="$(printf %s%s.%s%d "$version" "$datestamp" "$REVNOPREFIX" "$revno")" - if grep -q "^$PROJECT $version$" "$RECORDFILE" - then - echo "$version of $PROJECT already exists. Bailing out." >&2 - exit 1 - fi - fi - - printf "%s" "$version" -} - -if [ "$1" = "test" ] -then - PROJECT="testproj" - datestamp="12345678" - RECORDFILE=$(mktemp) - MILESTONEDIR=$(mktemp -d) - BRANCH=foo - revno="99923" - REVNOPREFIX="r" - - # Verify that we skip already built versions - echo "d2" > "${MILESTONEDIR}/$PROJECT-${BRANCH}" - echo "$PROJECT d2~$datestamp.001" > $RECORDFILE - expected_version="d2~12345678.r99923" - actual_version="$(find_next_version)" - test "${actual_version}" = "${expected_version}" || (echo Got ${actual_version}, expected ${expected_version} ; exit 1) - echo "For a milestoned project, we'd get: ${expected_version}" - - PROJECT="testproj2" - NOMILESTONE=true - expected_version="12345678.r99923" - actual_version="$(find_next_version)" - test "${actual_version}" = "${expected_version}" || (echo Got ${actual_version}, expected ${expected_version} ; exit 1) - echo "For a non-milestoned project, we'd get: ${expected_version}" - - echo All tests passed - exit 0 -fi - -if [ -z "$PROJECT" ] -then - echo '$PROJECT not set.' - exit 1 -fi - -RECORDFILE="$HOME/tarballversions" - -snapshotversion=$(find_next_version) -echo "$PROJECT $snapshotversion" >> "$RECORDFILE" - -# Should be ~ if tarball version is the one we're working *toward*. (By far preferred!) -# Should be + if tarball version is already released and we're moving forward after it. -SEPARATOR=${SEPARATOR:-'~'} - -rm -f dist/*.tar.gz -python setup.py sdist - -# There should only be one, so this should be safe. -tarball=$(echo dist/*.tar.gz) - -echo mv "$tarball" "dist/$(basename $tarball .tar.gz)${SEPARATOR}${snapshotversion}.tar.gz" -mv "$tarball" "dist/$(basename $tarball .tar.gz)${SEPARATOR}${snapshotversion}.tar.gz"