Update list-maintainers to output redmine syntax
[hoomd-blue.git] / packaging / redhat_build_package.sh
blobdbc8d52e4aab385b98e710adae9df19b5ce98f0c
1 #!/bin/bash
2 # This script facilitates automatic nightly builds of RPM hoomd packages.
3 # To simply build a package, consider using 'make rpm' instead, or refer to
4 # the README or spec file for more information.
6 # To perform automatic package builds, this script should be invoked from cron
7 # with the following additions to crontab:
8 # MAILTO=''
9 # 0 0 * * * $HOME/hoomd-blue/packaging/redhat_build_package.sh >> $HOME/redhat_package_build.out 2>&1
11 # If this script is invoked automatically (as via crontab) from $HOME/hoomd-blue/packaging/
12 # then updates in hoomd-blue git will take two subsequent runs to take effect.
14 # Use the -f flag to prevent the script from performing an automatic update
15 # of itself and the Makefile.
17 BRANCH=maint
18 PATH=/bin:/usr/bin:$PATH
19 # $0 can't be relied upon to identify the name of this script...
20 ME=redhat_build_package.sh
21 SPECFILE="hoomd.spec"
22 # number of RPMs to retain
23 NRPMS=8
24 # what architecture does rpm think we have?
25 ARCH=`rpm --eval '%{_arch}'`
27 QUIET='QUIET=true'
28 UPDATE="true"
29 while getopts fv OPT $@; do
30 case $OPT in
31 'f') unset UPDATE ;;
32 'v') unset QUIET ;;
33 esac
34 done
36 echo "$0 running at "`date`
38 cd $HOME/hoomd-blue
39 git fetch
40 git checkout ${BRANCH}
41 git pull --ff-only
42 cd packaging
44 # determine version and revision
45 HVERSION_BASE=$(git describe | awk 'BEGIN { FS = "-" } ; {print $1}' | cut -c2-)
47 HREVISION=$(git describe | awk 'BEGIN { FS = "-" } ; {print $2}')
48 #set a zero revision if HREVISION is blank
49 if [ -z "${HREVISION}" ]; then
50 HREVISION="0"
53 #check the previous version built
54 atrev=`cat $HOME/rh_old_revsion || echo 0`
55 new_rev=`git describe`
56 echo "Last revision built was $atrev"
57 echo "Current repository revision is $new_rev"
59 if [ "$atrev" = "$new_rev" ];then
60 echo "up to date"
61 else
62 echo "commence building"
63 # maybe some of this should be moved to cmake
64 mkdir -p $HOME/nightly-build
65 cp Makefile $HOME/nightly-build/
66 cp -R SPECS $HOME/nightly-build/
67 cd $HOME/nightly-build
69 make rpm VERSION=${HVERSION_BASE} RELEASE=${HREVISION} REFSPEC=${BRANCH} $QUIET || exit
70 #set the version we just built in rh_old_revsion so it won't be built again
71 echo $new_rev > $HOME/rh_old_revsion
72 #move files to be uploaded
73 destination="devel/incoming/"`/bin/cat /etc/redhat-release | /usr/bin/awk '{print $1}' | tr '[:upper:]' '[:lower:]'`
74 rsync -ue /usr/bin/ssh rpmbuild/RPMS/$ARCH/hoomd*.rpm joaander@foxx.engin.umich.edu:$destination/
77 #clean up
78 cd $HOME/nightly-build/rpmbuild/RPMS/$ARCH
79 rpmfiles=( `ls -td hoomd*.rpm` )
80 numfiles=${#rpmfiles[*]}
81 for (( i=$(( $NRPMS )); $i < $numfiles ; i++ )); do
82 rm ${rpmfiles[$i]};
83 done