You are not logged in.

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

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

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 ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

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

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,471

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)

Online

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

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,452
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

#4 2020-07-03 14:03:36

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

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

Sorry for not answering sooner.

I did start an awk tutorial and tried to understand the sed miltiliner, but both gave me the feeling I was using a supercomputer to play twonky  .


For those who never heard of twonky :
It's a text based maze game that was popular when a tty was a physical device that connected you with a mini computer or mainframe in another room.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

Board footer

Powered by FluxBB