2 # @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
5 # - Add -r option for mock to choose the distribution
6 # - add option to pass in spec file name, maybe use spec.in template
7 # - add option to pass in version and release
28 dist="fedora-19-x86_64"
29 pkg_dist_suffix="fc19"
30 mock_cmd="/usr/bin/mock"
44 # Maven is not installed at the system wide level but at the Jenkins level
45 # We need to map our Maven call to the Jenkins installed version
46 mvn_cmd="$JENKINS_HOME/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.0.4/bin/mvn"
48 # Define our push repositories here. We do it in code since we can't
49 # use a POM file for the RPM pushes (we're doing "one-off" file pushes)
51 # Repositories will be of the form baseRepositoryId-$dist{-testing}
52 # -testing if it's a snapshot build (not using -snapshot as the name as
53 # -testing is the more common testing repo suffix for yum)
54 baseURL="http://nexus.opendaylight.org/content/repositories/opendaylight-yum-"
55 baseRepositoryId="opendaylight-yum-"
59 readonly RCPARMSERROR=65
60 readonly RCRPMBUILDERROR=66
61 readonly RCRMOCKERROR=67
62 readonly RCGITERROR=68
71 local level=$1; shift;
73 if [ $level -le $loglevel ]; then
82 if [ "$outstr" != "" ]; then
87 echo "Usage: `basename $0` [OPTION...]"
90 echo " --buildtype TYPE build type, either snapshot or release, default snapshot"
91 echo " --buildroot DIRECTORY build root path. The path must exist."
92 echo " --buildtag tag the tmpbuild directory, i.e. Jenkins build number"
93 echo " --cleanroot clean buildroot directory before building"
94 echo " --cleantmp clean tmpbuild directory before building"
95 echo " --dist DIST distribution, default fedora-19-x86_64"
96 echo " --distsuffix SUFFIX package distribution suffix, default f19"
97 echo " --getsource METHOD method for getting source clone|snapshot|buildroot, default buildroot"
100 echo " --releasetag use the latest release tagged repos"
101 echo " --specrelease version used for spec Release:, default 1"
102 echo " --versiontype TYPE where to find version, user|pom|spec, default spec"
103 echo " --version VERSION version value to use in build output. Required for --version_type user option."
104 echo " --edversion VERSION version value to use in build output for edition rpms"
105 echo " --branch BRANCH branch to use for source"
107 echo "Repo sync options:"
108 echo " --repourl REPOURL url of the repo, include http://"
109 echo " --repouser REPOUSER user for repo"
110 echo " --repopw REPOPW password for repo"
112 echo "Deployment options:"
113 echo " --pushrpms push the built rpms to a maven repository"
114 echo " --mvn_cmd fully qualified path to where the mvn command"
115 echo " (defaults to Jenkins installation of Maven 3.0.4)"
116 echo " --baseURL base deployment URL. \$dist will be added to the end of this"
117 echo " If this is a snapshot build then -testing be added at the end"
118 echo " --baseRepositoryId base repository name. \$dist will be added to the end of this"
119 echo " If this is a snapshot build then -testing be added at the end"
122 echo " --mockinit Run mock init"
123 echo " --mockmvn replace the maven command used within mock"
126 echo " -?, -h, --help Display this help and exit"
127 echo " --debug Enable bash debugging output"
128 echo " --mockdebug Enable mock debugging output"
131 echo " --shortcircuits INDEX Start build with project index"
132 echo " --shortcircuite INDEX End build with project index"
133 echo " --listprojects List the projects and indexes"
134 echo " --timesuffix TIME Set the time suffix to use for build output"
140 readonly PJ_INTEGRATION=0
141 readonly PJ_CONTROLLER=1
143 readonly PJ_OPENFLOWJAVA=3
144 readonly PJ_OPENFLOWPLUGIN=4
145 readonly PJ_DEPENDENCIES=5
146 readonly PJ_OPENDAYLIGHT=6
147 readonly PJ_LISPFLOWMAPPING=7
148 readonly PJ_SNMP4SDN=8
149 readonly PJ_AFFINITY=9
150 readonly PJ_YANGTOOLS=10
151 readonly PJ_BGPCEP=11
152 readonly PJ_OPENDOVE=12
153 #readonly PJ_LAST=$PJ_BGPCEP
154 readonly PJ_LAST=$PJ_OPENDOVE
156 projects[$PJ_INTEGRATION]="integration"
157 projects[$PJ_CONTROLLER]="controller"
158 projects[$PJ_OVSDB]="ovsdb"
159 projects[$PJ_OPENFLOWJAVA]="openflowjava"
160 projects[$PJ_OPENFLOWPLUGIN]="openflowplugin"
161 projects[$PJ_DEPENDENCIES]="controller-dependencies"
162 projects[$PJ_OPENDAYLIGHT]="opendaylight"
163 projects[$PJ_LISPFLOWMAPPING]="lispflowmapping"
164 projects[$PJ_SNMP4SDN]="snmp4sdn"
165 projects[$PJ_AFFINITY]="affinity"
166 projects[$PJ_YANGTOOLS]="yangtools"
167 projects[$PJ_BGPCEP]="bgpcep"
168 projects[$PJ_OPENDOVE]="opendove"
170 versions[$PJ_INTEGRATION]=""
171 versions[$PJ_CONTROLLER]=""
172 versions[$PJ_OVSDB]=""
173 versions[$PJ_OPENFLOWJAVA]=""
174 versions[$PJ_OPENFLOWPLUGIN]=""
175 versions[$PJ_DEPENDENCIES]=""
176 versions[$PJ_OPENDAYLIGHT]=""
177 versions[$PJ_LISPFLOWMAPPING]=""
178 versions[$PJ_SNMP4SDN]=""
179 versions[$PJ_AFFINITY]=""
180 versions[$PJ_YANGTOOLS]=""
181 versions[$PJ_BGPCEP]=""
182 versions[$PJ_OPENDOVE]=""
184 suffix[$PJ_INTEGRATION]=""
185 suffix[$PJ_CONTROLLER]=""
187 suffix[$PJ_OPENFLOWJAVA]=""
188 suffix[$PJ_OPENFLOWPLUGIN]=""
189 suffix[$PJ_DEPENDENCIES]=""
190 suffix[$PJ_OPENDAYLIGHT]=""
191 suffix[$PJ_LISPFLOWMAPPING]=""
192 suffix[$PJ_SNMP4SDN]=""
193 suffix[$PJ_AFFINITY]=""
194 suffix[$PJ_YANGTOOLS]=""
195 suffix[$PJ_BGPCEP]=""
196 suffix[$PJ_OPENDOVE]=""
198 gitprojects="$PJ_INTEGRATION $PJ_CONTROLLER $PJ_OVSDB $PJ_OPENFLOWJAVA $PJ_OPENFLOWPLUGIN $PJ_LISPFLOWMAPPING $PJ_SNMP4SDN $PJ_AFFINITY $PJ_YANGTOOLS $PJ_BGPCEP $PJ_OPENDOVE"
200 # Clone the projects.
201 function clone_source {
203 for i in $gitprojects; do
204 if [ depth -eq 0 ]; then
205 # We only care about a shallow clone (no need to grab the entire project)
206 log $LOGINFO "Shallow cloning ${projects[$i]} to $buildroot/${projects[$i]}"
207 git clone --depth 0 https://git.opendaylight.org/gerrit/p/${projects[$i]}.git $buildroot/${projects[$i]}
209 log $LOGINFO "Full cloning ${projects[$i]} to $buildroot/${projects[$i]}"
210 git clone https://git.opendaylight.org/gerrit/p/${projects[$i]}.git $buildroot/${projects[$i]}
215 # Copy the projects from snapshots.
216 # shague: Fill in with the nexus info.
217 # Make mk_snapshot_archives that just sets up the version strings.
218 function snapshot_source {
219 log $LOGINFO "$FUNCNAME: Not implemented yet."
222 # Checkout the latest release-tagged branch.
223 # TODO: does this work for branches or for multiple releases?
224 function checkout_release_tag {
227 for i in $gitprojects; do
228 # Leave integration as is. The release version has a bug. Assume the latest in the
230 if [ "${projects[$i]}" == "${projects[$PJ_INTEGRATION]}" ]; then
233 cd $buildroot/${projects[$i]}
234 # Find the last release tag for the project.
235 # We assume that the first git log matching "[maven-release-plugin] prepare release"
236 # is where the tag was created.
237 tag=$(git log | grep -m 1 "\[maven-release-plugin\] prepare release" | awk '{print $4}')
238 if [ "$tag" != "" ]; then
239 git checkout --quiet "$tag"
241 log $LOGERROR "${projects[i]} is missing release tag"
247 # Checkout the requested branch.
248 function checkout_branch {
251 for i in $gitprojects; do
252 cd $buildroot/${projects[$i]}
257 function set_versions {
263 for i in $gitprojects; do
264 case "$versiontype" in
266 # User set the version.
267 versions[$i]=$version
271 # rpm query the spec file to get the Version.
272 cd $buildroot/${projects[$PJ_INTEGRATION]}/packaging/rpm
273 if [ ${projects[$i]} == ${projects[$PJ_INTEGRATION]} ]; then
274 # use opendaylight spec since there is no integration spec
275 versions[$i]="$( rpm -q --queryformat="%{version}\n" --specfile opendaylight.spec | head -n 1 | awk '{print $1}')"
277 versions[$i]="$( rpm -q --queryformat="%{version}\n" --specfile opendaylight-${projects[$i]}.spec | head -n 1 | awk '{print $1}')"
282 # Find the first version tag in the pom.xml file - this should be the correct version.
283 # Then strip the version tags and end up with the version string.
284 versions[$i]=$(grep -m 1 "<version>" $buildroot/${projects[$i]}/pom.xml | sed -n -e '/<version>/s/.*<version>//p' | sed -n -e 's/<\/version>//p')
288 if [ "$buildtype" == "snapshot" ]; then
289 cd $buildroot/${projects[$i]}
290 suffix[$i]="snap.$timesuffix.git.$(git log -1 --pretty=format:%h)"
291 versions[$i]="${versions[$i]}.${suffix[$i]}"
296 # Remove any -'s from the version. rpmbuild does not like them.
297 version=${versions[$i]}
298 versions[$i]=${version//-/.}
301 # The dependencies and opendaylight projects do not have a repo so set them to the
302 # controller and integration versions.
304 # Dependencies follows the controller.
305 suffix[$PJ_DEPENDENCIES]=${suffix[$PJ_CONTROLLER]}
306 versions[$PJ_DEPENDENCIES]=${versions[$PJ_CONTROLLER]}
308 # Opendaylight follows integration since they are the editions, unless the
309 # user wants to set the value explicitly.
310 if [ "$edversion" == "" ]; then
311 suffix[$PJ_OPENDAYLIGHT]=${suffix[$PJ_INTEGRATION]}
312 versions[$PJ_OPENDAYLIGHT]=${versions[$PJ_INTEGRATION]}
314 suffix[$PJ_OPENDAYLIGHT]=""
315 versions[$PJ_OPENDAYLIGHT]=$edversion
319 # Archive the projects to create the SOURCES for rpmbuild:
320 # - xz the source for later use by rpmbuild.
321 # - get the version and git hashes to produce a versions and suffix for each project.
322 # - copy the archives to the SOURCES dir
323 # shague: need another archive method for snapshot getsource builds since
324 # the source did not come from a git repo.
325 # versionmajor=0.1.0.snap.20140201.191633.git.7c5788d
326 # versionsnapsuffix=snap.20140201.191633.git.7c5788d
328 function mk_git_archives {
329 # local timesuffix=$1
331 for i in $gitprojects; do
332 log $LOGINFO "Building archive: $tmpbuild/opendaylight-${projects[$i]}-${versions[$i]}.tar.xz"
333 cd $buildroot/${projects[$i]}
334 git archive --prefix=opendaylight-${projects[$i]}-${versions[$i]}/ HEAD | \
335 xz > $tmpbuild/opendaylight-${projects[$i]}-${versions[$i]}.tar.xz
338 # Don't forget any patches.
339 cp $buildroot/${projects[$PJ_INTEGRATION]}/packaging/rpm/opendaylight-integration-fix-paths.patch $tmpbuild
342 # Pushes rpms to the specified Nexus repository
343 # This only happens if pushrpms is true
345 if [ $pushrpms = 1 ]; then
346 allrpms=`find $tmpbuild/repo -iname '*.rpm'`
348 log $LOGINFO "RPMS found"
349 for i in $allrpms; do
354 log $LOGINFO "::::: pushing RPMs"
356 for i in $allrpms; do
357 rpmname=`rpm -qp --queryformat="%{name}" $i`
358 rpmversion=`rpm -qp --queryformat="%{version}" $i`
359 distro=`echo $dist | tr - .`
361 if [ `echo $i | grep 'src.rpm'` ]; then
362 rpmrelease=`rpm -qp --queryformat="%{release}.src" $i`
365 rpmrelease=`rpm -qp --queryformat="%{release}.%{arch}" $i`
370 if [ "$buildtype" == "snapshot" ]; then
371 repositoryId="${baseRepositoryId}${dist}-testing"
372 pushURL="${baseURL}${dist}-testing"
374 repositoryId="${baseRepositoryId}${dist}"
375 pushURL="${baseURL}${dist}"
378 # Note version is the full version+release+{arch|src}
379 # if it is not configured this way on pushes then a download
380 # of the artifact will result in just the name-version.rpm
381 # instead of name-version-release.{arch|src}.rpm
382 $mvn_cmd org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy-file \
383 -Dfile=$i -DrepositoryId=$repositoryId \
384 -Durl=$pushURL -DgroupId=$groupId \
385 -Dversion=$rpmversion-$rpmrelease -DartifactId=$rpmname \
393 Building controller using:
395 suffix: $pkg_dist_suffix
396 buildtype: $buildtype
397 versiontype: $versiontype
399 edversion: $edversion
401 specrelease: $specrelease
402 releasetag: $releasetag
403 getsource: $getsource
404 buildroot: $buildroot
409 shortcircuits: $shortcircuits
410 shortcircuite: $shortcircuite
415 # Build a single project.
416 function build_project {
418 local versionmajor="$2"
419 local versionsnapsuffix="$3"
422 if [ "$project" == "opendaylight" ]; then
423 projectspec="opendaylight"
425 projectspec="opendaylight-$project"
429 log $LOGINFO "::::: building $projectspec.rpm"
432 cp -f $buildroot/${projects[$PJ_INTEGRATION]}/packaging/rpm/$projectspec.spec $tmpbuild
435 # Rewrite the Version and Release values in the spec files.
436 sed -r -i -e '/^Version:./c\Version: '"$versionmajor" $projectspec.spec
437 if [ "$buildtype" == "release" ]; then
438 if [ "$specrelease" != "" ]; then
439 sed -r -i -e '/^Release:./c\Release: '"$specrelease%{?dist}" $projectspec.spec
442 # if [ "$buildtype" == "release" ] && [ "$version" != "" ]; then
443 # # Find lines starting with Version: and replace the whole line with the version requested
444 # sed -r -i -e '/^Version:./c\Version: '"$versionmajor" $projectspec.spec
446 # # Find lines starting with Version: and replace the rest of the line with the versionsnapsuffix
447 # sed -r -i -e '/^Version:/s/\s*$/'".$versionsnapsuffix/" $projectspec.spec
450 # Set the right values in the spec files.
452 ${projects[$PJ_CONTROLLER]})
453 # Set the version for the integration source.
454 # Find lines with opendaylight-integration-%{version} and replace %{version} with the version.
455 sed -r -i -e '/opendaylight-integration-\%\{version\}/s/\%\{version\}/'"${versions[$PJ_INTEGRATION]}"'/g' \
459 ${projects[$PJ_DEPENDENCIES]})
460 # Set the version for ovsdb in the dependencies spec.
461 # Don't worry about opendaylight-controller version since the dependencies
462 # version is the same as the controller version.
463 # Find lines with opendaylight-ovsdb-%{version} and replace %{version} with the version.
464 sed -r -i -e '/opendaylight-ovsdb-\%\{version\}/s/\%\{version\}/'"${versions[$PJ_OVSDB]}"'/g' \
466 # Find lines with opendaylight-ovsdb-dependencies-%{version} and replace %{version} with the version.
467 sed -r -i -e '/opendaylight-ovsdb-dependencies-\%\{version\}/s/\%\{version\}/'"${versions[$PJ_OVSDB]}"'/g' \
475 # Rewrite the mvn command in the rpmbuild if the user requests it.
476 if [ "$mockmvn" != "" ]; then
477 # Find lines starting with export MAVEN_OPTS= and replace the whole line with $mockmvn
478 sed -r -i -e '/^export MAVEN_OPTS=./c\ '"$mockmvn" $projectspec.spec
481 # Build the source RPM for use by mock later.
482 #rm -f SRPMS/*.src.rpm
483 log $LOGINFO "::::: building $projectspec.src.rpm with rpmbuild"
484 rpmbuild -bs --define '%_topdir '"`pwd`" --define '%_sourcedir %{_topdir}' \
485 --define "%dist .$pkg_dist_suffix" $projectspec.spec
488 if [ $rc != 0 ]; then
489 log $LOGERROR "rpmbuild of $projectspec.src.rpm failed (rc=$rc)."
490 exit $RCRPMBUILDERROR
493 log $LOGINFO "::::: building $projectspec.rpm with mock"
495 if [ "$buildtype" == "release" ]; then
496 resultdir="repo/$projectspec.$pkg_dist_suffix.noarch"
498 resultdir="repo/$projectspec.$pkg_dist_suffix.noarch.snap"
501 # Build the rpm using mock.
502 # Keep the build because we will need the distribution zip file for later
503 # when building the controller-dependencies.rpm.
504 eval $mock_cmd $mockdebug -r $dist --no-clean --no-cleanup-after --resultdir \"$resultdir\" \
505 -D \"dist .$pkg_dist_suffix\" -D \"noclean 1\" \
506 SRPMS/$projectspec-$versionmajor-*.src.rpm
509 if [ $rc != 0 ]; then
510 log $LOGERROR "mock of $projectspec.rpm failed (rc=$rc)."
514 log $LOGINFO "::::: finished building $projectspec.rpm in mock"
516 # Copy the distribution zip from the controller and ovsdb projects
517 # for use in the dependencies.rpm.
519 ${projects[$PJ_CONTROLLER]})
520 log $LOGINFO "::::: Copying $projectspec distribution.zip."
521 eval $mock_cmd $mockdebug -r $dist --no-clean --no-cleanup-after --resultdir \"$resultdir\" \
522 -D \"dist .$pkg_dist_suffix\" -D \"noclean 1\" \
523 --copyout \"builddir/build/BUILD/$projectspec-$versionmajor/opendaylight/distribution/opendaylight/target/distribution.opendaylight-osgipackage.zip\" \"$resultdir/$projectspec-$versionmajor.zip\"
525 ln -sf $resultdir/$projectspec-$versionmajor.zip $tmpbuild
527 if [ ! -e $tmpbuild/$projectspec-$versionmajor.zip ]; then
528 log $LOGERROR "cannot find $projectspec distribution zip file (rc=$rc1:$rc2)."
533 ${projects[$PJ_OVSDB]})
534 log $LOGINFO "::::: Copying $projectspec distribution.zip."
535 # Grab the version from the pom.xml file.
536 # Get the lines between the parent tags, then get the line with the version tag and remove leading space and
537 # the tag itself, then remove the trailing tag to be left with the version.
538 pomversion=`sed -n -e '/<parent>/,/<\/parent>/p' "$buildroot/${projects[$PJ_OVSDB]}/pom.xml" | sed -n -e '/<version>/s/.*<version>//p' | sed -n -e 's/<\/version>//p'`
539 eval $mock_cmd $mockdebug -r $dist --no-clean --no-cleanup-after --resultdir \"$resultdir\" \
540 -D \"dist .$pkg_dist_suffix\" -D \"noclean 1\" \
541 --copyout \"builddir/build/BUILD/$projectspec-$versionmajor/distribution/opendaylight/target/distribution.ovsdb-$pomversion-osgipackage.zip\" \"$resultdir/$projectspec-$versionmajor.zip\"
543 ln -sf $resultdir/$projectspec-$versionmajor.zip $tmpbuild
545 if [ ! -e $tmpbuild/$projectspec-$versionmajor.zip ]; then
546 log $LOGERROR "cannot find $projectspec distribution zip file (rc=$rc1:$rc2)."
556 # Main function that builds the rpm's for snapshot's.
557 function build_snapshot {
558 set_versions "$timesuffix" "$versiontype" "$version" "$buildtype"
559 mk_git_archives "$timesuffix"
561 # Initialize our mock build location (we'll be using --no-clean later)
562 # If we don't do the first init we can't build since the environment
563 # doesn't get setup correctly!
564 if [ $mockinit -eq 1 ]; then
565 eval $mock_cmd $mockdebug -r $dist --init
571 if [ $shortcircuits -ne 0 ]; then
575 if [ $shortcircuite -ne 0 ]; then
579 echo "start:end = $start:$end"
581 for i in `seq $start $end`; do
582 build_project "${projects[$i]}" "${versions[$i]}" "${suffix[$i]}"
586 log $LOGINFO "::::: All projects have been built"
592 # Main function that builds the rpm's for release's.
593 # shague: should be similar to snapshot but use a different version or tag.
594 # spec files should be updated with correct version. If so, do
595 function build_release {
596 log $LOGINFO "$FUNCNAME: Not implemented yet."
599 function parse_options {
607 mockdebug="-v"; shift;
611 shift; buildtype="$1"; shift;
612 if [ "$buildtype" != "snapshot" ] && [ "$buildtype" != "release" ]; then
613 usage $RCPARMSERROR "Invalid build type.";
618 shift; buildroot="$1"; shift;
619 if [ "$buildroot" == "" ]; then
620 usage $RCPARMSERROR "Missing build root.";
622 if [ ! -d "$buildroot" ]; then
623 usage $RCPARMSERROR "Invalid build root path."
628 shift; buildtag="$1"; shift;
629 if [ "$buildtag" == "" ]; then
630 usage $RCPARMSERROR "Missing build tag.";
643 shift; getsource="$1"; shift;
644 if [ "$getsource" != "clone" ] && [ "$getsource" != "snapshot" ] && \
645 [ "$getsource" != "buildroot" ]; then
646 usage $RCPARMSERROR "Invalid getsource method.";
651 shift; dist="$1"; shift;
652 if [ "$dist" == "" ]; then
653 usage $RCPARMSERROR "Missing distribution.";
658 shift; pkg_dist_suffix="$1"; shift;
659 if [ "$pkg_dist_suffix" == "" ]; then
660 usage $RCPARMSERROR "Missing package distribution suffix.";
665 shift; versiontype="$1"; shift;
666 if [ "$versiontype" != "user" ] && [ "$versiontype" != "pom" ] && [ "$versiontype" != "spec" ]; then
667 usage $RCPARMSERROR "Invalid version type.";
672 shift; specrelease="$1"; shift;
673 if [ "$specrelease" == "" ]; then
674 usage $RCPARMSERROR "Missing specrelease.";
683 shift; version="$1"; shift;
684 if [ "$version" == "" ]; then
685 usage $RCPARMSERROR "Missing version.";
690 shift; edversion="$1"; shift;
691 if [ "$edversion" == "" ]; then
692 usage $RCPARMSERROR "Missing edversion.";
697 shift; branch="$1"; shift;
698 if [ "$branch" == "" ]; then
699 usage $RCPARMSERROR "Missing branch.";
705 shift; repourl="$1"; shift;
706 if [ "$repourl" == "" ]; then
707 usage $RCPARMSERROR "Missing repo url.";
712 shift; repouser="$1"; shift;
713 if [ "$repouser" == "" ]; then
714 usage $RCPARMSERROR "Missing repo user.";
719 shift; repopw="$1"; shift;
720 if [ "$repopw" == "" ]; then
721 usage $RCPARMSERROR "Missing repo pw.";
730 shift; timesuffix="$1"; shift;
731 if [ "$timesuffix" == "" ]; then
732 usage $RCPARMSERROR "Missing time suffix.";
737 shift; mvn_cmd="$1"; shift;
738 if [ "$mvn_cmd" == "" ]; then
739 usage $RCPARMSERROR "Missing mvn_cmd.";
748 shift; mockmvn="$1"; shift;
749 if [ "$mockmvn" == "" ]; then
750 usage $RCPARMSERROR "Missing mockmvn.";
755 shift; baseURL="$1"; shift;
756 if [ "$baseURL" == "" ]; then
757 usage $RCPARMSERROR "Missing baseURL.";
762 shift; baseRepositoryId="$1"; shift;
763 if [ "$baseRepositoryId" == "" ]; then
764 usage $RCPARMSERROR "Missing baseRepositoryId.";
769 shift; shortcircuits=$1; shift;
773 shift; shortcircuite=$1; shift;
777 listprojects=1; shift;
787 log $LOGINFO "Ignoring unknown option: $1"; shift;
793 #################### main ####################
795 if [ "$timesuffix" == "" ]; then
796 timesuffix="$(date +%F_%T | tr -d .:- | tr _ .)"
798 date_start=$(date +%s)
802 if [ $listprojects -eq 1 ]; then
803 for i in `seq $PJ_FIRST $PJ_LAST`; do
804 echo "$i ${projects[$i]}"
809 # Some more error checking...
810 if [ -z $buildroot ]; then
811 log $LOGERROR "Mising buildroot"
815 if [ $cleanroot -eq 1 ] && [ $getsource = "buildroot" ]; then
816 log $LOGERROR "Aborting. You probably do not want to clean the directory" \
817 "containing the source."
821 if [ "$versiontype" != "user" ] && [ "$version" == "" ]; then
822 log $LOGERROR "version type user requires a version"
825 # Can change tmpbuild to be an index or other tag
826 if [ -n "$buildtag" ]; then
827 tmpbuild="$buildroot/bld_$buildtag"
829 tmpbuild="$buildroot/bld"
834 if [ $cleanroot -eq 1 ]; then
839 if [ $cleantmp -eq 1 ]; then
843 # Setup the temp build directory.
844 mkdir -p $tmpbuild/repo
849 clone_source "$depth";
851 if [ -n "$branch" ]; then
852 checkout_branch $branch
855 if [ $releasetag -eq 1 ]; then
868 # Check if all the projects dirs are really there.
869 for i in $gitprojects; do
870 if [ ! -d ${projects[$i]} ]; then
871 log $LOGERROR "Missing ${projects[$i]}"
876 if [ -n "$branch" ]; then
877 checkout_branch $branch
880 if [ $releasetag -eq 1 ]; then
887 if [ "$buildtype" == "snapshot" ]; then
888 log $LOGINFO "Building a snapshot build"
891 log $LOGINFO "Building a release build"
896 diff=$(($date_end - $date_start))
897 log $LOGINFO "Build took $(($diff / 3600 % 24)) hours $(($diff / 60 % 60)) minutes and $(($diff % 60)) seconds."