1#!/bin/bash 2# 3# Ceres Solver - A fast non-linear least squares minimizer 4# Copyright 2012 Google Inc. All rights reserved. 5# http://code.google.com/p/ceres-solver/ 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions are met: 9# 10# * Redistributions of source code must retain the above copyright notice, 11# this list of conditions and the following disclaimer. 12# * Redistributions in binary form must reproduce the above copyright notice, 13# this list of conditions and the following disclaimer in the documentation 14# and/or other materials provided with the distribution. 15# * Neither the name of Google Inc. nor the names of its contributors may be 16# used to endorse or promote products derived from this software without 17# specific prior written permission. 18# 19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29# POSSIBILITY OF SUCH DAMAGE. 30# 31# Author: mierle@gmail.com (Keir Mierle) 32# 33# Note: You will need Sphinx and Pygments installed for this to work. 34 35if [ -z $1 ] ; then 36 echo 'usage: scripts/make_release <version>' 37 echo ' must be run from toplevel Ceres source directory' 38 exit 1 39fi 40 41TMP="/tmp/ceres-solver-$1" 42DOCS_TMP="/tmp/ceres-solver-docs-$1" 43VERSION=$(grep 'SET(CERES_VERSION_' CMakeLists.txt | \ 44 sed -e 's/\(.*\) \(.*\))/\2/' | \ 45 tr '\n' '.' | sed -e 's/.$//') 46ABI_VERSION=$(grep 'SET(CERES_ABI_VERSION' CMakeLists.txt | \ 47 sed -e 's/SET(CERES_ABI_VERSION //' | \ 48 sed -e 's/)//') 49VERSION_IN_HEADER=$(grep '#define CERES_VERSION' include/ceres/ceres.h | \ 50 sed -e 's/#define CERES_VERSION //') 51ABI_VERSION_IN_HEADER=$(grep '#define CERES_ABI_VERSION' \ 52 include/ceres/ceres.h | \ 53 sed -e 's/#define CERES_ABI_VERSION //') 54VERSION_IN_SPEC=$(grep '^Version:' scripts/ceres-solver.spec | \ 55 sed -e 's/Version: *//') 56GIT_COMMIT=$(git log -1 HEAD |grep commit) 57 58if [[ $1 != $VERSION ]] ; then 59 echo "ERROR: Version from the command line $1 does not match CERES_VERSION" 60 echo " in CMakeLists.txt, which is $VERSION. You may not be in the " 61 echo " toplevel source dir." 62 exit 1 63fi 64 65if [[ $VERSION_IN_HEADER != $VERSION ]] ; then 66 echo "ERROR: CERES_VERSION version from include/ceres/ceres.h, which is" 67 echo " $VERSION_IN_HEADER, does not match the ABI version" 68 echo " from the toplevel CMakeLists.txt, which is $ABI_VERSION." 69 echo " You may not be in the toplevel source directory, or the" 70 echo " versions are out of sync." 71 exit 1 72fi 73 74if [[ $ABI_VERSION_IN_HEADER != $ABI_VERSION ]] ; then 75 echo "ERROR: CERES_ABI_VERSION from include/ceres/ceres.h, which is" 76 echo " $ABI_VERSION_IN_HEADER, does not match the ABI version" 77 echo " from the toplevel CMakeLists.txt, which is $ABI_VERSION." 78 echo " You may not be in the toplevel source directory, or the" 79 echo " versions are out of sync." 80 exit 1 81fi 82 83if [[ $VERSION_IN_SPEC != $VERSION ]] ; then 84 echo "ERROR: Version string from scripts/ceres-solver.spec, which is" 85 echo " $VERSION_IN_SPEC, does not match the version" 86 echo " from the toplevel CMakeLists.txt, which is $ABI_VERSION." 87 echo " You may not be in the toplevel source directory, or the" 88 echo " versions are out of sync." 89 exit 1 90fi 91 92# Export repository. 93git checkout-index -f -a --prefix=$TMP/ 94 95# Build the VERSION file. 96VERSIONFILE=$TMP/VERSION 97echo "version $VERSION" >> $VERSIONFILE 98echo "abi_version $VERSION" >> $VERSIONFILE 99echo "$GIT_COMMIT" >> $VERSIONFILE 100 101# Build the documentation. 102python $TMP/scripts/make_docs.py $TMP $DOCS_TMP 103cp -pr $DOCS_TMP/html $TMP/docs 104 105# Build the tarball. 106cd /tmp 107tar -cvzf "ceres-solver-$1.tar.gz" "ceres-solver-$1" 108 109# Don't leave a mess behind. 110rm -rf $TMP 111rm -rf $DOCS_TMP 112 113# Reminder to upload. 114cat <<EOF 115 116TODO: 117 - Upload /tmp/ceres-solver-$1.tar.gz 118 119 - Update the release string in scripts/ceres-solver.spec if this is a RC 120 release or the first release after a RC release. 121 122 - Build and upload RPM package. 123 124EOF 125