-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpdev.spec.in
225 lines (209 loc) · 7.89 KB
/
mpdev.spec.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
%undefine _missing_build_ids_terminate_build
%global _unpackaged_files_terminate_build 1
%global debug_package %{nil}
%if %{defined _project}
# define if building on openSUSE build service
%global build_on_obs 1
%global reconfigure_mode 0
%else
%define _project local
%global build_on_obs 0
%global reconfigure_mode 0
%global _hardened_build 1
%endif
%global _prefix /usr
%global libexecdir @libexecdir@
%global sysconfdir @sysconfdir@
%global logdir /var/log/svc/mpdev
Name: mpdev
Version: @version@
Release: @release@%{?dist}
Summary: MPD Event Watcher
%if %build_on_obs == 1
License: GPL-3.0+
%else
License: GPLv3
%endif
URL: https://github.com/mbhangui/mpdev
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
BuildRequires: gcc gcc-c++ make autoconf automake libtool
%if %build_on_obs == 1
%if 0%{?suse_version}
BuildRequires: -post-build-checks
#!BuildIgnore: post-build-checks
%endif
%endif
BuildRequires: libqmail-devel libqmail
%if %{defined suse_version} || %{defined sles_version}
BuildRequires: libsqlite3-0 sqlite3-devel
%else
BuildRequires: sqlite-libs sqlite-devel
%endif
Requires: user(qmaill)
Requires: group(nofiles)
Requires: /usr/bin/mpd /usr/bin/mpc /usr/bin/sqlite3 daemontools coreutils
%description
mpdev is a daemon, written in C, that watches a Music Player Daemon events,
using mpd's idle command and execs user defined script on event changes.
* Uses mpd's idle mode.
* Calls user scripts in $HOME/.mpdev (player, playpause, output, mixer,
lcd_display)
* Sets special environment variables to pass data to the hooks.
* Optional support for scrobbling to last.fm, libre.fm through external scripts
* Included scripts:
- scrobbler
+ librefm-scrobbler
+ lastfm-scrobbler
- player
+ saves song data to a sqlite database
+ tracks play count of songs, artist, albums and genres.
+ helps chose songs based on listening habits using mpdplaylist
playlist generator
+ synchronizes stats and mpd's sticker db
- mixer
+ prints volume control value
- lcd_display
+ prints song information to a host running lcdDaemon for
display on a display with Hitachi HD44780 controller
%prep
%autosetup
%build
%configure --prefix=%{_prefix} --sysconfdir=/etc \
--libexecdir=%{libexecdir}
%{__make} -s %{?_smp_mflags}
(
echo "---------------- INFORMATION ------------------------"
echo target %_target
echo target_alias %_target_alias
echo target_cpu %_target_cpu
echo target_os %_target_os
echo target_vendor %_target_vendor
echo Project %{_project}
echo Building %{name}-%{version}-%{release} Build %{_build} OS %{_os}
echo "------------------------------------------------------"
) > %{name}-rpm.info
%install
%{__make} -s DESTDIR=%{buildroot} install-strip
%{__mkdir_p} %{buildroot}%{sysconfdir}/mpdev
install -m 0644 %{name}-rpm.info %{buildroot}%{sysconfdir}/mpdev/%{name}-rpm.info
%files
%dir %attr(755,root,root) %{libexecdir}/mpdev
%ghost %dir %attr(0755,qmaill,nofiles) %{logdir}
%ghost %attr(-,qmaill,nofiles) %{logdir}/*
%attr(755,root,root) %{_prefix}/bin/mpdev
%attr(755,root,root) %{_prefix}/bin/mpdplaylist
%attr(755,root,root) %{_prefix}/bin/karma
%attr(755,root,root) %{_prefix}/bin/songi
%attr(755,root,root) %{_prefix}/bin/mpdhist
%attr(755,root,root) %{_prefix}/bin/transfer_play
%attr(755,root,root) %{_prefix}/bin/lastfm-scrobbler
%attr(755,root,root) %{_prefix}/bin/librefm-scrobbler
%attr(755,root,root) %{libexecdir}/mpdev/mpdev_update
%attr(755,root,root) %{libexecdir}/mpdev/mpdev_cleanup
%attr(755,root,root) %{libexecdir}/mpdev/mpdev_rename
%attr(755,root,root) %{libexecdir}/mpdev/create_service
%attr(755,root,root) %{libexecdir}/mpdev/player
%attr(755,root,root) %{libexecdir}/mpdev/playpause
%attr(755,root,root) %{libexecdir}/mpdev/output
%attr(755,root,root) %{libexecdir}/mpdev/mixer
%attr(755,root,root) %{libexecdir}/mpdev/lcd_display
%attr(644,root,root) %{sysconfdir}/mpdev/mpd_local.te
%attr(644,root,root) %{sysconfdir}/mpdev/%{name}-release
%attr(644,root,root) %{sysconfdir}/mpdev/%{name}-rpm.info
%attr(644,root,root) %{_prefix}/share/man/man1/mpdev.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/songi.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/mpdev_update.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/mpdev_cleanup.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/mpdev_rename.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/mpdplaylist.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/karma.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/mpdhist.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/transfer_play.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/lastfm-scrobbler.1.gz
%attr(644,root,root) %{_prefix}/share/man/man1/librefm-scrobbler.1.gz
%license LICENSE
%docdir %{_prefix}/share/doc/%{name}
%if %build_on_obs == 0
%license %attr(644,root,root) %{_prefix}/share/doc/%{name}/LICENSE
%license %attr(644,root,root) %{_prefix}/share/doc/%{name}/moc-scrobbler-license
%else
%attr(644,root,root) %{_prefix}/share/doc/%{name}/LICENSE
%attr(644,root,root) %{_prefix}/share/doc/%{name}/moc-scrobbler-license
%endif
%attr(644,root,root) %{_prefix}/share/doc/%{name}/README.md
%attr(644,root,root) %{_prefix}/share/doc/%{name}/mpdev.changes
%pretrans
# stop mpdev services before upgrade
if [ -d /run ] ; then
rundir=/run/svscan
elif [ -d /var/run ] ; then
rundir=/var/run/svscan
else
rundir=/service
fi
%{_prefix}/bin/svstat /service/mpdev >/dev/null 2>&1
if [ $? -eq 0 ] ; then
%{__mkdir_p} ${rundir}/mpdev
%{_prefix}/bin/svc -d /service/mpdev
touch ${rundir}/mpdev/.down
fi
%post
argv1=$1
ID=$(id -u)
if [ $ID -ne 0 ] ; then
echo "You are not root" 1>&2
exit 1
fi
if [ -z "$argv1" ] ; then
argv1=0
fi
if [ ! -x %{_prefix}/sbin/minisvc ] ; then
echo "%{_prefix}/sbin/minisvc not found: Proceeding without creating mpdev service" 1>&2
exit 0
fi
# we are doing upgrade
if [ $argv1 -eq 2 ] ; then # upgrade
if [ -d /run ] ; then
rundir=/run/svscan
elif [ -d /var/run ] ; then
rundir=/var/run/svscan
else
rundir=/service
fi
# refresh mpdev services
if [ ! -f /service/mpdev/variables/.options ] ; then
%{__mkdir_p} /service/mpdev/variables
echo "/usr/libexec/mpdev/create_service --servicedir=/service --user=1000 --add-service" \
> /service/mpdev/variables/.options
fi
%{_prefix}/sbin/minisvc --servicedir=/service --refreshsvc="/service/mpdev" --silent
%{_prefix}/bin/svok /service/mpdev >/dev/null 2>&1
if [ $? -eq 0 -a -f ${rundir}/mpdev/.down ] ; then
%{__rm} -f ${rundir}/mpdev/.down
%{_prefix}/bin/svc -u /service/mpdev
fi
exit 0
fi
/usr/libexec/mpdev/create_service --servicedir=/service --user=1000 --add-service
%{_prefix}/sbin/minisvc --servicedir=/service --service-name=mpdev \
--export-variables=/service/mpdev/variables/.variables --force --silent
%preun
argv1=$1
ID=$(id -u)
if [ $ID -ne 0 ] ; then
echo "You are not root" 1>&2
exit 1
fi
if [ -z "$argv1" ] ; then
argv1=0
fi
# we are doing upgrade
if [ $argv1 -eq 1 ] ; then
exit 0
fi
echo "removing mpdev logs"
log_dir=%{logdir}
[ "$log_dir" != "/" ] && %{__rm} -fr $log_dir
echo "stopping and removing mpdev service"
/usr/libexec/mpdev/create_service --servicedir=/service --del-service
%changelog