From 736d6215ba018df6820b753a2cada030aa0c8613 Mon Sep 17 00:00:00 2001 From: Tom Callaway Date: Mar 01 2012 22:21:12 +0000 Subject: really fix gedit plugin and fix nautilus issue --- diff --git a/beesu-gedit-plugin-fix.patch b/beesu-gedit-plugin-fix.patch index f844aea..51e07d0 100644 --- a/beesu-gedit-plugin-fix.patch +++ b/beesu-gedit-plugin-fix.patch @@ -1,15 +1,373 @@ diff -up beesu-2.7/gedit-beesu-plugin-0.4/beesu.gedit-plugin.fix beesu-2.7/gedit-beesu-plugin-0.4/beesu.gedit-plugin ---- beesu-2.7/gedit-beesu-plugin-0.4/beesu.gedit-plugin.fix 2012-02-10 16:56:07.075334768 -0500 -+++ beesu-2.7/gedit-beesu-plugin-0.4/beesu.gedit-plugin 2012-02-10 16:56:13.722268371 -0500 +--- beesu-2.7/gedit-beesu-plugin-0.4/beesu.gedit-plugin.fix 2010-07-22 05:38:58.000000000 -0400 ++++ beesu-2.7/gedit-beesu-plugin-0.4/beesu.gedit-plugin 2012-03-01 16:54:11.491145515 -0500 @@ -1,4 +1,4 @@ -[Gedit Plugin] +[Plugin] Loader=python Module=beesu IAge=2 +diff -up beesu-2.7/gedit-beesu-plugin-0.4/beesu.py.fix beesu-2.7/gedit-beesu-plugin-0.4/beesu.py +--- beesu-2.7/gedit-beesu-plugin-0.4/beesu.py.fix 2010-11-04 16:35:56.000000000 -0400 ++++ beesu-2.7/gedit-beesu-plugin-0.4/beesu.py 2012-03-01 16:54:11.493145496 -0500 +@@ -1,4 +1,5 @@ + # 2010 - Copyright by Bee . ++# 2012 - Rewritten to work with modern Gedit by Tom Callaway + # This program is free software; you can redistribute it and/or + # modify it under the terms of the GNU General Public License + # as published by the Free Software Foundation; either version 2 +@@ -13,77 +14,91 @@ + # along with this program; if not, write to the Free Software + # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +-import gedit +-import pygtk +-pygtk.require('2.0') +-import gtk ++from gi.repository import GObject, Gtk, Gedit ++# import gedit ++# import pygtk ++# pygtk.require('2.0') ++# import gtk + from gettext import gettext as _ + import os + import tempfile + import time ++import sys ++import traceback + import subprocess + import pickle + +-def error_message(message): +- def msg_on_close_destroy(button,response_id,dialog): +- if response_id == gtk.RESPONSE_CLOSE: +- dialog.destroy() +- +- msg_dialog = gtk.MessageDialog(flags = gtk.DIALOG_MODAL, buttons = gtk.BUTTONS_CLOSE, type = gtk.MESSAGE_ERROR, message_format = message) +- msg_dialog.connect('response', msg_on_close_destroy, msg_dialog) +- msg_dialog.run() +- +-class WindowControl: +- def __init__(self, plugin, window): +- self._window = window +- self._plugin = plugin ++ui_str = """ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++""" ++ ++class beesuPlugin(GObject.Object, Gedit.WindowActivatable): ++ __gtype_name__ = "BeesuPlugin" ++ ++ window = GObject.property(type=Gedit.Window) ++ ++ def __init__(self): ++ GObject.Object.__init__(self) ++ ++ def do_activate(self): + self._insert_menu() + +- def deactivate(self): ++ def do_deactivate(self): + self._remove_menu() +- self._window = self._plugin = self._action_group = None ++ ++ def _remove_menu(self): ++ manager = self.window.get_ui_manager() ++ manager.remove_ui(self._ui_id) ++ manager.remove_action_group(self._action_group) ++ self._action_group = None ++ manager.ensure_update() + + def _insert_menu(self): +- manager = self._window.get_ui_manager() ++ manager = self.window.get_ui_manager() + +- self._action_group = gtk.ActionGroup("beesuPluginActions") +- self._action_group.add_actions([("beesuPlugin", None, ++ self._action_group = Gtk.ActionGroup(name="beesuPluginActions") ++ self._action_group.add_actions([("beesuPlugin", None, + _("Open as \"root\""), +- None, ++ None, + _("Open this document as \"root\" in gedit with SED_BEESU_COMMAND_LINE_NAME"), + self.beesu)]) + + manager.insert_action_group(self._action_group, -1) +- +- ui_str = """ +- +- +- +- +- +- +- +- +- """ +- + self._ui_id = manager.add_ui_from_string(ui_str) + +- def _remove_menu(self): +- manager = self._window.get_ui_manager() +- manager.remove_ui(self._ui_id) +- manager.remove_action_group(self._action_group) +- manager.ensure_update() ++ def is_configurable(self): ++ return False ++ ++ def error_message(message): ++ def msg_on_close_destroy(button,response_id,dialog): ++ if response_id == Gtk.ResponseType.CLOSE: ++ dialog.destroy() ++ ++ msg_dialog = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, message) ++ msg_dialog.connect('response', msg_on_close_destroy, msg_dialog) ++ msg_dialog.run() + +- def update_ui(self): +- self._action_group.set_sensitive(self._window.get_active_document() != None) + + def beesu(self, action): +- tab = self._window.get_active_tab() +- doc = self._window.get_active_document() ++ tab = self.window.get_active_tab() ++ doc = self.window.get_active_document() + + filename = None + if doc: +- filename = doc.get_uri() ++ location = doc.get_location() ++ if location: ++ uri = location.get_uri() ++ if uri is not None: ++ if uri[:7] == "file://": ++ filename = location.get_parse_name() + + if not self.beesu_exec(filename): + return +@@ -91,45 +106,36 @@ class WindowControl: + if tab: + if doc == tab.get_document(): + if doc.get_readonly() or doc.is_untouched(): +- self._window.close_tab(tab) +- if self._window.get_active_document() == None and self._window.get_active_tab() == None: +- self._window.destroy() +- ++ self.window.close_tab(tab) ++ if self.window.get_active_document() == None and self.window.get_active_tab() == None: ++ self.window.destroy() ++ + def beesu_exec(self, filename): + tmp = tempfile.NamedTemporaryFile(delete = False) + lockfile = tmp.name + tmp.close() +- #['beesu', '-l', '-c', '/usr/libexec/gedit-beesu-plugin','gedit-beesu-plugin','/usr/bin/gedit','gedit',lockfile] +- shell_args = [SED_BEESU_COMMAND_LINE_SU,'/usr/libexec/gedit-beesu-plugin','gedit-beesu-plugin','gedit','gedit',lockfile] ++ #shell_args = [SED_BEESU_COMMAND_LINE_SU,'/usr/libexec/gedit-beesu-plugin','gedit-beesu-plugin','gedit','gedit',lockfile] + if filename != None and filename != '': +- shell_args.append(filename) ++ # shell_args = ['beesu', '-l', '-c', '\"/usr/bin/gedit %s\"' % filename] ++ shell_args = ['beesu', '-l', '-c', '/usr/libexec/gedit-beesu-plugin','gedit-beesu-plugin','gedit','gedit',lockfile, filename] ++ # shell_args = ['/usr/libexec/gedit-beesu-plugin','gedit-beesu-plugin','gedit','gedit', lockfile, filename] ++ else: ++ return False ++ print shell_args + try: + subprocess.Popen(shell_args, stderr=open(os.devnull)).wait() + except: +- error_message(_("Error running SED_BEESU_COMMAND_LINE_NAME: " + sys.exc_info()[0])) ++ etype = sys.exc_info()[0] ++ evalue = sys.exc_info()[1] ++ etb = traceback.extract_tb(sys.exc_info()[2]) ++ myerror = 'Error running SED_BEESU_COMMAND_LINE_NAME: ' + '\n' + 'Error Type: ' + str(etype) + '\n' + 'Error Value: ' + str(evalue) + '\n' + 'Traceback: ' + str(etb) ++ self.error_message(_(myerror)) + return False + ++ print 'Hey, it says the Popen succeeded.' ++ + if os.path.isfile(lockfile): + os.remove(lockfile) + return False + + return True +- +-class beesuPlugin(gedit.Plugin): +- def __init__(self): +- gedit.Plugin.__init__(self) +- self._instances = {} +- +- def activate(self, window): +- self._instances[window] = WindowControl(self, window) +- +- def deactivate(self, window): +- self._instances[window].deactivate() +- del self._instances[window] +- +- def update_ui(self, window): +- self._instances[window].update_ui() +- +- def is_configurable(self): +- return False +- +diff -up beesu-2.7/gedit-beesu-plugin-0.4/libexec/gedit-beesu-plugin.c.fix beesu-2.7/gedit-beesu-plugin-0.4/libexec/gedit-beesu-plugin.c +--- beesu-2.7/gedit-beesu-plugin-0.4/libexec/gedit-beesu-plugin.c.fix 2011-01-07 11:33:15.000000000 -0500 ++++ beesu-2.7/gedit-beesu-plugin-0.4/libexec/gedit-beesu-plugin.c 2012-03-01 16:59:49.454787493 -0500 +@@ -40,61 +40,109 @@ int main(int argc, char **argv) + int fd; + int pid; + int status; ++ int dup2_return = 0; + char syncfile[]="/tmp/gbeesu.XXXXXX"; ++ pid_t cpid; + if(argc > REQUIRED_ARGC) + { ++ printf("DEBUG: Number of necessary args found.\n"); + command = argv[1]; // 1, REQUIRED_ARGC - 3 + if(strcmp(command, "gedit-beesu-plugin") == 0) + { ++ printf("DEBUG: strcmp succeeded.\n"); + command = argv[2]; // 2, REQUIRED_ARGC - 2 + commandline[0] = argv[3]; // 3, REQUIRED_ARGC - 1 + lockfile = argv[4]; // 4, REQUIRED_ARGC + if(argc > (REQUIRED_ARGC + 1)) ++ printf("DEBUG: Appending additional args to commandline.\n"); + commandline[1] = argv[REQUIRED_ARGC + 1];// 5, REQUIRED_ARGC + 1 + if(lstat(lockfile, &buf) == 0) + { ++ printf("DEBUG: lstat on lockfile succeeded.\n"); + if(buf.st_size == 0 && S_ISREG(buf.st_mode)) + { ++ printf("DEBUG: buf checks passed.\n"); + fd = mkstemp(syncfile); +- if(fd == -1) ++ printf("DEBUG: fd initialized.\n"); ++ if(fd == -1) { ++ printf("DEBUG: fd failure, exiting.\n"); + return EXIT_FAILURE; ++ } ++ printf("DEBUG: About to close fd.\n"); + close(fd); ++ printf("DEBUG: fd closed, about to fork.\n"); + pid = fork(); ++ printf("DEBUG: Going into PID switch.\n"); + switch(pid) + { + case 0: ++ printf("DEBUG: PID switch case 0.\n"); ++/* + fd = open("/dev/null", O_RDWR); + if(fd != -1) + { +- dup2(fd, 0); +- dup2(fd, 1); +- dup2(fd, 2); +- close(fd); ++ printf("DEBUG: Opened fd for /dev/null.\n"); ++ printf("DEBUG: Calling dup2 for 0\n"); ++ dup2_return = dup2(fd, 0); ++ if(dup2_return < 0) { ++ printf("DEBUG: dup2(fd, 0) failed with error %d.\n", dup2_return); ++ } else { ++ printf("DEBUG: dup2(fd, 0) succeeded.\n"); ++ } ++ printf("DEBUG: Calling dup2 for 1\n"); ++ dup2_return = dup2(fd, 1); ++ if(dup2_return < 0) { ++ printf("DEBUG: dup2(fd, 1) failed with error %d.\n", dup2_return); ++ ++ } else { ++ printf("DEBUG: dup2(fd, 1) succeeded.\n"); ++ } ++ printf("DEBUG: Calling dup2 for 2\n"); ++ dup2_return = dup2(fd, 2); ++ if(dup2_return < 0) { ++ printf("DEBUG: dup2(fd, 2) failed with error %d.\n", dup2_return); ++ } else { ++ printf("DEBUG: dup2(fd, 2) succeeded.\n"); ++ } + } ++ printf("DEBUG: Closing fd for /dev/null.\n"); ++ close(fd); ++*/ ++ printf("DEBUG: About to call signal(SIGHUP, SIG_IGN).\n"); + signal(SIGHUP, SIG_IGN); ++ printf("DEBUG: Going into FORK switch.\n"); + switch(fork()) // internal fork!! + { + case -1: ++ printf("DEBUG: FORK switch case -1.\n"); + _exit(EXIT_FAILURE); + break; + case 0: ++ printf("DEBUG: FORK switch case 0.\n"); + signal(SIGHUP, SIG_IGN); + unlink(syncfile); +- execvp(command, commandline); ++ printf("DEBUG: About to execvp %s %s %s.\n", command, commandline[0], commandline[1]); ++ if (execvp(command, commandline) < 0) { ++ printf("DEBUG: execvp failed.\n"); ++ } + _exit(EXIT_FAILURE); + break; + default: ++ printf("DEBUG: FORK switch default.\n"); + break; + } + _exit(EXIT_SUCCESS); + break; + case -1: ++ printf("DEBUG: PID switch case -1.\n"); + unlink(syncfile); + return EXIT_FAILURE; + break; + default: ++ printf("DEBUG: PID switch case default.\n"); + waitpid(pid, &status, 0); + // Wait (max 20 seconds!!!) for the syncfile to be removed!!! ++ printf("DEBUG: Waiting for the syncfile to be removed.\n"); + for(status = 0; status < 20; status++) + { + if(access(syncfile, F_OK) == 0) +@@ -108,15 +156,19 @@ int main(int argc, char **argv) + } + if(access(syncfile, F_OK) == 0) + { ++ printf("DEBUG: Syncfile error.\n"); + // Enter here on error + unlink(syncfile); + } + else + { ++ printf("DEBUG: Syncfile success.\n"); + // Enter here on success!!!!!! +- usleep(50000); ++ printf("DEBUG: usleeping for 5000000, hope that is long enough for gedit to respawn.\n"); ++ usleep(5000000); + unlink(lockfile); + } ++ printf("DEBUG: About to return SUCCESS.\n"); + return EXIT_SUCCESS; + break; + } +@@ -124,6 +176,7 @@ int main(int argc, char **argv) + } + } + } ++ printf("DEBUG: About to return FAILURE.\n"); + return EXIT_FAILURE; + } + diff -up beesu-2.7/gedit-beesu-plugin-0.4/Makefile.in.fix beesu-2.7/gedit-beesu-plugin-0.4/Makefile.in --- beesu-2.7/gedit-beesu-plugin-0.4/Makefile.in.fix 2010-11-04 16:39:29.000000000 -0400 -+++ beesu-2.7/gedit-beesu-plugin-0.4/Makefile.in 2012-02-10 16:54:13.781360974 -0500 ++++ beesu-2.7/gedit-beesu-plugin-0.4/Makefile.in 2012-03-01 16:54:11.497145456 -0500 @@ -13,19 +13,19 @@ all: # To install things in the right place diff --git a/beesu-nautilus-no-browser.patch b/beesu-nautilus-no-browser.patch new file mode 100644 index 0000000..0fa9bd6 --- /dev/null +++ b/beesu-nautilus-no-browser.patch @@ -0,0 +1,10 @@ +--- beesu-2.7/nautilus-beesu-manager-1.7/libexec/scripts/Open Nautilus Here.nfix 2012-03-01 17:02:55.344922134 -0500 ++++ beesu-2.7/nautilus-beesu-manager-1.7/libexec/scripts/Open Nautilus Here 2012-03-01 17:03:00.214873732 -0500 +@@ -6,6 +6,6 @@ else + while [ ! -z "$1" -a ! -d "$base/$1" ]; do shift; done + dir="$base/$1" + fi +-beesu - nautilus --browser "$dir" ++beesu - nautilus "$dir" + # F12 + /bin/true diff --git a/beesu.spec b/beesu.spec index 4f87771..a955b6a 100644 --- a/beesu.spec +++ b/beesu.spec @@ -5,7 +5,7 @@ Name: beesu Version: 2.7 # Don't ever decrease this version (unless all beesu, nbm, and gbp update) or the subpackages will go backwards. # It is easier to do this than to track a separate release field. -Release: 6%{?dist} +Release: 7%{?dist} Summary: Graphical wrapper for su URL: http://www.honeybeenet.altervista.org Group: Applications/System @@ -14,6 +14,7 @@ Source0: http://honeybeenet.altervista.org/beesu/files/beesu-sources/%{name}-%{v Source1: http://honeybeenet.altervista.org/beesu/files/beesu-manager/nautilus-beesu-manager-%{nbmversion}.tar.bz2 Source2: http://honeybeenet.altervista.org/beesu/files/beesu-gedit/gedit-beesu-plugin-%{geditver}.tar.bz2 Patch0: beesu-gedit-plugin-fix.patch +Patch1: beesu-nautilus-no-browser.patch BuildRequires: desktop-file-utils Requires: pam, usermode @@ -48,6 +49,7 @@ Open as root. %prep %setup -q -a1 -a2 %patch0 -p1 -b .fix +%patch1 -p1 chmod -x nautilus-beesu-manager-%{nbmversion}/COPYING nautilus-beesu-manager-%{nbmversion}/README %build @@ -123,6 +125,10 @@ fi %{_libexecdir}/gedit-beesu-plugin %changelog +* Thu Mar 1 2012 Tom Callaway - 2.7-7 +- remove --browser from nautilus invocation +- fix gedit-beesu-plugin (this time for real) + * Fri Feb 10 2012 Tom Callaway - 2.7-6 - fix gedit-beesu-plugin (bz 786734)