snafu
[myplc.git] / myplc-native.spec
1 Vendor: PlanetLab
2 Packager: PlanetLab Central <support@planet-lab.org>
3 Distribution: PlanetLab 4.0
4 URL: http://cvs.planet-lab.org/cvs/myplc
5
6 Summary: PlanetLab Central (PLC) Portable Installation
7 Name: myplc-native
8 Version: 0.5
9 Release: 4%{?pldistro:.%{pldistro}}%{?date:.%{date}}
10 License: PlanetLab
11 Group: Applications/Systems
12 Source0: %{name}-%{version}.tar.gz
13 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
14
15 Requires: bzip2
16 Requires: sendmail-cf
17 Requires: tar 
18 Requires: less
19 Requires: perl-GD
20 Requires: openssl
21 Requires: xmlsec1
22 Requires: gd
23 Requires: expect
24 Requires: php-pgsql
25 Requires: curl
26 Requires: python-pycurl
27 Requires: httpd
28 Requires: rsync
29 Requires: mod_python
30 Requires: mod_ssl
31 Requires: bootmanager
32 Requires: python-devel
33 Requires: SOAPpy
34 Requires: vixie-cron
35 Requires: yum
36 Requires: php-gd
37 Requires: PLCWWW
38 Requires: PLCAPI
39 Requires: PyXML
40 Requires: sendmail
41 Requires: python >= 2.4
42 Requires: createrepo
43 Requires: postgresql-python
44 Requires: cpio
45 Requires: postgresql-server
46 Requires: wget
47 Requires: php
48 Requires: xmlsec1-openssl
49 Requires: postgresql
50 Requires: openssh
51 Requires: cvs
52 Requires: dev
53 Requires: bootcd
54 Requires: dnsmasq
55 Requires: diffutils
56 Requires: gzip
57 Requires: findutils
58
59 %define debug_package %{nil}
60
61 %description
62 MyPLC is a complete PlanetLab Central (PLC) portable installation
63 contained within a chroot jail. The default installation consists of a
64 web server, an XML-RPC API server, a boot server, and a database
65 server: the core components of PLC. The installation may be customized
66 through a graphical interface. All PLC services are started up and
67 shut down through a single System V init script installed in the host
68 system.
69
70 %prep
71 %setup -q
72
73 %build
74 pushd myplc
75 rm -rf $RPM_BUILD_ROOT
76 ./build-native.sh $RPM_BUILD_ROOT
77 popd
78
79 %install
80
81 %clean
82 rm -rf $RPM_BUILD_ROOT
83
84 # If run under sudo
85 if [ -n "$SUDO_USER" ] ; then
86     # Allow user to delete the build directory
87     chown -h -R $SUDO_USER .
88     # Some temporary cdroot files like /var/empty/sshd and
89     # /usr/bin/sudo get created with non-readable permissions.
90     find . -not -perm +0600 -exec chmod u+rw {} \;
91     # Allow user to delete the built RPM(s)
92     chown -h -R $SUDO_USER %{_rpmdir}/%{_arch}
93 fi
94
95 %pre
96 if [ -x %{_sysconfdir}/init.d/plc ] ; then
97     %{_sysconfdir}/init.d/plc stop
98 fi
99
100 # Old versions of myplc used to ship with a bootstrapped database and
101 # /etc/planetlab directory. Including generated files in the manifest
102 # was dangerous; if /plc/data/var/lib/pgsql/data/base/1/16676 changed
103 # names from one RPM build to another, it would be rpmsaved and thus
104 # effectively deleted. Now we do not include these files in the
105 # manifest. However, to avoid deleting these files in the process of
106 # upgrading from one of these old versions of myplc, we must back up
107 # the database and /etc/planetlab and restore them after the old
108 # version has been uninstalled in %triggerpostun (also in %post, in
109 # case we are force upgrading to the same version).
110 #
111 # This code can be removed once all myplc-0.4-1 installations have
112 # been upgraded to at least myplc-0.4-2.
113
114 # 0 = install, 1 = upgrade
115 if [ $1 -gt 0 ] ; then
116     for dir in /var/lib/pgsql/data /etc/planetlab ; do
117         if [ -d $dir ] ; then
118             echo "Preserving $dir"
119             mkdir -p $dir.rpmsave
120             tar -C $dir -cpf - . | \
121                tar -C $dir.rpmsave -xpf -
122
123             # Except for the default configuration file and DTD, which
124             # really should be considered for upgrade.
125             rm -f $dir.rpmsave/{default_config.xml,plc_config.dtd}
126         fi
127     done
128 fi
129
130 %post
131 if [ -x /sbin/chkconfig ] ; then
132     /sbin/chkconfig --add plc
133     /sbin/chkconfig plc on
134 fi
135
136 %triggerpostun -- %{name}
137 # 0 = erase, 1 = upgrade
138 if [ $1 -gt 0 ] ; then
139     for dir in /var/lib/pgsql/data /etc/planetlab ; do
140         if [ -d $dir.rpmsave -a -d $dir ] ; then
141             echo "Merging $dir"
142             if tar -C $dir.rpmsave -cpf - . | \
143                tar -C $dir -xpf - ; then
144                 rm -rf $dir.rpmsave
145             fi
146         fi
147     done
148 fi    
149
150 %preun
151 # 0 = erase, 1 = upgrade
152 if [ $1 -eq 0 ] ; then
153     %{_sysconfdir}/init.d/plc stop
154     if [ -x /sbin/chkconfig ] ; then
155         /sbin/chkconfig plc off
156         /sbin/chkconfig --del plc
157     fi
158 fi
159
160 %files
161 %defattr(-,root,root,-)
162 # Host startup script and configuration file
163 /etc/init.d/plc
164 /usr/bin/plc-config
165 /usr/bin/plc-config-tty
166 /usr/bin/db-config
167 /usr/bin/dns-config
168 /usr/bin/gen-sites-xml.py*
169 /usr/bin/gen-slices-xml-05.py*
170 /usr/bin/gen-static-content.py*
171 /etc/plc.d
172 /etc/planetlab
173 /var/www/html/install-rpms/planetlab
174
175 %changelog
176 * Fri Aug 31 2007 Marc E. Fiuczynski <mef@CS.Princeton.EDU>
177 - initial build.
178
179