diff --git a/App/tools/driver.makefile b/App/tools/driver.makefile index cd952ba..80c6b85 100644 --- a/App/tools/driver.makefile +++ b/App/tools/driver.makefile @@ -33,9 +33,10 @@ # # Module names are derived from the directory name (unless overwritten # with the MODULE variable in your Makefile). -# A LIBVERSION number is generated from the latest CVS or GIT tag of the sources. -# If any file is not up-to-date in CVS/GIT, not tagged, or tagged differently from the -# other files, the version is a test version and labelled with the user name. +# A LIBVERSION number is generated from the latest GIT tag of the sources. +# All changes must be committed, tagged and pushed (including the tag) +# and the tag found on the remote repo must match the local tag. +# Otherwise, the version is a test version and labelled with the user name. # The library is installed to ${EPICS_MODULES}/${MODULE}/${LIBVERSION}/lib/${T_A}/. # A module can be loaded with require "" [,""] [,"=, ..."] # @@ -113,7 +114,7 @@ INSTALLRULE=install:: BUILDRULE=build:: CLEANRULE = clean:: -IGNOREFILES = .cvsignore .gitignore +IGNOREFILES = .gitignore %: ${IGNOREFILES} ${IGNOREFILES}: @echo -e "O.*\n.*ignore" > $@ @@ -178,7 +179,7 @@ export MAKE_FIRST export SUBMODULES export USE_LIBVERSION -export ORIGIN=$(firstword $(shell git remote -v 2>/dev/null | awk '/psi.ch.*(fetch)/{print $$2;exit}')$(patsubst %,[%],$(shell git describe --tags --dirty --always --long 2>/dev/null)) $(addsuffix /,$(shell cat CVS/Root 2>/dev/null))$(shell cat CVS/Repository 2>/dev/null) $(PWD)) +export ORIGIN=$(firstword $(shell git remote -v 2>/dev/null | awk '/psi.ch.*(fetch)/{print $$2;exit}')$(patsubst %,[%],$(shell git describe --tags --dirty --always --long 2>/dev/null)) $(PWD)) # Some shell commands: RMDIR = rm -rf diff --git a/App/tools/getVersion.pl b/App/tools/getVersion.pl index e82220b..22d4700 100755 --- a/App/tools/getVersion.pl +++ b/App/tools/getVersion.pl @@ -8,13 +8,6 @@ use File::Glob qw/bsd_glob/; use IPC::Open3 qw/open3/; use Symbol qw/gensym/; -# cvs status parsing state -use constant { - GLOBAL => 0, - FILE => 1, - SKIP => 2 -}; - my $version; my $tag; my $remote; @@ -92,101 +85,6 @@ sub check_output { return split(/\n/, $output); } -sub parse_cvs_output { - my @output = @{$_[0]}; - my $scope = GLOBAL; - my $file; - my %rev; - my %tag; - my ($major, $minor, $patch); - - foreach my $line (@output) { - chomp($line); - if ($scope == SKIP) { - if ($line =~ /=================/) { - $scope = GLOBAL; - } - } - elsif ($scope == FILE) { - if ($line =~ /Working revision:/) { - $rev{$file} = (split " ", $line)[2]; - } - elsif ($line =~ /Sticky Tag:.*_([0-9]+)_([0-9]+)(_([0-9]+))?[ \t]+\(revision: /) { - $major = $1; - $minor = $2; - $patch = $4 || 0; - $tag{$file} = (split " ", $line)[2] . " (sticky)"; - $scope = SKIP; - } - elsif ($line =~ /_([0-9]+)_([0-9]+)(_([0-9]+))?[ \t]+\(revision: ([\.0-9]+)\)/) { - if ($rev{$file} eq $5) { - my $Major = $1; - my $Minor = $2; - my $Patch = $4 || 0; - if (!defined($major) || - $Major > $major || - ($Major == $major && ($Minor > $minor - || ($Minor == $minor && $Patch > $patch)))) { - $major = $Major; - $minor = $Minor; - $patch = $Patch; - $tag{$file} = (split " ", $line)[0]; - } - } - } - elsif ($line =~ /=================/) { - if (!defined($major)) { - say STDERR "checking $file: revision $rev{$file} not tagged => version test"; - $version = "test"; - } else { - say STDERR "checking $file: revision $rev{$file} tag $tag{$file} => version $major.$minor.$patch"; - if (!defined($version)) { - $version = "$major.$minor.$patch"; - } else { - if ($version ne "$major.$minor.$patch") { - $version = "test"; - } - } - } - $scope = GLOBAL; - } - } - elsif ($scope == GLOBAL) { - if ($line =~ /there is no version here/) { - return; - } - elsif ($line =~ /cvs status: failed/) { - say STDERR "Error: $line"; - return; - } - elsif ($line =~ /no such directory `(.*)'/) { - say STDERR "checking directory $1: no so such directory"; - return; - } - elsif ($line =~ /cvs \[status aborted\]: there is no version here/) { - return; - } - elsif ($line =~ /^File: (\S+)\s+Status: Up-to-date/) { - $file = $1; - $major = undef(); - $minor = undef(); - $patch = undef(); - $scope = FILE; - } - elsif ($line =~ /^File: (\S+)\s+Status: (.*)/) { - $file = $1; - say STDERR "checking $file: $2 => verson test"; - $version = "test"; - } - elsif ($line =~ /^\? .*/) { - $file = (split " ", $line)[1]; - say STDERR "checking $file: not in cvs => version test"; - $version = "test"; - } - } - } -} - sub parse_git_output { my @output = @{$_[0]}; @@ -367,24 +265,5 @@ eval { exit; }; -eval { -# cvs bug: calling cvs status for files in other directories spoils status -# information for local files. -# fix: check local and non local files separately - - # fails if we have no cvs or server has a problem - @statusinfo = check_output("cvs status -l -v $files"); - # mark the finsh of the last file for the parser - push @statusinfo, "==================================================================="; - parse_cvs_output(\@statusinfo); - if (!defined($version)) { - say STDERR "Could not find out version tag => version test"; - $version = "test"; - } - - say $version; - exit; -}; - say STDERR "No repository found => version test"; say "test"; diff --git a/Readme.md b/Readme.md index ce14d4b..670be40 100644 --- a/Readme.md +++ b/Readme.md @@ -423,13 +423,15 @@ driver.makefile, simply remove the `GNUmakefile` but keep (or create) the ### Versions and Tags -The version is generated from a tag in CVS or GIT. If all used files are -checked in (committed) and tagged and the tag ends in two or three numbers -separated by `_` or consists of two or three numbers separated by `.` then -the version number is generated from these numbers. A missing third number -is replaced with 0. +The version is generated from a GIT tag which must consist of two or three +numbers separated by `.` or (for backward compatibility) must end in two or +three numbers separated by `_`. A missing third number is replaced with 0. -**Examples:** `mydriver_7_2`, `1.2.3` +All used files must be committed, the commit must be tagged and pushed +together with the tag and the tag on the remote server must match the local +tag. + +**Examples:** `1.2.3`, `mydriver_7_2` The first number is the major version number. It must be incremented if any change in the module is not backward compatible. Such changes include: @@ -458,8 +460,9 @@ The third number is the patch level. It resets whenever the minor version number is changed. Increment the patch level with every bug fix. Do not add new features without using a new minor version number. -When the current source is not tagged, not committed (or, for GIT, not -pushed) or not even tracked by CVS or GIT, then a test version is built. +If the current source is not tagged, not committed, not pushed or not even +tracked by GIT, or the remote tag is not on the same commit as the local one, +then a test version is built. By default the version string is the content of the `$USER` variable. You can overwrite this by calling `make LIBVERSION=versionstring`. Be careful when doing this!