Skip to content

Commit

Permalink
Added git_check, git_get
Browse files Browse the repository at this point in the history
Added dashboard and keystone autobuild scripts
Some fixes and improvements
  • Loading branch information
vasichkin committed Aug 5, 2011
1 parent 707209b commit 7eb1813
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 81 deletions.
45 changes: 32 additions & 13 deletions build_helpers
Expand Up @@ -13,20 +13,36 @@ check_tarball_update() {

}

check_git_update() {
GitRev="$(curl -s http://github.com/api/v2/json/commits/list/$GithubUserProject/$GitCurBranch/$OurSpec | perl -MJSON::XS -e "\$a='';while(<>){\$a.=\$_} \$d=decode_json(\$a);print \$d->{'commits'}[0]->{'id'}")"
OurRev=$(git log --pretty=format:"%H" -1 $OurSpec)
check_spec_update() {
SpecGitRev="$(curl -s http://github.com/api/v2/json/commits/list/$GithubUserProject/$GitCurBranch/$OurSpec | perl -MJSON::XS -e "\$a='';while(<>){\$a.=\$_} \$d=decode_json(\$a);print \$d->{'commits'}[0]->{'id'}")"
SpecOurRev="$(git log --pretty=format:"%H" -1 $OurSpec)"

[ $Debug ] && echo "SPEC Github Revision = $GitRev"
[ $Debug ] && echo "SPEC Local Revision = $OurRev"
[ $Debug ] && echo "SPEC Github Revision = $SpecGitRev"
[ $Debug ] && echo "SPEC Local Revision = $SpecOurRev"

if [[ "$GitRev" != "$OurRev" ]]; then
# Git revision was updated in upstream repository, need to build it
if [[ "$SpecGitRev" != "$SpecOurRev" ]]; then
# Git SPEC revision was updated in upstream repository, need to build it
[ $Debug ] && echo "SPEC github update!"
FireNewBuild=1
fi
}


check_git_update() {
# NOT TESTED YET
SourceGitRev="$(curl -s http://github.com/api/v2/json/commits/list/$GithubSource/$GitCurBranch | perl -MJSON::XS -e "\$a='';while(<>){\$a.=\$_} \$d=decode_json(\$a);print \$d->{'commits'}[0]->{'id'}")"
[ ! -f "$LocalSourcePath/$prj-$ActualVersion" ] && SourceOurRev="$(git --git-dir="$LocalSourcePath/$prj-$ActualVersion/.git" log --pretty=format:"%H" -1)"
[ $Debug ] && echo "Github SOURCE Revision = $SourceGitRev"
[ $Debug ] && echo "Local SOURCE Revision = $SourceOurRev"

if [[ "$SourceGitRev" != "$SourceOurRev" ]]; then
# Git SOURCECODE revision was updated in upstream repository, need to build it
[ $Debug ] && echo "SOURCE github update!"
FireNewBuild=1
fi

}

check_for_update() {
check_tarball_update
check_git_update
Expand Down Expand Up @@ -200,10 +216,13 @@ update_repo() {
}

get_git() {
[ $Debug ] && echo "Getting repo http://github.com/$GithubUserProject"
[ ! -f "/tmp/$prj-$ActualVersion" ] && mkdir "/tmp/$prj-$ActualVersion" ||exit -1
git clone "https://github.com/$GithubUserProject" "/tmp/$prj-$ActualVersion"
tar -czf "$RpmTree/SOURCES/$prj-$ActualVersion.tar.gz" -C "/tmp" --strip-components=1 "$prj-$ActualVersion"
rm -rf "/tmp/$prj-$ActualVersion"
[ $Debug ] && echo "TarBall= $RpmTree/SOURCES/$prj-$ActualVersion.tar.gz"
[ $Debug ] && echo "Getting repo http://github.com/$GithubSource"
[ ! -f "$LocalSourcePath/$prj-$ActualVersion" ] && rm -rf "$LocalSourcePath/$prj-$ActualVersion"
mkdir -p "$LocalSourcePath/$prj-$ActualVersion" ||exit -1
git clone "https://github.com/$GithubSource" "$LocalSourcePath/$prj-$ActualVersion"
cd $LocalSourcePath
tar -czf "$RpmTree/SOURCES/$prj-$ActualVersion.tar.gz" "$prj-$ActualVersion"
cd $dirname
[ $Debug ] && echo "Writing TarBall $RpmTree/SOURCES/$prj-$ActualVersion.tar.gz"

}
6 changes: 3 additions & 3 deletions openstack-dashboard.spec
Expand Up @@ -23,7 +23,7 @@
%define py_puresitedir /usr/lib/python2.6/site-packages

Name: openstack-dashboard
Release: 0.20110715.18%{?dist}
Release: 0.20110805.20%{?dist}
Version: 1.0
Url: http://www.openstack.org
Summary: Django based reference implementation of a web based management interface for OpenStack.
Expand All @@ -33,7 +33,7 @@ Source0: http://openstack-dashboard.openstack.org/tarballs/%{name}-%{ve
Source1: %{name}.init
Source2: %{name}-%{version}-setup.py
Source3: %{name}-%{version}-dashboard
Patch: %{name}-%{version}-conf.patch
#Patch: %{name}-%{version}-conf.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: python-devel python-setuptools
BuildArch: noarch
Expand All @@ -46,7 +46,7 @@ OpenStack Nova cloud controller.

%prep
%setup -q -n %{name}-%{version}/openstack-dashboard/
%patch -p1
#%patch -p1

%build
cp %{SOURCE2} setup.py
Expand Down
8 changes: 4 additions & 4 deletions openstack-keystone.spec
Expand Up @@ -23,16 +23,16 @@
%define py_puresitedir /usr/lib/python2.6/site-packages

Name: openstack-keystone
Release: 0.20110715.17%{?dist}
Release: 0.20110805.19%{?dist}
Version: 1.0
# Upstream repo: https://github.com/openstack/keystone
Url: http://keystone.openstack.org
Summary: Python bindings to the OS API
License: Apache 2.0
Group: Development/Languages/Python
Source0: %{name}-%{version}.tar.gz
Source0: http://openstack-keystone.openstack.org/tarballs/%{name}-%{version}.tar.gz
Source1: %{name}.init
Patch: %{name}-%{version}-conf.patch
#Patch: %{name}-%{version}-conf.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: python-devel python-setuptools python-sphinx >= 0.6.0
BuildArch: noarch
Expand All @@ -43,7 +43,7 @@ Authentication service - proposed for OpenStack

%prep
%setup -q -n %{name}-%{version}
%patch -p1
#%patch -p1

%build
python setup.py build
Expand Down
71 changes: 41 additions & 30 deletions trigger-dashboard-new
Expand Up @@ -5,55 +5,66 @@ dirname="$(dirname $abspath)"
cd "$dirname" || exit -1

OurSpec="openstack-dashboard.spec"
prj=$(grep '^Name:' $OurSpec | sed 's/^Name:\s\+//')



source trigger.conf


GithubUserProject="4P/openstack-dashboard.git"
GithubUserProject="griddynamics/openstack-rhel"
GithubSource="griddynamics/openstack-dashboard"
ActualVersion="$(grep '^Version:' $OurSpec | sed 's/^Version:\s\+//')"
ActualRelease="0.`date +%Y%m%d.%H`"
ActualTarBall=%{name}-%{version}.tar.gz

source trigger.conf
source build_helpers


# If you need to build a specific version - specify it as ./build release_num (digits only).
# If build # is not specified, latest available tarball will be built



case "$1" in
build)
get_git
# check_for_update
# check_enviroment
update_spec
#
# get_tarball
create_srpm
create_rpm #&& commit_spec || undo_changes
sign_rpm
update_repo
# #do_mock
check_enviroment
check_spec_update
check_git_update
[[ $FireNewBuild == "1" ]] && {
get_git
update_spec
create_srpm
create_rpm # && commit_spec || undo_changes
sign_rpm
update_repo
}
#do_mock
;;
check)
check_for_update
# curl -s "http://$jenkins/job/$JobName/build"
[ $Debug ] && echo "Fire jenkins to build $JobName"
check_git_update
check_spec_update
curl -s "http://$jenkins/job/$JobName/build"
[ $Debug ] && echo "Fire jenkins to build $JobName"
exit 0
;;
release)
ActualRelease=$2
build
;;
build_ver)
ActualRelease=$2
build
;;
release_check)
check_spec_update
[[ $FireNewBuild == "1" ]] || exit 0
curl -s "http://$jenkins/job/$JobName/build"
[ $Debug ] && echo "Fire jenkins to build $JobName"
exit 0
;;
release_build)
create_rpm # && commit_spec || undo_changes
sign_rpm
update_repo
;;

*)
echo $"Usage: $0 {build|check|release}"
echo $"Usage: $0 {build|check|build_ver|release}"
echo "build - build rpms"
echo "check - check for updates and trigger jenkins"
echo "release NUM - build specified release"
echo "build_ver NUM - build specified release"
echo "release_check - check release if spec update"
echo "release_build - build release"
exit 2

esac
exit $?
2 changes: 1 addition & 1 deletion trigger-glance-new
Expand Up @@ -45,7 +45,7 @@ case "$1" in
build
;;
release_check)
check_git_update
check_spec_update
[[ $FireNewBuild == "1" ]] || exit 0
curl -s "http://$jenkins/job/$JobName/build"
[ $Debug ] && echo "Fire jenkins to build $JobName"
Expand Down
84 changes: 58 additions & 26 deletions trigger-keystone-new
Expand Up @@ -7,53 +7,85 @@ cd "$dirname" || exit -1
OurSpec="openstack-keystone.spec"
prj=$(grep '^Name:' $OurSpec | sed 's/^Name:\s\+//')



source trigger.conf


GithubUserProject="rackspace/keystone.git"
GithubSource="rackspace/keystone"
ActualVersion="$(grep '^Version:' $OurSpec | sed 's/^Version:\s\+//')"
ActualRelease="0.`date +%Y%m%d.%H`"
ActualTarBall=%{name}-%{version}.tar.gz

source trigger.conf
source build_helpers


# If you need to build a specific version - specify it as ./build release_num (digits only).
# If build # is not specified, latest available tarball will be built

#
# Project details:
# To build we need take rackspace sources from their tree, generate tar.gz, take OUR spec file and patches from openstack-rhel and build it all together
# To auto-build we are checking if OUR spec updated. If yes - get new sources and run build. We DO NOT run build after update of sources.
# Usual usage:
# get new version to local pc
# test and fix
# generate patches for release
# update spec (insert patches, update version)
# push spec and patches to github
# Commands to run:
# build - get new sources and build project
# check - check for sources update
# build_ver - build specified release
# release_check - check for speck update
# release_build - build without downloading sources (if spec update)
#



case "$1" in
build)
get_git
# check_for_update
# check_enviroment
update_spec
#
# get_tarball
create_srpm
create_rpm #&& commit_spec || undo_changes
sign_rpm
update_repo
# #do_mock
check_enviroment
check_spec_update
[[ $FireNewBuild == "1" ]] && {
get_git
update_spec
create_srpm
create_rpm # && commit_spec || undo_changes
sign_rpm
update_repo
}
#do_mock
exit 0
;;
check)
check_for_update
# curl -s "http://$jenkins/job/$JobName/build"
[ $Debug ] && echo "Fire jenkins to build $JobName"
check_git_update
check_spec_update
curl -s "http://$jenkins/job/$JobName/build"
[ $Debug ] && echo "Fire jenkins to build $JobName"
exit 0
;;
build_ver)
ActualRelease=$2
build
;;
release_check)
check_spec_update
[[ $FireNewBuild == "1" ]] || exit 0
curl -s "http://$jenkins/job/$JobName/build"
[ $Debug ] && echo "Fire jenkins to build $JobName"
exit 0
;;
release)
ActualRelease=$2
build
;;
release_build)
create_rpm # && commit_spec || undo_changes
sign_rpm
update_repo
;;

*)
echo $"Usage: $0 {build|check|release}"
echo $"Usage: $0 {build|check|build_ver|release}"
echo "build - build rpms"
echo "check - check for updates and trigger jenkins"
echo "release NUM - build specified release"
echo "build_ver NUM - build specified release"
echo "release_check - check release if spec update"
echo "release_build - build release"
exit 2

esac
exit $?
2 changes: 1 addition & 1 deletion trigger-nova-new
Expand Up @@ -42,7 +42,7 @@ case "$1" in
build
;;
release_check)
check_git_update
check_spec_update
[[ $FireNewBuild == "1" ]] || exit 0
curl -s "http://$jenkins/job/$JobName/build"
[ $Debug ] && echo "Fire jenkins to build $JobName"
Expand Down
2 changes: 1 addition & 1 deletion trigger-swift-new
Expand Up @@ -50,7 +50,7 @@ case "$1" in
build
;;
release_check)
check_git_update
check_spec_update
[[ $FireNewBuild == "1" ]] || exit 0
curl -s "http://$jenkins/job/$JobName/build"
[ $Debug ] && echo "Fire jenkins to build $JobName"
Expand Down
11 changes: 9 additions & 2 deletions trigger.conf
@@ -1,8 +1,16 @@
Debug="1"

jenkins="localhost:8080"
# Name of our project. Taken from spec by default
prj=$(grep '^Name:' $OurSpec | sed 's/^Name:\s\+//')


# Storage for our specs
[ $GithubUserProject ] || GithubUserProject="griddynamics/openstack-rhel"

# Source taken from here
[ $GithubSource ] || GithubSource=$GithubUserProject

## Where is tarballs?
[ $TarballsHome ] || TarballsHome="http://$prj.openstack.org/tarballs"

Expand Down Expand Up @@ -38,8 +46,7 @@ RpmTree=`grep topdir $HOME/.rpmmacros 2>/dev/null | awk '{print ($2)}'`


RepoPath="/home/build/repo/$GitCurBranch/openstack"
LocalSourcePath="/home/build/local-source"

JobName="$(echo $dirname | sed 's/^.*\/jobs\/\([^/]\+\)\/workspace$/\1/')"

#BuildLog=`mktemp`
#BuildLog=/tmp/build-$prj.log

0 comments on commit 7eb1813

Please sign in to comment.