From 66653b0602e8af09cf0a3ac0fc250caa0a1db77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Thu, 20 Nov 2014 11:54:19 +0100 Subject: [PATCH] * Added script to build rpm for RH based distros * Added spec file to create rpm (more work needs to be done) * Making compatible Linux Actor with RH based distros * A lot of work :) --- actors/.gitignore | 1 + actors/linux/Makefile | 13 ++++- actors/linux/buildrpm.sh | 9 +++ actors/linux/debian/init | 4 +- actors/linux/debian/links | 4 +- actors/linux/desktop/UDSActorTool.desktop | 6 +- actors/linux/scripts/UDSActorTool-startup | 4 +- actors/linux/scripts/udsactor | 2 +- actors/linux/udsactor-1.7.0.spec | 59 ++++++++++++++++++++ actors/src/udsactor/REST.py | 5 +- actors/src/udsactor/linux/UDSActorService.py | 8 ++- 11 files changed, 104 insertions(+), 11 deletions(-) create mode 100755 actors/linux/buildrpm.sh create mode 100644 actors/linux/udsactor-1.7.0.spec diff --git a/actors/.gitignore b/actors/.gitignore index 78a2418a..675118bb 100644 --- a/actors/.gitignore +++ b/actors/.gitignore @@ -5,3 +5,4 @@ udsactor*.build udsactor*.changes /udsactor_1.7.0.dsc /udsactor_1.7.0.tar.xz +/udsactor-1.7.0-1.noarch.rpm diff --git a/actors/linux/Makefile b/actors/linux/Makefile index 712eaf07..809db0eb 100644 --- a/actors/linux/Makefile +++ b/actors/linux/Makefile @@ -3,11 +3,12 @@ # Directories SOURCEDIR := ../src -LIBDIR := $(DESTDIR)/usr/share/pyshared/UDSActor +LIBDIR := $(DESTDIR)/usr/share/UDSActor BINDIR := $(DESTDIR)/usr/bin SBINDIR = $(DESTDIR)/usr/sbin APPSDIR := $(DESTDIR)/usr/share/applications CFGDIR := $(DESTDIR)/etc/udsactor +INITDIR := $(DESTDIR)/etc/init.d POLKITDIR := $(DESTDIR)/usr/share/polkit-1/actions/ XDGAUTOSTARTDIR := $(DESTDIR)/etc/xdg/autostart KDEAUTOSTARTDIR := $(DESTDIR)/usr/share/autostart @@ -18,6 +19,7 @@ CACHES := $(shell find $(SOURCEDIR) -name '__pycache__') clean: rm -rf $(PYC) $(CACHES) $(DESTDIR) install: + rm -rf $(DESTDIR) mkdir -p $(LIBDIR) mkdir -p $(BINDIR) mkdir -p $(SBINDIR) @@ -57,10 +59,19 @@ install: # Fix permissions chmod 755 $(BINDIR)/udsactor chmod 755 $(BINDIR)/UDSActorTool-startup + chmod 755 $(SBINDIR)/UDSActorConfig-pkexec chmod 755 $(LIBDIR)/UDSActorConfig.py chmod 755 $(LIBDIR)/UDSActorUser.py chmod 644 $(POLKITDIR)/org.openuds.pkexec.UDSActorConfig.policy + # If for red hat based, copy init.d +ifeq ($(DISTRO),rh) + mkdir -p $(INITDIR) + cp debian/init $(INITDIR)/udsactor + ln -s /usr/share/UDSActor/UDSActorConfig.py $(SBINDIR)/UDSActorConfig + ln -s /usr/share/UDSActor/UDSActorUser.py $(BINDIR)/UDSActorTool +endif + # chmod 0755 $(BINDIR)/udsactor uninstall: rm -rf $(LIBDIR) diff --git a/actors/linux/buildrpm.sh b/actors/linux/buildrpm.sh new file mode 100755 index 00000000..f47385cf --- /dev/null +++ b/actors/linux/buildrpm.sh @@ -0,0 +1,9 @@ +#!/bin/bash + + +top=`pwd` +#rm -rf rpm +for folder in SOURCES BUILD RPMS SPECS SRPMS; do + mkdir -p rpm/$folder +done +rpmbuild -v -bb --clean --target noarch 'udsactor-1.7.0.spec' 2>&1 diff --git a/actors/linux/debian/init b/actors/linux/debian/init index bb5d2798..27576717 100755 --- a/actors/linux/debian/init +++ b/actors/linux/debian/init @@ -1,6 +1,6 @@ #!/bin/sh -e ### BEGIN INIT INFO -# Provides: uds-actor +# Provides: udsactor # Required-Start: $local_fs $remote_fs $network $syslog $named # Required-Stop: $local_fs $remote_fs $network $syslog $named # Default-Start: 2 3 4 5 @@ -9,7 +9,7 @@ ### END INIT INFO # -. /lib/lsb/init-functions +# . /lib/lsb/init-functions case "$1" in start|stop|restart) diff --git a/actors/linux/debian/links b/actors/linux/debian/links index 649de20c..6dd3d539 100644 --- a/actors/linux/debian/links +++ b/actors/linux/debian/links @@ -1,2 +1,2 @@ -/usr/share/pyshared/UDSActor/UDSActorConfig.py /usr/sbin/UDSActorConfig -/usr/share/pyshared/UDSActor/UDSActorUser.py /usr/bin/UDSActorTool \ No newline at end of file +/usr/share/UDSActor/UDSActorConfig.py /usr/sbin/UDSActorConfig +/usr/share/UDSActor/UDSActorUser.py /usr/bin/UDSActorTool \ No newline at end of file diff --git a/actors/linux/desktop/UDSActorTool.desktop b/actors/linux/desktop/UDSActorTool.desktop index 57f2c1fb..22e7b517 100644 --- a/actors/linux/desktop/UDSActorTool.desktop +++ b/actors/linux/desktop/UDSActorTool.desktop @@ -5,4 +5,8 @@ Exec=/usr/bin/UDSActorTool-startup Icon=/usr/share/pyshared/UDSActor/img/uds.png Terminal=false Type=Application -NoDisplay=true \ No newline at end of file +NoDisplay=true +X-KDE-autostart-after=panel +X-KDE-StartupNotify=false +X-DBUS-StartupType=Unique +X-KDE-UniqueApplet=true diff --git a/actors/linux/scripts/UDSActorTool-startup b/actors/linux/scripts/UDSActorTool-startup index 11cd14aa..ec379ab3 100644 --- a/actors/linux/scripts/UDSActorTool-startup +++ b/actors/linux/scripts/UDSActorTool-startup @@ -1,4 +1,6 @@ #!/bin/sh +# Simple hack to wait for systray to be present sleep 5 -/usr/bin/UDSActorTool \ No newline at end of file +# Exec tool +exec /usr/bin/UDSActorTool \ No newline at end of file diff --git a/actors/linux/scripts/udsactor b/actors/linux/scripts/udsactor index d1dccd36..777b2d07 100755 --- a/actors/linux/scripts/udsactor +++ b/actors/linux/scripts/udsactor @@ -1,6 +1,6 @@ #!/bin/sh -FOLDER=/usr/share/pyshared/UDSActor +FOLDER=/usr/share/UDSActor cd $FOLDER python -m udsactor.linux.UDSActorService $@ diff --git a/actors/linux/udsactor-1.7.0.spec b/actors/linux/udsactor-1.7.0.spec new file mode 100644 index 00000000..c94b411b --- /dev/null +++ b/actors/linux/udsactor-1.7.0.spec @@ -0,0 +1,59 @@ +%define _topdir %(echo $PWD)/rpm +%define name udsactor +%define version 1.7.0 +%define release 1 +%define buildroot %{_topdir}/%{name}-%{version}-%{release}-root + +BuildRoot: %{buildroot} +Name: %{name} +Version: %{version} +Release: %{release} +Summary: Actor for Universal Desktop Services (UDS) Broker +License: BSD3 +Group: Admin +Requires: python-six python-requests PyQt4 + +%define _rpmdir ../ +%define _rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm + + +%install +curdir=`pwd` +cd ../.. +make DESTDIR=$RPM_BUILD_ROOT DISTRO=rh install +cd $curdir + +%clean +rm -rf $RPM_BUILD_ROOT +curdir=`pwd` +cd ../.. +make DESTDIR=$RPM_BUILD_ROOT DISTRO=rh clean +cd $curdir + + +%post +#!/bin/sh + +%preun +#!/bin/sh + +%postun +#!/bin/sh + +%description +This package provides the required components to allow this machine to work on an environment managed by UDS Broker. + +%files +%defattr(-,root,root) +/etc/udsactor +/etc/xdg/autostart/UDSActorTool.desktop +/etc/init.d/udsactor +/usr/bin/UDSActorTool-startup +/usr/bin/udsactor +/usr/bin/UDSActorTool +/usr/sbin/UDSActorConfig +/usr/sbin/UDSActorConfig-pkexec +/usr/share/UDSActor/* +/usr/share/applications/UDS_Actor_Configuration.desktop +/usr/share/autostart/UDSActorTool.desktop +/usr/share/polkit-1/actions/org.openuds.pkexec.UDSActorConfig.policy diff --git a/actors/src/udsactor/REST.py b/actors/src/udsactor/REST.py index 260bcc54..2a80fda9 100644 --- a/actors/src/udsactor/REST.py +++ b/actors/src/udsactor/REST.py @@ -122,7 +122,10 @@ class Api(object): self.mac = None self.url = "{}://{}/rest/actor/".format(('http', 'https')[ssl], self.host) self.secretKey = six.text_type(uuid.uuid4()) - self.newerRequestLib = 'verify' in requests.sessions.Session.__attrs__ + try: + self.newerRequestLib = 'verify' in requests.sessions.Session.__attrs__ + except: + self.newerRequestLib = False # Disable logging requests messages except for errors, ... logging.getLogger("requests").setLevel(logging.ERROR) diff --git a/actors/src/udsactor/linux/UDSActorService.py b/actors/src/udsactor/linux/UDSActorService.py index 5385c6b3..08b32026 100644 --- a/actors/src/udsactor/linux/UDSActorService.py +++ b/actors/src/udsactor/linux/UDSActorService.py @@ -44,7 +44,11 @@ from udsactor.linux.daemon import Daemon from udsactor.linux import renamer import sys -import prctl +try: + from prctl import set_proctitle +except Exception: # Platform may not include prctl, so in case it's not available, we let the "name" as is + def set_proctitle(_): + pass class UDSActorSvc(Daemon, CommonService): @@ -79,7 +83,7 @@ class UDSActorSvc(Daemon, CommonService): initCfg() logger.debug('Running Daemon') - prctl.set_proctitle('UDSActorDaemon') + set_proctitle('UDSActorDaemon') # Linux daemon will continue running unless something is requested to if self.interactWithBroker() is False: