File scpm.spec of Package scpm

#
# spec file for package scpm
#
# Copyright (c) 2012 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/
#


Name:           scpm
BuildRequires:  doxygen
BuildRequires:  gcc-c++
BuildRequires:  graphviz
BuildRequires:  graphviz-gnome
BuildRequires:  libjpeg-devel
BuildRequires:  libpng-devel
BuildRequires:  mhash-devel
BuildRequires:  xz
%if 0%{suse_version} > 1220
BuildRequires:  makeinfo
%endif
Summary:        System Configuration Profile Management
License:        GPL-2.0+
Group:          System/Base
Version:        1.1.7
Release:        0
Source:         %{name}-%{version}.tar.xz
Source1:        logrotate-scpm
Patch1:         scpm-fix_boot_script.patch
Patch2:         scpm-1.1.7-gcc44.patch
Patch3:         scpm-1.1.7-no_static_linking.patch
Patch4:         scpm-fix_link_order.patch
Patch5:         scpm-header.patch
Patch6:         scpm-remove_unneeded_typedef.patch
Patch7:         scpm-no_using_in_header.patch
Patch8:         scpm-constification.patch
Patch9:         scpm-doc_config.patch
Requires:       diffutils
Requires:       textutils
Requires(post): awk
Recommends:     logrotate
Suggests:       %{name}-lang
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         %insserv_prereq %fillup_prereq %install_info_prereq

%description
SCPM enables your system to save different configurations in profiles.
You can boot directly into a profile as well as switch profiles at run
time. It is the successor of scheme management.


%package        devel
Summary:        Header files and API documentation for SCPM
Group:          Development/Libraries/C and C++
Provides:       scpm:/usr/include/scpm.h
Requires:       %{name} = %{version}

%description devel
This package is only needed if you want to compile applications that
make use of libscpm.


%package        lang
Summary:        Localized messages for scpm
Group:          Development/Libraries/C and C++
Requires:       scpm = %{version}

%description lang
This package contains the localized messages for scpm.

%prep
%setup -q
%patch1 -p0
%patch2
%patch3
%patch4
%patch5 -p1
%patch6
%patch7
%patch8
%patch9

%build
export CXXFLAGS="%{optflags}"
echo -e "#!/bin/bash\n$(which %__cxx) \"\$@\"" >g++
chmod 755 g++
export PATH=`pwd`:$PATH
make

%install
mkdir -p %{buildroot}%{_libdir}
mkdir -p %{buildroot}%{_sbindir}
mkdir -p %{buildroot}%{_var}/lib
mkdir -p %{buildroot}%{_prefix}/include
mkdir -p %{buildroot}%{_datadir}/locale/de/LC_MESSAGES
mkdir -p %{buildroot}%{_datadir}/update-messages/en
mkdir -p %{buildroot}%{_defaultdocdir}
mkdir -p %{buildroot}%{_infodir}
mkdir -p %{buildroot}%{_mandir}
mkdir -p %{buildroot}/sbin/conf.d
mkdir -p %{buildroot}/etc/logrotate.d
mkdir -p %{buildroot}/var/adm/fillup-templates
make PREFIX=%{buildroot} EXEC_PREFIX=%{_prefix} install
install -m 755 -d %{buildroot}/%{_defaultdocdir}/scpm
# work around until scpm gets autoconf'd
if [ "%{_lib}" != "lib" ]; then
	mv %{buildroot}%{_prefix}/lib/libscpm* %{buildroot}%{_libdir}
fi
install -m 644 %{SOURCE1} %{buildroot}/etc/logrotate.d/scpm
mkdir -p %{buildroot}/var/log
touch %{buildroot}/var/log/scpm
%find_lang %name

%post
/sbin/ldconfig
%{fillup_and_insserv -y boot.scpm}
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz

INITIALIZED=$( scpm status | awk '{ if ($1 == "enabled") print $3 }' )
test $INITIALIZED = no && exit 0

NEEDS_UPDATE=$( scpm status | awk '{ if (($1 == "needs") && ($2 == "reinit")) print $4 }'  )
test $NEEDS_UPDATE  = no && exit 0

TMP=$(mktemp /tmp/scpm_update.XXXXXX)
test -z "$TMP" && TMP=/dev/stdout

scpm -x db set 'status*system' "`head -n 1 /etc/SuSE-release`" > $TMP
scpm -x update_resources > $TMP

test "$TMP" != "/dev/stdout" && rm -f $TMP

%postun
/sbin/ldconfig
%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz
%{insserv_cleanup}

%files
%defattr(-,root,root)
%config(noreplace) /etc/scpm.users
%config /etc/init.d/boot.scpm
%config /etc/logrotate.d/scpm
%config /etc/bash_completion.d/scpm_completion.sh
%{_sbindir}/scpm
%{_libdir}/libscpm.so.*
%{_prefix}/lib/scpm
%{_mandir}/man8/scpm.8.gz
%{_infodir}/scpm.info.gz
%doc CHANGES README
%dir /var/lib/scpm
%dir /var/lib/scpm/scdb
%dir /var/lib/scpm/profiles
%dir /var/lib/scpm/resource_sets
%dir /var/lib/scpm/resource_groups
%config /var/lib/scpm/active_groups
%config /var/lib/scpm/active_groups
%ghost /var/log/scpm
/var/adm/fillup-templates/sysconfig.scpm

%files devel
%defattr(-,root,root)
%{_includedir}/*
%{_libdir}/libscpm.so
%doc doc/api

%files lang  -f %name.lang
%defattr(-,root,root)

%changelog
openSUSE Build Service is sponsored by