virt-manager: Fix running with --no-fork

This removes nixpkgs' custom runners and instead copies the main python source
files to the bin directory, then wraps them up as usual.

Hopefully this will be more reliable than other previous wrapping methods.
This commit is contained in:
Ricardo M. Correia 2014-01-14 03:24:27 +01:00 committed by Rok Garbas
parent 51a5f9c364
commit 0cf9a083d9
2 changed files with 5 additions and 30 deletions

View File

@ -1,13 +0,0 @@
#!/usr/bin/python -t
# this script was written to use /etc/nixos/nixpkgs/pkgs/development/python-modules/generic/wrap.sh
# which already automates python executable wrapping by extending the PATH/pythonPath
# from http://docs.python.org/library/subprocess.html
# Warning Invoking the system shell with shell=True can be a security hazard if combined with untrusted input. See the warning under Frequently Used Arguments for details.
from subprocess import Popen, PIPE, STDOUT
cmd = 'PYTHON_EXECUTABLE_PATH -t THE_CUSTOM_PATH/share/virt-manager/THE_CUSTOM_PROGRAM.py'
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
output = p.stdout.read()
print output

View File

@ -41,10 +41,6 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ makeWrapper pythonPackages.wrapPython ];
# patch the runner script in order to make wrapPythonPrograms work and run the program using a syscall
# example code: /etc/nixos/nixpkgs/pkgs/development/interpreters/spidermonkey/1.8.0-rc1.nix
customRunner = ./custom_runner.py;
# TODO
# virt-manager -> import gtk.glade -> No module named glade --> fixed by removing 'pygtk' and by only using pyGtkGlade
# -> import gconf -> ImportError: No module named gconf
@ -62,21 +58,13 @@ stdenv.mkDerivation rec {
# -> fixed by http://nixos.org/wiki/Solve_GConf_errors_when_running_GNOME_applications & a restart
# virt-manager-tui -> ImportError: No module named newt_syrup.dialogscreen
patchPhase = ''
cat ${customRunner} > src/virt-manager.in
substituteInPlace "src/virt-manager.in" --replace "THE_CUSTOM_PATH" "$out"
substituteInPlace "src/virt-manager.in" --replace "THE_CUSTOM_PROGRAM" "virt-manager"
substituteInPlace "src/virt-manager.in" --replace "PYTHON_EXECUTABLE_PATH" "${python}/bin/python"
cat ${customRunner} > src/virt-manager-tui.in
substituteInPlace "src/virt-manager-tui.in" --replace "THE_CUSTOM_PATH" "$out"
substituteInPlace "src/virt-manager-tui.in" --replace "THE_CUSTOM_PROGRAM" "virt-manager-tui"
substituteInPlace "src/virt-manager-tui.in" --replace "PYTHON_EXECUTABLE_PATH" "${python}/bin/python"
'';
# /etc/nixos/nixpkgs/pkgs/development/python-modules/generic/wrap.sh
installPhase = ''
make install
# A hack, but the most reliable method so far
echo "#!/usr/bin/env python" | cat - src/virt-manager.py > $out/bin/virt-manager
echo "#!/usr/bin/env python" | cat - src/virt-manager-tui.py > $out/bin/virt-manager-tui
wrapPythonPrograms
'';