1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#!/bin/sh
# PDFedit - free program for PDF document manipulation.
# Copyright (C) 2006-2009 PDFedit team: Michal Hocko,
# Jozef Misutka,
# Martin Petricek
# Former team members: Miroslav Jahoda
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (in doc/LICENSE.GPL); if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
# Project is hosted on http://sourceforge.net/projects/pdfedit
# This file controls current PDFedit version for whole build process.
# We recognize two types of versions:
# - short - contains only VERSION (see bellow) and it is used for
# package name and distribution directory names if we
# want to distinguish different installations
# - full - contains VERSION[-RELEASE] and it is only as information
# about built tree state in version strings and so on. This
# should be used when reporting bugs.
#
# where
# VERSION - stands for the last upstream release
# RELEASE - contains the times-stamp (in YYYYMMDDHHMMSS format) of the
# last modified file so that we are able to find out the state
# of compiled sources (newer than released, patch for testing
# correctly applied, etc.).
# This string is empty for upstream releases (when
# PACKAGE_VERSION variable changes) which is recognized
# by the times-stamp stored in the RELEASE_STAMP_FILE when we
# do a release. If the current time-stamp is different from
# the one stored in RELEASE_STAMP_FILE (or this file doesn't
# exist - case for CVS checkout) than the release string is
# used - and we know that the compiled version is not from
# the same released sources (or at least we can check that
# easily).
#
# Usage:
# ./getversion [[v] [-r]|[-f]|[-t]
# where
# -v prints VERSION
# -r prints REVISION
# -f prints files (with full paths) examined for getting proper revision
# (all other parameters are ignored if this parameter is specified).
# This can be used for dependency creation for files which directly
# depend on generated revision
# -t prints time-stamp for revision (intended for makedist script which
# should store this time-stamp to the RELEASE_STAMP_FILE)
# (all other parameters are ignored if this parameter is specified).
#
# Nothing is printed if no parameter is specified
PACKAGE_VERSION=0.4.5
PACKAGE_RELEASE=""
GETVERSION_DIR=`dirname $0`
EXLUDE_FILES="version_exclude"
RELEASE_STAMP_FILE="release_stamp"
cd $GETVERSION_DIR
print_version()
{
echo -n $PACKAGE_VERSION
}
CWD=`pwd`
FIND="find src -type f \( -name '*.cc' -o -name '*.h' -o -name '*.qs' \) \
| grep -v -f $EXLUDE_FILES \
| sed 's@^@$CWD/@'"
print_files()
{
eval $FIND
}
print_timestamp()
{
export TZ="UTC"
date --date=@`print_files | xargs stat -c "%Y" | \
grep -v -f $EXLUDE_FILES| \
sort -r | head -n1` -u +%Y%m%d%H%M%S
}
print_release()
{
# Files which shouldn't be checked during PACKAGE_RELEASE calculation
PACKAGE_RELEASE_FILE="`print_timestamp`"
# Calculates current release, if we are not releasing
# set release only if timestamp doesn't exist (sources from CVS)
# or timestamp is doesn't match
if [ ! -f "$RELEASE_STAMP_FILE" ] || [ "`cat $RELEASE_STAMP_FILE`" != "$PACKAGE_RELEASE_FILE" ]
then
echo Using new revision: $PACKAGE_RELEASE_FILE >&2
PACKAGE_RELEASE="-$PACKAGE_RELEASE_FILE"
echo -n $PACKAGE_RELEASE
exit 0
fi
echo We are at the clean release tree: no release >&2
}
while [ $# -gt 0 ]
do
case $1 in
-v ) PRINT_VERSION="1" ;;
-r ) PRINT_RELEASE="1" ;;
-t ) print_timestamp; exit 0;;
-f ) print_files; exit 0;;
esac
shift
done
[ -n "$PRINT_VERSION" ] && print_version
[ -n "$PRINT_RELEASE" ] && print_release
exit 0
|