linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Sojka <michal.sojka@cvut.cz>
To: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	linux-trace-devel@vger.kernel.org,
	Michal Sojka <michal.sojka@cvut.cz>
Subject: [PATCH 3/4] kernel-shark: Allow installing polkit policy separately
Date: Wed, 17 Mar 2021 17:41:00 +0100	[thread overview]
Message-ID: <20210317164101.30848-4-michal.sojka@cvut.cz> (raw)
In-Reply-To: <20210317164101.30848-1-michal.sojka@cvut.cz>

For a polkit policy to be found by polkit daemon, it must be installed
to a single system-wide location, typically /usr/share/polkit-1/actions.
CMakeLists file reflects that and always installs the policy under /usr.
But when one wants to install kernel-shark to a non-standard location,
e.g., by configuring it as follows:

    cmake -D_INSTALL_PREFIX=$HOME ...

then "make install" fails, with the following error:

    CMake Error at src/cmake_install.cmake:225 (file):
      file INSTALL cannot copy file
      "/home/user/src/trace-cmd/kernel-shark/org.freedesktop.kshark-record.policy"
      to "/usr/share/polkit-1/actions/org.freedesktop.kshark-record.policy".

This commit fixes that by changing two things:
- custom location where to install polkit policy can be specified via
  cmake command line argument -D_POLKIT_INSTALL_PREFIX=... This will
  also help distributions where polkit is configured with different
  prefix than /usr.
- polkit policy is now a separate cmake component, which can be
  installed separately from the rest.

The later allows generating better messages for the user to understand
that the failed polkit policy installation is not a critical error.

Signed-off-by: Michal Sojka <michal.sojka@cvut.cz>
---
 CMakeLists.txt       |  6 ++++++
 build/install_gui.sh | 10 +++++++++-
 src/CMakeLists.txt   |  4 ++--
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c4731c1..94023a8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,6 +36,12 @@ elseif (NOT _LIBDIR)
 
 endif ()
 
+if (NOT _POLKIT_INSTALL_PREFIX)
+
+    set(_POLKIT_INSTALL_PREFIX "/usr")
+
+endif ()
+
 set(CMAKE_MODULE_PATH "${KS_DIR}/build")
 find_package(TraceEvent REQUIRED)
 find_package(TraceFS    REQUIRED)
diff --git a/build/install_gui.sh b/build/install_gui.sh
index 1583fb9..d262f79 100755
--- a/build/install_gui.sh
+++ b/build/install_gui.sh
@@ -1 +1,9 @@
-sudo cmake -DCOMPONENT=kernelshark -P cmake_install.cmake
+if sudo cmake -DCOMPONENT=kernelshark -P cmake_install.cmake; then
+    echo "Kernelshark installed correctly"
+else
+    exit 1
+fi
+
+if ! sudo cmake -DCOMPONENT=polkit-policy -P cmake_install.cmake; then
+    echo >&2 "Warning: polkit policy not installed"
+fi
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b81d7d9..b557eb7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -127,8 +127,8 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
                 COMPONENT                 kernelshark)
 
     install(FILES "${KS_DIR}/org.freedesktop.kshark-record.policy"
-            DESTINATION /usr/share/polkit-1/actions/
-                COMPONENT                 kernelshark)
+            DESTINATION ${_POLKIT_INSTALL_PREFIX}/share/polkit-1/actions/
+                COMPONENT                 polkit-policy)
 
     install(PROGRAMS "${KS_DIR}/bin/kshark-su-record"
             DESTINATION ${_INSTALL_PREFIX}/bin/
-- 
2.30.1


  parent reply	other threads:[~2021-03-17 16:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17 16:40 [PATCH 0/4] kernel-shark: CMake changes Michal Sojka
2021-03-17 16:40 ` [PATCH 1/4] kernel-shark: Allow specifying PKG_CONFIG_DIR on cmake command line Michal Sojka
2021-03-17 16:40 ` [PATCH 2/4] kernel-shark: Allow specifying TT_FONT_FILE " Michal Sojka
2021-03-17 16:41 ` Michal Sojka [this message]
2021-03-17 16:41 ` [PATCH 4/4] kernel-shark: Do not use sudo in install_gui.sh + update README Michal Sojka
2021-03-23 13:45 ` [PATCH 0/4] kernel-shark: CMake changes Yordan Karadzhov (VMware)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210317164101.30848-4-michal.sojka@cvut.cz \
    --to=michal.sojka@cvut.cz \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=y.karadz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).