From 1d2a6a15cc36c5e415b7c3893504bff8a23d9a7b Mon Sep 17 00:00:00 2001 From: JohanSaaw <81185596+JohanSaaw@users.noreply.github.com> Date: Wed, 7 Apr 2021 12:32:00 +0200 Subject: [PATCH] Some further amendments to the RPM spec file Added some extra tests to ensure that a symbolic link to /usr/lib/perl5/vendor_perl/Slim is really created even if previously a hard link or a copy of the source directory has been created in the target location. --- redhat/README.systemd | 29 ++++++++++------ redhat/squeezeboxserver.spec | 65 +++++++++++++++++++++++++----------- 2 files changed, 64 insertions(+), 30 deletions(-) diff --git a/redhat/README.systemd b/redhat/README.systemd index 49c531c9..db95c23c 100644 --- a/redhat/README.systemd +++ b/redhat/README.systemd @@ -8,12 +8,12 @@ start-up. Systemd is the future, whatever we might think about it. * More information -Please read the man pages +Please read the following man pages for in depth information on how +the systemd unit files work. systemd.unit systemd.service -for in depth information on how the systemd units work. * Stop/Start/Check status of squeezeboxserver @@ -40,7 +40,7 @@ The content of the file should be (without the dashed lines) ----------------------------------------------- -[Unit] +[Service] USER=add-the-user-id-you-want-to-use-here @@ -49,10 +49,11 @@ USER=add-the-user-id-you-want-to-use-here * Passing extra arguments to the squeezeboxserver The way the variable SQUEEZEBOX_ARGS is defined in /etc/sysconfig/squeezeboxserver -makes it unusable in the systemd unit. If you have added parameters to this -variable in the file and you want to keep them, then you must instead add them -to the new variable SQUEEZEBOX_ADDITIONAL_ARGS. You can do this just by adding -the following in the /etc/sysconfig/squeezeboxserver file (without the dashed line) +makes it unusable in the systemd unit file. If you have added parameters to +this variable in the file and you want to keep them, then you must instead add +them to the new variable SQUEEZEBOX_ADDITIONAL_ARGS. You can do this by adding +the following in the /etc/sysconfig/squeezeboxserver file (without the dashed +lines) ------------------------------------------------ @@ -63,7 +64,15 @@ SQUEEZEBOX_ADDITIONAL_ARGS="--checkstrings --nomysqueezebox" ***PLEASE NOTE*** You can't use nested variables like in the past for SQUEEZEBOX_ARGS. -An alternative is to create a drop-in file for systemd as described here above for the -USER. You can of course use the same drop-in file, just add an line like this +An alternative is to create a drop-in file for systemd as described here above +for the USER. You can of course use the same drop-in file, just add an +additional line like this -Environment="SQUEEZEBOX_ADDITIONAL_ARGS=--checkstring --nomysqueezebox" +Environment="SQUEEZEBOX_ADDITIONAL_ARGS=--checkstrings --nomysqueezebox" + +Please remember that the content of /etc/sysconfig/squeezeboxserver will +override the content of the drop-in files in +/etc/systemd/system/squeezeboxserver.service.d. This means that if you define +SQUEEZEBOX_ADDITIONAL_ARGS both in the drop-in file and in +/etc/sysconfig/squeezeboxserver, then it is the content of the latter that will +be used. diff --git a/redhat/squeezeboxserver.spec b/redhat/squeezeboxserver.spec index 264017f6..07c147b1 100644 --- a/redhat/squeezeboxserver.spec +++ b/redhat/squeezeboxserver.spec @@ -207,9 +207,9 @@ function setSelinux { if [ -x /usr/sbin/selinuxenabled ] ; then if /usr/sbin/selinuxenabled ; then [ -x /usr/sbin/semanage ] && /usr/sbin/semanage port -a -t mysqld_port_t -p tcp ${MYSQLPORT} > /dev/null 2>&1 - [ -x /usr/sbin/semanage ] && /usr/sbin/semanage fcontext -a -t mysqld_db_t "${CACHEDIR}(/.*)?" - [ -x /usr/sbin/semanage ] && /usr/sbin/semanage fcontext -a -t mysqld_var_run_t "${CACHEDIR}/squeezeboxserver-mysql.sock" - /sbin/restorecon -R ${CACHEDIR} + [ -x /usr/sbin/semanage ] && /usr/sbin/semanage fcontext -a -t mysqld_db_t "${CACHEDIR}(/.*)?" > /dev/null 2>&1 + [ -x /usr/sbin/semanage ] && /usr/sbin/semanage fcontext -a -t mysqld_var_run_t "${CACHEDIR}/squeezeboxserver-mysql.sock" > /dev/null 2>&1 + /sbin/restorecon -R ${CACHEDIR} > /dev/null 2>&1 fi fi } @@ -217,12 +217,12 @@ function setSelinux { function setSYSV { # This is a SYSV server. Copy SYSV script to the correct place. - cp -p %{_datadir}/squeezeboxserver/squeezeboxserver.SYSV %{_sysconfdir}/init.d/squeezeboxserver + cp -p %{_datadir}/squeezeboxserver/squeezeboxserver.SYSV %{_sysconfdir}/init.d/squeezeboxserver >/dev/null 2>&1 || : #SME Server uses runlevel 7 if [ -f /etc/e-smith-release -a -d /etc/rc7.d ] ; then - ln -sf %{_sysconfdir}/init.d/squeezeboxserver /etc/rc7.d/S80squeezeboxserver - db configuration set squeezeboxserver service status enabled + ln -sf %{_sysconfdir}/init.d/squeezeboxserver /etc/rc7.d/S80squeezeboxserver >/dev/null 2>&1 || : + db configuration set squeezeboxserver service status enabled >/dev/null 2>&1 || : fi /sbin/chkconfig --add squeezeboxserver >/dev/null 2>&1 || : /sbin/service squeezeboxserver restart >/dev/null 2>&1 || : @@ -268,18 +268,38 @@ if [ -f /etc/redhat-release -o -n "$(echo $ID_LIKE |/usr/bin/grep -i -E '(centos setSelinux - # 64 bit fedora/RedHat/CentOS want the Slim in /usr/lib64/perl5/vendor_perl - if [ ! -e /usr/lib64/perl5/vendor_perl/Slim ] ; then - ln -s %{_usr}/lib/perl5/vendor_perl/Slim %{_usr}/lib64/perl5/vendor_perl/Slim || : - fi + # 64 bit fedora/RedHat/CentOS want the Slim in + # /usr/lib64/perl5/vendor_perl so we will need to create a symbolic + # link in that location. + if [ -e %{_usr}/lib64/perl5/vendor_perl/Slim ] ; then + # The target location exists + if [ ! -h %{_usr}/lib64/perl5/vendor_perl/Slim ] ; then + # The target location exists, but it isn't a symlink + # Remove this hard link or copied location to avoid + # anomalies with new versions of squeezeboxserver + /usr/bin/mv %{_usr}/lib64/perl5/vendor_perl/Slim %{_usr}/lib64/perl5/vendor_perl/Slim.rpmsave >/dev/null 2>&1 || : + fi + fi + + # Force the creation of a symbolic link. + /usr/bin/ln -sfT %{_usr}/lib/perl5/vendor_perl/Slim %{_usr}/lib64/perl5/vendor_perl/Slim >/dev/null 2>&1 || : elif [ -f /etc/SuSE-release -o -n "$(echo $ID_LIKE | /usr/bin/grep -i suse)" ] ; then # Suse is expecting us in site_perl? - if [ ! -e /usr/lib/perl5/site_perl/Slim ] ; then - ln -s %{_usr}/lib/perl5/vendor_perl/Slim %{_usr}/lib/perl5/site_perl/Slim || : - fi + if [ -e %{_usr}/lib/perl5/site_perl/Slim ] ; then + # The target location exists + if [ ! -h %{_usr}/lib/perl5/site_perl/Slim ] ; then + # The target location exists, but it isn't a symlink + # Remove this hard link or copied location to avoid + # anomalies with new versions of squeezeboxserver + /usr/bin/mv %{_usr}/lib/perl5/site_perl/Slim %{_usr}/lib/perl5/site_perl/Slim.rpmsave >/dev/null 2>&1 || : + fi + fi + + # Force the creation of a symbolic link. + /usr/bin/ln -sfT %{_usr}/lib/perl5/vendor_perl/Slim %{_usr}/lib/perl5/site_perl/Slim >/dev/null 2>&1 || : fi @@ -299,7 +319,6 @@ fi echo "Point your web browser to http://$HOSTNAME:$PORT/ to configure Logitech Media Server." %preun -# Source /etc/os-release #set -x function unsetSelinux { @@ -323,10 +342,10 @@ function unsetSYSV { /sbin/service squeezeboxserver stop >/dev/null 2>&1 || : if [ -f /etc/e-smith-release -a -d /etc/rc7.d ] ; then #SME Server uses runlevel 7 - db configuration set squeezeboxserver service status disabled - rm /etc/rc7.d/S80squeezeboxserver + db configuration set squeezeboxserver service status disabled >/dev/null 2>&1 || : + rm /etc/rc7.d/S80squeezeboxserver || : fi - /sbin/chkconfig --del squeezeboxserver >/dev/null 2>&1 + /sbin/chkconfig --del squeezeboxserver >/dev/null 2>&1 || : # Remove the SYSV file we copied in the post script. rm -f /etc/init.d/squeezeboxserver || : @@ -337,10 +356,10 @@ function unsetSystemd { # systemd /usr/bin/systemctl unmask squeezeboxserver.service >/dev/null 2>&1 || : /usr/bin/systemctl disable squeezeboxserver.service >/dev/null 2>&1 || : - /usr/bin/systemctl stop squeezeboxserver.service || : + /usr/bin/systemctl stop squeezeboxserver.service >/dev/null 2>&1 || : # Remove the unit file we copied in the post script. rm -f /usr/lib/systemd/system/squeezeboxserver.service || : - /usr/bin/systemctl daemon-reload + /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : } @@ -433,7 +452,13 @@ fi %changelog -* Sun Mar 21 2021 Johan Saeaew +* Tue Apr 06 2021 Johan S. +- Amended post install script with better tests on the locations of the + symbolic links to /usr/lib/perl5/vendor_perl/Slim, to remove any hard links + or copies of the target in order to ensure that the latest version of the + perl libraries is used. +- Added some missing re-directs of STDOUT and STDERR to a couple of commands. +* Sun Mar 21 2021 Johan S. - Rewrite of the post install and preuninstall scripts. Taking care of whether to use SYSV or systemd unit files. The RPM drops those files in /usr/share/squeezeboxserver and the