Skip to content

Commit

Permalink
Bump version to 2.9. Add compatibility-map to allow running older ver…
Browse files Browse the repository at this point in the history
…sions

of shournal's kernel module, if possible.
  • Loading branch information
tycho-kirchner committed Sep 19, 2022
1 parent ebb7b4b commit e340113
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ endif()

# version applies to all released files: shournal, shournal-run, libshournal-shellwatch.so
# and shell-integration-scripts (e.g. integration_ko.bash)
set(shournal_version "2.8")
set(shournal_version "2.9")

cmake_policy( SET CMP0048 NEW )
project(shournal VERSION ${shournal_version} LANGUAGES CXX C)
Expand Down
29 changes: 23 additions & 6 deletions src/shournal-run/mark_helper.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
#include "mark_helper.h"

#include <sys/user.h>

#include <QHash>
#include <QVersionNumber>

#include "app.h"
#include "shournalk_ctrl.h"
#include "stdiocpp.h"
#include "translation.h"
#include "os.h"

using std::unordered_map;
using std::string;

// To avoid unnecessary unloading of the kernel module shournalk
// when a new version is installed,
// define a compatibility map, where the key corresponds
// to the "current" version and the value determines the *minimum*
// required version.
static const QHash<QVersionNumber, QVersionNumber> KVERSION_COMPATIBILITY_MAP = {
{QVersionNumber{2,9}, QVersionNumber{2,8}}
};

ExcShournalk::ExcShournalk(const QString &text) :
QExcCommon(text, false)
Expand Down Expand Up @@ -58,11 +70,16 @@ ShournalkControl::ShournalkControl()
.arg(translation::strerror_l(errno)));
}
if(strcmp(SHOURNAL_VERSION, kversion.ver_str) != 0){
throw ExcShournalk(qtr("Version mismatch - %1 version is %2, but "
"%3 version is %4")
.arg(app::SHOURNAL_RUN).arg(SHOURNAL_VERSION)
.arg("kernel-module").arg(kversion.ver_str)
);
auto kver = QVersionNumber::fromString(kversion.ver_str);
const auto & compatible_ver = KVERSION_COMPATIBILITY_MAP.find(app::version());
if(compatible_ver == KVERSION_COMPATIBILITY_MAP.end() ||
kver < compatible_ver.value()){
throw ExcShournalk(qtr("Version mismatch - %1 version is %2, but "
"%3 version is %4")
.arg(app::SHOURNAL_RUN).arg(SHOURNAL_VERSION)
.arg("kernel-module").arg(kversion.ver_str)
);
}
}

m_tmpFileTarget = stdiocpp::tmpfile(O_NOATIME); // tmpfile auto deletes..
Expand Down

0 comments on commit e340113

Please sign in to comment.