0.9.3-5: Various fixes.

epel8
Alec Leamas 10 years ago
parent 2c2e81ce1e
commit 73d0d20447

@ -1,185 +0,0 @@
From afd89cd1a0f41bdfd0bf049e4245258abe7deffb Mon Sep 17 00:00:00 2001
From: Alec Leamas <leamas.alec@gmail.com>
Date: Mon, 7 Sep 2015 13:36:30 +0200
Subject: [PATCH] tools: Add missing file lirc-setup/database.py.
---
tools/Makefile.am | 3 +-
tools/lirc-setup/database.py | 151 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 153 insertions(+), 1 deletion(-)
create mode 100644 tools/lirc-setup/database.py
diff --git a/tools/Makefile.am b/tools/Makefile.am
index f3fd3c4..d0d820c 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -85,7 +85,8 @@ pkgpython_PYTHON = lirc-setup/mvc_control.py \
lirc-setup/mvc_view.py \
lirc-setup/mvc_model.py \
lirc-setup/choosers.py \
- lirc-setup/baseview.py
+ lirc-setup/baseview.py \
+ lirc-setup/database.py
dist_pkgpython_SCRIPTS = lirc-setup/lirc-setup
dist_pkgpython_DATA = lirc-setup/lirc-setup.ui
endif
diff --git a/tools/lirc-setup/database.py b/tools/lirc-setup/database.py
new file mode 100644
index 0000000..1c1e70b
--- /dev/null
+++ b/tools/lirc-setup/database.py
@@ -0,0 +1,151 @@
+''' Simple lirc setup tool - database part.
+
+The database is loaded from some YAML files:
+
+ - kernel-drivers.yaml: Info on the kernel drivers.
+ - drivers,yaml, Info on the uerspace drivers, collected from their
+ compiled information.
+ - confs_by_driver.yaml: Mapping of drivers -> suggested remote files,
+ created by irdb-get.
+
+The directory used to load these files is (first match used):
+ - Current directory
+ - The 'configs' dir.
+ - The ../../configs
+
+Although python cannot guarantee this, the database is designed to be a
+read-only structure.
+
+'''
+
+
+import glob
+import os
+import os.path
+import sys
+
+YAML_MSG = '''
+"Cannot import the yaml library. Please install the python3
+yaml package, on many distributions known as python3-PyYAML. It is also
+available as a pypi package at https://pypi.python.org/pypi/PyYAML.'''
+
+try:
+ import yaml
+except ImportError:
+ print(YAML_MSG)
+ sys.exit(1)
+
+
+def _here(path):
+ ''' Return path added to current dir for __file__. '''
+ return os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
+
+
+class Config(object):
+ ''' The configuration selected, and it's sources. '''
+ # pylint: disable=too-many-instance-attributes
+
+ def __init__(self, config=None):
+ self.device = None # << selected device.
+ self.driver = {} # << Read-only driver dict in db
+ self.config = {} # << Read-only config dict in db
+ self.modinit = "" # << Substituted data from driver
+ self.modprobe = "" # << Substituted data from driver
+ self.lircd_conf = "" # << Name of lircd.conf file
+ self.lircmd_conf = "" # << Name of lircmd.conf file
+ self.label = "" # << Label for driver + device
+ if config:
+ for key, value in config.items():
+ setattr(self, key, value)
+
+
+class Database(object):
+ ''' Reflects the *.yaml files in the configs/ directory. '''
+
+ def __init__(self, path=None):
+
+ if path and os.path.exists(path):
+ configdir = path
+ elif path:
+ raise FileNotFoundError(path)
+ elif os.path.exists(_here('configs')):
+ configdir = _here('configs')
+ elif os.path.exists(_here('../configs')):
+ configdir = _here('../configs')
+ else:
+ raise FileNotFoundError(configdir)
+ db = {}
+ with open(os.path.join(configdir, "confs_by_driver.yaml")) as f:
+ cf = yaml.load(f.read())
+ db['lircd_by_driver'] = cf['lircd_by_driver'].copy()
+ db['lirmcd_by_driver'] = cf['lircmd_by_driver'].copy()
+
+ with open(os.path.join(configdir, "kernel-drivers.yaml")) as f:
+ cf = yaml.load(f.read())
+ db['kernel-drivers'] = cf['drivers'].copy()
+ db['drivers'] = cf['drivers'].copy()
+ with open(os.path.join(configdir, "drivers.yaml")) as f:
+ cf = yaml.load(f.read())
+ db['drivers'].update(cf['drivers'].copy())
+ for key, d in db['drivers'].items():
+ d['id'] = key
+
+ configs = {}
+ for path in glob.glob(configdir + '/*.conf'):
+ with open(path) as f:
+ cf = yaml.load(f.read())
+ configs[cf['config']['id']] = cf['config']
+ db['configs'] = configs
+ self.db = db
+
+ @property
+ def kernel_drivers(self):
+ ''' The kernel-drivers dictionary, drivers.yaml + kernel-drivers.yaml.
+ '''
+ return self.db['kernel-drivers']
+
+ @property
+ def drivers(self):
+ ''' The drivers dictionary, drivers.yaml + kernel-drivers.yaml. '''
+ return self.db['drivers']
+
+ @property
+ def configs(self):
+ ''' Return dict of parsed config/*.conf files, keyd by id. '''
+ return self.db['configs']
+
+ def remotes_by_driver(self, driver):
+ ''' Return the list of remotes suggested for a given driver. '''
+ if isinstance(driver, dict):
+ driver = driver['id']
+ try:
+ return self.db['lircd_by_driver'][driver]
+ except KeyError:
+ return []
+
+ def driver_by_remote(self, remote):
+ ''' Return the driver (possibly None) suggested for a remote. '''
+ for driver, files in self.db['lircd_by_driver'].items():
+ if remote in files:
+ return self.db['drivers'][driver]
+ return None
+
+ def find_config(self, key, value):
+ ''' Return item (a config) in configs where config[key] == value. '''
+ found = [c for c in self.db['configs'].values()
+ if key in c and c[key] == value]
+ if len(found) > 1:
+ print("find_config: not properly found %s, %s): " % (key, value)
+ + ', '.join([c['id'] for c in found]))
+ return None
+ elif not found:
+ print("find_config: Nothing found for %s, %s): " % (key, value))
+ return None
+ found = dict(found[0])
+ if 'device_hint' not in found:
+ found['device_hint'] = \
+ self.db['drivers'][found['driver']]['device_hint']
+ return found
+
+
+# vim: set expandtab ts=4 sw=4:
--
2.4.2

@ -0,0 +1,24 @@
From dffeb373e2116d3486169872116fd0b2dd39885a Mon Sep 17 00:00:00 2001
From: Alec Leamas <leamas.alec@gmail.com>
Date: Wed, 9 Sep 2015 14:24:30 +0200
Subject: [PATCH] lib: Fix missing --lirc flag.
---
lib/Makefile.am | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 9e14641..4f9435a 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -30,6 +30,7 @@ liblirc_la_SOURCES = config_file.c \
transmit.c \
util.c
+libirrecord_la_LDFLAGS = -llirc
libirrecord_la_SOURCES = irrecord.c
liblirc_client_la_LDFLAGS = -version-info 3:0:3
--
2.4.2

@ -10,9 +10,9 @@ Name: lirc
Version: 0.9.3
%global src_vers %(echo %{version} | sed 's/_/-/g' )
%if 0%{?released}
Release: 4%{?dist}
Release: 5%{?dist}
%else
Release: 0.6.pre3%{tag}
Release: 0.7.pre3%{tag}
%endif
Summary: The Linux Infrared Remote Control package
@ -31,7 +31,9 @@ Source6: README.fedora
Source7: 99-remote-control-lirc.rules
# Config only, cannot be upstreamed.
Patch1: 0001-Changing-effective-user-default.patch
Patch2: 0002-tools-Add-missing-file-lirc-setup-database.py.patch
# Already in upstream release branch.
Patch2: 0002-irrecord-Fix-crash-when-invoked-without-arguments.patch
Patch3: 0003-lib-Fix-missing-lirc-flag.patch
BuildRequires: alsa-lib-devel
Buildrequires: autoconf
@ -76,6 +78,7 @@ packages to get a smaller installation.
%package core
Summary: LIRC core, always needed to run LIRC
Requires: lirc-libs%{?_isa} = %{version}-%{release}
%description core
The LIRC core contains the lircd daemons, the devinput and
@ -101,7 +104,6 @@ the same as installing previous versions of the lirc package.
%package libs
Summary: LIRC libraries
Group: System Environment/Libraries
Requires: lirc-core%{?_isa} = %{version}-%{release}
%description libs
LIRC is a package that allows you to decode and send infra-red and
@ -125,7 +127,7 @@ LIRC configuration process.
%package devel
Summary: Development files for LIRC
Group: Development/Libraries
Requires: lirc-libs%{?_isa} = %{version}-%{release}
Requires: lirc-core%{?_isa} = %{version}-%{release}
%description devel
LIRC is a package that allows you to decode and send infra-red and
@ -219,6 +221,7 @@ full support for the ftdi device.
%endif
%patch1 -p1
%patch2 -p1
%patch3 -p1
sed -i -e 's|/usr/local/etc/|/etc/|' contrib/irman2lirc
@ -233,7 +236,7 @@ make %{?_smp_mflags}
make install DESTDIR=$RPM_BUILD_ROOT
cd $RPM_BUILD_ROOT%{_datadir}/lirc/contrib
chmod 755 irman2lirc devinput.sh
chmod 755 lirc.debian lirc.redhat lircs lirc.suse*
rm -f lirc.debian lirc.redhat lircs lirc.suse*
cd $OLDPWD
rm $RPM_BUILD_ROOT%{_libdir}/*.la
rm $RPM_BUILD_ROOT%{_libdir}/lirc/plugins/*.la
@ -247,30 +250,31 @@ install -Dpm 644 %{SOURCE7} \
cp -a %{SOURCE6} README.fedora
mkdir -p $RPM_BUILD_ROOT/%{_tmpfilesdir}
echo "d /var/run/lirc 0755 root root 10d" \
echo "d /var/run/lirc 0755 lirc lirc 10d" \
> $RPM_BUILD_ROOT%{_tmpfilesdir}/lirc.conf
%pre
%pre core
getent group lirc >/dev/null || groupadd -r lirc
getent passwd lirc >/dev/null || \
useradd -r -g lirc -d /var/log/lirc -s /sbin/nologin \
-c "LIRC daemon user, runs lircd." lirc
exit 0
%post
%post core
%systemd_post lircd.service lircmd.service
systemd-tmpfiles --create %{_tmpfilesdir}/lirc.conf
# Remove stale links after service name change lirc -> lircd:
find /etc/systemd -name lirc.service -xtype l -delete || :
%post libs -p /sbin/ldconfig
%preun
%preun core
%systemd_preun lircd.service lircmd.service
%postun
%postun core
%systemd_postun_with_restart lircd.service lircmd.service
%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig
@ -377,6 +381,13 @@ find /etc/systemd -name lirc.service -xtype l -delete || :
%{_udevrulesdir}/99-remote-control-lirc.rules
%changelog
* Wed Sep 09 2015 Alec Leamas <leamas.alec@gmail.com> - 0.9.3-5
- Move scriptles to lirc-core (#1261289).
- Adjust deps between lib, core, and devel (also #1261289).
- Make temporary files owned by lirc:lirc
- Add missing library flag causing rpmlint noise.
- Remove foreign distro stuff in contrib/.
* Mon Sep 07 2015 Alec Leamas <leamas.alec@gmail.com> - 0.9.3-4
- Fix missing file database.py (lirc-setup cannot start).

Loading…
Cancel
Save