Skip to content

Commit e340113

Browse files
Bump version to 2.9. Add compatibility-map to allow running older versions
of shournal's kernel module, if possible.
1 parent ebb7b4b commit e340113

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ endif()
66

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

1111
cmake_policy( SET CMP0048 NEW )
1212
project(shournal VERSION ${shournal_version} LANGUAGES CXX C)

src/shournal-run/mark_helper.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
#include "mark_helper.h"
22

33
#include <sys/user.h>
4-
4+
#include <QHash>
5+
#include <QVersionNumber>
56

67
#include "app.h"
78
#include "shournalk_ctrl.h"
89
#include "stdiocpp.h"
910
#include "translation.h"
1011
#include "os.h"
1112

13+
using std::unordered_map;
14+
using std::string;
15+
16+
// To avoid unnecessary unloading of the kernel module shournalk
17+
// when a new version is installed,
18+
// define a compatibility map, where the key corresponds
19+
// to the "current" version and the value determines the *minimum*
20+
// required version.
21+
static const QHash<QVersionNumber, QVersionNumber> KVERSION_COMPATIBILITY_MAP = {
22+
{QVersionNumber{2,9}, QVersionNumber{2,8}}
23+
};
1224

1325
ExcShournalk::ExcShournalk(const QString &text) :
1426
QExcCommon(text, false)
@@ -58,11 +70,16 @@ ShournalkControl::ShournalkControl()
5870
.arg(translation::strerror_l(errno)));
5971
}
6072
if(strcmp(SHOURNAL_VERSION, kversion.ver_str) != 0){
61-
throw ExcShournalk(qtr("Version mismatch - %1 version is %2, but "
62-
"%3 version is %4")
63-
.arg(app::SHOURNAL_RUN).arg(SHOURNAL_VERSION)
64-
.arg("kernel-module").arg(kversion.ver_str)
65-
);
73+
auto kver = QVersionNumber::fromString(kversion.ver_str);
74+
const auto & compatible_ver = KVERSION_COMPATIBILITY_MAP.find(app::version());
75+
if(compatible_ver == KVERSION_COMPATIBILITY_MAP.end() ||
76+
kver < compatible_ver.value()){
77+
throw ExcShournalk(qtr("Version mismatch - %1 version is %2, but "
78+
"%3 version is %4")
79+
.arg(app::SHOURNAL_RUN).arg(SHOURNAL_VERSION)
80+
.arg("kernel-module").arg(kversion.ver_str)
81+
);
82+
}
6683
}
6784

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

0 commit comments

Comments
 (0)