All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] [PATCH v2 0/2] coccinelle: add localversion information
@ 2015-07-24 18:50 Luis R. Rodriguez
  2015-07-24 18:50 ` [Cocci] [PATCH v2 1/2] autotools: unify the way to determine version information Luis R. Rodriguez
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luis R. Rodriguez @ 2015-07-24 18:50 UTC (permalink / raw)
  To: cocci

From: "Luis R. Rodriguez" <mcgrof@suse.com>

This v2 removes the superfluous tr calls and switches to using stdin
instead of using cat for the first look at the version file. While
at it, since I am taking this from the Linux kernel and since the
script used had quite a bit of love over the years I've provided
attribution information to the file. Since Coccinelle does not
currently used PGP signed tags I've also added support for that
and enabled its use by default but am in hopes we can consider
using PGP keys for signed tags in the future.

I also made a small note about using PGP subkeys for deprecating releases,
for details on why that may be good see:

http://lkml.kernel.org/r/20150721002438.GG30479 at wotan.suse.de

In short, I'd encourage folks to use PGP subkeys for different purposes.
For instance use one PGP subkey for making releases, and another different
PGP subkey for deprecating releaes. Using two different PGP keys (different
keys are overkill, hence why I say just use subkeys) can help tools to infer
what releases are supported and unsupported, directly from the git tree.
Feel free to ignore all this if you do not care for tools to infer releases
for coccinelle, but if for instance you do care for it and if it is desirable
for the release page to be made automatically, I can volunteer to help
integrate it as part of rel-html. Example release pages with rel-html:

http://drvbp1.linux-foundation.org/~mcgrof/rel-html/

Lastly, I realize a 'make release' is used right now for releases, I
didn't amend those instructions (on Makefile.release) but here's a way 
to use upkeep a linear git tree (not done right now on Coccinelle) even
if you wanted to bump release with autotools:

Say you have a linear set of history and you are about to make a 1.0.2
release, you'd do this:

a) edit version file and bump it to 1.0.2
b) git clean -f -x -d
   Careful, this will delete *everything* that is not commited in your
   git tree.
c) make a temporary tag for git with 1.0.2, so that when you run ./autogen it
   will pick up all the 1.0.2 tag and detect your tree is intact and all code
   is part of the release.
   git tag -s 1.0.2
d) run ./autogen
e) git commit -a -s
f) delete the temporary tag:
   git tag -d 1.0.2
g) make a new tag now that matches the autogen run:
   git tag -s 1.0.2

This allows you to keep using 1 tag for both git development and autotools
official releases. This means that if people check out a release on the
tag 1.0.2 you will always get 1.0.2 on the version information so long as
you didn't do any modifications and provided your autotools versions match
(this later requirement is less important to developers). It also means that
same git tree checkout for non-developers, who do not run ./autgen but just
run ./configure will always get the same version information.

Luis R. Rodriguez (2):
  autotools: unify the way to determine version information
  autotools: add localversion information

 Makefile                |   2 +-
 configure.ac            |   2 +-
 scripts/setlocalversion | 117 ++++++++++++++++++++++++++++++++++++++++++++++++
 version.sh              |   4 ++
 4 files changed, 123 insertions(+), 2 deletions(-)
 create mode 100755 scripts/setlocalversion
 create mode 100755 version.sh

-- 
2.3.2.209.gd67f9d5.dirty

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Cocci] [PATCH v2 1/2] autotools: unify the way to determine version information
  2015-07-24 18:50 [Cocci] [PATCH v2 0/2] coccinelle: add localversion information Luis R. Rodriguez
@ 2015-07-24 18:50 ` Luis R. Rodriguez
  2015-07-24 18:50 ` [Cocci] [PATCH v2 2/2] autotools: add localversion information Luis R. Rodriguez
  2015-07-24 18:56 ` [Cocci] [PATCH v2 0/2] coccinelle: " Luis R. Rodriguez
  2 siblings, 0 replies; 4+ messages in thread
From: Luis R. Rodriguez @ 2015-07-24 18:50 UTC (permalink / raw)
  To: cocci

From: "Luis R. Rodriguez" <mcgrof@suse.com>

The version information you get when you run: spatch --version
comes from what ./confgure.ac ends up figuring out for you.
The top level Makefile uses the same mechanism to tell you
and use the version information at build time, but if the
strategy is updated in one place it would need to be updated
in both places.

Avoid this duplicatin of work and instead just make version
information come from ./version.sh script. Then if we update
how we get the version information it just needs to be done
in one place.

We make the version.sh script use old shell mechanisms to be
able to work on any supported unix system.

Cc: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: Nikolay Orlyuk <virkony@gmail.com>
Cc: S?bastien Hinderer <Sebastien.Hinderer@inria.fr>
Cc: Quentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 Makefile     | 2 +-
 configure.ac | 2 +-
 version.sh   | 3 +++
 3 files changed, 5 insertions(+), 2 deletions(-)
 create mode 100755 version.sh

diff --git a/Makefile b/Makefile
index fd369415b1ec..57e01e2afb1c 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ endif
 -include /etc/Makefile.coccinelle  # local customizations, if any
 
 
-VERSION=$(shell cat ./version | tr -d '\n')
+VERSION=$(shell ./version.sh)
 CCVERSION=$(shell cat scripts/coccicheck/README | egrep -o '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' | head -n1)
 PKGVERSION=$(shell dpkg-parsechangelog -ldebian/changelog.$(DISTRIB_CODENAME) 2> /dev/null \
 	 | sed -n 's/^Version: \(.*\)/\1/p' )
diff --git a/configure.ac b/configure.ac
index d4072004228c..4c610afa5a2d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@ dnl  run 'automake -acf' to update setup/{install-sh,missing}
 
 dnl  standard initialization (we only use autoconf not automake)
 AC_PREREQ([2.68])
-AC_INIT([coccinelle], m4_esyscmd([cat ./version | tr -d '\n']), [cocci at systeme.lip6.fr], [], [http://coccinelle.lip6.fr/])
+AC_INIT([coccinelle], m4_esyscmd([./version.sh]), [cocci at systeme.lip6.fr], [], [http://coccinelle.lip6.fr/])
 AC_CONFIG_MACRO_DIR([setup])
 AC_CONFIG_AUX_DIR([setup])
 AC_SUBST([CONFIGURE_FLAGS], ["$*"])
diff --git a/version.sh b/version.sh
new file mode 100755
index 000000000000..a464ab47dbd6
--- /dev/null
+++ b/version.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+VERSION=`tr -d '\n' < ./version`
+printf '%s' $VERSION
-- 
2.3.2.209.gd67f9d5.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Cocci] [PATCH v2 2/2] autotools: add localversion information
  2015-07-24 18:50 [Cocci] [PATCH v2 0/2] coccinelle: add localversion information Luis R. Rodriguez
  2015-07-24 18:50 ` [Cocci] [PATCH v2 1/2] autotools: unify the way to determine version information Luis R. Rodriguez
@ 2015-07-24 18:50 ` Luis R. Rodriguez
  2015-07-24 18:56 ` [Cocci] [PATCH v2 0/2] coccinelle: " Luis R. Rodriguez
  2 siblings, 0 replies; 4+ messages in thread
From: Luis R. Rodriguez @ 2015-07-24 18:50 UTC (permalink / raw)
  To: cocci

From: "Luis R. Rodriguez" <mcgrof@suse.com>

When someone is building Coccinelle from source on a git tree
with some modifications we currently cannot tell what type of
modifications were, if any, were done. Add a localversion info
postix which will be pegged onto the version string *iff* the
git tree used has either a change non-commited  yet or if the
git tree has some commits beyond what was officially released
and tagged.

So if you have a dirty tree with some uncommited changes the
version will be postfixed with -dirty. For example if 1.0.2 was
blessed and released and you had a series of uncommited changes
you'd end yup with:

1.0.2-dirty

Likewise if your tree has some commits not upstream these will be
reflected. For instance, say you had one extra commit, you'd end
up with:

1.0.2-00001-g8870d8b0cf33

The purpose of this is to enable developers and tools within
Coccinelle to be able to tell when folks have modified upstream
code.

The setlocalversion file was take and modified from the Linux
kernel, it was repurposed for Coccinelle by just simplifying it
by hardcoding it to use the long version string if there is any
delta. It also supports unsigned and un-annotated tags (how
Coccinelle makes releases today) but encourages folks to switch
to PGP signed releases, as well as using another PGP subkey for
deprecating releases.

Cc: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: Nikolay Orlyuk <virkony@gmail.com>
Cc: S?bastien Hinderer <Sebastien.Hinderer@inria.fr>
Cc: Quentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 scripts/setlocalversion | 117 ++++++++++++++++++++++++++++++++++++++++++++++++
 version.sh              |   3 +-
 2 files changed, 119 insertions(+), 1 deletion(-)
 create mode 100755 scripts/setlocalversion

diff --git a/scripts/setlocalversion b/scripts/setlocalversion
new file mode 100755
index 000000000000..728b54e9ee9f
--- /dev/null
+++ b/scripts/setlocalversion
@@ -0,0 +1,117 @@
+#!/bin/sh
+#
+# Copyright (c) 2005-2006 Ryan Anderson <ryan@michonline.com>
+# Copyright (c) 2006 Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
+# Copyright (c) 2006 Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de>
+# Copyright (c) 2007 Aron Griffis <aron@hp.com>
+# Copyright (c) 2007 Theodore Ts'o <tytso@mit.edu>
+# Copyright (c) 2008 Bryan Wu <bryan.wu@analog.com>
+# Copyright (c) 2008 Mike Frysinger <vapier@gentoo.org>
+# Copyright (c) 2008 Peter Korsgaard <jacmet@sunsite.dk>
+# Copyright (c) 2008 Sebastian Siewior <lkml@ml.breakpoint.cc>
+# Copyright (c) 2008 Trent Piepho <tpiepho@freescale.com>
+# Copyright (c) 2009 Mike Frysinger <vapier.adi@gmail.com>
+# Copyright (c) 2009 Nico Schottelius <nico-linuxsetlocalversion@schottelius.org>
+# Copyright (c) 2009 Peter Korsgaard <jacmet@sunsite.dk>
+# Copyright (c) 2010 Linus Torvalds <torvalds@linux-foundation.org>
+# Copyright (c) 2010 Michael Prokop <mika@grml.org>
+# Copyright (c) 2010 Micha? G?rny <gentoo@mgorny.alt.pl>
+# Copyright (c) 2010 Michal Marek <mmarek@suse.cz>
+# Copyright (c) 2010 Milton Miller <miltonm@bga.com>
+# Copyright (c) 2011 Mike Crowe <mcrowe@zipitwireless.com>
+# Copyright (c) 2012 Roland Dreier <roland@purestorage.com>
+# Copyright (c) 2013 Christian Kujau <lists@nerdbynature.de>
+# Copyright (c) 2013 Christophe Leroy <christophe.leroy@c-s.fr>
+# Copyright (c) 2013 Franck Bui-Huu <fbuihuu@gmail.com>
+# Copyright (c) 2015 Luis R. Rodriguez <mcgrof@do-not-panic.com>
+#
+# This file is released under the GPLv2.
+#
+# Taken from the Linux kernel as of v4.2-rc2 with a few modifications
+# described below.
+#
+# This scripts adds local version information from the version
+# control systems. It was taken from the Linux kernel as of v4.2-rc2
+# and simplified for use on Coccinelle by mcgrof. The version info
+# was hard coded to use long version. The svn postfix details were
+# also removed. I also added the option to enable this script to
+# work well for trees that do not use PGP signed tags or annotated
+# tags (git tag -s or git tag -a), git describe by default will only
+# look for these tags. If you do not use these you will want to set
+# the below variable to TAGS="--tags". If  you requires --tags, consider
+# to start signing your releases "git tag -s" and use a subkey for that.
+# If you do that, consider also using another PGP subkey for annotating
+# releases as deprecated.
+#
+# Set to emtpy variable if you use properly signed tags. You should do this!
+TAGS="--tags"
+
+srctree=.
+
+scm_version()
+{
+	local short
+	short=false
+
+
+	# Check for git and a git repo.
+	if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
+	   head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
+
+		# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
+		# it, because this version is defined in the top level Makefile.
+		if [ -z "`git describe $TAGS --exact-match 2>/dev/null`" ]; then
+
+			# If only the short version is requested, don't bother
+			# running further git commands
+			if $short; then
+				echo "+"
+				return
+			fi
+			# If we are past a tagged commit (like
+			# "v2.6.30-rc5-302-g72357d5"), we pretty print it.
+			if atag="`git describe $TAGS 2>/dev/null`"; then
+				echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
+
+			# If we don't have a tag at all we print -g{commitish}.
+			else
+				printf '%s%s' -g $head
+			fi
+		fi
+
+		# Check for uncommitted changes
+		if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then
+			printf '%s' -dirty
+		fi
+
+		# All done with git
+		return
+	fi
+
+	# Check for mercurial and a mercurial repo.
+	if test -d .hg && hgid=`hg id 2>/dev/null`; then
+		# Do we have an tagged version?  If so, latesttagdistance == 1
+		if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then
+			id=`hg log -r . --template '{latesttag}'`
+			printf '%s%s' -hg "$id"
+		else
+			tag=`printf '%s' "$hgid" | cut -d' ' -f2`
+			if [ -z "$tag" -o "$tag" = tip ]; then
+				id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
+				printf '%s%s' -hg "$id"
+			fi
+		fi
+
+		# Are there uncommitted changes?
+		# These are represented by + after the changeset id.
+		case "$hgid" in
+			*+|*+\ *) printf '%s' -dirty ;;
+		esac
+
+		# All done with mercurial
+		return
+	fi
+}
+
+res="$res$(scm_version)"
+echo "$res"
diff --git a/version.sh b/version.sh
index a464ab47dbd6..157b3e2d549c 100755
--- a/version.sh
+++ b/version.sh
@@ -1,3 +1,4 @@
 #!/bin/sh
 VERSION=`tr -d '\n' < ./version`
-printf '%s' $VERSION
+LOCALVERSION=`./scripts/setlocalversion | tr -d '\n'`
+printf '%s%s' $VERSION $LOCALVERSION
-- 
2.3.2.209.gd67f9d5.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Cocci] [PATCH v2 0/2] coccinelle: add localversion information
  2015-07-24 18:50 [Cocci] [PATCH v2 0/2] coccinelle: add localversion information Luis R. Rodriguez
  2015-07-24 18:50 ` [Cocci] [PATCH v2 1/2] autotools: unify the way to determine version information Luis R. Rodriguez
  2015-07-24 18:50 ` [Cocci] [PATCH v2 2/2] autotools: add localversion information Luis R. Rodriguez
@ 2015-07-24 18:56 ` Luis R. Rodriguez
  2 siblings, 0 replies; 4+ messages in thread
From: Luis R. Rodriguez @ 2015-07-24 18:56 UTC (permalink / raw)
  To: cocci

On Fri, Jul 24, 2015 at 11:50:11AM -0700, Luis R. Rodriguez wrote:
> a) edit version file and bump it to 1.0.2

Forgot to mention you'd need to commit this after as part of this step.

  Luis

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-24 18:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-24 18:50 [Cocci] [PATCH v2 0/2] coccinelle: add localversion information Luis R. Rodriguez
2015-07-24 18:50 ` [Cocci] [PATCH v2 1/2] autotools: unify the way to determine version information Luis R. Rodriguez
2015-07-24 18:50 ` [Cocci] [PATCH v2 2/2] autotools: add localversion information Luis R. Rodriguez
2015-07-24 18:56 ` [Cocci] [PATCH v2 0/2] coccinelle: " Luis R. Rodriguez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.