!9 Fix kylin-user-guide version is empty

From: @peijiankang 
Reviewed-by: @tanyulong2021 
Signed-off-by: @tanyulong2021
This commit is contained in:
openeuler-ci-bot 2022-06-09 06:49:22 +00:00 committed by Gitee
commit ad27ae966f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 57 additions and 1 deletions

View File

@ -0,0 +1,50 @@
From 6433e34bc3e113a11aa2d56b8eec8607f43a1927 Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Thu, 9 Jun 2022 14:12:37 +0800
Subject: [PATCH] Fix kylin-user-guide version is empty
---
src/main.cpp | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/main.cpp b/src/main.cpp
index 68e5c11..2d3b270 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -78,16 +78,25 @@ static void crashHandler(int sig)
}
QString getAppVersion(){
+ QString m_appVersion;
+ QStringList options;
QProcess process;
- QString cmd = "dpkg-parsechangelog";
- QStringList arg;
- arg.clear();
- arg << "-l" << CHANGELOG_PATH << "--show-field" << "Version";
- process.start(cmd,arg);
+ options << "-qa" << "|" << "grep" << "kylin-user-guide";
+ process.start("rpm", options);
process.waitForFinished();
- QByteArray result = process.readAllStandardOutput();
- result = result.left(result.length()-1);
- return result;
+ QString dpkgInfo = process.readAll();
+ QStringList infoList = dpkgInfo.split("\n");
+ for (int n = 0; n < infoList.size(); n++) {
+ QString strInfoLine = infoList[n];
+ if (strInfoLine.contains("kylin-user-guide")) {
+ QStringList lineInfoList = strInfoLine.split(QRegExp("-"));
+ if (lineInfoList.size() >= 3) {
+ m_appVersion = lineInfoList[3];
+ }
+ break;
+ }
+ }
+ return m_appVersion;
}
int main(int argc, char *argv[])
--
2.33.0

View File

@ -1,12 +1,13 @@
%define debug_package %{nil}
Name: kylin-user-guide
Version: 1.0.4
Release: 2
Release: 3
Summary: A component of the ukui desktop environment that provides convenient text
License: CC-BY-SA-4.0 and GPL-3.0-or-later
URL: http://www.ukui.org
Source0: %{name}-%{version}.tar.gz
Patch01: 0001-modify-compile-error-of-None.patch
Patch02: 0002-Fix-kylin-user-guide-version-is-empty.patch
BuildRequires: cmake
BuildRequires: qt5-qtbase-devel
@ -40,6 +41,7 @@ this packages contains the picture of application
%prep
%setup -q
%patch01 -p1
%patch02 -p1
%build
mkdir build && cd build
@ -79,7 +81,11 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/kylin-user-guide/translations/*.qm
%{_datadir}/kylin-user-guide/data/*
%changelog
* Thu Jun 9 2022 peijiankang <peijiankang@kylinos.cn> - 1.0.4-3
- Fix kylin-user-guide version is empty
* Wed Jun 8 2022 peijiankang <peijiankang@kylinos.cn> - 1.0.4-2
- add js-marked requires