Added code to use remote versions files.

This commit is contained in:
Monty Taylor
2011-07-16 12:59:50 -04:00
parent 8c2cd9e4ef
commit 56bff085af
4 changed files with 134 additions and 124 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -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"