You are not logged in.

#1 2019-12-24 20:55:03

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 7,813

how to use version in CMakelists.txt in pkgver for vcs package ?

I'm working on a git package for the fork of openscenegraph at https://github.com/OpenMW/osg .
The package will built recommended plugins for openmw only.

$ git describe --long | sed 's/^OpenSceneGraph-//;s/\([^-]*-g\)/r\1/;s/-/./g'
$ 3.5.10.r289.gecedf3232

This looks ok at first , but the 3.5.10 doesn't match CMakelists.txt and the 289 is only relevant against 3.5.10 tag.


$ echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
$ 15768.ecedf3232

This gives number of commits since start and short hash, which is useful.

top of CMakelIsts.txt

#
# OpenSceneGraph CMake build file
#
SET(OPENSCENEGRAPH_MAJOR_VERSION 3)
SET(OPENSCENEGRAPH_MINOR_VERSION 7)
SET(OPENSCENEGRAPH_PATCH_VERSION 0)
SET(OPENSCENEGRAPH_SOVERSION 160)

How can I extract the 3 7 0 from CMakelists.txt and combine them with $(git rev-list --count HEAD).$(git rev-parse --short HEAD) so it forms 3.7.0.15768.ecedf3232 as version ?


Multi-init booting with apg Openrc and systemd coexisting
Automounting : not needed, i prefer pmount
Aur helpers : makepkg + my own local repo === rarely need them

Offline

#2 2019-12-25 06:03:53

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 7,513

Re: how to use version in CMakelists.txt in pkgver for vcs package ?

untested:

_major_ver=$(sed -n '/^SET(OPENSCENEGRAPH_MAJOR_VERSION .*)$/ {s/[^0-9]//g;p}' CMakelists.txt)

awk match would work just as well.

Last edited by Scimmia (2019-12-25 06:07:43)

Offline

#3 2019-12-25 13:56:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,810
Website

Re: how to use version in CMakelists.txt in pkgver for vcs package ?

If you are going to use sed, you may as well get all three numbers with one invocation:

sed -n '
   1,9 {
      /^SET.*_VERSION/ {
         s/[^0-9]*\([0-9]*\).*/\1/
         H
      }
   }
   $ {
      x
      s/^\n//
      s/\n/./g
      p
   }
' CMakeLists.txt

Or if you prefer a single but ugly (and butt-ugly) line:

sed -n '1,9{/^SET.*_VERSION/{s/[^0-9]*\([0-9]*\).*/\1/;H;};};${x;s/^\n//;s/\n/./g;p;}' CMakeLists.txt

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB