Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > by-pkgid > dab3ef6055b81a0664704aa7f68e9383 > files > 1

collectl-3.4.0-1mdv2010.1.src.rpm

--- INSTALL.rpm	2010-01-15 17:31:08.000000000 +0100
+++ INSTALL	2010-01-15 18:38:35.000000000 +0100
@@ -1,85 +1,96 @@
 #!/bin/bash
 
-BINDIR=/usr/bin
-DOCDIR=/usr/share/doc/collectl
-SHRDIR=/usr/share/collectl
+# By default an application should be installed under /usr/local on Linux
+# If packaged, then there is a need to have the BUILDDIR path taken in account
+# and in that case the root is different (/usr, /etc, ...)
+
+if [ "_$PREFIX" != "_" ]; then
+	USR=${PREFIX}/usr
+	VAR=${PREFIX}/var
+	ETC=${PREFIX}/etc
+else
+	USR=/usr/local
+	ETC=/usr/local/etc
+	VAR=/usr/local/var
+fi
+
+BINDIR=$USR/sbin
+DOCDIR=$USR/share/doc/collectl
+SHRDIR=$USR/share/collectl
 
+mkdir -p $BINDIR
+mkdir -p $USR/share/man/man1
 mkdir -p $DOCDIR
 mkdir -p $SHRDIR
+mkdir -p $ETC/init.d
 mkdir -p $SHRDIR/util
-mkdir -p /var/log/collectl
+mkdir -p $VAR/log/collectl
 
-cp collectl.pl           $BINDIR/collectl
-cp collectl.conf         /etc
-cp initd/*               /etc/init.d
-cp man1/*                /usr/share/man/man1
-
-cp docs/*                $DOCDIR
-cp GPL ARTISTIC COPYING  $DOCDIR
-cp RELEASE-collectl      $DOCDIR
-
-cp UNINSTALL             $SHRDIR
-cp formatit.ph           $SHRDIR
-cp lexpr.ph sexpr.ph     $SHRDIR
-cp gexpr.ph misc.ph      $SHRDIR
-cp envrules.std          $SHRDIR
-cp vmstat.ph             $SHRDIR
-cp client.pl readS       $SHRDIR/util
-cp col2tlviz.pl          $SHRDIR/util
+install -m 755 collectl.pl           $BINDIR/collectl
+install -m 644 collectl.conf         $ETC
+install -m 755 initd/*               $ETC/init.d
+install -m 644 man1/*                $USR/share/man/man1
+
+install -m 644 docs/*                $DOCDIR
+install -m 644 GPL ARTISTIC COPYING  $DOCDIR
+install -m 644 README                $DOCDIR
+install -m 644 RELEASE-collectl      $DOCDIR
+
+install -m 644 UNINSTALL             $SHRDIR
+install -m 644 formatit.ph           $SHRDIR
+install -m 644 lexpr.ph sexpr.ph     $SHRDIR
+install -m 644 gexpr.ph misc.ph      $SHRDIR
+install -m 644 envrules.std          $SHRDIR
+install -m 644 vmstat.ph             $SHRDIR
+install -m 755 client.pl readS       $SHRDIR/util
+install -m 755 col2tlviz.pl          $SHRDIR/util
 
 # Force in case redoing the install and files already zipped
-gzip -f /usr/share/man/man1/collectl*
-
-chmod 755 /etc/init.d/collectl*
-chmod 444 /etc/collectl.conf
-chmod 755 $BINDIR/collectl
-chmod 444 $DOCDIR/ARTISTIC $DOCDIR/COPYING $DOCDIR/GPL
-chmod 755 $SHRDIR/util/*
-chmod 444 $SHRDIR/formatit.ph $SHRDIR/*expr.ph $SHRDIR/vmstat.ph
+gzip -f $USR/share/man/man1/collectl*
 
 # remove any stale versions in case the names/numbers used have changed.
-# on new ROCKS installion 'rm' isn't there yet!  [thanks roy]
+# on new ROCKS installation 'rm' isn't there yet!  [thanks roy]
 if [ -x /bin/rm ] ; then
-  /bin/rm -f /etc/init.d/rc*.d/*collectl
-  /bin/rm -f /etc/rc.d/rc*.d/*collectl
+  /bin/rm -f $ETC/init.d/rc*.d/*collectl
+  /bin/rm -f $ETC/rc.d/rc*.d/*collectl
 fi
 
 # Try and decide which distro this is based on distro specific files.
 distro=1
 if [[ -f /sbin/yast ]]; then
     distro=2
-    cp -f /etc/init.d/collectl-suse /etc/init.d/collectl
-    rm -f /etc/init.d/collectl-suse
-    rm -f /etc/init.d/collectl-debian
-    rm -f /etc/init.d/collectl-generic
+    cp -f $ETC/init.d/collectl-suse $ETC/init.d/collectl
+    rm -f $ETC/init.d/collectl-suse
+    rm -f $ETC/init.d/collectl-debian
+    rm -f $ETC/init.d/collectl-generic
 fi
 
 # debian
 if [[ -f /usr/sbin/update-rc.d ]]; then
     distro=3
-    cp -f /etc/init.d/collectl-debian /etc/init.d/collectl
-    rm -f /etc/init.d/collectl-suse
-    rm -f /etc/init.d/collectl-debian
-    rm -f /etc/init.d/collectl-generic
+    cp -f $ETC/init.d/collectl-debian $ETC/init.d/collectl
+    rm -f $ETC/init.d/collectl-suse
+    rm -f $ETC/init.d/collectl-debian
+    rm -f $ETC/init.d/collectl-generic
     update-rc.d collectl defaults
 fi
 
 # redhat
 if [[ -f /etc/redhat-release ]]; then
     distro=4
-    rm -f /etc/init.d/collectl-suse
-    rm -f /etc/init.d/collectl-debian
-    rm -f /etc/init.d/collectl-generic
+    rm -f $ETC/init.d/collectl-suse
+    rm -f $ETC/init.d/collectl-debian
+    rm -f $ETC/init.d/collectl-generic
     chkconfig --add collectl
 fi
 
 # gentoo
 if [[ -f /etc/gentoo-release ]]; then
     distro=5
-    cp -f /etc/init.d/collectl-generic /etc/init.d/collectl
-    rm -f /etc/init.d/collectl-suse
-    rm -f /etc/init.d/collectl-debian
-    rm -f /etc/init.d/collectl-generic
+    cp -f $ETC/init.d/collectl-generic $ETC/init.d/collectl
+    rm -f $ETC/init.d/collectl-suse
+    rm -f $ETC/init.d/collectl-debian
+    rm -f $ETC/init.d/collectl-generic
     rc-update -a collectl default
 fi
 
@@ -88,10 +99,10 @@
 # rc-update you're going to have to add some custom code below...
 if [[ ${distro} = 1 ]]; then
 
-    cp -f /etc/init.d/collectl-generic /etc/init.d/collectl
-    rm -f /etc/init.d/collectl-suse
-    rm -f /etc/init.d/collectl-debian
-    rm -f /etc/init.d/collectl-generic
+    cp -f $ETC/init.d/collectl-generic $ETC/init.d/collectl
+    rm -f $ETC/init.d/collectl-suse
+    rm -f $ETC/init.d/collectl-debian
+    rm -f $ETC/init.d/collectl-generic
 
     # figure out how to handle reboots
     if [[ -f /sbin/chkconfig ]]; then