File gnustep-base.spec of Package gnustep-base

#
# spec file for package gnustep-base
#
# Copyright (c) 2011 SUSE LINUX Products 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/
#


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

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

%if 0%{?suse_version}
PreReq:         %insserv_prereq
#reReq:         permissions
BuildRequires:  gcc-objc
BuildRequires:  gmp-devel
BuildRequires:  gnustep-make
BuildRequires:  gnutls
BuildRequires:  gnutls-devel
BuildRequires:  libffi-devel >= 3.0.9
BuildRequires:  libicu-devel
BuildRequires:  libxml2-devel >= 2.3.0
BuildRequires:  libxslt-devel
BuildRequires:  mDNSResponder-devel
BuildRequires:  openssl-devel
BuildRequires:  pkgconfig
BuildRequires:  zlib-devel
%endif

%if 0%{?suse_version} > 1030 || 0%{?fedora_version} > 8
BuildRequires:  fdupes
%endif

%if 0%{?fedora}
BuildRequires:  avahi-compat-libdns_sd-devel
BuildRequires:  gmp-devel
BuildRequires:  gnutls-devel
BuildRequires:  pkgconfig
BuildRequires:  texi2html
BuildRequires:  texinfo-tex
%endif
#
Requires:       gnustep-make
Requires:       gnutls

%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" -exec rm {} \;

%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.
CPPFLAGS="-Wno-unused" \
%if 0%{?rhel_version}
%ifarch x86_64
%configure --disable-ffcall \
  --with-ffi-include=/usr/lib64/libffi-3.0.6/include \
  --with-installation-domain=SYSTEM
%else
ffi_include=$(pkg-config --cflags-only-I libffi | sed -e 's/^\-\I//')
%configure --disable-ffcall \
  --with-ffi-include=$ffi_include \
  --with-installation-domain=SYSTEM
%endif
%endif
%if 0%{?fedora}
ffi_include=$(pkg-config --cflags-only-I libffi | sed -e 's/^\-\I//')
%configure --disable-ffcall \
  --with-ffi-include=$ffi_include \
  --with-installation-domain=SYSTEM
%endif
%if 0%{?suse_version}
%configure \
  --enable-ffi
%endif
make %{?_smp_mflags}


%install
%if 0%{?fedora} || 0%{?rhel_version}

make DESTDIR=%{buildroot} \
  GNUSTEP_INSTALLATION_DOMAIN=SYSTEM \
  install

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

rm -f Examples/.cvsignore
rm -f Examples/.gdbinit

# We need a modified GNUstep.conf, because the DTDs are install not
# on there 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

# 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

# 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

. /etc/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}
# save discspace: symlink duplicates
%if 0%{?suse_version} > 1030 || 0%{?fedora_version} > 8
%fdupes -s %{buildroot}
%endif
%endif

%preun
%if 0%{?suse_version}
if [ "${1}" = "0" ]; then
    # Stop the gdomap service
    %stop_on_removal %{gs_daemon}

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

%post
#if 0%{?suse_version} > 1140
#set_permissions %{_bindir}/%{gs_daemon}
#endif
%if 0%{?fedora} || 0%{?rhel_version}
/sbin/ldconfig
%else
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}' /etc/services \
        || (echo -e "%{gs_daemon}\t\t538/tcp\t\t\t\t# GNUstep distributed objects" >> /etc/services  \
        && echo -e "%{gs_daemon}\t\t538/udp\t\t\t\t# GNUstep distributed objects" >> /etc/services)

    # Add the %{gs_daemon} service. Note this is not started
    # automatically - the user will need to start it using YaST2.
    %{fillup_and_insserv -fy %{gs_daemon}}
fi
%endif

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

%postun
/sbin/ldconfig
%if 0%{?suse_version}
%restart_on_update %{gs_daemon}
%insserv_cleanup
%endif

%clean
rm -rf %{buildroot}

%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}/pl*
%{_bindir}/sfparse
%{_bindir}/xmlparse
%{gs_library}
%{gs_makefiles}
%{_libdir}/libgnustep-base.so.*
%{_mandir}/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