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

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

When working with pycocci I noticed that 1) the git tree version of coccinelle
at Inria has different tags than the git tree at github, and 2) that I was not
able to easily get Coccinelle's own tools to determine if we had some sort of
dirty tree or tree with changes beyond a tagged official release. As an example
even though --jobs is now fixed on the inria git tree, this code is not yet
on github.

The issue with 1) prevents me to build custom versions of coccinelle
and get pycocci to work with my goal to support the future 1.0.2 release
or a release beyond 1.0.1. The issues with 1) may hopefully be fixed by
streamlining how the releases are made with development but discussion is
ongoing with this.

Provided 1) was fixed, and say the inria git tree had the proper 1.0.1 tag
as well, I'd then be able to modify pycocci to say: hey, use --jobs if you
detect you are on a release which is > 1.0.1. I can't do this though as the
version information on coccinelle does not take into consideration local
deltas. I've decided to borrow the Linux kernel mechanism for determining
this and allowing Coccinelle to make use of it. With these changes we will
keep the version string clean if no tree modifications are on your tree and
your tags are synced up.

If you have modifications you can end up either with a -dirty postfixed tree,
or a tree that shows the delta of commits on top of a blessed release. For
instance, if you have changes not commited you'll now get on spatch --version:

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 something like:

1.0.2-00001-g8870d8b0cf33

Provided we address 1) then tools can infer local hacks and let you move on
with life as the coccinelle development train moves forward.

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

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

-- 
2.3.2.209.gd67f9d5.dirty

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

* [Cocci] [PATCH 1/2] autotools: unify the way to determine version information
  2015-07-21 20:50 [Cocci] [PATCH 0/2] coccinelle: add localversion information Luis R. Rodriguez
@ 2015-07-21 20:51 ` Luis R. Rodriguez
  2015-07-23  4:18   ` Nikolay Orlyuk
  2015-07-21 20:51 ` [Cocci] [PATCH 2/2] autotools: add localversion information Luis R. Rodriguez
  1 sibling, 1 reply; 11+ messages in thread
From: Luis R. Rodriguez @ 2015-07-21 20:51 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..cff8412019fa 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 | tr -d '\n')
 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..679660956401 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 | tr -d '\n']), [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..f18206344a76
--- /dev/null
+++ b/version.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+VERSION=`cat ./version | tr -d '\n'`
+printf '%s' $VERSION
-- 
2.3.2.209.gd67f9d5.dirty

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

* [Cocci] [PATCH 2/2] autotools: add localversion information
  2015-07-21 20:50 [Cocci] [PATCH 0/2] coccinelle: add localversion information Luis R. Rodriguez
  2015-07-21 20:51 ` [Cocci] [PATCH 1/2] autotools: unify the way to determine version information Luis R. Rodriguez
@ 2015-07-21 20:51 ` Luis R. Rodriguez
  1 sibling, 0 replies; 11+ messages in thread
From: Luis R. Rodriguez @ 2015-07-21 20:51 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.

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 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++
 version.sh              |  3 +-
 2 files changed, 79 insertions(+), 1 deletion(-)
 create mode 100755 scripts/setlocalversion

diff --git a/scripts/setlocalversion b/scripts/setlocalversion
new file mode 100755
index 000000000000..f6b6d9df5ed9
--- /dev/null
+++ b/scripts/setlocalversion
@@ -0,0 +1,77 @@
+#!/bin/sh
+#
+# 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.
+
+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 --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 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 f18206344a76..a12597c246ca 100755
--- a/version.sh
+++ b/version.sh
@@ -1,3 +1,4 @@
 #!/bin/sh
 VERSION=`cat ./version | tr -d '\n'`
-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] 11+ messages in thread

* [Cocci] [PATCH 1/2] autotools: unify the way to determine version information
  2015-07-21 20:51 ` [Cocci] [PATCH 1/2] autotools: unify the way to determine version information Luis R. Rodriguez
@ 2015-07-23  4:18   ` Nikolay Orlyuk
  2015-07-23  7:12     ` Sébastien Hinderer
  2015-07-24 17:12     ` [Cocci] [PATCH 1/2] " Luis R. Rodriguez
  0 siblings, 2 replies; 11+ messages in thread
From: Nikolay Orlyuk @ 2015-07-23  4:18 UTC (permalink / raw)
  To: cocci

Do we still need VERSION=$(shell ./version.sh | tr -d '\n') ? I'm pretty
sure that VERSION=$(shell ./version.sh) will be enough. Same for
configure.ac.
Moreover why script version.sh can't be simply?

#!/bin/sh
> tr -d '\n' < ./version
>

Other option would be to introduce subst. variable in configure.ac and use
it in configurable Makefile. This approach might be more widespread.

2015-07-21 23:51 GMT+03:00 Luis R. Rodriguez <mcgrof@do-not-panic.com>:

> 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..cff8412019fa 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 | tr -d '\n')
>  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..679660956401 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 | tr -d '\n']), [
> 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..f18206344a76
> --- /dev/null
> +++ b/version.sh
> @@ -0,0 +1,3 @@
> +#!/bin/sh
> +VERSION=`cat ./version | tr -d '\n'`
> +printf '%s' $VERSION
> --
> 2.3.2.209.gd67f9d5.dirty
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20150723/e3cd44fc/attachment-0001.html>

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

* [Cocci] [PATCH 1/2] autotools: unify the way to determine version information
  2015-07-23  4:18   ` Nikolay Orlyuk
@ 2015-07-23  7:12     ` Sébastien Hinderer
  2015-07-24 18:53       ` Luis R. Rodriguez
  2015-07-24 17:12     ` [Cocci] [PATCH 1/2] " Luis R. Rodriguez
  1 sibling, 1 reply; 11+ messages in thread
From: Sébastien Hinderer @ 2015-07-23  7:12 UTC (permalink / raw)
  To: cocci

Hi,

Nikolay Orlyuk (2015/07/23 07:18 +0300):
> Do we still need VERSION=$(shell ./version.sh | tr -d '\n') ? I'm pretty
> sure that VERSION=$(shell ./version.sh) will be enough. Same for
> configure.ac.
> Moreover why script version.sh can't be simply?
> 
> #!/bin/sh
> > tr -d '\n' < ./version
> >
> 
> Other option would be to introduce subst. variable in configure.ac and use
> it in configurable Makefile. This approach might be more widespread.

Yes, I believe this second approach would be better.

S?bastien.

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

* [Cocci] [PATCH 1/2] autotools: unify the way to determine version information
  2015-07-23  4:18   ` Nikolay Orlyuk
  2015-07-23  7:12     ` Sébastien Hinderer
@ 2015-07-24 17:12     ` Luis R. Rodriguez
  2015-07-26  6:55       ` Nikolay Orlyuk
  1 sibling, 1 reply; 11+ messages in thread
From: Luis R. Rodriguez @ 2015-07-24 17:12 UTC (permalink / raw)
  To: cocci

On Thu, Jul 23, 2015 at 07:18:34AM +0300, Nikolay Orlyuk wrote: > Do we still need VERSION=$(shell ./version.sh | tr -d '\n') ? I'm pretty
> sure that VERSION=$(shell ./version.sh) will be enough. Same for
> configure.ac.
> Moreover why script version.sh can't be simply?
> 
> #!/bin/sh
> > tr -d '\n' < ./version
> >

These are identical:

VERSION=`cat ./version | tr -d '\n'`
VERSION=`tr -d '\n' < ./version`

I'll give you calling cat can be avoided so lets go with that.
Either way we want to stash it into a variable so we can later
expand on it with something not in the version file which is
instead taken from the script we are adding.

> Other option would be to introduce subst. variable in configure.ac and use
> it in configurable Makefile. This approach might be more widespread.

We don't use automake, I think its best to keep it that way. I'll
just remove the double tr -d calls on both configure.ac and the top
level Makefile.

  Luis

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

* [Cocci] [PATCH 1/2] autotools: unify the way to determine version information
  2015-07-23  7:12     ` Sébastien Hinderer
@ 2015-07-24 18:53       ` Luis R. Rodriguez
  2015-07-31 13:40         ` [Cocci] " SF Markus Elfring
  0 siblings, 1 reply; 11+ messages in thread
From: Luis R. Rodriguez @ 2015-07-24 18:53 UTC (permalink / raw)
  To: cocci

On Thu, Jul 23, 2015 at 09:12:44AM +0200, S?bastien Hinderer wrote:
> Hi,
> 
> Nikolay Orlyuk (2015/07/23 07:18 +0300):
> > Do we still need VERSION=$(shell ./version.sh | tr -d '\n') ? I'm pretty
> > sure that VERSION=$(shell ./version.sh) will be enough. Same for
> > configure.ac.
> > Moreover why script version.sh can't be simply?
> > 
> > #!/bin/sh
> > > tr -d '\n' < ./version
> > >
> > 
> > Other option would be to introduce subst. variable in configure.ac and use
> > it in configurable Makefile. This approach might be more widespread.
> 
> Yes, I believe this second approach would be better.

Do you mean AC_SUBST()? Using AC_SUBST() is overkill and we don't use automake.
But up to you folks.  I try to avoid using autotools at all costs so if you
would like that instead a replacement patch by you might be more suitable.

  Luis

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

* [Cocci] [PATCH 1/2] autotools: unify the way to determine version information
  2015-07-24 17:12     ` [Cocci] [PATCH 1/2] " Luis R. Rodriguez
@ 2015-07-26  6:55       ` Nikolay Orlyuk
  2015-07-27 19:26         ` Luis R. Rodriguez
  0 siblings, 1 reply; 11+ messages in thread
From: Nikolay Orlyuk @ 2015-07-26  6:55 UTC (permalink / raw)
  To: cocci

2015-07-24 20:12 GMT+03:00 Luis R. Rodriguez <mcgrof@suse.com>:

> On Thu, Jul 23, 2015 at 07:18:34AM +0300, Nikolay Orlyuk wrote: > Do we
> still need VERSION=$(shell ./version.sh | tr -d '\n') ? I'm pretty
> > sure that VERSION=$(shell ./version.sh) will be enough. Same for
> > configure.ac.
> > Moreover why script version.sh can't be simply?
> >
> > #!/bin/sh
> > > tr -d '\n' < ./version
> > >
>
> These are identical:
>
> VERSION=`cat ./version | tr -d '\n'`
> VERSION=`tr -d '\n' < ./version`
>
> I'll give you calling cat can be avoided so lets go with that.
> Either way we want to stash it into a variable so we can later
> expand on it with something not in the version file which is
> instead taken from the script we are adding.
>

That script is equivalent to:

#!/bin/sh
> tr -d '\n' < version
> ./scripts/setlocalversion | tr -d '\n'
>

Storing variables just to expand it isn't required. I'd agree if there
would be something like "${VERSION}-dirty${LOCALVERSION}" or printf "%s.%s"
"${VERSION}" "${LOCALVERSION}"
Just collecting output to print it again as-is seems redundant for me.
That's all I wanted to say regarding that script.
Note that expansion of variable as argument without double-quotes for
printf "%s" will results in removing spaces. If that's normal behavior it
can be achieved more explicitly with "tr -d ' \n'" (include space in set of
deleted chars alongside with '\n')


> > Other option would be to introduce subst. variable in configure.ac and
> use
> > it in configurable Makefile. This approach might be more widespread.
>
> We don't use automake, I think its best to keep it that way. I'll
> just remove the double tr -d calls on both configure.ac and the top
> level Makefile.
>

I do not refer to automake.
But we definitely use AC_INIT in configure.ac (autoconf) and according to
http://www.gnu.org/software/autoconf/manual/autoconf.html#Initializing-configure
we already can write:

diff --git a/Makefile b/Makefile
index 061dbc1..9e4a47f 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,6 @@ endif
 -include /etc/Makefile.coccinelle  # local customizations, if any


-VERSION=$(shell cat ./version | tr -d '\n')
 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/Makefile.config.in b/Makefile.config.in
index 10189d2..13cf64f 100644
--- a/Makefile.config.in
+++ b/Makefile.config.in
@@ -1,3 +1,5 @@
+VERSION=@PACKAGE_VERSION@
+
 # * for each library $1, add another entry in the same manner
 MAKELIBS=@MAKE_dynlink@ @MAKE_menhirLib@ @MAKE_pycaml@ @MAKE_pcre@ \
   @MAKE_parmap@
== cut ==



>
>   Luis
>

Cheers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20150726/30b0df5c/attachment.html>

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

* [Cocci] [PATCH 1/2] autotools: unify the way to determine version information
  2015-07-26  6:55       ` Nikolay Orlyuk
@ 2015-07-27 19:26         ` Luis R. Rodriguez
  0 siblings, 0 replies; 11+ messages in thread
From: Luis R. Rodriguez @ 2015-07-27 19:26 UTC (permalink / raw)
  To: cocci

On Sun, Jul 26, 2015 at 09:55:46AM +0300, Nikolay Orlyuk wrote:
> 2015-07-24 20:12 GMT+03:00 Luis R. Rodriguez <mcgrof@suse.com>:
> 
> > On Thu, Jul 23, 2015 at 07:18:34AM +0300, Nikolay Orlyuk wrote: > Do we
> > still need VERSION=$(shell ./version.sh | tr -d '\n') ? I'm pretty
> > > sure that VERSION=$(shell ./version.sh) will be enough. Same for
> > > configure.ac.
> > > Moreover why script version.sh can't be simply?
> > >
> > > #!/bin/sh
> > > > tr -d '\n' < ./version
> > > >
> >
> > These are identical:
> >
> > VERSION=`cat ./version | tr -d '\n'`
> > VERSION=`tr -d '\n' < ./version`
> >
> > I'll give you calling cat can be avoided so lets go with that.
> > Either way we want to stash it into a variable so we can later
> > expand on it with something not in the version file which is
> > instead taken from the script we are adding.
> >
> 
> That script is equivalent to:
> 
> #!/bin/sh
> > tr -d '\n' < version
> > ./scripts/setlocalversion | tr -d '\n'
> >
> 
> Storing variables just to expand it isn't required. I'd agree if there
> would be something like "${VERSION}-dirty${LOCALVERSION}" or printf "%s.%s"
> "${VERSION}" "${LOCALVERSION}"
> Just collecting output to print it again as-is seems redundant for me.
> That's all I wanted to say regarding that script.

Its a small optimization you seek for, the tradefoff IMHO is readibility and
since this code does not run often I don't think the optimization of not using
a variable helps much, and would easily allow extensions and customizations
as you note.

> Note that expansion of variable as argument without double-quotes for
> printf "%s" will results in removing spaces. If that's normal behavior it
> can be achieved more explicitly with "tr -d ' \n'" (include space in set of
> deleted chars alongside with '\n')

Not sure if that printf behaviour is POSIX compliant, in fact I hate /bin/sh
complaince confusion for the ambiguity here and in other places. I'll go with
what you propose.

> > > Other option would be to introduce subst. variable in configure.ac and
> > use
> > > it in configurable Makefile. This approach might be more widespread.
> >
> > We don't use automake, I think its best to keep it that way. I'll
> > just remove the double tr -d calls on both configure.ac and the top
> > level Makefile.
> >
> 
> I do not refer to automake.
> But we definitely use AC_INIT in configure.ac (autoconf) and according to
> http://www.gnu.org/software/autoconf/manual/autoconf.html#Initializing-configure
> we already can write:
> 
> diff --git a/Makefile b/Makefile
> index 061dbc1..9e4a47f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -43,7 +43,6 @@ endif
>  -include /etc/Makefile.coccinelle  # local customizations, if any
> 
> 
> -VERSION=$(shell cat ./version | tr -d '\n')
>  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/Makefile.config.in b/Makefile.config.in
> index 10189d2..13cf64f 100644
> --- a/Makefile.config.in
> +++ b/Makefile.config.in
> @@ -1,3 +1,5 @@
> +VERSION=@PACKAGE_VERSION@
> +
>  # * for each library $1, add another entry in the same manner
>  MAKELIBS=@MAKE_dynlink@ @MAKE_menhirLib@ @MAKE_pycaml@ @MAKE_pcre@ \
>    @MAKE_parmap@

Ah very nice, yes. OK I'll respin and try to use this. I also I think found a way
to not require removing a git tag for a release, I'll add that too. I'll also highlight
that my this respin I addressed not requiring PGP tags, instead these are optional.

 Luis

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

* [Cocci] autotools: unify the way to determine version information
  2015-07-24 18:53       ` Luis R. Rodriguez
@ 2015-07-31 13:40         ` SF Markus Elfring
  2015-08-05 21:13           ` Luis R. Rodriguez
  0 siblings, 1 reply; 11+ messages in thread
From: SF Markus Elfring @ 2015-07-31 13:40 UTC (permalink / raw)
  To: cocci

> Using AC_SUBST() is overkill and we don't use automake.

How do you think about the consequences from a call of the macro "AM_INIT_AUTOMAKE" then?
https://github.com/coccinelle/coccinelle/blob/e7dd46783d6addd7efad735144d85ed8fde841ce/configure.ac#L13
http://www.gnu.org/software/automake/manual/html_node/Requirements.html


> I try to avoid using autotools at all costs so if you would like that
> instead a replacement patch by you might be more suitable.

Do you fiddle also with other software build specifications occasionally?

Regards,
Markus

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

* [Cocci] autotools: unify the way to determine version information
  2015-07-31 13:40         ` [Cocci] " SF Markus Elfring
@ 2015-08-05 21:13           ` Luis R. Rodriguez
  0 siblings, 0 replies; 11+ messages in thread
From: Luis R. Rodriguez @ 2015-08-05 21:13 UTC (permalink / raw)
  To: cocci

On Fri, Jul 31, 2015 at 03:40:38PM +0200, SF Markus Elfring wrote:
> > Using AC_SUBST() is overkill and we don't use automake.
> 
> How do you think about the consequences from a call of the macro "AM_INIT_AUTOMAKE" then?
> https://github.com/coccinelle/coccinelle/blob/e7dd46783d6addd7efad735144d85ed8fde841ce/configure.ac#L13
> http://www.gnu.org/software/automake/manual/html_node/Requirements.html

Can't say I care.

> > I try to avoid using autotools at all costs so if you would like that
> > instead a replacement patch by you might be more suitable.
> 
> Do you fiddle also with other software build specifications occasionally?

I've only looked enough at autotools to pationately hate it.

Its year 2015 and the requirements for designing autotools
should now be superceded with simple mechanisms and modern
helpers.

  Luis

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

end of thread, other threads:[~2015-08-05 21:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-21 20:50 [Cocci] [PATCH 0/2] coccinelle: add localversion information Luis R. Rodriguez
2015-07-21 20:51 ` [Cocci] [PATCH 1/2] autotools: unify the way to determine version information Luis R. Rodriguez
2015-07-23  4:18   ` Nikolay Orlyuk
2015-07-23  7:12     ` Sébastien Hinderer
2015-07-24 18:53       ` Luis R. Rodriguez
2015-07-31 13:40         ` [Cocci] " SF Markus Elfring
2015-08-05 21:13           ` Luis R. Rodriguez
2015-07-24 17:12     ` [Cocci] [PATCH 1/2] " Luis R. Rodriguez
2015-07-26  6:55       ` Nikolay Orlyuk
2015-07-27 19:26         ` Luis R. Rodriguez
2015-07-21 20:51 ` [Cocci] [PATCH 2/2] autotools: add localversion information 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.