- use cvs- instead of cvs.
[myplc.git] / myplc.spec
index 29a8960..6beb36d 100644 (file)
@@ -39,8 +39,8 @@ source code, and all the tools necessary to compile it.
 
 %build
 pushd myplc
-#./build_devel.sh
-#./build.sh
+./build_devel.sh
+./build.sh
 popd
 
 %install
@@ -82,6 +82,10 @@ install -D -m 644 devel/root.img $RPM_BUILD_ROOT/plc/devel/root.img
 # Install data directory
 find devel/data | cpio -p -d -u $RPM_BUILD_ROOT/plc/
 
+# Make sure /cvs is never upgraded once installed by giving it a
+# unique name. A hard-linked copy is made in %post.
+mv $RPM_BUILD_ROOT/plc/devel/data/{cvs,cvs-%{version}-%{release}}
+
 popd
 
 %clean
@@ -112,11 +116,15 @@ fi
 # upgrading from one of these old versions of myplc, we must back up
 # the database and /etc/planetlab and restore them after the old
 # version has been uninstalled in %triggerpostun.
+#
+# This code can be removed once all myplc-0.4-1 installations have
+# been upgraded to at least myplc-0.4-2.
 
 # 0 = install, 1 = upgrade
 if [ $1 -gt 0 ] ; then
     for dir in /var/lib/pgsql/data /etc/planetlab ; do
        if [ -d /plc/data/$dir ] ; then
+           echo "Preserving /plc/data/$dir"
            mv /plc/data/$dir /plc/data/$dir.rpmsave
        fi
     done
@@ -142,6 +150,7 @@ touch /plc/data/etc/planetlab/default_config.xml
 if [ $1 -gt 0 ] ; then
     for dir in /var/lib/pgsql/data /etc/planetlab ; do
        if [ -d /plc/data/$dir.rpmsave -a -d /plc/data/$dir ] ; then
+           echo "Merging /plc/data/$dir"
            if tar -C /plc/data/$dir.rpmsave -cpf - . | \
               tar -C /plc/data/$dir -xpf - ; then
                rm -rf /plc/data/$dir.rpmsave
@@ -165,30 +174,17 @@ if [ -x %{_sysconfdir}/init.d/plc-devel ] ; then
     %{_sysconfdir}/init.d/plc-devel stop
 fi
 
-# 0 = install, 1 = upgrade
-if [ $1 -gt 0 ] ; then
-    # Never overwrite /cvs
-    if [ -d /plc/devel/data/cvs ] ; then
-       echo "Preserving /plc/devel/data/cvs"
-       mv /plc/devel/data/cvs /plc/devel/data/cvs.rpmsave
-    fi
-fi
-
 %post devel
 if [ -x /sbin/chkconfig ] ; then
     /sbin/chkconfig --add plc-devel
     /sbin/chkconfig plc-devel on
 fi
 
-%triggerpostun -- %{name}
-# 0 = erase, 1 = upgrade
-if [ $1 -gt 0 ] ; then
-    if [ -d /plc/devel/data/cvs.rpmsave ] ; then
-       echo "Restoring /plc/devel/data/cvs"
-       mv /plc/devel/data/cvs /plc/devel/data/cvs.%{version}-%{release}
-       mv /plc/devel/data/cvs.rpmsave /plc/devel/data/cvs
-    fi
-fi    
+# If /cvs does not already exist, make a hard-linked copy of this
+# version's /cvs repository.
+if [ ! -d /plc/devel/data/cvs ] ; then
+    cp -rl /plc/devel/data/{cvs-%{version}-%{release},cvs}
+fi
 
 %preun devel
 # 0 = erase, 1 = upgrade