summaryrefslogtreecommitdiff
path: root/build/tar
diff options
context:
space:
mode:
Diffstat (limited to 'build/tar')
-rw-r--r--build/tar/GNUmakefile51
-rw-r--r--build/tar/README19
-rwxr-xr-xbuild/tar/checkmodes46
-rw-r--r--build/tar/postinstall.head.in9
-rwxr-xr-xbuild/tar/postinstall.tail230
-rw-r--r--build/tar/preinstall.head.in30
-rw-r--r--build/tar/preinstall.tail35
-rwxr-xr-xbuild/tar/remove122
8 files changed, 542 insertions, 0 deletions
diff --git a/build/tar/GNUmakefile b/build/tar/GNUmakefile
new file mode 100644
index 0000000..1b95b7c
--- /dev/null
+++ b/build/tar/GNUmakefile
@@ -0,0 +1,51 @@
+#
+# Copyright (c) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+
+TOPDIR = ../..
+include $(TOPDIR)/src/include/builddefs
+-include ./GNUlocaldefs
+SCRIPTS = $(TOPDIR)/build
+
+LSRCFILES = remove README \
+ preinstall.head.in preinstall.head preinstall.tail \
+ postinstall.head.in postinstall.head postinstall.tail
+
+LDIRT = $(wildcard pcp*.tar.gz pcp*.md5sum.src) \
+ preinstall preinstall.head postinstall postinstall.head
+
+default install install_pcp default_pcp : preinstall postinstall
+
+preinstall: preinstall.head $(SCRIPTS)/cleanconfigs preinstall.tail
+ rm -f $@
+ cat preinstall.head $(SCRIPTS)/cleanconfigs preinstall.tail > $@
+ chmod ugo+x $@
+
+postinstall: postinstall.head $(SCRIPTS)/cleantmpdirs postinstall.tail
+ rm -f $@
+ cat postinstall.head $(SCRIPTS)/cleantmpdirs postinstall.tail > $@
+ chmod ugo+x $@
+
+# Note on sed below
+# for f and l lines of manifest, want the last word (target name),
+# stripped of leading /
+#
+.PHONY: pack_pcp
+pack_pcp :
+ @ BINTAR=$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(PACKAGE_BUILD).tar.gz; \
+ HERE=`pwd`; cd $${DIST_ROOT:-/}; \
+ sort -u $$DIST_MANIFEST | sed -n -e '/^[fl]/s/.* \/*//p' \
+ | $(TAR) -T - -cf - \
+ | gzip > $$HERE/$$BINTAR; echo Wrote: $$HERE/$$BINTAR
+
+include $(BUILDRULES)
diff --git a/build/tar/README b/build/tar/README
new file mode 100644
index 0000000..f0c08fe
--- /dev/null
+++ b/build/tar/README
@@ -0,0 +1,19 @@
+Instructions for installing Performance Co-Pilot (PCP) from a tarball package
+
+If PCP is delivered as a tarball, there will be 2 compressed tar files
+in this directory
+
+pcp-<version_number>-<build>.src.tar.gz all of the source
+pcp-<version_number>-<build>.tar.gz a binary distribution
+
+To install or upgrade, run the following commands as "root":
+
+ # ./preinstall
+ # here=`pwd`
+ # ( cd /; tar xpf $here/pcp-*-[0-9]*.tar.gz )
+ # ./postinstall
+
+To remove PCP, run the following command as "root":
+
+ # ./remove
+
diff --git a/build/tar/checkmodes b/build/tar/checkmodes
new file mode 100755
index 0000000..81fd730
--- /dev/null
+++ b/build/tar/checkmodes
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# very crude ... use the debian postinst scripts as the reference
+# and check ownership and mode on the local filesystem
+#
+
+cat ../../debian/*postinst* \
+| sed -n \
+ -e '/^#/d' \
+ -e '/chown pcp/{
+s/chown //
+s/:/ /
+p
+}' \
+| while read owner group path
+do
+ echo -n "$path: "
+ if [ -d $path ]
+ then
+ # expect
+ # drwxrwxr-x 2 pcp pcp 4096 Aug 24 06:22 /etc/pcp/pmie
+ #
+ if ls -ld $path | grep -q "^drwxrwxr-x *[0-9][0-9]* *$owner *$group "
+ then
+ echo OK
+ else
+ echo -n "BAD "
+ ls -ld $path
+ fi
+ elif [ -f $path ]
+ then
+ # expect
+ # -rw-rw-r-- 1 pcp pcp 1729 Aug 8 07:24 /etc/pcp/pmie/control
+ #
+ if ls -l $path | grep -q "^-rw-rw-r-- *[0-9][0-9]* *$owner *$group "
+ then
+ echo OK
+ else
+ echo -n "BAD "
+ ls -l $path
+ fi
+ else
+ echo "Eh? missing"
+ fi
+done
+
diff --git a/build/tar/postinstall.head.in b/build/tar/postinstall.head.in
new file mode 100644
index 0000000..1de0232
--- /dev/null
+++ b/build/tar/postinstall.head.in
@@ -0,0 +1,9 @@
+#!/bin/sh
+#
+# Generic script to be run after installing PCP from a tarball
+#
+
+# The new place ... this should match the setting in /etc/pcp.conf
+# _after_ the installation
+#
+PCP_TMP_DIR=@pcp_tmp_dir@
diff --git a/build/tar/postinstall.tail b/build/tar/postinstall.tail
new file mode 100755
index 0000000..3d3ee66
--- /dev/null
+++ b/build/tar/postinstall.tail
@@ -0,0 +1,230 @@
+sts=0
+tmp=/var/tmp
+trap "rm -f $tmp.*; exit \$sts" 0 1 2 3 15
+
+if [ ! -f /etc/pcp.env ]
+then
+ # PCP not installed ... seems odd
+ #
+ echo "Error: /etc/pcp.env not installed!"
+ sts=1
+ exit
+fi
+
+. /etc/pcp.env
+
+# no need to touch $PCP_VAR_DIR/pmns/.NeedRebuild as this file
+# is included in the tarball
+#
+
+for conf in \
+ $PCP_PMCDCONF_PATH $PCP_PMCDOPTIONS_PATH $PCP_PMCDRCLOCAL_PATH \
+ $PCP_PMIECONTROL_PATH $PCP_PMLOGGERCONTROL_PATH \
+ $PCP_PMPROXYOPTIONS_PATH $PCP_PMWEBDOPTIONS_PATH
+do
+ if [ -f "$conf.pre" -a -f "$conf" ]
+ then
+ if diff "$conf" "$conf.pre" >/dev/null 2>&1
+ then
+ rm -f "$conf.pre"
+ else
+ mv "$conf" "$conf.dist"
+ mv "$conf.pre" "$conf"
+ echo "Warning: $conf: original restored, new version in $conf.dist"
+ fi
+ fi
+done
+
+_clean_tmpdirs $PCP_TMP_DIR /var/tmp mmv pmdabash pmie pmlogger
+
+# set up pcp and pcpqa users
+#
+if [ -f /etc/passwd ]
+then
+ # things like useradd may be hiding in odd places ...
+ #
+ PATH=$PATH:/usr/sbin
+ # common command-line options
+ # -c comment
+ # -g primary_group_name
+ # -d home_directory
+ # -m create home directory
+ # -s shell
+ # command-line variations
+ # do not create home directory
+ # -M for Linux, nothing for netbsd
+ # system account (no aging, sys gid/uid range, no home dir creation)
+ # -r for Linux, not supported for netbsd
+ #
+ if [ $PCP_PLATFORM = netbsd ]
+ then
+ no_home_dir=''
+ sys_acc=''
+ nologin=/sbin/nologin
+ bash=/usr/pkg/bin/bash
+ elif [ $PCP_PLATFORM = solaris ]
+ then
+ no_home_dir=''
+ sys_acc=''
+ nologin=`which false`
+ bash=`which bash`
+ else
+ no_home_dir='-M'
+ sys_acc='-r'
+ nologin=/usr/sbin/nologin
+ bash=/bin/bash
+ fi
+ if grep '^pcp:' /etc/group >/dev/null
+ then
+ :
+ else
+ if which groupadd >/dev/null 2>&1
+ then
+ groupadd $sys_acc pcp
+ else
+ if [ $PCP_PLATFORM = freebsd ]
+ then
+ : adduser does this for us ...
+ else
+ echo "postinstall: Error: don't know how to add group \"pcp\""
+ sts=1
+ exit
+ fi
+ fi
+ fi
+ if grep '^pcp:' /etc/passwd >/dev/null
+ then
+ :
+ else
+ if which useradd >/dev/null 2>&1
+ then
+ useradd -c "Performance Co-Pilot" -g pcp -d /var/lib/pcp $no_home_dir $sys_acc -s $nologin pcp
+ elif which adduser >/dev/null 2>&1
+ then
+ echo "pcp::::::Performance Co-Pilot:/var/lib/pcp::" \
+ | adduser -f - -w no
+ else
+ echo "postinstall: Error: don't know how to add user \"pcp\""
+ sts=1
+ exit
+ fi
+ fi
+ if grep '^pcpqa:' /etc/group >/dev/null
+ then
+ :
+ else
+ if which groupadd >/dev/null 2>&1
+ then
+ groupadd $sys_acc pcpqa
+ else
+ if [ $PCP_PLATFORM = freebsd ]
+ then
+ : adduser does this for us ...
+ else
+ echo "postinstall: Error: don't know how to add group \"pcpqa\""
+ sts=1
+ exit
+ fi
+ fi
+ fi
+ if grep '^pcpqa:' /etc/passwd >/dev/null
+ then
+ :
+ else
+ if which useradd >/dev/null 2>&1
+ then
+ useradd -c "PCP Quality Assurance" -g pcpqa -d /var/lib/pcp/testsuite $no_home_dir $sys_acc -s $bash pcpqa
+ elif which adduser >/dev/null 2>&1
+ then
+ # no bash for default FreeBSD
+ bash=`which sh`
+ echo "pcpqa::::::PCP Quality Assurance:/var/lib/pcp/testsuite:$bash:" \
+ | adduser -f - -w no
+ else
+ echo "postinstall: Error: don't know how to add user \"pcpqa\""
+ sts=1
+ exit
+ fi
+ fi
+fi
+
+# permissions ...
+#
+# pcp:pcp and mode 775 directories
+#
+for dir in $PCP_LOG_DIR \
+ $PCP_LOG_DIR/pmcd $PCP_LOG_DIR/pmie $PCP_LOG_DIR/pmwebd \
+ $PCP_LOG_DIR/pmproxy $PCP_LOG_DIR/pmlogger $PCP_LOG_DIR/pmmgr \
+ $PCP_RUN_DIR \
+ $PCP_VAR_DIR/tmp $PCP_VAR_DIR/tmp/pmie $PCP_VAR_DIR/tmp/pmlogger \
+ $PCP_VAR_DIR/config/pmda \
+ $PCP_SYSCONF_DIR/pmie $PCP_SYSCONF_DIR/pmlogger
+do
+ [ -d $dir ] || mkdir $dir
+ chmod 775 $dir
+ chown pcp:pcp $dir
+done
+
+# pcp:pcp and mode 664 files
+#
+for file in $PCP_SYSCONF_DIR/pmie/control $PCP_SYSCONF_DIR/pmlogger/control
+do
+ [ -f $file ] || continue
+ chmod 664 $file
+ chown pcp:pcp $file
+done
+
+# pcpqa:pcpqa and mode 755 dir and all below there
+#
+[ -d $PCP_VAR_DIR/testsuite ] || mkdir $PCP_VAR_DIR/testsuite
+chmod 775 $PCP_VAR_DIR/testsuite
+chown -R pcpqa:pcpqa $PCP_VAR_DIR/testsuite
+
+# Note: do not start pcp, pmwebd, pmproxy nor pmmgr by default
+#
+if which svcs >/dev/null 2>&1
+then
+ # in Solaris land, we need an XML file to control all of this
+ #
+ if [ ! -f ../sun/pcp.xml ]
+ then
+ echo "Warning: Solaris SMF XML missing: ../sun/pcp.xml"
+ else
+ svccfg import ../sun/pcp.xml
+ fi
+else
+ for svc in pcp pmcd pmlogger pmproxy pmwebd pmmgr
+ do
+ if which rc-update >/dev/null 2>&1
+ then
+ if rc-update show | grep " $svc " >/dev/null 2>&1
+ then
+ # service is already installed ...
+ #
+ rc-update delete $svc
+ fi
+ rc-update add $svc
+ fi
+
+ # disable or enable and start as required by default policy
+ case $svc
+ in
+ pmcd|pmlogger|pmie)
+ if which rc-update >/dev/null 2>&1
+ then
+ : TODO?
+ fi
+ $PCP_RC_DIR/$svc start
+ ;;
+ *)
+ if which rc-update >/dev/null 2>&1
+ then
+ : TODO?
+ fi
+ ;;
+ esac
+
+ done
+fi
+
+exit
diff --git a/build/tar/preinstall.head.in b/build/tar/preinstall.head.in
new file mode 100644
index 0000000..362730f
--- /dev/null
+++ b/build/tar/preinstall.head.in
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# Generic script to be run before installing PCP from a tarball
+#
+
+if [ ! -f /etc/pcp.conf ]
+then
+ echo "No /etc/pcp.conf ... assume PCP not installed or disabled"
+ exit 0
+fi
+
+# The new place ... this should match the setting in /etc/pcp.conf
+# _after_ the installation
+#
+PCP_SYSCONF_DIR=@pcp_sysconf_dir@
+# and same here ...
+#
+PCP_LOG_DIR=@pcp_log_dir@
+[ -d "$PCP_LOG_DIR" ] || mkdir "$PCP_LOG_DIR"
+
+# and some other things we need ...
+#
+PCP_RC_DIR=@pcp_rc_dir@
+PCP_PMCDCONF_PATH=@pcp_pmcdconf_path@
+PCP_PMCDOPTIONS_PATH=@pcp_pmcdoptions_path@
+PCP_PMCDRCLOCAL_PATH=@pcp_pmcdrclocal_path@
+PCP_PMIECONTROL_PATH=@pcp_pmiecontrol_path@
+PCP_PMLOGGERCONTROL_PATH=@pcp_pmloggercontrol_path@
+PCP_PMPROXYOPTIONS_PATH=@pcp_pmproxyoptions_path@
+PCP_PMWEBDOPTIONS_PATH=@pcp_pmwebdoptions_path@
diff --git a/build/tar/preinstall.tail b/build/tar/preinstall.tail
new file mode 100644
index 0000000..f82090c
--- /dev/null
+++ b/build/tar/preinstall.tail
@@ -0,0 +1,35 @@
+# migrate and clean configs
+echo >>$PCP_LOG_DIR/install.log
+date >>$PCP_LOG_DIR/install.log
+for base in pmcd pmie pmlogger pmwebd pmproxy
+do
+ _clean_configs -v 2>>$PCP_LOG_DIR/install.log $PCP_SYSCONF_DIR/$base /var/lib/pcp/config/$base /etc/$base /etc/pcp/$base /etc/sysconfig/$base
+done
+
+for svc in pmproxy pmwebd pmie pmlogger pmcd pcp
+do
+ [ -f $PCP_RC_DIR/$svc ] && $PCP_RC_DIR/$svc stop
+ if which rc-update >/dev/null 2>&1
+ then
+ if rc-update show | grep " $svc " >/dev/null 2>&1
+ then
+ # service is installed ...
+ #
+ rc-update delete $svc
+ fi
+ fi
+done
+
+for conf in \
+ $PCP_PMCDCONF_PATH $PCP_PMCDOPTIONS_PATH $PCP_PMCDRCLOCAL_PATH \
+ $PCP_PMIECONTROL_PATH $PCP_PMLOGGERCONTROL_PATH \
+ $PCP_PMPROXYOPTIONS_PATH $PCP_PMWEBDOPTIONS_PATH
+do
+ if [ -f "$conf" ]
+ then
+ rm -f "$conf.pre"
+ mv "$conf" "$conf.pre"
+ fi
+done
+
+exit 0
diff --git a/build/tar/remove b/build/tar/remove
new file mode 100755
index 0000000..6ebec06
--- /dev/null
+++ b/build/tar/remove
@@ -0,0 +1,122 @@
+#!/bin/sh
+#
+# Generic script to remove PCP after installation from a tarball
+#
+# exit status
+# 0 all OK
+# 1 warnings
+# 2 errors
+#
+
+if [ ! -f /etc/pcp.env ]
+then
+ # PCP not installed before, do nothing
+ #
+ exit 0
+fi
+
+. /etc/pcp.env
+
+# debugging
+#
+RM="echo + rm"
+RMDIR="echo + rmdir"
+WARN="echo Warning:"
+
+# do the work
+#
+RM=rm
+RMDIR=rmdir
+
+for svc in pmproxy pmwebd pmie pcp
+do
+ [ -f $PCP_RC_DIR/$svc ] && $PCP_RC_DIR/$svc stop
+ if which rc-update >/dev/null 2>&1
+ then
+ rc-update delete $svc
+ fi
+done
+
+if [ ! -f pcp-*[0-9].tar.gz ]
+then
+ echo "Error: cannot find tarball matching pcp-*[0-9].tar.gz"
+ exit 1
+fi
+
+sts=0
+
+tar tf pcp-*[0-9].tar.gz \
+| sed -e 's/^\.//' -e 's/^[^/]/\/&/' \
+| while read file
+do
+ if [ -f $file -o -L $file ]
+ then
+ if $RM $file
+ then
+ :
+ else
+ sts=2
+ fi
+ else
+ $WARN "file $file is missing"
+ [ $sts = 0 ] && sts=1
+ fi
+done
+
+for conf in \
+ $PCP_PMCDCONF_PATH $PCP_PMCDOPTIONS_PATH $PCP_PMCDRCLOCAL_PATH \
+ $PCP_PMIECONTROL_PATH $PCP_PMLOGGERCONTROL_PATH \
+ $PCP_PMPROXYOPTIONS_PATH $PCP_PMWEBDOPTIONS_PATH
+do
+ rm -f "$conf.pre" "$conf.dist"
+done
+
+_rmdir_if_empty()
+{
+ if [ "`echo $1/*`" = "$1/*" ]
+ then
+ if $RMDIR "$1"
+ then
+ :
+ else
+ sts=2
+ fi
+ else
+ # directory is not empty
+ $WARN "directory $1 is not empty, not removed"
+ [ $sts = 0 ] && sts=1
+ fi
+}
+
+# some special case cleanup in $PCP_VAR_DIR for files that
+# are known/expected to be created after the installation and
+# so not part of the tarball
+#
+$RM -rf $PCP_VAR_DIR/config/pmda
+$RM -rf $PCP_VAR_DIR/pmns
+$RM -rf $PCP_VAR_DIR/pmdas/simple
+$RM -rf $PCP_VAR_DIR/pmdas/sample
+$RM -f $PCP_VAR_DIR/pmdas/*/*.pag $PCP_VAR_DIR/pmdas/*/*.dir $PCP_VAR_DIR/pmdas/*/*.log
+
+# we leave $PCP_LOG_DIR but clean up everything else that is not
+# empty ... order is a bit tricky, make sure possible leaf directories
+# come before any parent directories
+#
+for dir in $PCP_BINADM_DIR $PCP_INC_DIR $PCP_MPI_DIRS \
+ $PCP_RUN_DIR $PCP_PMDAS_DIR $PCP_VAR_DIR \
+ $PCP_DOC_DIR $PCP_DEMOS_DIR $PCP_SHARE_DIR
+do
+ if [ -d "$dir" ]
+ then
+ find "$dir" -depth -type d \
+ | while read subdir
+ do
+ _rmdir_if_empty "$subdir"
+ done
+ fi
+done
+
+# TODO
+# if $PCP_SYSCONFIG_DIR is not empty (RH sysconfig only?) what to do?
+
+exit $sts