## rivendell.spec.in
##
##    The Rivendell Radio Automation System
##    Copyright (C) 2002-2014  Fred Gleason <fredg@paravelsystems.com>
##
##    This program is free software; you can redistribute it and/or modify
##    it under the terms of version 2 of the GNU General Public License as
##    published by the Free Software Foundation;
##
##    This program is distributed in the hope that it will be useful,
##    but WITHOUT ANY WARRANTY; without even the implied warranty of
##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##    GNU General Public License for more details.
##
##    You should have received a copy of the GNU General Public License
##    along with this program; if not, write to the Free Software
##    Foundation, Inc., 59 Temple Place, Suite 330, 
##    Boston, MA  02111-1307  USA
##

Summary: Radio Broadcast Automation System
Name: rivendell
Version: @VERSION@
Release: @RPM_RELEASE@
License: GPL
Packager: Fred Gleason <fredg@paravelsystems.com>
Group: Productivity/Multimedia/Other
Source: rivendell-@VERSION@.tar.gz
Requires: @QT3_MYSQL_PKG@ @APACHE_PKG@ @QT3_DEVEL_PKG@ curl @USERMODE_PKG@ rivendell-base
BuildRoot: /var/tmp/rivendell-@VERSION@

%package base
Summary: The base components for the Rivendell Radio Automation System
Group: Productivity/Multimedia/Other
Requires: @QT3_MYSQL_PKG@

%package importers
Summary: Library importers for the Rivendell Broadcast Automation System
Group: Productivity/Multimedia/Other
Requires: rivendell madplay


%package devel
Summary: Header files and example code for developing Rivendell Loadable Modules
Group: Productivity/Multimedia/Other

%package select
Summary: The RDSelect system selector tool for Rivendell.
Group: Productivity/Multimedia/Other
Requires: rivendell


%description
Rivendell is a complete radio broadcast automation solution, with
facilities for the acquisition, management, scheduling and playout of
audio content.  Modules for the production and management of podcast
audio are also included.


%description base
This package contains the common base components for the Rivendell
Radio Broadcast Automation system, including the applications libraries
and Core Audio Engine (CAE) daemon.


%description importers
This package contains various importer scripts, which can be used to
import audio from existing legacy automation systems into Rivendell.
Currently, scripts exist for the AirForce Wings, Prophet NexGen and Sierra
Automated Systems SASAuto systems, as well as from another Rivendell system
(useful for 'merging' multiple databases).  Additionally, scripts for
initializing switcher matrices for the Christian Radio Consortium
(CRC) Unity4000 network and copying RDCatch event lists between hosts
are included.


%description devel
This package contains header files and example code for developing Rivendell 
Loadable Modules (RLMs), which can be used to generate custom Now & Next data
outputs for a wide variety of external devices.


%description select
This package contains the RDMonitor/RDSelect tool for Rivendell, which can
be used to select which amoung multiple Rivendell instances a host should be
associated with.

%prep


%setup


%build
%configure --libexecdir=@libexecdir@ --sysconfdir=@sysconfdir@
make


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
mkdir $RPM_BUILD_ROOT/.qt
touch $RPM_BUILD_ROOT/.qt/qt
rm -f $RPM_BUILD_ROOT/lib/security/pam_rd.la
rm -f $RPM_BUILD_ROOT/lib64/security/pam_rd.la
if test "@WIN32_SOURCE@" ; then
  mkdir -p $RPM_BUILD_ROOT/var/win32
  cp @WIN32_SOURCE@ $RPM_BUILD_ROOT/var/win32/
fi


%post
ldconfig
if test "@DISTRO@" = "suse" ; then
  PACKAGE_DOC_DIR=%_docdir/%{name}
fi
if test "@DISTRO@" = "redhat" ; then
  PACKAGE_DOC_DIR=%_docdir/%{name}-@VERSION@
fi
/usr/sbin/groupadd -r -g 150 %{name} &>/dev/null || :
/usr/sbin/useradd -o -u 150 -g %{name} -s /bin/false -r -c "Rivendell radio automation system" -d /var/snd %{name} &>/dev/null || :
if test ! -e /var/snd ; then
  mkdir -p /var/snd
  chown rivendell:rivendell /var/snd
  chmod 775 /var/snd
fi
mkdir -p -m 777 /var/run/rivendell
if test ! -d /etc/rivendell.d ; then
  mkdir -p /etc/rivendell.d
  chmod 775 /etc/rivendell.d
fi
if test ! -e /etc/rd.conf ; then
  cp $PACKAGE_DOC_DIR/rd.conf-sample /etc/rivendell.d/rd-default.conf
  ln -s /etc/rivendell.d/rd-default.conf /etc/rd.conf
fi
if test ! -h /etc/rd.conf ; then
  mv /etc/rd.conf /etc/rivendell.d/rd-default.conf
  ln -s /etc/rivendell.d/rd-default.conf /etc/rd.conf
fi
if test ! -e /etc/asound.conf ; then
  cp $PACKAGE_DOC_DIR/asound.conf-sample /etc/asound.conf
fi
if test -f /etc/init.d/mysql ; then
  /etc/init.d/mysql start
  MYSQL_INIT="/etc/init.d/mysql"
fi
if test -f /etc/init.d/mysqld ; then
  /etc/init.d/mysqld start
  MYSQL_INIT="/etc/init.d/mysqld"
fi
if test -f /usr/lib/systemd/system/mariadb.service ; then
  systemctl start mariadb.service
  MYSQL_INIT="systemctl start mariadb.service"
fi
@LOCAL_PREFIX@/bin/rdadmin --check-db --mysql-admin-user=root --mysql-admin-password
/etc/init.d/rivendell restart
if test "@DISTRO@" = "suse" ; then
  /etc/init.d/apache2 restart
  insserv -d -f /etc/init.d/apache2 /etc/init.d/rivendell $MYSQL_INIT
fi
if test "@DISTRO@" = "redhat" ; then
  if test -f /etc/init.d/httpd ; then
    service httpd restart
    chkconfig httpd on
  fi
  if test -f /usr/lib/systemd/system/httpd.service ; then
    systemctl restart httpd.service
    systemctl enable httpd.service
  fi
  chkconfig --add rivendell
  chkconfig --levels 35 rivendell on
  if test -n "$MYSQL_INIT" ; then
    if test -f /etc/init.d/mysqld ; then
      chkconfig mysqld on
    fi
    if test -f /usr/lib/systemd/system/mariadb.service ; then
      systemctl enable mariadb.service
    fi
  fi
fi
if [ -x %{_bindir}/gtk-update-icon-cache ] ; then
  %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
fi
exit 0


%preun
if test "$1" = "0" ; then
  /etc/init.d/rivendell stop
  if test "@DISTRO@" = "suse" ; then
    insserv -r -d -f /etc/init.d/rivendell
  fi
  if test "@DISTRO@" = "redhat" ; then
    chkconfig --levels 35 rivendell off
    chkconfig --del rivendell
  fi
fi
exit 0


%postun
if [ -x %{_bindir}/gtk-update-icon-cache ] ; then
  %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
fi


%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
@LOCAL_PREFIX@/@RD_LIB_PATH@/rivendell/*.rlm
@LOCAL_PREFIX@/bin/rdadmin
@LOCAL_PREFIX@/bin/rdairplay
@LOCAL_PREFIX@/bin/rdpanel
@LOCAL_PREFIX@/bin/rdcartslots
@LOCAL_PREFIX@/bin/rdcatch
%attr(4755,root,root)@LOCAL_PREFIX@/bin/rdcatchd
%attr(4755,root,root)@LOCAL_PREFIX@/bin/rdrepld
@LOCAL_PREFIX@/bin/rdgen
@LOCAL_PREFIX@/bin/rdlibrary
@LOCAL_PREFIX@/bin/rdlogedit
@LOCAL_PREFIX@/bin/rdlogmanager
@LOCAL_PREFIX@/bin/rdcastmanager
@LOCAL_PREFIX@/bin/rdlogin
@LOCAL_PREFIX@/bin/rmlsend
@LOCAL_PREFIX@/bin/rdsoftkeys
@LOCAL_PREFIX@/bin/rdpopup
@LOCAL_PREFIX@/bin/rdalsaconfig
@CONSOLEHELPER_RDALSACONFIG@
@LOCAL_PREFIX@/bin/rdgpimon
@LOCAL_PREFIX@/bin/rddelete
@LOCAL_PREFIX@/bin/rdimport
@LOCAL_PREFIX@/bin/rdpurgecasts
@LOCAL_PREFIX@/bin/rdmaint
@LOCAL_PREFIX@/bin/rdcollect
@LOCAL_PREFIX@/bin/rdcheckcuts
@LOCAL_PREFIX@/bin/rd_audio_sync
@LOCAL_PREFIX@/bin/rd_config
@LOCAL_PREFIX@/bin/sage_endec_rwt.sh
@LOCAL_PREFIX@/bin/rd_backup
@LOCAL_PREFIX@/bin/rdchunk
@LOCAL_PREFIX@/bin/rdmemcheck.sh
%attr(4755,root,root)@LOCAL_PREFIX@/bin/ripcd
@LOCAL_PREFIX@/sbin/sas_shim
@LOCAL_PREFIX@/sbin/rddbcheck
@LOCAL_PREFIX@/sbin/rdmarkerset
@LOCAL_PREFIX@/share/rivendell/*
/etc/init.d/rdrepld
@LOCAL_PREFIX@/share/icons/hicolor/16x16/apps/rivendell.png
@LOCAL_PREFIX@/share/icons/hicolor/22x22/apps/rivendell.png
@LOCAL_PREFIX@/share/icons/hicolor/32x32/apps/rivendell.png
@LOCAL_PREFIX@/share/icons/hicolor/48x48/apps/rivendell.png
@LOCAL_PREFIX@/share/icons/hicolor/64x64/apps/rivendell.png
@LOCAL_PREFIX@/share/icons/hicolor/128x128/apps/rivendell.png
@LOCAL_PREFIX@/share/X11/fvwm2/pixmaps/mini.rivendell.xpm
@LOCAL_PREFIX@/share/X11/fvwm2/pixmaps/rivendell.xpm
@LOCAL_PREFIX@/share/applications/rivendell-rdadmin.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdlogin.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdairplay.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdmonitor.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdpanel.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdcartslots.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdcatch.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdgpimon.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdalsaconfig-root.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdlibrary.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdlogedit.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdlogmanager.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdcastmanager.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rmlsend.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rdsoftkeys.desktop
@LOCAL_PREFIX@/share/desktop-directories/rivendell-configuration.directory
@LOCAL_PREFIX@/share/desktop-directories/rivendell-logtools.directory
@LOCAL_PREFIX@/share/desktop-directories/rivendell-rivendell.directory
@LOCAL_PREFIX@/share/desktop-directories/rivendell-utilities.directory
/etc/xdg/menus/applications-merged/rivendell-rivendell.menu
/@RD_LIB_PATH@/security/pam_rd.so
/.qt/qt
@libexecdir@/*
%attr(6755,root,root) @libexecdir@/rdxport.cgi
@sysconfdir@/rd-bin.conf
@WIN32_PATH@
/etc/pam.d/rdalsaconfig-root
/etc/security/console.apps/rdalsaconfig-root
%{_mandir}/man1/rdimport.1.gz
%{_mandir}/man8/rdmarkerset.8.gz
%doc AUTHORS
%doc ChangeLog
%doc COPYING 
%doc INSTALL 
%doc NEWS 
%doc README 
%doc UPGRADING
%doc CODINGSTYLE
%doc conf/rd.conf-sample
%doc conf/my.cnf-master
%doc conf/my.cnf-standby
%doc docs/cae.sxw 
%doc docs/catchd.txt 
%doc docs/colors 
%doc docs/GPIO.txt 
%doc docs/ripc.txt 
%doc docs/SWITCHERS.txt
%doc docs/JACK.txt
%doc docs/ENCODERS.txt
%doc docs/pam_rd.txt
%doc docs/rml.sxw
%doc docs/MESSAGE_BOX.txt
%doc docs/tables/audio_perms.txt 
%doc docs/tables/audio_ports.txt 
%doc docs/tables/cart.txt 
%doc docs/tables/cartslots.txt 
%doc docs/tables/clipboard.txt 
%doc docs/tables/cuts.txt 
%doc docs/tables/decks.txt 
%doc docs/tables/groups.txt 
%doc docs/tables/isci_xreference.txt
%doc docs/tables/log_format.txt 
%doc docs/tables/logs.txt 
%doc docs/tables/panels.txt 
%doc docs/tables/rd_airplay.txt 
%doc docs/tables/rd_library.txt 
%doc docs/tables/rd_logedit.txt 
%doc docs/tables/recordings.txt 
%doc docs/tables/services.txt 
%doc docs/tables/sources.txt 
%doc docs/tables/svc_rec_format.txt
%doc docs/tables/stations.txt 
%doc docs/tables/triggers.txt 
%doc docs/tables/ttys.txt 
%doc docs/tables/users.txt 
%doc docs/tables/version.txt 
%doc docs/asound.conf-sample
%doc docs/web_api.odt
%doc conf/rlm_serial.conf
%doc conf/rlm_udp.conf
%doc conf/rlm_twitter.conf
%doc conf/rlm_facebook.conf
%doc conf/rlm_xmpad.conf
%doc conf/rlm_ando.conf
%doc conf/rlm_liqcomp.conf
%doc conf/rlm_padpoint.conf
%doc conf/rlm_inno713.conf
%doc conf/rlm_xds.conf
%doc conf/rlm_icecast2.conf
%doc conf/rlm_shoutcast1.conf
%doc conf/rlm_spottrap.conf
%doc conf/rlm_filewrite.conf
%doc conf/rlm_spinitron_plus.conf
%doc docs/implemented_macros.txt
%doc utils/sas_shim/rc.sas_shim
%doc docs/datetime_wildcards.txt
%doc docs/reports.txt
%doc docs/NOW+NEXT.txt
%doc docs/WIN32.txt
%doc docs/ALSA.txt
%doc docs/RDMONITOR.txt
%doc docs/scheduler_formats.ods
%doc docs/copy_split_format.odt
%doc docs/ando_interface.odt
%doc docs/metadata_wildcards.txt
%doc scripts/rd_backup
%doc scripts/start_traverso.sh
%doc icons/rivendell-16x16.png
%doc icons/rivendell-22x22.png
%doc icons/rivendell-32x32.png
%doc icons/rivendell-48x48.png
%doc icons/rivendell-64x64.png
%doc icons/rivendell-128x128.png
%doc scripts/rd_mysql_enable_host.sh
%doc scripts/rd_backup_system.sh
%doc scripts/rd_restore_system.sh


%files base
%defattr(-,root,root)
@LOCAL_PREFIX@/@RD_LIB_PATH@/librd-@VERSION@.so
@LOCAL_PREFIX@/@RD_LIB_PATH@/librd.a
@LOCAL_PREFIX@/@RD_LIB_PATH@/librd.la
@LOCAL_PREFIX@/@RD_LIB_PATH@/librd.so
%attr(4755,root,root) @LOCAL_PREFIX@/bin/caed
/etc/init.d/rivendell
%config /etc/sysconfig/rivendell
@HPI_FILE1@
@HPI_FILE2@
@HPI_FILE3@
@HPI_FILE4@
@HPI_FILE5@
@HPI_FILE6@
@HPI_FILE7@
@HPI_FILE8@
@HPI_FILE9@
@HPI_FILE10@
@HPI_FILE11@
@HPI_FILE12@
@HPI_FILE13@
@HPI_FILE14@
@HPI_FILE15@


%files importers
@LOCAL_PREFIX@/bin/wings_filter
@LOCAL_PREFIX@/bin/rivendell_filter
@LOCAL_PREFIX@/bin/nexgen_filter
@LOCAL_PREFIX@/bin/sas_filter
@LOCAL_PREFIX@/bin/crc-unity4k.sh
@LOCAL_PREFIX@/bin/rdcatch_copy
@LOCAL_PREFIX@/bin/panel_copy
@LOCAL_PREFIX@/bin/rddgimport
@LOCAL_PREFIX@/bin/rddiscimport
@LOCAL_PREFIX@/share/applications/rivendell-rddgimport.desktop
@LOCAL_PREFIX@/share/applications/rivendell-rddiscimport.desktop
%doc docs/WINGS_FILTER.txt
%doc docs/RIVENDELL_FILTER.txt
%doc docs/NEXGEN_FILTER.txt


%files devel
@LOCAL_PREFIX@/include/rlm/*
@LOCAL_PREFIX@/src/rlm/*


%files select
%attr(4755,root,root) @LOCAL_PREFIX@/bin/rdselect
@LOCAL_PREFIX@/bin/rdmonitor
/etc/X11/xinit/xinitrc.d/start-rdmonitor.sh


%changelog
* @RPM_DATESTAMP@ Fred Gleason <fredg@paravelsystems.com> - @VERSION@-@RPM_RELEASE@
-- Autogenerated from build tree.
