-# 0 = erase, 1 = upgrade
-if [ $1 -eq 0 ] ; then
- [ "`/sbin/runlevel`" = "unknown" ] || service vservers stop
- chkconfig vservers off
- chkconfig --del vservers
-fi
-
-%files
-%defattr(-,root,root)
-%doc AUTHORS COPYING ChangeLog NEWS README THANKS
-%_sbindir/*
-%_libdir/%name
-%_includedir/vserver.h
-%_libdir/libvserver.a
-%_mandir/man8/*
-%config %_initrddir/*
-%config(noreplace) /etc/vservers.conf
-%config(noreplace) /etc/vcached.conf
-/etc/logrotate.d/vcached
-/etc/cron.d/vcached
-%dir /etc/vservers
-%attr(0,root,root) %dir /vservers
-%attr(4755,root,root) /usr/sbin/vsh
-%attr(4755,root,root) /bin/vsh
-
-%exclude %_sbindir/newvserver
-%exclude %_mandir/man8/newvserver*
-
-%files linuxconf
-%defattr(-,root,root)
-%config(noreplace) /etc/vservers/newvserver.defaults
-%_sbindir/newvserver
-%_mandir/man8/newvserver*
+test "$1" != 0 || rm -rf %_localstatedir/cache/vservers/* 2>/dev/null || :
+
+
+%post lib -p /sbin/ldconfig
+%postun lib -p /sbin/ldconfig
+
+
+%post sysv
+%chkconfig --add vservers-default
+%chkconfig --add vprocunhide
+%chkconfig --add util-vserver
+%chkconfig vprocunhide on
+%chkconfig util-vserver on
+
+%preun sysv
+test "$1" != 0 || %_initrddir/vprocunhide stop &>/dev/null || :
+
+test "$1" != 0 || %chkconfig --del vprocunhide
+test "$1" != 0 || %chkconfig --del vservers-default
+test "$1" != 0 || %chkconfig --del util-vserver
+
+
+%postun sysv
+test "$1" = 0 || %_initrddir/vprocunhide condrestart >/dev/null || :
+
+
+%triggerin build -- fedora-release, centos-release
+function copy()
+{
+ base=$1
+ shift
+
+ for i; do
+ test -r "$i" || continue
+
+ target=%confdir/.distributions/.common/pubkeys/$base-$(basename "$i")
+ cp -a "$i" "$target"
+ done
+}
+copy fedora /usr/share/doc/fedora-release-*/RPM-GPG-*
+copy fedora /etc/pki/rpm-gpg/RPM-GPG-*
+copy centos /usr/share/doc/centos-*/RPM-GPG-KEY-*
+
+
+%pre build
+x="%_libdir/util-vserver/distributions/etch"
+test -d "$x" && mv "$x" "$x.rpmsave" || :
+
+
+%post build
+test -d /vservers/.hash || mkdir -m0700 /vservers/.hash
+
+f="%confdefaultdir/apps/vunify/hash"; test -e "$f"/method -o -e "$f"/00 || \
+ ln -s /vservers/.hash "$f"/00
+
+%_sbindir/setattr --barrier /vservers/.hash || :
+
+
+%preun build
+test "$1" != 0 || rm -f %confdir/.distributions/.common/pubkeys/fedora-*
+
+
+## Temporary workaround to remove old v_* files; it will conflict
+## somehow with the -legacy package but can be fixed by reinstalling
+## this package.
+## TODO: remove me in the final .spec file
+%define v_services httpd named portmap sendmail smb sshd xinetd gated
+%triggerun sysv -- util-vserver-sysv < 0.30.198
+for i in %v_services; do
+ %chkconfig --del v_$i || :
+done
+
+
+%post legacy
+%chkconfig --add rebootmgr
+%chkconfig --add vservers-legacy
+
+for i in %v_services; do
+ %chkconfig --add v_$i
+done
+
+
+%preun legacy
+test "$1" != 0 || %_initrddir/rebootmgr stop &>/dev/null || :
+
+test "$1" != 0 || for i in %v_services; do
+ %chkconfig --del v_$i
+done
+
+test "$1" != 0 || %chkconfig --del rebootmgr
+test "$1" != 0 || %chkconfig --del vservers-legacy
+
+%postun legacy
+test "$1" = 0 || %_initrddir/rebootmgr condrestart >/dev/null || :
+
+
+%files -f %name-base.list
+%defattr(-,root,root,-)
+%doc AUTHORS COPYING NEWS README THANKS
+#%doc AUTHORS COPYING ChangeLog NEWS README THANKS
+#%doc doc/*.html doc/*.css
+/sbin/vshelper
+%dir %confdir
+%dir %confdefaultdir
+%dir %confdefaultdir/apps
+%dir %confdefaultdir/files
+%dir %pkglibdir/defaults
+%ghost %confdefaultdir/cachebase
+%ghost %confdefaultdir/vdirbase
+%ghost %confdefaultdir/run.rev
+
+%dir %_localstatedir/cache/vservers
+%dir %_localstatedir/run/vservers
+%dir %_localstatedir/run/vservers.rev
+%dir %_localstatedir/run/vshelper
+
+
+%files lib -f %name-lib.list
+%files sysv -f %name-sysv.list
+
+
+%files core -f %name-core.list
+%defattr(-,root,root,-)
+%dir %pkglibdir
+
+
+%files build -f %name-build.list
+%defattr(-,root,root,-)
+%doc contrib/yum*.patch
+%dir %confdir/.distributions
+%dir %confdir/.distributions/*
+%dir %confdir/.distributions/*/apt
+%dir %confdir/.distributions/.common
+%dir %confdir/.distributions/.common/pubkeys
+%dir %confdefaultdir/apps/vunify
+%dir %confdefaultdir/apps/vunify/hash
+
+
+%files legacy -f %name-legacy.list
+%defattr(-,root,root,-)
+%dir %pkglibdir/legacy
+
+
+%files devel -f %name-devel.list
+%defattr(-,root,root,-)
+%{!?_without_doc:%doc lib/apidoc/latex/refman.pdf}
+%{!?_without_doc:%doc lib/apidoc/html}
+
+
+%files python
+%defattr(-,root,root,-)
+%{!?_without_python:%{python_sitearch}/*}
+