1 |
commit: 73b9eb1973d6ca6954412dd58b552ef73fe9ae5e |
2 |
Author: Michael Perlov <perlovka <AT> gmail <DOT> com> |
3 |
AuthorDate: Tue Oct 16 12:03:32 2018 +0000 |
4 |
Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Oct 27 19:02:37 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=73b9eb19 |
7 |
|
8 |
sys-power/nut: Add USE gui to install NUT-Monitor |
9 |
|
10 |
Acked-by: Matthew Thode <prometheanfire <AT> gentoo.org> |
11 |
Signed-off-by: Michael Perlov <perlovka <AT> gmail.com> |
12 |
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org> |
13 |
Package-Manager: Portage-2.3.51, Repoman-2.3.11 |
14 |
|
15 |
sys-power/nut/files/NUT-Monitor-1.3-paths.patch | 48 +++++++++++++++++++++++++ |
16 |
sys-power/nut/metadata.xml | 1 + |
17 |
sys-power/nut/nut-2.7.4-r2.ebuild | 30 ++++++++++++++-- |
18 |
3 files changed, 77 insertions(+), 2 deletions(-) |
19 |
|
20 |
diff --git a/sys-power/nut/files/NUT-Monitor-1.3-paths.patch b/sys-power/nut/files/NUT-Monitor-1.3-paths.patch |
21 |
new file mode 100644 |
22 |
index 00000000000..17bedaead72 |
23 |
--- /dev/null |
24 |
+++ b/sys-power/nut/files/NUT-Monitor-1.3-paths.patch |
25 |
@@ -0,0 +1,48 @@ |
26 |
+--- a/scripts/python/app/NUT-Monitor |
27 |
++++ b/scripts/python/app/NUT-Monitor |
28 |
+@@ -70,7 +70,7 @@ |
29 |
+ ( cmd_opts, args ) = opt_parser.parse_args() |
30 |
+ |
31 |
+ |
32 |
+- self.__glade_file = os.path.join( os.path.dirname( sys.argv[0] ), "gui-1.3.glade" ) |
33 |
++ self.__glade_file = '/usr/share/nut/gui-1.3.glade' |
34 |
+ |
35 |
+ self.__widgets["interface"] = gtk.glade.XML( self.__glade_file, "window1", APP ) |
36 |
+ self.__widgets["main_window"] = self.__widgets["interface"].get_widget("window1") |
37 |
+@@ -103,11 +103,11 @@ |
38 |
+ |
39 |
+ # Create the tray icon and connect it to the show/hide method... |
40 |
+ self.__widgets["status_icon"] = gtk.StatusIcon() |
41 |
+- self.__widgets["status_icon"].set_from_file( os.path.join( os.path.dirname( sys.argv[0] ), "pixmaps", "on_line.png" ) ) |
42 |
++ self.__widgets["status_icon"].set_from_file( "/usr/share/nut/pixmaps/on_line.png" ) |
43 |
+ self.__widgets["status_icon"].set_visible( True ) |
44 |
+ self.__widgets["status_icon"].connect( "activate", self.tray_activated ) |
45 |
+ |
46 |
+- self.__widgets["ups_status_image"].set_from_file( os.path.join( os.path.dirname( sys.argv[0] ), "pixmaps", "on_line.png" ) ) |
47 |
++ self.__widgets["ups_status_image"].set_from_file( "/usr/share/nut/pixmaps/on_line.png" ) |
48 |
+ |
49 |
+ # Define interface callbacks actions |
50 |
+ self.__callbacks = { "on_window1_destroy" : self.quit, |
51 |
+@@ -265,8 +265,8 @@ |
52 |
+ #------------------------------------------------------------------- |
53 |
+ # Change the status icon and tray icon |
54 |
+ def change_status_icon( self, icon="on_line", blink=False ) : |
55 |
+- self.__widgets["status_icon"].set_from_file( os.path.join( os.path.dirname( sys.argv[0] ), "pixmaps", "%s.png" % icon ) ) |
56 |
+- self.__widgets["ups_status_image"].set_from_file( os.path.join( os.path.dirname( sys.argv[0] ), "pixmaps", "%s.png" % icon ) ) |
57 |
++ self.__widgets["status_icon"].set_from_file( "/usr/share/nut/pixmaps/%s.png" % icon ) |
58 |
++ self.__widgets["ups_status_image"].set_from_file( "/usr/share/nut/pixmaps/%s.png" % icon ) |
59 |
+ self.__widgets["status_icon"].set_blinking( blink ) |
60 |
+ |
61 |
+ #------------------------------------------------------------------- |
62 |
+@@ -719,9 +719,9 @@ |
63 |
+ |
64 |
+ for k,v in vars.iteritems() : |
65 |
+ if ( rwvars.has_key( k ) ) : |
66 |
+- icon_file = os.path.join( os.path.dirname( sys.argv[0] ), "pixmaps", "var-rw.png" ) |
67 |
++ icon_file = "/usr/share/nut/pixmaps/var-rw.png" |
68 |
+ else : |
69 |
+- icon_file = os.path.join( os.path.dirname( sys.argv[0] ), "pixmaps", "var-ro.png" ) |
70 |
++ icon_file = "/usr/share/nut/pixmaps/var-ro.png" |
71 |
+ |
72 |
+ icon = gtk.gdk.pixbuf_new_from_file( icon_file ) |
73 |
+ self.__widgets["ups_vars_tree_store"].append( [ icon, k, v ] ) |
74 |
|
75 |
diff --git a/sys-power/nut/metadata.xml b/sys-power/nut/metadata.xml |
76 |
index d9ab89aeb36..85d0b12815a 100644 |
77 |
--- a/sys-power/nut/metadata.xml |
78 |
+++ b/sys-power/nut/metadata.xml |
79 |
@@ -9,6 +9,7 @@ |
80 |
<email>prometheanfire@g.o</email> |
81 |
</maintainer> |
82 |
<use> |
83 |
+ <flag name="gui">Install NUT-Monitor python gui</flag> |
84 |
<flag name="ipmi">Support IPMI-based UPSes.</flag> |
85 |
<flag name="ups_drivers_al175">Driver for Eltek UPS models with AL175 alarm module</flag> |
86 |
<flag name="ups_drivers_bcmxcp">Driver for UPSes supporting the serial BCM/XCP protocol</flag> |
87 |
|
88 |
diff --git a/sys-power/nut/nut-2.7.4-r2.ebuild b/sys-power/nut/nut-2.7.4-r2.ebuild |
89 |
index 5045bf0a37c..031f61d9dd9 100644 |
90 |
--- a/sys-power/nut/nut-2.7.4-r2.ebuild |
91 |
+++ b/sys-power/nut/nut-2.7.4-r2.ebuild |
92 |
@@ -3,7 +3,9 @@ |
93 |
|
94 |
EAPI=6 |
95 |
|
96 |
-inherit autotools bash-completion-r1 fixheadtails user systemd flag-o-matic toolchain-funcs |
97 |
+PYTHON_COMPAT=( python2_7 ) |
98 |
+ |
99 |
+inherit autotools bash-completion-r1 desktop fixheadtails flag-o-matic python-single-r1 systemd toolchain-funcs user |
100 |
|
101 |
MY_P=${P/_/-} |
102 |
|
103 |
@@ -14,11 +16,13 @@ LICENSE="GPL-2" |
104 |
SLOT="0" |
105 |
KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~x86 ~x86-fbsd" |
106 |
|
107 |
-IUSE="cgi ipmi snmp +usb selinux ssl tcpd xml zeroconf" |
108 |
+IUSE="cgi gui ipmi snmp +usb selinux ssl tcpd xml zeroconf" |
109 |
+REQUIRED_USE="gui? ( ${PYTHON_REQUIRED_USE} )" |
110 |
|
111 |
COMMON_DEPEND="dev-libs/libltdl:* |
112 |
virtual/udev |
113 |
cgi? ( >=media-libs/gd-2[png] ) |
114 |
+ gui? ( dev-python/pygtk[${PYTHON_USEDEP}] ) |
115 |
ipmi? ( sys-libs/freeipmi ) |
116 |
snmp? ( net-analyzer/net-snmp ) |
117 |
ssl? ( >=dev-libs/openssl-1 ) |
118 |
@@ -88,6 +92,7 @@ pkg_setup() { |
119 |
# in some cases on old systems it wasn't in the nut group either! |
120 |
gpasswd -a nut nut 2>/dev/null |
121 |
warningmsg ewarn |
122 |
+ use gui && python-single-r1_pkg_setup |
123 |
} |
124 |
|
125 |
src_prepare() { |
126 |
@@ -106,6 +111,8 @@ src_prepare() { |
127 |
-e 's:@LIBSSL_LDFLAGS@:@LIBSSL_LIBS@:' \ |
128 |
lib/libupsclient{.pc,-config}.in || die #361685 |
129 |
|
130 |
+ use gui && eapply "${FILESDIR}"/NUT-Monitor-1.3-paths.patch |
131 |
+ |
132 |
eautoreconf |
133 |
} |
134 |
|
135 |
@@ -169,6 +176,25 @@ src_install() { |
136 |
elog "If you use lighttpd, see lighttpd_nut.conf in the documentation." |
137 |
fi |
138 |
|
139 |
+ if use gui; then |
140 |
+ python_fix_shebang scripts/python/app |
141 |
+ python_domodule scripts/python/module/PyNUT.py |
142 |
+ python_doscript scripts/python/app/NUT-Monitor |
143 |
+ |
144 |
+ insinto /usr/share/nut |
145 |
+ doins scripts/python/app/gui-1.3.glade |
146 |
+ |
147 |
+ dodir /usr/share/nut/pixmaps |
148 |
+ insinto /usr/share/nut/pixmaps |
149 |
+ doins scripts/python/app/pixmaps/* |
150 |
+ |
151 |
+ sed -i -e 's/nut-monitor.png/nut-monitor/' -e 's/Application;//' \ |
152 |
+ scripts/python/app/${PN}-monitor.desktop || die |
153 |
+ |
154 |
+ doicon scripts/python/app/${PN}-monitor.png |
155 |
+ domenu scripts/python/app/${PN}-monitor.desktop |
156 |
+ fi |
157 |
+ |
158 |
# this must be done after all of the install phases |
159 |
for i in "${D}"/etc/nut/*.sample ; do |
160 |
mv "${i}" "${i/.sample/}" || die |