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