qtile: rework package
* Use absolute paths to load gobject, pango and cairo. * Add xcb-cursor support (also with absolute path) * Avoid tainting child processes environment: Save PATH and PYTHONPATH in wrapper, and restore them in python code. * Alter restart process, using $0 saved in wrapper, which allow user to restart qtile after system rebuild to upgrade it.
This commit is contained in:
parent
9b166f0db2
commit
28c44a15c7
@ -0,0 +1,43 @@
|
|||||||
|
From 00c5af939567429d40877845dc52b54fde2d8a50 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Alexander V. Nikolaev" <avn@avnik.info>
|
||||||
|
Date: Thu, 26 Nov 2015 10:53:12 +0200
|
||||||
|
Subject: [PATCH 1/3] Substitution vars for absolute paths
|
||||||
|
|
||||||
|
---
|
||||||
|
libqtile/pangocffi.py | 6 +++---
|
||||||
|
libqtile/xcursors.py | 2 +-
|
||||||
|
2 files changed, 4 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libqtile/pangocffi.py b/libqtile/pangocffi.py
|
||||||
|
index 27691d1..25f690d 100644
|
||||||
|
--- a/libqtile/pangocffi.py
|
||||||
|
+++ b/libqtile/pangocffi.py
|
||||||
|
@@ -58,9 +58,9 @@ except ImportError:
|
||||||
|
else:
|
||||||
|
raise ImportError("No module named libqtile._ffi_pango, be sure to run `python ./libqtile/ffi_build.py`")
|
||||||
|
|
||||||
|
-gobject = ffi.dlopen('libgobject-2.0.so.0')
|
||||||
|
-pango = ffi.dlopen('libpango-1.0.so.0')
|
||||||
|
-pangocairo = ffi.dlopen('libpangocairo-1.0.so.0')
|
||||||
|
+gobject = ffi.dlopen('@glib@/lib/libgobject-2.0.so.0')
|
||||||
|
+pango = ffi.dlopen('@pango@/lib/libpango-1.0.so.0')
|
||||||
|
+pangocairo = ffi.dlopen('@pango@/lib/libpangocairo-1.0.so.0')
|
||||||
|
|
||||||
|
|
||||||
|
def CairoContext(cairo_t):
|
||||||
|
diff --git a/libqtile/xcursors.py b/libqtile/xcursors.py
|
||||||
|
index e0e55e1..59b6428 100644
|
||||||
|
--- a/libqtile/xcursors.py
|
||||||
|
+++ b/libqtile/xcursors.py
|
||||||
|
@@ -114,7 +114,7 @@ class Cursors(dict):
|
||||||
|
|
||||||
|
def _setup_xcursor_binding(self):
|
||||||
|
try:
|
||||||
|
- xcursor = ffi.dlopen('libxcb-cursor.so')
|
||||||
|
+ xcursor = ffi.dlopen('@xcb-cursor@/lib/libxcb-cursor.so')
|
||||||
|
except OSError:
|
||||||
|
self.log.warning("xcb-cursor not found, fallback to font pointer")
|
||||||
|
return False
|
||||||
|
--
|
||||||
|
2.6.3
|
||||||
|
|
@ -0,0 +1,67 @@
|
|||||||
|
From f299a0aa0eefcf16bb4990f00ac3946727f43ef3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Alexander V. Nikolaev" <avn@avnik.info>
|
||||||
|
Date: Fri, 27 Nov 2015 10:49:48 +0200
|
||||||
|
Subject: [PATCH 2/3] Restore PATH and PYTHONPATH
|
||||||
|
|
||||||
|
---
|
||||||
|
bin/qtile | 1 +
|
||||||
|
bin/qtile-run | 1 +
|
||||||
|
bin/qtile-session | 2 ++
|
||||||
|
libqtile/utils.py | 7 +++++++
|
||||||
|
4 files changed, 11 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/bin/qtile b/bin/qtile
|
||||||
|
index 66034fe..ce3fcd1 100755
|
||||||
|
--- a/bin/qtile
|
||||||
|
+++ b/bin/qtile
|
||||||
|
@@ -131,6 +131,7 @@ def make_qtile():
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
+ __import__("importlib").import_module("libqtile.utils").restore_os_environment()
|
||||||
|
rename_process()
|
||||||
|
q = make_qtile()
|
||||||
|
try:
|
||||||
|
diff --git a/bin/qtile-run b/bin/qtile-run
|
||||||
|
index ccedb96..646a476 100755
|
||||||
|
--- a/bin/qtile-run
|
||||||
|
+++ b/bin/qtile-run
|
||||||
|
@@ -50,6 +50,7 @@ def main():
|
||||||
|
proc.wait()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
+ __import__("importlib").import_module("libqtile.utils").restore_os_environment()
|
||||||
|
try:
|
||||||
|
main()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
diff --git a/bin/qtile-session b/bin/qtile-session
|
||||||
|
index 84f6a2d..da31b12 100755
|
||||||
|
--- a/bin/qtile-session
|
||||||
|
+++ b/bin/qtile-session
|
||||||
|
@@ -25,6 +25,8 @@
|
||||||
|
Qtile session manager.
|
||||||
|
"""
|
||||||
|
|
||||||
|
+__import__("importlib").import_module("libqtile.utils").restore_os_environment()
|
||||||
|
+
|
||||||
|
from libqtile.log_utils import init_log
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
diff --git a/libqtile/utils.py b/libqtile/utils.py
|
||||||
|
index d5f975b..0fdb080 100644
|
||||||
|
--- a/libqtile/utils.py
|
||||||
|
+++ b/libqtile/utils.py
|
||||||
|
@@ -208,3 +208,10 @@ def get_cache_dir():
|
||||||
|
if not os.path.exists(cache_directory):
|
||||||
|
os.makedirs(cache_directory)
|
||||||
|
return cache_directory
|
||||||
|
+
|
||||||
|
+def restore_os_environment():
|
||||||
|
+ pythonpath = os.environ.pop("QTILE_SAVED_PYTHONPATH", "")
|
||||||
|
+ os.environ["PYTHONPATH"] = pythonpath
|
||||||
|
+ path = os.environ.pop("QTILE_SAVED_PATH", None)
|
||||||
|
+ if path:
|
||||||
|
+ os.environ["PATH"] = path
|
||||||
|
--
|
||||||
|
2.6.3
|
||||||
|
|
@ -0,0 +1,25 @@
|
|||||||
|
From b560c11078fecc35df2c62f34beda06c4e80a10d Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Alexander V. Nikolaev" <avn@avnik.info>
|
||||||
|
Date: Fri, 27 Nov 2015 10:54:35 +0200
|
||||||
|
Subject: [PATCH 3/3] Restart executable
|
||||||
|
|
||||||
|
---
|
||||||
|
libqtile/manager.py | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/libqtile/manager.py b/libqtile/manager.py
|
||||||
|
index b1a38e2..110f7d8 100644
|
||||||
|
--- a/libqtile/manager.py
|
||||||
|
+++ b/libqtile/manager.py
|
||||||
|
@@ -1339,7 +1339,7 @@ class Qtile(command.CommandObject):
|
||||||
|
argv = [s for s in argv if not s.startswith('--with-state')]
|
||||||
|
argv.append('--with-state=' + buf.getvalue().decode())
|
||||||
|
|
||||||
|
- self.cmd_execute(sys.executable, argv)
|
||||||
|
+ self.cmd_execute(os.environ.get("QTILE_WRAPPER", "@out@/bin/qtile"), argv[1:])
|
||||||
|
|
||||||
|
def cmd_spawn(self, cmd):
|
||||||
|
"""
|
||||||
|
--
|
||||||
|
2.6.3
|
||||||
|
|
@ -1,5 +1,10 @@
|
|||||||
{ stdenv, fetchFromGitHub, buildPythonPackage, python27Packages, pkgs }:
|
{ stdenv, fetchFromGitHub, buildPythonPackage, python27Packages, pkgs }:
|
||||||
|
|
||||||
|
let cairocffi-xcffib = python27Packages.cairocffi.override {
|
||||||
|
pythonPath = [ python27Packages.xcffib ];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
name = "qtile-${version}";
|
name = "qtile-${version}";
|
||||||
version = "0.10.2";
|
version = "0.10.2";
|
||||||
@ -11,29 +16,28 @@ buildPythonPackage rec {
|
|||||||
sha256 = "0dhdwjr4pdlzli68fa8glrnsjzxp6agdab9cnmpsqlwiwh97x9a6";
|
sha256 = "0dhdwjr4pdlzli68fa8glrnsjzxp6agdab9cnmpsqlwiwh97x9a6";
|
||||||
};
|
};
|
||||||
|
|
||||||
patches = [ ./restart_executable.patch ];
|
patches = [
|
||||||
|
./0001-Substitution-vars-for-absolute-paths.patch
|
||||||
|
./0002-Restore-PATH-and-PYTHONPATH.patch
|
||||||
|
./0003-Restart-executable.patch
|
||||||
|
];
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
substituteInPlace libqtile/manager.py --subst-var-by out $out
|
substituteInPlace libqtile/manager.py --subst-var-by out $out
|
||||||
|
substituteInPlace libqtile/pangocffi.py --subst-var-by glib ${pkgs.glib}
|
||||||
|
substituteInPlace libqtile/pangocffi.py --subst-var-by pango ${pkgs.pango}
|
||||||
|
substituteInPlace libqtile/xcursors.py --subst-var-by xcb-cursor ${pkgs.xorg.xcbutilcursor}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
buildInputs = [ pkgs.pkgconfig pkgs.glib pkgs.xorg.libxcb pkgs.cairo pkgs.pango python27Packages.xcffib ];
|
buildInputs = [ pkgs.pkgconfig pkgs.glib pkgs.xorg.libxcb pkgs.cairo pkgs.pango python27Packages.xcffib ];
|
||||||
|
|
||||||
cairocffi-xcffib = python27Packages.cairocffi.override {
|
pythonPath = with python27Packages; [ xcffib cairocffi-xcffib trollius readline];
|
||||||
LD_LIBRARY_PATH = "${pkgs.xorg.libxcb}/lib:${pkgs.cairo}/lib";
|
|
||||||
pythonPath = [ python27Packages.xcffib ];
|
|
||||||
};
|
|
||||||
|
|
||||||
pythonPath = with python27Packages; [ xcffib cairocffi-xcffib trollius readline ];
|
|
||||||
|
|
||||||
LD_LIBRARY_PATH = "${pkgs.xorg.libxcb}/lib:${pkgs.cairo}/lib";
|
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
wrapProgram $out/bin/qtile \
|
wrapProgram $out/bin/qtile \
|
||||||
--prefix LD_LIBRARY_PATH : ${pkgs.xorg.libxcb}/lib \
|
--set QTILE_WRAPPER '"$0"' \
|
||||||
--prefix LD_LIBRARY_PATH : ${pkgs.glib}/lib \
|
--set QTILE_SAVED_PYTHONPATH '"$PYTHONPATH"' \
|
||||||
--prefix LD_LIBRARY_PATH : ${pkgs.cairo}/lib \
|
--set QTILE_SAVED_PATH '"$PATH"'
|
||||||
--prefix LD_LIBRARY_PATH : ${pkgs.pango}/lib
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
diff -ruP a/libqtile/manager.py b/libqtile/manager.py
|
|
||||||
--- a/libqtile/manager.py 2015-07-26 21:26:16.947976520 +0200
|
|
||||||
+++ b/libqtile/manager.py 2015-07-26 21:37:45.581316712 +0200
|
|
||||||
@@ -1262,7 +1262,7 @@
|
|
||||||
argv = [s for s in argv if not s.startswith('--with-state')]
|
|
||||||
argv.append('--with-state=' + buf.getvalue().decode())
|
|
||||||
|
|
||||||
- self.cmd_execute(sys.executable, argv)
|
|
||||||
+ self.cmd_execute("@out@/bin/qtile", argv[1:])
|
|
||||||
|
|
||||||
def cmd_spawn(self, cmd):
|
|
||||||
"""
|
|
Loading…
Reference in New Issue
Block a user