Fix so that vsh works from /bin/vsh again.
[util-vserver.git] / util-vserver.spec
1 %define name util-vserver
2 %define version 0.30
3 %define release 1.planetlab%{?date:.%{date}}
4
5 Vendor: PlanetLab
6 Packager: PlanetLab Central <support@planet-lab.org>
7 Distribution: PlanetLab 3.0
8 URL: http://www.planet-lab.org
9
10 %define __chattr        /usr/bin/chattr
11
12 Summary:        Linux virtual server utilities
13 Name:           %{name}
14 Version:        %{version}
15 Release:        %{release}
16 Epoch:          0
17 Copyright:      GPL
18 Group:          System Environment/Base
19 Source0:        http://savannah.nongnu.org/download/util-vserver/stable.pkg/%version/%name-%version.tar.bz2
20 Provides:       %name-devel = %epoch:%version-%release
21 BuildRoot:      %_tmppath/%name-%version-%release-root
22 Provides:       vserver = %epoch:%version-%release
23 Conflicts:      vserver < %epoch:%version-%release
24 Conflicts:      vserver > %epoch:%version-%release
25 BuildRequires:  e2fsprogs-devel
26 Requires(post): %__chattr
27
28 %package linuxconf
29 Summary:        Linuxconf administration modules for vservers
30 Group:          Applications/System
31 Requires:       %name = %epoch:%version-%release
32 Provides:       vserver-admin = %epoch:%version-%release
33 Conflicts:      vserver-admin < %epoch:%version-%release
34 Conflicts:      vserver-admin > %epoch:%version-%release
35
36 %description
37 This package provides the components and a framework to setup virtual
38 servers.  A virtual server runs inside a linux server. It is nevertheless
39 highly independent. As such, you can run various services with normal
40 configuration. The various vservers can't interact with each other and
41 can't interact with services in the main server.
42
43 This requires a special kernel supporting the new new_s_context and
44 set_ipv4root system call.
45
46
47 %description linuxconf
48 This package provides the components to setup virtual servers with
49 linuxconf.
50
51
52 %prep
53 %setup -q
54 aclocal -I m4
55 autoconf
56 automake --add-missing
57 # bootstrap to avoid BuildRequires of kernel-source
58 for linux in $RPM_BUILD_DIR/linux-* /lib/modules/`uname -r`/build ; do
59    [[ -d $linux/include ]] && %configure --with-kerneldir=$linux --enable-linuxconf && break
60 done
61
62
63 %build
64 make
65
66 %install
67 rm -rf $RPM_BUILD_ROOT
68 %__make DESTDIR=$RPM_BUILD_ROOT install
69
70 mkdir -p $RPM_BUILD_ROOT/vservers
71 test "%_initrddir" = %_sysconfdir/init.d || {
72         mkdir -p ${RPM_BUILD_ROOT}%_initrddir
73         mv ${RPM_BUILD_ROOT}%_sysconfdir/init.d/* ${RPM_BUILD_ROOT}%_initrddir/
74 }
75
76 %clean
77 rm -rf $RPM_BUILD_ROOT
78
79 %define services vcached vservers
80
81 %pre
82 # 1 = install, 2 = upgrade/reinstall
83 if [ $1 -eq 2 ] ; then
84     for i in %{services} ; do
85         [ "`/sbin/runlevel`" = "unknown" ] || service $i stop || :
86     done
87 fi
88
89 %post
90 # 1 = install, 2 = upgrade/reinstall
91 if [ $1 -eq 1 ] ; then
92     for i in %{services} ; do
93         chkconfig --add $i
94         chkconfig $i on
95     done
96 fi
97 for i in %{services} ; do
98     [ "`/sbin/runlevel`" = "unknown" ] || service $i start
99 done
100 if [ ! -f /etc/shells ] || ! grep -q '^/bin/vsh$' /etc/shells ; then
101     echo /bin/vsh >> /etc/shells
102 fi
103 ln -f /usr/sbin/vsh /bin/vsh
104
105 %__chattr +t /vservers || :
106
107
108 %postun
109 # 0 = erase, 1 = upgrade
110 if [ "$1" = 0 ] ; then
111     perl -i -n -e 'next if /^\/bin\/vsh$/; print' /etc/shells
112 fi
113 rm -f /usr/sbin/vsh /bin/vsh
114
115 %preun
116 # 0 = erase, 1 = upgrade
117 if [ $1 -eq 0 ] ; then
118     for i in %{services} ; do
119         [ "`/sbin/runlevel`" = "unknown" ] || service $i stop || :
120         chkconfig $i off
121         chkconfig --del $i
122     done
123 fi
124
125 %files
126 %defattr(-,root,root)
127 %doc AUTHORS COPYING ChangeLog NEWS README THANKS
128 %_sbindir/*
129 %_libdir/%name
130 %_includedir/vserver.h
131 %_libdir/libvserver.a
132 %_mandir/man8/*
133 %config %_initrddir/*
134 %config(noreplace) /etc/vservers.conf
135 %config(noreplace) /etc/vcached.conf
136 %dir /etc/vservers
137 %attr(0,root,root) %dir /vservers
138 %attr(4755,root,root) /usr/sbin/vsh
139 %attr(4755,root,root) /bin/vsh
140
141 %exclude %_sbindir/newvserver
142 %exclude %_mandir/man8/newvserver*
143
144 %files linuxconf
145 %defattr(-,root,root)
146 %config(noreplace) /etc/vservers/newvserver.defaults
147 %_sbindir/newvserver
148 %_mandir/man8/newvserver*
149
150 %changelog
151 * Mon Oct 11 2004 Marc E. Fiuczynski <mef@cs.princeton.edu> 0.1-1.planetlab
152 - added vsh
153
154 * Wed Aug 11 2004 Mark Huang <mlhuang@cs.princeton.edu> 0.29-1.planetlab
155 - initial PlanetLab 3.0 build.
156
157 * Thu Mar 18 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:0.29.3-0
158 - removed '%%doc doc/FAQ.txt' since file does not exist anymore
159
160 * Fri Sep 26 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:0.23.4-1
161 - initial build.
162