typo
[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 Requires: 
15
16 %define debug_package %{nil}
17
18 %description
19 MyPLC is a complete PlanetLab Central (PLC) portable installation
20 contained within a chroot jail. The default installation consists of a
21 web server, an XML-RPC API server, a boot server, and a database
22 server: the core components of PLC. The installation may be customized
23 through a graphical interface. All PLC services are started up and
24 shut down through a single System V init script installed in the host
25 system.
26
27 %prep
28 %setup -q
29
30 %build
31 pushd myplc
32 rm -rf $RPM_BUILD_ROOT
33 ./build-native.sh $RPM_BUILD_ROOT
34 popd
35
36 %install
37
38 %clean
39 rm -rf $RPM_BUILD_ROOT
40
41 # If run under sudo
42 if [ -n "$SUDO_USER" ] ; then
43     # Allow user to delete the build directory
44     chown -h -R $SUDO_USER .
45     # Some temporary cdroot files like /var/empty/sshd and
46     # /usr/bin/sudo get created with non-readable permissions.
47     find . -not -perm +0600 -exec chmod u+rw {} \;
48     # Allow user to delete the built RPM(s)
49     chown -h -R $SUDO_USER %{_rpmdir}/%{_arch}
50 fi
51
52 %pre
53 if [ -x %{_sysconfdir}/init.d/plc ] ; then
54     %{_sysconfdir}/init.d/plc stop
55 fi
56
57 # Old versions of myplc used to ship with a bootstrapped database and
58 # /etc/planetlab directory. Including generated files in the manifest
59 # was dangerous; if /plc/data/var/lib/pgsql/data/base/1/16676 changed
60 # names from one RPM build to another, it would be rpmsaved and thus
61 # effectively deleted. Now we do not include these files in the
62 # manifest. However, to avoid deleting these files in the process of
63 # upgrading from one of these old versions of myplc, we must back up
64 # the database and /etc/planetlab and restore them after the old
65 # version has been uninstalled in %triggerpostun (also in %post, in
66 # case we are force upgrading to the same version).
67 #
68 # This code can be removed once all myplc-0.4-1 installations have
69 # been upgraded to at least myplc-0.4-2.
70
71 # 0 = install, 1 = upgrade
72 if [ $1 -gt 0 ] ; then
73     for dir in /var/lib/pgsql/data /etc/planetlab ; do
74         if [ -d $dir ] ; then
75             echo "Preserving $dir"
76             mkdir -p $dir.rpmsave
77             tar -C $dir -cpf - . | \
78                tar -C $dir.rpmsave -xpf -
79
80             # Except for the default configuration file and DTD, which
81             # really should be considered for upgrade.
82             rm -f $dir.rpmsave/{default_config.xml,plc_config.dtd}
83         fi
84     done
85 fi
86
87 %post
88 if [ -x /sbin/chkconfig ] ; then
89     /sbin/chkconfig --add plc
90     /sbin/chkconfig plc on
91 fi
92
93 %triggerpostun -- %{name}
94 # 0 = erase, 1 = upgrade
95 if [ $1 -gt 0 ] ; then
96     for dir in /var/lib/pgsql/data /etc/planetlab ; do
97         if [ -d $dir.rpmsave -a -d $dir ] ; then
98             echo "Merging $dir"
99             if tar -C $dir.rpmsave -cpf - . | \
100                tar -C $dir -xpf - ; then
101                 rm -rf $dir.rpmsave
102             fi
103         fi
104     done
105 fi    
106
107 %preun
108 # 0 = erase, 1 = upgrade
109 if [ $1 -eq 0 ] ; then
110     %{_sysconfdir}/init.d/plc stop
111     if [ -x /sbin/chkconfig ] ; then
112         /sbin/chkconfig plc off
113         /sbin/chkconfig --del plc
114     fi
115 fi
116
117 %files
118 %defattr(-,root,root,-)
119 # Host startup script and configuration file
120 %{_sysconfdir}/init.d/plc
121 %{_sysconfdir}/sysconfig/plc
122 /usr/bin/plc-config
123 /usr/bin/plc-config-tty
124 /usr/bin/db-config
125 /usr/bin/dns-config
126 /usr/bin/gen-sites-xml.py
127 /usr/bin/gen-slices-xml-05.py
128 /usr/bin/gen-static-content.py
129 /etc/httpd/conf.d/drupal.conf
130
131 %dir %{_sysconfdir}/plc.d
132 %dir %{_sysconfdir}/planetlab
133 %dir /var/www/html/*
134
135 %changelog
136 * Fri Aug 31 2007 Marc E. Fiuczynski <mef@CS.Princeton.EDU>
137 - initial build.