Skip to content

Commit

Permalink
- show snapper and libsnapper versions
Browse files Browse the repository at this point in the history
  • Loading branch information
aschnell committed Sep 14, 2023
1 parent 4457b8a commit cb05a52
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 8 deletions.
2 changes: 1 addition & 1 deletion LIBVERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.1.2
7.2.0
9 changes: 7 additions & 2 deletions client/snapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@

#include "config.h"

#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <cstring>
#include <iostream>

#include <snapper/Snapper.h>
#include <snapper/SnapperTmpl.h>
#include <snapper/Enum.h>
#include <snapper/Version.h>

#include "utils/text.h"
#include "utils/Table.h"
Expand Down Expand Up @@ -178,6 +179,10 @@ main(int argc, char** argv)
if (global_options.version())
{
cout << "snapper " << Snapper::compileVersion() << endl;
cout << "libsnapper " << LIBSNAPPER_VERSION_STRING;
if (strcmp(LIBSNAPPER_VERSION_STRING, get_libversion_string()) != 0)
cout << " (" << get_libversion_string() << ")";
cout << '\n';
cout << "flags " << Snapper::compileFlags() << endl;
exit(EXIT_SUCCESS);
}
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ fi
AC_CHECK_HEADER(acl/libacl.h,[],[AC_MSG_ERROR([Cannout find libacl headers. Please install libacl-devel])])

AC_SUBST(VERSION)
AC_SUBST(LIBVERSION)
AC_SUBST(LIBVERSION_MAJOR)
AC_SUBST(LIBVERSION_MINOR)
AC_SUBST(LIBVERSION_PATCHLEVEL)
Expand Down
2 changes: 1 addition & 1 deletion snapper/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ libsnapper_la_SOURCES = \
SnapperTmpl.h \
SnapperTypes.h \
SnapperDefines.h \
Version.h
Version.cc Version.h

if ENABLE_BTRFS
libsnapper_la_SOURCES += \
Expand Down
4 changes: 3 additions & 1 deletion snapper/Snapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "snapper/Hooks.h"
#include "snapper/ComparisonImpl.h"
#include "snapper/Systemctl.h"
#include "snapper/Version.h"
#ifdef ENABLE_BTRFS
#include "snapper/Btrfs.h"
#include "snapper/BtrfsUtils.h"
Expand Down Expand Up @@ -94,7 +95,8 @@ namespace snapper
: snapshots(this)
{
y2mil("Snapper constructor");
y2mil("libsnapper version " VERSION);
y2mil("snapper version " VERSION);
y2mil("libsnapper version " LIBSNAPPER_VERSION_STRING);
y2mil("config_name:" << config_name << " root_prefix:" << root_prefix <<
" disable_filters:" << disable_filters);

Expand Down
35 changes: 35 additions & 0 deletions snapper/Version.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 SUSE LLC
*
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, contact Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail, you may
* find current contact information at www.novell.com.
*/


#include "snapper/Version.h"


namespace snapper
{

const char*
get_libversion_string()
{
return LIBSNAPPER_VERSION_STRING;
}

}
21 changes: 18 additions & 3 deletions snapper/Version.h.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013 Novell, Inc.
* Copyright (c) 2023 SUSE LLC
*
* All Rights Reserved.
*
Expand All @@ -24,13 +25,27 @@
#define SNAPPER_VERSION_H


#define LIBSNAPPER_VERSION_STRING "@LIBVERSION@"

#define LIBSNAPPER_MAJOR "@LIBVERSION_MAJOR@"
#define LIBSNAPPER_MINOR "@LIBVERSION_MINOR@"
#define LIBSNAPPER_PATCHLEVEL "@LIBVERSION_PATCHLEVEL@"

#define LIBSNAPPER_VERSION ( LIBSNAPPER_MAJOR * 10000 + \\
LIBSNAPPER_MINOR * 100 + \\
LIBSNAPPER_PATCHLEVEL )
#define LIBSNAPPER_VERSION_AT_LEAST(major, minor) \
((LIBSNAPPER_VERSION_MAJOR > (major)) || \
(LIBSNAPPER_VERSION_MAJOR == (major) && LIBSNAPPER_VERSION_MINOR >= (minor)))


namespace snapper
{

/**
* Return LIBSNAPPER_VERSION_STRING libsnapper was compiled with. May differ
* from the define (compile time vs. link time).
*/
const char* get_libversion_string();

}


#endif

0 comments on commit cb05a52

Please sign in to comment.