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