Require tar.
[myplc.git] / myplc.spec
1 #
2 # $Id$
3 #
4 %define url $URL$
5
6 %define name myplc
7 %define version 4.0
8 %define subversion 15
9
10 %define release %{subversion}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
11
12 Summary: PlanetLab Central (PLC) Portable Installation
13 Name: %{name}
14 Version: %{version}
15 Release: %{release}
16 License: PlanetLab
17 Group: Applications/Systems
18 Source0: %{name}-%{version}.tar.gz
19 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
20
21 Vendor: PlanetLab
22 Packager: PlanetLab Central <support@planet-lab.org>
23 Distribution: PlanetLab 4.0
24 URL: %(echo %{url} | cut -d ' ' -f 2)
25 Requires: tar
26
27 %define debug_package %{nil}
28
29 %description
30 MyPLC is a complete PlanetLab Central (PLC) portable installation
31 contained within a chroot jail. The default installation consists of a
32 web server, an XML-RPC API server, a boot server, and a database
33 server: the core components of PLC. All PLC services are started up and
34 shut down through a single System V init script installed in the host
35 system. The related Web Interface is now separately packaged
36 in the PLCWWW component. 
37
38 %prep
39 %setup -q
40
41 %build
42 pushd MyPLC
43 ./build.sh %{pldistro}
44 popd
45
46 %install
47 rm -rf $RPM_BUILD_ROOT
48
49 pushd MyPLC
50
51 #
52 # myplc
53 #
54
55 # Install host startup script and configuration file
56 install -D -m 755 host.init $RPM_BUILD_ROOT/%{_sysconfdir}/init.d/plc
57 install -D -m 644 plc.sysconfig $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/plc
58
59 # Create convenient symlink
60 install -d -m 755 $RPM_BUILD_ROOT/%{_sysconfdir}
61 ln -sf /plc/data/etc/planetlab $RPM_BUILD_ROOT/%{_sysconfdir}/planetlab
62
63 # Install root filesystem
64 install -d -m 755 $RPM_BUILD_ROOT/plc/root
65 install -D -m 644 root.img $RPM_BUILD_ROOT/plc/root.img
66
67 # Install data directory
68 find data | cpio -p -d -u $RPM_BUILD_ROOT/plc/
69
70 popd
71
72 %clean
73 rm -rf $RPM_BUILD_ROOT
74
75 # If run under sudo
76 if [ -n "$SUDO_USER" ] ; then
77     # Allow user to delete the build directory
78     chown -h -R $SUDO_USER .
79     # Some temporary cdroot files like /var/empty/sshd and
80     # /usr/bin/sudo get created with non-readable permissions.
81     find . -not -perm +0600 -exec chmod u+rw {} \;
82     # Allow user to delete the built RPM(s)
83     chown -h -R $SUDO_USER %{_rpmdir}/%{_arch}
84 fi
85
86 %pre
87 if [ -x %{_sysconfdir}/init.d/plc ] ; then
88     %{_sysconfdir}/init.d/plc safestop
89 fi
90
91 # Old versions of myplc used to ship with a bootstrapped database and
92 # /etc/planetlab directory. Including generated files in the manifest
93 # was dangerous; if /plc/data/var/lib/pgsql/data/base/1/16676 changed
94 # names from one RPM build to another, it would be rpmsaved and thus
95 # effectively deleted. Now we do not include these files in the
96 # manifest. However, to avoid deleting these files in the process of
97 # upgrading from one of these old versions of myplc, we must back up
98 # the database and /etc/planetlab and restore them after the old
99 # version has been uninstalled in %triggerpostun (also in %post, in
100 # case we are force upgrading to the same version).
101 #
102 # This code can be removed once all myplc-0.4-1 installations have
103 # been upgraded to at least myplc-0.4-2.
104
105 # 0 = install, 1 = upgrade
106 if [ $1 -gt 0 ] ; then
107     for dir in /var/lib/pgsql/data /etc/planetlab ; do
108         if [ -d /plc/data/$dir ] ; then
109             echo "Preserving /plc/data/$dir"
110             mkdir -p /plc/data/$dir.rpmsave
111             tar -C /plc/data/$dir -cpf - . | \
112                tar -C /plc/data/$dir.rpmsave -xpf -
113
114             # Except for the default configuration file and DTD, which
115             # really should be considered for upgrade.
116             rm -f /plc/data/$dir.rpmsave/{default_config.xml,plc_config.dtd}
117         fi
118     done
119 fi
120
121 %post
122 if [ -x /sbin/chkconfig ] ; then
123     /sbin/chkconfig --add plc
124     /sbin/chkconfig plc on
125 fi
126
127 %triggerpostun -- %{name}
128 # 0 = erase, 1 = upgrade
129 if [ $1 -gt 0 ] ; then
130     for dir in /var/lib/pgsql/data /etc/planetlab ; do
131         if [ -d /plc/data/$dir.rpmsave -a -d /plc/data/$dir ] ; then
132             echo "Merging /plc/data/$dir"
133             if tar -C /plc/data/$dir.rpmsave -cpf - . | \
134                tar -C /plc/data/$dir -xpf - ; then
135                 rm -rf /plc/data/$dir.rpmsave
136             fi
137         fi
138     done
139 fi    
140
141 %preun
142 # 0 = erase, 1 = upgrade
143 if [ $1 -eq 0 ] ; then
144     %{_sysconfdir}/init.d/plc safestop
145     if [ -x /sbin/chkconfig ] ; then
146         /sbin/chkconfig plc off
147         /sbin/chkconfig --del plc
148     fi
149 fi
150
151 %files
152 %defattr(-,root,root,-)
153 # Host startup script and configuration file
154 %{_sysconfdir}/init.d/plc
155 %{_sysconfdir}/sysconfig/plc
156
157 # Symlink to /etc/planetlab within data directory
158 %{_sysconfdir}/planetlab
159
160 # Root filesystem
161 /plc/root.img
162 /plc/root
163
164 # Data directory
165 %dir /plc/data
166 %config(noreplace) /plc/data/*
167
168 %changelog
169 * Fri Jan 19 2007 Mark Huang <mlhuang@CS.Princeton.EDU> - 0.5-3
170 - Split off myplc-devel into separate spec file, so that it can be
171   built standalone.
172
173 * Tue Aug 22 2006 Mark Huang <mlhuang@CS.Princeton.EDU> - 0.4-3, 0.5-3
174 - MyPLC 0.4 RC3.
175 - Fix upgrade path from RC1.
176 - Always regenerate plc_config.xml at first startup
177 - Upgrade kernel, iptables, vnet to 2.6.17-1.2142_FC4-3.planetlab
178 - Minor PlanetFlow fixes
179 - pl_mom/swapmon: Minor fixes
180 - bootcd: Added Supermicro IPMI support
181 - bootmanager: Cleanup, fixed check for new disks
182
183 * Wed Aug 09 2006 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
184 - introduces variable %{build_devel} to allow custom sites to skip building
185   the myplc-devel package.
186
187 * Thu Jul 13 2006 Mark Huang <mlhuang@CS.Princeton.EDU> - 0.4-2, 0.5-2
188 - MyPLC 0.4 RC2.
189 - Fix many spec files (License replaces Copyright).
190 - Fix kernel build under gcc32 (module verification bug).
191 - Fix vnet build under gcc32
192 - Fix PlanetFlow. MySQL RPM postinstall script no longer starts the
193   server. Also, get hostnames list from PLC_WWW_HOST, not
194   www.planet-lab.org.
195 - Fix pl_mom/bwmon to use cached values if NM is unresponsive
196 - Fix pl_mom/swapmon reset logic to avoid endless loops
197 - Remove ksymoops, add kernel-smp to standard PlanetLab package group
198 - Add kernel-smp boot support to bootmanager
199 - Add badblock search support to bootmanager
200 - Build development environment (myplc-devel). Add support for
201   building myplc itself inside myplc-devel.
202 - Move step-specific initialization to appropriate plc.d scripts
203 - Fix postgresql startup failure when bootstrapping
204 - Allow CA to be configured for each SSL certificate set. Stop doing
205   root CA stuff, this is outside the scope of MyPLC. MyPLC now only
206   generates self-signed certificates, but supports replacement of the
207   self-signed certificates with real certifcates signed by another CA,
208   as long as the CA is specified.
209 - Self-sign the MA/SA SSL certificate (and by extension, the MA/SA API
210   certificate).
211 - pl_mom: Workarounds for when NM queries time out.
212 - plc_api: Honor PLC_MAIL_ENABLED.
213
214 * Wed Jul  6 2006 Mark Huang <mlhuang@CS.Princeton.EDU> - 0.4-1, 0.5-1
215 - First stable release of MyPLC 0.4 RC1.
216
217 * Wed Apr  5 2006 Mark Huang <mlhuang@CS.Princeton.EDU> - 0.2-1
218 - Basic functionality complete. Consolidate into a single package
219   installed in /plc.
220
221 * Fri Mar 17 2006 Mark Huang <mlhuang@CS.Princeton.EDU> - 0.1-1
222 - Initial build.
223