File gnustep-base.spec of Package gnustep-base

#
# spec file for package gnustep-base
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           gnustep-base
Summary:        GNUstep Base library package
Version:        1.25.0
Release:        0
License:        LGPL-2.1+ and GPL-3.0+
Group:          System/GUI/Other
Url:            http://www.gnustep.org/
Source:         ftp://ftp.gnustep.org/pub/gnustep/core/%{name}-%{version}.tar.gz
Source1:        ftp://ftp.gnustep.org/pub/gnustep/core/%{name}-%{version}.tar.gz.sig
Source2:        %{name}-rpmlintrc
BuildRoot:      %{_tmppath}/%{name}-%{version}-build


#SUSE specfile docs say prereq is deprecated and it causes the build to fail on Fedora 
#However the RPM macros doc says it must be used if various other macros
#e.g. fillup_and_insserv are use. This change is a test for Fedora
%if 0%{?suse_version}
PreReq:         %insserv_prereq
#PreReq:         permissions
%endif

BuildRequires:  gcc-objc
BuildRequires:  gmp-devel
BuildRequires:  gnustep-make
BuildRequires:  gnutls
BuildRequires:  libffi-devel >= 3.0.9
BuildRequires:  libicu-devel
BuildRequires:  libxml2-devel >= 2.3.0
BuildRequires:  libxslt-devel
BuildRequires:  openssl-devel
BuildRequires:  pkgconfig
BuildRequires:  zlib-devel

#Handle different package names on fedora and suse
%if 0%{?suse_version}
BuildRequires: avahi-compat-mDNSResponder-devel
BuildRequires: libgnutls-devel
%endif
%if 0%{?fedora}
BuildRequires:  avahi-compat-libdns_sd
BuildRequires:  avahi-compat-libdns_sd-devel
BuildRequires:  gnutls-devel
BuildRequires:  texi2html
BuildRequires:  texinfo-tex
%endif

BuildRequires:  fdupes

%define         gnustep_sh       GNUstep.sh
%define         gs_config        %{_sysconfdir}/GNUstep/GNUstep.conf
%define         init_dir         %{_sysconfdir}/init.d
%define         gs_sysinit       %{init_dir}/gdomap
%define         gs_daemon        gdomap
%define         profile_dir      %{_sysconfdir}/profile.d
%define         gs_userstart     GNUstep-start.sh
%define         gs_makefiles     %{_datadir}/GNUstep/Makefiles
%define         gs_library       %{_libdir}/GNUstep

%description
The GNUstep Base Library is a powerful fast library of general-
purpose, non-graphical Objective C classes, inspired by the superb
OpenStep API but implementing Apple and GNU additions to the API
as well.  It includes, for example, classes for unicode strings,
arrays, dictionaries, sets, byte streams, typed coders, invocations,
notifications, notification dispatchers, scanners, tasks, files,
networking, threading, remote object messaging support (distributed
objects), event loops, loadable bundles, attributed unicode strings,
xml, mime, user defaults. This package includes development headers
too. It was configured for the FHS file system layout, customised
for SUSE.

%package devel
Summary:        Devel package for GNUstep Base Library
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description devel
This package contains include files for developing applications
using the GNUstep Base Library.

%prep
%setup -q
find . -type f -name "*.swp" -delete

%build
# Source GNUstep environment variables. This is done unconditionally
# to ensure that the values appropriate to this build get defined,
# irrespective of what happened to be in force for the build system.
. %{gs_config}
GNUSTEP_SH_EXPORT_ALL_VARIABLES="yes"
. ${GNUSTEP_MAKEFILES}/%{gnustep_sh}

# Configure and make.
%configure \
   --libdir=%{_libdir} --enable-ffi \
%ifarch aarch64 armv6hl
   --enable-fake-main \
%endif
%if 0%{?suse_version} == 1110
   --disable-icu \
%endif
   --with-installation-domain=SYSTEM
make %{?_smp_mflags}


%install
# Source GNUstep environment variables. This is done unconditionally
# to ensure that the values appropriate to this build get defined,
# irrespective of what happened to be in force for the build system.
. %{gs_config}
GNUSTEP_SH_EXPORT_ALL_VARIABLES="yes"
. ${GNUSTEP_MAKEFILES}/%{gnustep_sh}

# Install into RPM "build root" directory.
make -e DESTDIR=%{buildroot} \
  GNUSTEP_INSTALLATION_DOMAIN=SYSTEM \
  install

# Rename pl to pllist to fix naming conflict
mv %{buildroot}%{_bindir}/pl %{buildroot}%{_bindir}/pllist

%if 0%{?fedora}
rm -f Examples/.cvsignore
rm -f Examples/.gdbinit

# We need a modified GNUstep.conf, because the DTDs are install not
# on their real destination

sed -e "s|GNUSTEP_SYSTEM_LIBRARY=|GNUSTEP_SYSTEM_LIBRARY=%{buildroot}|" \
    -e "s|GNUSTEP_SYSTEM_HEADERS=|GNUSTEP_SYSTEM_HEADERS=%{buildroot}|" \
    %{_sysconfdir}/GNUstep/GNUstep.conf >GNUstep.conf

export LD_LIBRARY_PATH=%{buildroot}%{_libdir}
export GNUSTEP_CONFIG_FILE=$(pwd)/GNUstep.conf

%else


# Create startup/shutdown script for gdomap service.
# Note this version of the code is designed to fit in
# with SuSE linux's version of sys V init.

install -d %{buildroot}%{init_dir}
cat > %{buildroot}%{gs_sysinit} << "EOF"
#!/bin/sh
#
# GNUstep daemons
#
### BEGIN INIT INFO
# Provides:          %{gs_daemon}
# Required-Start:    $syslog $local_fs $remote_fs
# Should-Start:
# Required-Stop:     $syslog $local_fs $remote_fs
# Should-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: %{gs_daemon} service
# Description:       Start up the %{gs_daemon} service
#       used by GNUstep applications.
### END INIT INFO

. %{_sysconfdir}/rc.status
. %{gs_config}

case "${1}" in
    start)
        echo -n "Starting %{gs_daemon}: "
        startproc ${GNUSTEP_SYSTEM_TOOLS}/%{gs_daemon}
        echo

	# Remember status and be verbose
	rc_status -v
        ;;

    stop)
        echo -n "Stopping %{gs_daemon}: "
        killproc ${GNUSTEP_SYSTEM_TOOLS}/%{gs_daemon}
        echo

	# Remember status and be verbose
	rc_status -v
        ;;

    restart|reload)
        ${0} stop
        ${0} start

	# Remember status and be quiet
	rc_status
        ;;

    status)
	echo -n "Checking for service %{gs_daemon} "
        checkproc ${GNUSTEP_SYSTEM_TOOLS}/%{gs_daemon}
	rc_status -v
	;;

    *)
        echo "Usage: %{gs_sysinit} {start|stop|status|restart|reload}"
        exit 1
esac
rc_exit
EOF
chmod 755 %{buildroot}%{gs_sysinit}
install -d %{buildroot}%{_sbindir}
ln -sf ../../%{gs_sysinit} %{buildroot}%{_sbindir}/rc%{gs_daemon}

# Create scripts to source GNUstep environment variables,
# start up user GNUstep services gdnc & gpbs, and update cache
# of services and applications, on user login.
mkdir -p %{buildroot}%{profile_dir}
cat > %{buildroot}%{profile_dir}/%{gs_userstart} << "EOF"
#!/bin/sh
. %{gs_config}

function runtool {
local toolpath=${GNUSTEP_SYSTEM_TOOLS}/${1}

# Check whether the tool exists
if [ -x ${toolpath} ]
then
    # Check whether the tool is already running for this user
    if ! ps -U $(id -u) -o cmd --no-headers | grep -q "^${toolpath}\>"
    then
        ${toolpath}
    fi
fi
unset toolpath
}

if [ -d ${HOME}/${GNUSTEP_USER_DIR} ]
then

    # Start up the GNUstep Distributed Notification Center daemon
    runtool gdnc

    # Start up the GNUstep PasteBoard Server daemon, if we're running X
    [ ${DISPLAY} ] && runtool gpbs

    # Start up the GNUstep Sound daemon if we have portaudio sound
    if portaudiolib=$(/sbin/ldconfig -p | grep '^[[:space:]]*libportaudio.so[[:space:]]') \
       && [ -e $(echo ${portaudiolib} | sed 's/^.*=>[[:space:]]*\([^[:space:]]*\)$/\1/') ]
    then
        runtool gnustep_sndd
    fi
    unset portaudiolib


    # Run 'make_services' in background if possible. We run it in a subshell;
    # otherwise, shells with job control (like bash) output an annoying
    # message when make_services is done, while we want it to happen silently.

    [ -x "${GNUSTEP_SYSTEM_TOOLS}/make_services" ] \
      && ("${GNUSTEP_SYSTEM_TOOLS}/make_services" &)

fi
EOF
chmod 755 %{buildroot}%{profile_dir}/%{gs_userstart}
%endif

# save discspace: symlink duplicates
%fdupes -s %{buildroot}

# Comment out checks because they break building on some systems. The NSOperation test seems to loop infinite.
#%check
#make check

%post
#if 0%{?suse_version} > 1140
#set_permissions %{_bindir}/%{gs_daemon}
#endif
if [ "${1}" = "1" ]; then
    # Path to GNUstep libraries was added to ld.so.conf in gnustep-make.
    # Run ldconfig to add gnustep-base libraries to the library cache.
    /sbin/ldconfig

    # Add lines for %{gs_daemon} into /etc/services, if not already there
    grep -q '^%{gs_daemon}' %{_sysconfdir}/services \
        || (echo -e "%{gs_daemon}\t\t538/tcp\t\t\t\t# GNUstep distributed objects" >> %{_sysconfdir}/services  \
        && echo -e "%{gs_daemon}\t\t538/udp\t\t\t\t# GNUstep distributed objects" >> %{_sysconfdir}/services)

    # Add the %{gs_daemon} service. Note this is not started
    # automatically - the user will need to start it using YaST2.
%if %{defined suse_version}
    %{fillup_and_insserv -fy %{gs_daemon}}
%else
    #Fedora only
    /sbin/chkconfig --add %{gs_daemon}
    #Apparently we can do all dist with this - just not yet
    #%service_add %{gs_daemon}
%endif
fi

#if 0%{?suse_version} > 1100
#verifyscript
#verify_permissions -e %{_bindir}/%{gs_daemon}
#endif

%preun
if [ "${1}" = "0" ]; then
    # Stop the gdomap service
%if 0%{?suse_version}
    %stop_on_removal %{gs_daemon}
%else
    #Fedora only
    if [ “$1” = 0 ] ; then service %{gs_daemon} stop >/dev/null 2>&1
    fi
    /sbin/chkconfig --del %{gs_daemon}
    #For the future
    #%service_del_preun %{gs_daemon}
%endif

    # Remove lines for gdomap from /etc/services
    mv -f %{_sysconfdir}/services %{_sysconfdir}/services.orig
    grep -v "^%{gs_daemon}[[:space:]]*538" %{_sysconfdir}/services.orig > %{_sysconfdir}/services
    rm -f %{_sysconfdir}/services.orig
fi

%postun
/sbin/ldconfig
%if 0%{?suse_version}
    %restart_on_update %{gs_daemon}
    %insserv_cleanup
%else
    if [ “$1” -ge 1 ] ; then
    fi
    service %{gs_daemon} condrestart >/dev/null 2>&1
   #For the future
   #%service_del_postun %{gs_daemon}
%endif

%files
%defattr(-,root,root)
%doc ANNOUNCE ChangeLog COPYING COPYING.LIB NEWS README
%{_bindir}/HTMLLinker
%{_bindir}/autogsdoc
%{_bindir}/cvtenc
%{_bindir}/defaults
%{_bindir}/gdnc
%{_bindir}/gspath
%{_bindir}/make_strings
%{_bindir}/pl2link
%{_bindir}/pldes
%{_bindir}/plget
%{_bindir}/pllist
%{_bindir}/plmerge
%{_bindir}/plparse
%{_bindir}/plser
%{_bindir}/sfparse
%{_bindir}/xmlparse
%{gs_library}
%{gs_makefiles}
%{_libdir}/libgnustep-base.so.*
%{_mandir}/man1/HTMLLinker.1%{ext_man}
%{_mandir}/man1/autogsdoc.1%{ext_man}
%{_mandir}/man1/cvtenc.1%{ext_man}
%{_mandir}/man1/defaults.1%{ext_man}
%{_mandir}/man1/gdnc.1%{ext_man}
%{_mandir}/man1/gspath.1%{ext_man}
%{_mandir}/man1/make_strings.1%{ext_man}
%{_mandir}/man1/pldes.1%{ext_man}
%{_mandir}/man1/sfparse.1%{ext_man}
%{_mandir}/man1/xmlparse.1%{ext_man}
%{_mandir}/man8/gdomap.8%{ext_man}
#verify(not mode) %attr(6755,root,root) %{_bindir}/%{gs_daemon}
%{_bindir}/%{gs_daemon}
%if 0%{?suse_version}
%config(noreplace) %{profile_dir}/%{gs_userstart}
%config %{gs_sysinit}
%{_sbindir}/rc%{gs_daemon}
%endif

%files devel
%defattr (-, root, root)
%{_includedir}/*
%{_libdir}/libgnustep-base.so

openSUSE Build Service is sponsored by