Skip to contentSkip to conversation

Cmake: determening Ceph version when there is no git checkout.

DISCUSSION Willem Jan Withagen 3 participants 8 messages Jul 11, 2017 – Jul 12, 2017

lore
Share & tools
lore
#0 lore raw

Hi,

I'm doing some work to be ready when Luminous gets fully released. But I now run into the following code from src/CMakeLists.txtx
====

# the src/.git_version file may be written out by make-dist; otherwise
# we pull the git version from .git
option(ENABLE_GIT_VERSION "build Ceph with git version string" ON)
if(${ENABLE_GIT_VERSION})
  get_git_head_revision(GIT_REFSPEC CEPH_GIT_VER)
  git_describe(CEPH_GIT_NICE_VER --always)
  #if building from a source tarball via make-dist
  if(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
    message(STATUS "Ceph/.git directory not found, parsing
${CMAKE_CURRENT_SOURCE_DIR}/.git_version for CEPH_GIT_VER and
CEPH_GIT_NICE_VER")
    file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/.git_version
CEPH_GIT_SHA_AND_TAG)
    list(GET CEPH_GIT_SHA_AND_TAG 0 CEPH_GIT_VER)
    list(GET CEPH_GIT_SHA_AND_TAG 1 CEPH_GIT_NICE_VER)
  endif(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
  # remove 'v' prefix from raw git version
  string(SUBSTRING ${CEPH_GIT_NICE_VER} 1 -1 CEPH_GIT_NICE_VER)
else(${ENABLE_GIT_VERSION})
  set(CEPH_GIT_VER "no_version")
  set(CEPH_GIT_NICE_VER "Development")
endif(${ENABLE_GIT_VERSION})
====

This build the Ceph version from data in the .git repo.
But that is not how FreeBSD packaging works. There a tarbal is fetched but that does not contain any git info.

Work is done in:

	/usr/ports/net/ceph/work/ceph-12.1.0

and that is about all where I can extract some versioning from.

Does anybody have suggestions for an easy way out? Other than hardcode it in the Makefile as an option to CMake.

--WjW

#1 lore raw
Quoted 33 lines · Willem Jan Withagen

Hi,

I'm doing some work to be ready when Luminous gets fully released. But I now run into the following code from src/CMakeLists.txtx
====

# the src/.git_version file may be written out by make-dist; otherwise
# we pull the git version from .git
option(ENABLE_GIT_VERSION "build Ceph with git version string" ON)
if(${ENABLE_GIT_VERSION})
  get_git_head_revision(GIT_REFSPEC CEPH_GIT_VER)
  git_describe(CEPH_GIT_NICE_VER --always)
  #if building from a source tarball via make-dist
  if(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
    message(STATUS "Ceph/.git directory not found, parsing
${CMAKE_CURRENT_SOURCE_DIR}/.git_version for CEPH_GIT_VER and
CEPH_GIT_NICE_VER")
    file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/.git_version
CEPH_GIT_SHA_AND_TAG)
    list(GET CEPH_GIT_SHA_AND_TAG 0 CEPH_GIT_VER)
    list(GET CEPH_GIT_SHA_AND_TAG 1 CEPH_GIT_NICE_VER)
  endif(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
  # remove 'v' prefix from raw git version
  string(SUBSTRING ${CEPH_GIT_NICE_VER} 1 -1 CEPH_GIT_NICE_VER)
else(${ENABLE_GIT_VERSION})
  set(CEPH_GIT_VER "no_version")
  set(CEPH_GIT_NICE_VER "Development")
endif(${ENABLE_GIT_VERSION})
====

This build the Ceph version from data in the .git repo.
But that is not how FreeBSD packaging works. There a tarbal is fetched but that does not contain any git info.

Quoted 6 lines

Work is done in:

	/usr/ports/net/ceph/work/ceph-12.1.0

and that is about all where I can extract some versioning from.

Does anybody have suggestions for an easy way out? Other than hardcode it in the Makefile as an option to CMake.

Take a look at the make-dist script; it puts the git version info in a tarball that has everything needed to build. (i.e., it writes out the .git_version file referenced above.)

sage

#2 lore raw
Quoted 38 lines · Sage Weil
Quoted 37 lines · Willem Jan Withagen

Hi,

I'm doing some work to be ready when Luminous gets fully released. But I now run into the following code from src/CMakeLists.txtx
====

# the src/.git_version file may be written out by make-dist; otherwise
# we pull the git version from .git
option(ENABLE_GIT_VERSION "build Ceph with git version string" ON)
if(${ENABLE_GIT_VERSION})
  get_git_head_revision(GIT_REFSPEC CEPH_GIT_VER)
  git_describe(CEPH_GIT_NICE_VER --always)
  #if building from a source tarball via make-dist
  if(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
    message(STATUS "Ceph/.git directory not found, parsing
${CMAKE_CURRENT_SOURCE_DIR}/.git_version for CEPH_GIT_VER and
CEPH_GIT_NICE_VER")
    file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/.git_version
CEPH_GIT_SHA_AND_TAG)
    list(GET CEPH_GIT_SHA_AND_TAG 0 CEPH_GIT_VER)
    list(GET CEPH_GIT_SHA_AND_TAG 1 CEPH_GIT_NICE_VER)
  endif(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
  # remove 'v' prefix from raw git version
  string(SUBSTRING ${CEPH_GIT_NICE_VER} 1 -1 CEPH_GIT_NICE_VER)
else(${ENABLE_GIT_VERSION})
  set(CEPH_GIT_VER "no_version")
  set(CEPH_GIT_NICE_VER "Development")
endif(${ENABLE_GIT_VERSION})
====

This build the Ceph version from data in the .git repo.
But that is not how FreeBSD packaging works. There a tarbal is fetched but that does not contain any git info.

Work is done in:

	/usr/ports/net/ceph/work/ceph-12.1.0

and that is about all where I can extract some versioning from.

Quoted 6 lines
Quoted 2 lines

Does anybody have suggestions for an easy way out? Other than hardcode it in the Makefile as an option to CMake.

Take a look at the make-dist script; it puts the git version info in a tarball that has everything needed to build. (i.e., it writes out the .git_version file referenced above.)

I think I used the wrong words....

The make-dis script begins with:
if [ ! -d .git ]; then
echo "no .git present. run this from the base dir of the git checkout." exit 1
fi

When I say tarball, I mean that the FreeBSD packaging system will fetch something like:
https://codeload.github.com/ceph/ceph-v12.1.0_GH0.tar.gz

And that tar file does not contain ANY git information.
So I have to extract that from somewhere/something else. All I know is the TAG v12.1.0. So if I want to have a git hash in the version I need to construct it from that, or use that reference to fetch the hash.

Otherwise I'll need to put it in the package makefile everytime, I release a new version.

--WjW

#3 lore raw
Quoted 58 lines · Willem Jan Withagen
Quoted 38 lines · Sage Weil
Quoted 37 lines · Willem Jan Withagen

Hi,

I'm doing some work to be ready when Luminous gets fully released. But I now run into the following code from src/CMakeLists.txtx
====

# the src/.git_version file may be written out by make-dist; otherwise
# we pull the git version from .git
option(ENABLE_GIT_VERSION "build Ceph with git version string" ON)
if(${ENABLE_GIT_VERSION})
  get_git_head_revision(GIT_REFSPEC CEPH_GIT_VER)
  git_describe(CEPH_GIT_NICE_VER --always)
  #if building from a source tarball via make-dist
  if(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
    message(STATUS "Ceph/.git directory not found, parsing
${CMAKE_CURRENT_SOURCE_DIR}/.git_version for CEPH_GIT_VER and
CEPH_GIT_NICE_VER")
    file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/.git_version
CEPH_GIT_SHA_AND_TAG)
    list(GET CEPH_GIT_SHA_AND_TAG 0 CEPH_GIT_VER)
    list(GET CEPH_GIT_SHA_AND_TAG 1 CEPH_GIT_NICE_VER)
  endif(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
  # remove 'v' prefix from raw git version
  string(SUBSTRING ${CEPH_GIT_NICE_VER} 1 -1 CEPH_GIT_NICE_VER)
else(${ENABLE_GIT_VERSION})
  set(CEPH_GIT_VER "no_version")
  set(CEPH_GIT_NICE_VER "Development")
endif(${ENABLE_GIT_VERSION})
====

This build the Ceph version from data in the .git repo.
But that is not how FreeBSD packaging works. There a tarbal is fetched but that does not contain any git info.

Work is done in:

	/usr/ports/net/ceph/work/ceph-12.1.0

and that is about all where I can extract some versioning from.

Quoted 6 lines
Quoted 2 lines

Does anybody have suggestions for an easy way out? Other than hardcode it in the Makefile as an option to CMake.

Take a look at the make-dist script; it puts the git version info in a tarball that has everything needed to build. (i.e., it writes out the .git_version file referenced above.)

I think I used the wrong words....

The make-dis script begins with:
if [ ! -d .git ]; then
echo "no .git present. run this from the base dir of the git checkout." exit 1
fi

When I say tarball, I mean that the FreeBSD packaging system will fetch something like:
https://codeload.github.com/ceph/ceph-v12.1.0_GH0.tar.gz

Quoted 7 lines

And that tar file does not contain ANY git information.
So I have to extract that from somewhere/something else. All I know is the TAG v12.1.0. So if I want to have a git hash in the version I need to construct it from that, or use that reference to fetch the hash.

Otherwise I'll need to put it in the package makefile everytime, I release a new version.

Can you instead fetch the tarball from download.ceph.com? Those tarballs are generated with make-dist and already include the .git_version information.

sage

#4 lore raw
Quoted 64 lines · Sage Weil
Quoted 63 lines · Willem Jan Withagen
Quoted 38 lines · Sage Weil
Quoted 37 lines · Willem Jan Withagen

Hi,

I'm doing some work to be ready when Luminous gets fully released. But I now run into the following code from src/CMakeLists.txtx
====

# the src/.git_version file may be written out by make-dist; otherwise
# we pull the git version from .git
option(ENABLE_GIT_VERSION "build Ceph with git version string" ON)
if(${ENABLE_GIT_VERSION})
  get_git_head_revision(GIT_REFSPEC CEPH_GIT_VER)
  git_describe(CEPH_GIT_NICE_VER --always)
  #if building from a source tarball via make-dist
  if(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
    message(STATUS "Ceph/.git directory not found, parsing
${CMAKE_CURRENT_SOURCE_DIR}/.git_version for CEPH_GIT_VER and
CEPH_GIT_NICE_VER")
    file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/.git_version
CEPH_GIT_SHA_AND_TAG)
    list(GET CEPH_GIT_SHA_AND_TAG 0 CEPH_GIT_VER)
    list(GET CEPH_GIT_SHA_AND_TAG 1 CEPH_GIT_NICE_VER)
  endif(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
  # remove 'v' prefix from raw git version
  string(SUBSTRING ${CEPH_GIT_NICE_VER} 1 -1 CEPH_GIT_NICE_VER)
else(${ENABLE_GIT_VERSION})
  set(CEPH_GIT_VER "no_version")
  set(CEPH_GIT_NICE_VER "Development")
endif(${ENABLE_GIT_VERSION})
====

This build the Ceph version from data in the .git repo.
But that is not how FreeBSD packaging works. There a tarbal is fetched but that does not contain any git info.

Work is done in:

	/usr/ports/net/ceph/work/ceph-12.1.0

and that is about all where I can extract some versioning from.

Quoted 6 lines
Quoted 2 lines

Does anybody have suggestions for an easy way out? Other than hardcode it in the Makefile as an option to CMake.

Take a look at the make-dist script; it puts the git version info in a tarball that has everything needed to build. (i.e., it writes out the .git_version file referenced above.)

I think I used the wrong words....

The make-dis script begins with:
if [ ! -d .git ]; then
echo "no .git present. run this from the base dir of the git checkout." exit 1
fi

When I say tarball, I mean that the FreeBSD packaging system will fetch something like:
https://codeload.github.com/ceph/ceph-v12.1.0_GH0.tar.gz

And that tar file does not contain ANY git information.
So I have to extract that from somewhere/something else. All I know is the TAG v12.1.0. So if I want to have a git hash in the version I need to construct it from that, or use that reference to fetch the hash.

Quoted 6 lines
Quoted 2 lines

Otherwise I'll need to put it in the package makefile everytime, I release a new version.

Can you instead fetch the tarball from download.ceph.com? Those tarballs are generated with make-dist and already include the .git_version information.

Right...

I'll have to check on how to do that with the remainder of the stuff coming from github. The packaging infrastructure is rather nice, but if you want to go out of the box, then things tend to get akward rather fast.

--WjW

#5 lore raw
In reply to Sage Weil
Quoted 64 lines · Sage Weil
Quoted 63 lines · Willem Jan Withagen
Quoted 38 lines · Sage Weil
Quoted 37 lines · Willem Jan Withagen

Hi,

I'm doing some work to be ready when Luminous gets fully released. But I now run into the following code from src/CMakeLists.txtx
====

# the src/.git_version file may be written out by make-dist; otherwise
# we pull the git version from .git
option(ENABLE_GIT_VERSION "build Ceph with git version string" ON)
if(${ENABLE_GIT_VERSION})
  get_git_head_revision(GIT_REFSPEC CEPH_GIT_VER)
  git_describe(CEPH_GIT_NICE_VER --always)
  #if building from a source tarball via make-dist
  if(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
    message(STATUS "Ceph/.git directory not found, parsing
${CMAKE_CURRENT_SOURCE_DIR}/.git_version for CEPH_GIT_VER and
CEPH_GIT_NICE_VER")
    file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/.git_version
CEPH_GIT_SHA_AND_TAG)
    list(GET CEPH_GIT_SHA_AND_TAG 0 CEPH_GIT_VER)
    list(GET CEPH_GIT_SHA_AND_TAG 1 CEPH_GIT_NICE_VER)
  endif(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
  # remove 'v' prefix from raw git version
  string(SUBSTRING ${CEPH_GIT_NICE_VER} 1 -1 CEPH_GIT_NICE_VER)
else(${ENABLE_GIT_VERSION})
  set(CEPH_GIT_VER "no_version")
  set(CEPH_GIT_NICE_VER "Development")
endif(${ENABLE_GIT_VERSION})
====

This build the Ceph version from data in the .git repo.
But that is not how FreeBSD packaging works. There a tarbal is fetched but that does not contain any git info.

Work is done in:

	/usr/ports/net/ceph/work/ceph-12.1.0

and that is about all where I can extract some versioning from.

Quoted 6 lines
Quoted 2 lines

Does anybody have suggestions for an easy way out? Other than hardcode it in the Makefile as an option to CMake.

Take a look at the make-dist script; it puts the git version info in a tarball that has everything needed to build. (i.e., it writes out the .git_version file referenced above.)

I think I used the wrong words....

The make-dis script begins with:
if [ ! -d .git ]; then
echo "no .git present. run this from the base dir of the git checkout." exit 1
fi

When I say tarball, I mean that the FreeBSD packaging system will fetch something like:
https://codeload.github.com/ceph/ceph-v12.1.0_GH0.tar.gz

And that tar file does not contain ANY git information.
So I have to extract that from somewhere/something else. All I know is the TAG v12.1.0. So if I want to have a git hash in the version I need to construct it from that, or use that reference to fetch the hash.

Quoted 6 lines
Quoted 2 lines

Otherwise I'll need to put it in the package makefile everytime, I release a new version.

Can you instead fetch the tarball from download.ceph.com? Those tarballs are generated with make-dist and already include the .git_version information.

mmmm,
That is everything in one blow...
So no mucking with git submodules, but have it all ready to compile... Could work easier, especially for official releases.

I'll try and make an alternative version for the release-ports.

Alternative would be to create a dir on download.ceph.com with a hash file per released version to download??

--WjW

#6 lore raw
Quoted 3 lines · Willem Jan Withagen

Alternative would be to create a dir on download.ceph.com with a hash file per released version to download??

I'm not quite sure what you're asking, mind providing an example?

- Ken

#7 lore raw
Quoted 6 lines · Ken Dreyer
Quoted 3 lines · Willem Jan Withagen

Alternative would be to create a dir on download.ceph.com with a hash file per released version to download??

I'm not quite sure what you're asking, mind providing an example?

	http://download.ceph.com/tarballs/ceph_12.1.0.orig.tar.gz
and then something like
	http://download.ceph.com/tarballs/ceph_12.1.0.hash.txt

which contains the hash that goes with the version.

Also note that the sha256 are only created for older versions. So "verification" for correctness with the tgz's is not possible.

--WjW