blob: a997c0f4b7b5afecaac1ee111f802e12b43e3e14 [file] [log] [blame] [edit]
#!/bin/sh
# (c) 2010 Quest Software, Inc. All rights reserved
pp_revision="283"
# Copyright 2010 Quest Software, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of Quest Software, Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Please see <http://rc.quest.com/topics/polypkg/> for more information
pp_version="1.0.0.$pp_revision"
pp_copyright="Copyright 2010, Quest Software, Inc. All rights reserved."
pp_opt_debug=false
pp_opt_destdir="$DESTDIR"
pp_opt_install_script=
pp_opt_list=false
pp_opt_no_clean=false
pp_opt_no_package=false
pp_opt_only_front=false
pp_opt_platform=
pp_opt_probe=false
pp_opt_strip=false
pp_opt_save_unstripped=false
pp_opt_vas_platforms=false
pp_opt_wrkdir="`pwd`/pp.work.$$"
pp_opt_verbose=false
pp_opt_version=false
pp_opt_input="-"
pp_opt_init_vars=""
pp_opt_eval=
test -n "$PP_NO_CLEAN" && pp_opt_no_clean=true
test -n "$PP_DEBUG" && pp_opt_debug=true
test -n "$PP_VERBOSE" && pp_opt_verbose=true
pp_main_cleanup () {
pp_debug "main_cleanup"
pp_remove_later_now
if $pp_opt_no_clean || test x"$pp_platform" = x"unknown"; then
: no cleanup
else
pp_backend_${pp_platform}_cleanup
$pp_errors && pp_die "Errors during cleanup"
if test -d "$pp_wrkdir"; then
if $pp_opt_debug; then
pp_debug "not removing $pp_wrkdir"
else
pp_verbose rm -rf "$pp_wrkdir"
fi
fi
fi
}
pp_parseopts () {
typeset a n _var _val
while test $# -gt 0; do
# convert -[dilpv] to --long-options
case "$1" in
--?*=?*) n=`echo "$1" | sed -ne 's/^--\([^=]*\)=.*/\1/p'`
a=`echo "$1" | sed -ne 's/^--[^=]*=\(.*\)/\1/p'`
shift
set -- "--$n" "$a" "$@";;
--?*) : ;;
-d) shift; set -- "--debug" "$@";;
-d*) a=`echo "$1" | sed -ne 's/^-.//'`
shift; set -- "--debug" "$@";;
-i) shift; set -- "--install-script" "$@";;
-i*) a=`echo "$1" | sed -ne 's/^-.//'`
shift; set -- "--install-script" "$a" "$@";;
-l) shift; set -- "--list" "$@";;
-l*) a=`echo "$1" | sed -ne 's/^-.//'`
shift; set -- "--list" "$@";;
-p) shift; set -- "--platform" "$@";;
-p*) a=`echo "$1" | sed -ne 's/^-.//'`
shift; set -- "--platform" "$a" "$@";;
-v) shift; set -- "--verbose" "$@";;
-v*) a=`echo "$1" | sed -ne 's/^-.//'`
shift; set -- "--verbose" "$@";;
-\?) shift; set -- "--help" "$@";;
-\?*) a=`echo "$1" | sed -ne 's/^-.//'`
shift; set -- "--help" "$@";;
esac
case "$1" in
--destdir|--eval|--install-script|--platform|--wrkdir)
test $# -ge 2 || pp_error "missing argument to $1";;
esac
case "$1" in
--) shift;break;;
--debug) pp_opt_debug=true; shift;;
--destdir) pp_opt_destdir="$2"; shift;shift;;
--eval) pp_opt_eval="$2"; shift;shift;; # undoc
--install-script) pp_opt_install_script="$2"; shift;shift;;
--list) pp_opt_list=true; shift;;
--no-clean) pp_opt_no_clean=true; shift;;
--no-package) pp_opt_no_package=true; shift;;
--only-front) pp_opt_only_front=true; shift;;
--platform) pp_opt_platform="$2"; shift;shift;;
--probe) pp_opt_probe=true; shift;;
--strip) pp_opt_strip=true; shift;;
--save-unstripped) pp_opt_save_unstripped=true; shift;;
--wrkdir) pp_opt_wrkdir="$2"; shift;shift;;
--vas-platforms) pp_opt_vas_platforms=true; shift;;
--verbose) pp_opt_verbose=true; shift;;
--version) pp_opt_version=true; shift;;
--help) pp_errors=true; shift;;
-) break;;
-*) pp_error "unknown option $1"; shift;;
*) break;;
esac
done
pp_opt_input=-
if test $# -gt 0; then
pp_opt_input="$1"
shift
fi
#-- extra arguments of the form Foo=bar alter *global* vars
while test $# -gt 0; do
case "$1" in
-*) pp_error "unexpected option '$1'"
shift;;
*=*) _val="${1#*=}"
_var=${1%="$_val"}
_val=`echo "$_val"|sed -e 's/[$"\\]/\\&/g'`
pp_debug "setting $_var = \"$_val\""
pp_opt_init_vars="$pp_opt_init_vars$_var=\"$_val\";"
shift;;
*) pp_error "unexpected argument $1'"
shift;;
esac
done
test $# -gt 0 &&
pp_error "unknown argument $1"
if $pp_errors; then
cat <<. >&2
polypkg $pp_version $pp_copyright
usage: $0 [options] [input.pp] [var=value ...]
-d --debug -- write copious info to stderr
--destdir=path -- file root, defaults to \$DESTDIR
-? --help -- display this information
-i --install-script=path -- create an install helper script
-l --list -- write package filenames to stdout
--no-clean -- don't remove temporary files
--no-package -- do everything but create packages
--only-front -- only perform front-end actions
-p --platform=platform -- defaults to local platform
--probe -- print local system identifier, then exit
--strip -- strip debug symbols from binaries before
packaging (modifies files in destdir)
--save-unstripped -- save unstripped binaries to
\$name-\$version-unstripped.tar.gz
--wrkdir=path -- defaults to subdirectory of \$TMPDIR or /tmp
-v --verbose -- write info to stderr
--version -- display version and quit
.
exit 1
fi
}
pp_drive () {
# initialise the front and back ends
pp_model_init
pp_frontend_init
$pp_opt_only_front || pp_backend_init
# run the front-end to generate the intermediate files
# set $pp_input_dir to be the 'include dir' if needed
pp_debug "calling frontend on $pp_opt_input"
case "$pp_opt_input" in
-) pp_input_dir=.
test -t 1<&0 &&
pp_warn "reading directives from standard input"
pp_frontend
;;
*/*) pp_input_dir=${pp_opt_input%/*}
pp_frontend <"$pp_opt_input"
;;
*) pp_input_dir=.
pp_frontend <"$pp_opt_input"
;;
esac
pp_files_ignore_others
pp_service_scan_groups
# some sanity checks after front-end processing
if test x"$pp_platform" != x"null"; then
pp_debug "sanity checks"
test -n "$pp_components" || pp_error "No components?"
pp_check_var_is_defined "name"
pp_check_var_is_defined "version"
pp_files_check_duplicates
pp_files_check_coverage
pp_die_if_errors "Errors during sanity checks"
fi
# stop now if we're only running the front
$pp_opt_only_front && return
if test x"$pp_opt_strip" = x"true"; then
pp_strip_binaries
fi
# run the back-end to generate the package
pp_debug "calling backend"
pp_backend
pp_die_if_errors "Errors during backend processing"
# copy the resulting package files to PP_PKGDESTDIR or .
for f in `pp_backend_names` -; do
test x"$f" = x"-" && continue
pp_debug "copying: $f to `pwd`"
if pp_verbose cp -r $pp_wrkdir/$f ${PP_PKGDESTDIR:-.}; then
echo "${PP_PKGDESTDIR:+$PP_PKGDESTDIR/}$f"
else
pp_error "$f: missing package"
fi
done
pp_die_if_errors "Errors during package copying"
}
pp_install_script () {
pp_debug "writing install script to $pp_opt_install_script"
rm -f $pp_opt_install_script
pp_backend_install_script > $pp_opt_install_script
pp_die_if_errors "Errors during package install script"
chmod +x $pp_opt_install_script
}
pp_main () {
# If PP_DEV_PATH is set, then jump to that script.
# (Useful when working on polypkg source that isn't installed)
if test -n "$PP_DEV_PATH" -a x"$PP_DEV_PATH" != x"$0"; then
pp_warn "switching from $0 to $PP_DEV_PATH ..."
exec "$PP_DEV_PATH" "$@" || exit 1
fi
pp_set_expand_converter_or_reexec "$@"
pp_parseopts "$@"
if $pp_opt_version; then
#-- print version and exit
echo "polypkg $pp_version"
exit 0
fi
pp_set_platform
trap 'pp_main_cleanup' 0
pp_wrkdir="$pp_opt_wrkdir"
pp_debug "pp_wrkdir = $pp_wrkdir"
rm -rf "$pp_wrkdir"
mkdir -p "$pp_wrkdir"
pp_destdir="$pp_opt_destdir"
pp_debug "pp_destdir = $pp_destdir"
if $pp_opt_probe; then
pp_backend_init
pp_backend_probe
elif $pp_opt_vas_platforms; then
pp_backend_init
pp_backend_vas_platforms
elif test -n "$pp_opt_eval"; then
#-- execute a shell command
eval "$pp_opt_eval" || exit
else
pp_drive
if test -n "$pp_opt_install_script"; then
pp_install_script
fi
fi
exit 0
}
pp_errors=false
if test -n "$TERM" -a -t 1 && (tput op) >/dev/null 2>/dev/null; then
pp_col_redfg=`tput setf 4` 2>/dev/null
pp_col_bluefg=`tput setf 1` 2>/dev/null
pp_col_reset=`tput op` 2>/dev/null
else
pp_col_redfg='['
pp_col_bluefg='['
pp_col_reset=']'
fi
pp__warn () {
if test x"" = x"$pp_lineno"; then
echo "$1 $2" >&2
else
echo "$1 line $pp_lineno: $2" >&2
fi
}
pp_warn () {
pp__warn "pp: ${pp_col_redfg}warning${pp_col_reset}" "$*"
}
pp_error () {
pp__warn "pp: ${pp_col_redfg}error${pp_col_reset}" "$*"
pp_errors=true
}
pp_die () {
pp_error "$@"
exit 1
}
pp_die_if_errors () {
$pp_errors && pp_die "$@"
}
pp_debug () {
$pp_opt_debug && echo "${pp_col_bluefg}debug${pp_col_reset} $*" >&2
}
pp_verbose () {
$pp_opt_verbose && echo "pp: ${pp_col_bluefg}info${pp_col_reset} $*" >&2
"$@";
}
pp_substitute () {
sed -e 's,%(\([^)]*\)),`\1`,g' \
-e 's,%{\([^}]*\)},${\1},g' \
-e 's,$,,' |
tr '' '\012' |
sed -e '/^[^]/s/["$`\\]/\\&/g' \
-e 's/^//' \
-e '1s/^/echo "/' \
-e '$s,$,",' \
-e 's,,"echo ",g' |
tr -d '\012' |
tr '' '\012'
echo
}
pp_incr () {
eval "$1=\`expr \$$1 + 1\`"
}
pp_decr () {
eval "$1=\`expr \$$1 - 1\`"
}
pp_check_var_is_defined () {
if eval test -z "\"\$$1\""; then
pp_error "\$$1: not set"
eval "$1=undefined"
fi
}
pp_contains () {
case " $1 " in
*" $2 "*) return 0;;
*) return 1;;
esac
}
pp_contains_all () {
typeset _s _c
_l="$1"; shift
for _w
do
pp_contains "$_l" "$_w" || return 1
done
return 0
}
pp_contains_any () {
typeset _s _c
_l="$1"; shift
for _w
do
pp_contains "$_l" "$_w" && return 0
done
return 1
}
pp_add_to_list () {
if eval test -z \"\$$1\"; then
eval $1='"$2"'
elif eval pp_contains '"$'$1'"' '"$2"'; then
: already there
else
eval $1='"$'$1' $2"'
fi
}
pp_unique () {
typeset result element
result=
for element
do
pp_add_to_list result $element
done
echo $result
}
pp_mode_strip_altaccess () {
case "$1" in
??????????+)
echo `echo "$1" | cut -b -10`;;
*)
echo "$1";;
esac
}
pp_mode_from_ls () {
typeset umode gmode omode smode
set -- `pp_mode_strip_altaccess "$1"`
case "$1" in
?--[-X]??????) umode=0;;
?--[xs]??????) umode=1;;
?-w[-X]??????) umode=2;;
?-w[xs]??????) umode=3;;
?r-[-X]??????) umode=4;;
?r-[xs]??????) umode=5;;
?rw[-X]??????) umode=6;;
?rw[xs]??????) umode=7;;
*) pp_error "bad user mode $1";;
esac
case "$1" in
????--[-S]???) gmode=0;;
????--[xs]???) gmode=1;;
????-w[-S]???) gmode=2;;
????-w[xs]???) gmode=3;;
????r-[-X]???) gmode=4;;
????r-[xs]???) gmode=5;;
????rw[-X]???) gmode=6;;
????rw[xs]???) gmode=7;;
*) pp_error "bad group mode $1";;
esac
case "$1" in
???????--[-T]) omode=0;;
???????--[xt]) omode=1;;
???????-w[-T]) omode=2;;
???????-w[xt]) omode=3;;
???????r-[-T]) omode=4;;
???????r-[xt]) omode=5;;
???????rw[-T]) omode=6;;
???????rw[xt]) omode=7;;
*) pp_error "bad other mode $1";;
esac
case "$1" in
???[-x]??[-x]??[-x]) smode=;;
???[-x]??[-x]??[tT]) smode=1;;
???[-x]??[Ss]??[-x]) smode=2;;
???[-x]??[Ss]??[tT]) smode=3;;
???[Ss]??[-x]??[-x]) smode=4;;
???[Ss]??[-x]??[tT]) smode=5;;
???[Ss]??[Ss]??[-x]) smode=6;;
???[Ss]??[Ss]??[tT]) smode=7;;
*) pp_error "bad set-id mode $1";;
esac
echo "$smode$umode$gmode$omode"
}
pp_find_recurse () {
pp_debug "find: ${1#$pp_destdir}/"
for f in "$1"/.* "$1"/*; do
case "$f" in */.|*/..) continue;; esac # should never happen!
if test -d "$f" -o -f "$f" -o -h "$f"; then
if test -d "$f" -a ! -h "$f"; then
echo "${f#$pp_destdir}/"
pp_find_recurse "$f"
else
echo "${f#$pp_destdir}"
fi
fi
done
}
pp_prepend () {
#test -t && pp_warn "pp_prepend: stdin is a tty?"
if test -f $1; then
pp_debug "prepending to $1"
mv $1 $1._prepend
cat - $1._prepend >$1
rm -f $1._prepend
else
pp_debug "prepend: creating $1"
cat >$1
fi
}
pp_note_file_used() {
echo "$1" >> $pp_wrkdir/all.files
}
pp_create_dir_if_missing () {
case "$1" in
*/) pp_error "pp_create_dir_if_missing: trailing / forbidden";;
"") return 0;;
*) if test ! -d "$pp_destdir$1"; then
pp_debug "fabricating directory $1/"
pp_create_dir_if_missing "${1%/*}"
mkdir "$pp_destdir$1" &&
pp_note_file_used "$1/"
pp_remove_later "$1" &&
chmod ${2:-755} "$pp_destdir$1"
fi;;
esac
}
pp_add_file_if_missing () {
typeset dir
#-- check that the file isn't already declared in the component
if test -s $pp_wrkdir/%files.${2:-run}; then
awk "\$6 == \"$1\" {exit 1}" < $pp_wrkdir/%files.${2:-run} || return 1
fi
pp_create_dir_if_missing "${1%/*}"
pp_debug "fabricating file $1"
echo "f ${3:-755} - - ${4:--} $1" >> $pp_wrkdir/%files.${2:-run}
pp_note_file_used "$1"
pp_remove_later "$1"
return 0
}
pp_add_transient_file () {
test -f "$pp_destdir$1" && pp_die "$pp_destdir$1: exists"
pp_create_dir_if_missing "${1%/*}"
pp_debug "transient file $1"
pp_note_file_used "$1"
pp_remove_later "$1"
}
pp_remove_later () {
{
echo "$1"
test -s $pp_wrkdir/pp_cleanup && cat $pp_wrkdir/pp_cleanup
} > $pp_wrkdir/pp_cleanup.new
mv $pp_wrkdir/pp_cleanup.new $pp_wrkdir/pp_cleanup
}
pp_ls_readlink () {
if test -h "$1"; then
ls -1ld "$1" | sed -ne 's,.* -> ,,p'
else
echo "$1: not a symbolic link" >&2
return 1
fi
}
pp_remove_later_now () {
typeset f
if test -s $pp_wrkdir/pp_cleanup; then
pp_debug "pp_remove_later_now"
while read f; do
pp_debug "removing $pp_destdir$f"
if test -d $pp_destdir$f; then
rmdir $pp_destdir$f
else
rm $pp_destdir$f
fi
done < $pp_wrkdir/pp_cleanup
rm $pp_wrkdir/pp_cleanup
fi
}
pp_readlink() {
pp_debug "&& pp_readlink_fn=$pp_readlink_fn"
if test -n "$pp_readlink_fn"; then
pp_debug "&& calling $pp_readlink_fn $*"
"$pp_readlink_fn" "$@"
else
readlink "$@"
fi
}
pp_install_script_common () {
cat <<-.
# Automatically generated for
# $name $version ($pp_platform)
# by PolyPackage $pp_version
usage () {
case "$1" in
"list-services")
echo "usage: \$0 list-services" ;;
"list-components")
echo "usage: \$0 list-components" ;;
"list-files")
echo "usage: \$0 list-files {cpt...|all}" ;;
"install")
echo "usage: \$0 install {cpt...|all}" ;;
"uninstall")
echo "usage: \$0 uninstall {cpt...|all}" ;;
"start")
echo "usage: \$0 start {svc...}" ;;
"stop")
echo "usage: \$0 stop {svc...}" ;;
"print-platform")
echo "usage: \$0 print-platform" ;;
*)
echo "usage: \$0 [-q] command [args]"
echo " list-services"
echo " list-components"
echo " list-files {cpt...|all}"
echo " install {cpt...|all}"
echo " uninstall {cpt...|all}"
echo " start {svc...}"
echo " stop {svc...}"
echo " print-platform"
;;
esac >&2
exit 1
}
if test x"\$1" = x"-q"; then
shift
verbose () { "\$@"; }
verbosemsg () { : ; }
else
verbose () { echo "+ \$*"; "\$@"; }
verbosemsg () { echo "\$*"; }
fi
.
}
pp_functions () {
typeset func deps allfuncs
allfuncs=
while test $# -gt 0; do
pp_add_to_list allfuncs "$1"
deps=`pp_backend_function "$1:depends"`
shift
set -- `pp_unique "$@" $deps`
done
for func in $allfuncs
do
pp_debug "generating function code for '$1'"
echo ""
echo "$func () {"
case "$func" in
pp_mkgroup|pp_mkuser|pp_havelib) echo <<.;;
if test \$# -lt 1; then
echo "$func: not enough arguments" >&2
return 1
fi
.
esac
pp_backend_function "$func" || cat <<.
echo "$func: not implemented" >&2
return 1
.
echo "}"
done
}
pp_function () {
pp_functions "$1"
}
pp_makevar () {
#-- convert all non alpha/digits to underscores
echo "$*" | tr -c '[a-z][A-Z][0-9]\012' '[_*]'
}
pp_getpwuid () {
awk -F: '$3 == uid { if (!found) print $1; found=1; } END { if (!found) exit 1; }' uid="$1" \
< /etc/passwd || pp_error "no local username for uid $1"
}
pp_getgrgid () {
awk -F: '$3 == gid { if (!found) print $1; found=1; } END { if (!found) exit 1; }' gid="$1" \
< /etc/group || pp_error "no local group for gid $1"
}
pp_backend_function_getopt () {
cat <<'..'
pp_getopt () {
_pp_optstring="$1"; shift; eval `_pp_getopt "$_pp_optstring"`
}
_pp_getopt_meta=s,[\\\\\"\'\`\$\&\;\(\)\{\}\#\%\ \ ],\\\\\&,g
_pp_protect () {
sed "$_pp_getopt_meta" <<. | tr '\012' ' '
$*
.
}
_pp_protect2 () {
sed "s,^..,,$pp_getopt_meta" <<. | tr '\012' ' '
$*
.
}
_pp_nonl () {
tr '\012' ' ' <<.
$*
.
}
_pp_getopt () {
_pp_nonl '_pp_nonl set --; while test $# -gt 0; do case "$1" in "--") shift; break;;'
sed 's/\([^: ]:*\)/<@<\1>@>/g;
s/<@<\(.\):>@>/"-\1") _pp_nonl -"\1"; _pp_protect "$2"; shift; shift;; "-\1"*) _pp_nonl -"\1"; _pp_protect2 "$1"; shift;;/g;s/<@<\(.\)>@>/ "-\1") _pp_nonl -"\1"; shift;; "-\1"*) _pp_nonl -"\1"; _pp_tmp="$1"; shift; set -- -`_pp_protect2 "$_pp_tmp"` "$@";;/g' <<.
$1
.
_pp_nonl '-*) echo "$1: unknown option">&2; return 1;; *) break;; esac; done; _pp_nonl --; while test $# -gt 0; do _pp_nonl "$1"; shift; done; echo'
echo
}
..
}
pp_copy_unstripped () {
typeset filedir realdir
filedir="`dirname ${1#$pp_destdir}`"
realdir="$pp_wrkdir/unstripped/$filedir"
mkdir -p "$realdir"
# Can't use hardlinks because `strip` modifies the original file in-place
cp "$1" "$realdir"
}
pp_package_stripped_binaries () {
(cd "$pp_wrkdir/unstripped" && tar -c .) \
| gzip > "$name-dbg-$version.tar.gz"
rm -rf "$pp_wrkdir/unstripped"
}
pp_strip_binaries () {
if test x"$pp_opt_save_unstripped" = x"true"; then
rm -rf "$pp_wrkdir/unstripped"
mkdir "$pp_wrkdir/unstripped"
fi
for f in `find "$pp_destdir" -type f`; do
if file "$f" | awk '{print $2}' | grep ^ELF >/dev/null 2>&1; then
if test x"$pp_opt_save_unstripped" = x"true"; then
if file "$f" | LC_MESSAGES=C grep 'not stripped' >/dev/null 2>&1; then
pp_debug "Saving unstripped binary $f"
pp_copy_unstripped "$f"
else
pp_debug "$f is already stripped; not saving a copy"
fi
fi
pp_debug "Stripping unnecessary symbols from $f"
strip "$f"
fi
done
if test x"$pp_opt_save_unstripped" = x"true"; then
pp_package_stripped_binaries
fi
}
pp_if_true=0
pp_if_false=0
pp_frontend_init () {
name=
version=
summary="no summary"
description="No description"
copyright="Copyright 2010 Quest Software, Inc. All rights reserved."
#-- if the user supplied extra arguments on the command line
# then load them now.
pp_debug "pp_opt_init_vars=$pp_opt_init_vars"
test -n "$pp_opt_init_vars" && eval "$pp_opt_init_vars"
}
pp_is_qualifier () {
typeset ret
case "$1" in
"["*"]") ret=true;;
*) ret=false;;
esac
pp_debug "is_qualifier: $* -> $ret"
test $ret = true
}
pp_eval_qualifier () {
typeset ret
case "$1" in
"[!$pp_platform]"| \
"[!"*",$pp_platform]"| \
"[!$pp_platform,"*"]"| \
"[!"*",$pp_platform,"*"]") ret=false;;
"[!"*"]") ret=true;;
"[$pp_platform]"| \
"["*",$pp_platform]"| \
"[$pp_platform,"*"]"| \
"["*",$pp_platform,"*"]") ret=true;;
"["*"]") ret=false;;
*) pp_die "pp_eval_qualifier: bad qualifier '$1'"
esac
pp_debug "eval: $* -> $ret"
test true = $ret
}
pp_frontend_if () {
typeset ifcmd ifret
ifcmd="$1";
shift
case "$ifcmd" in
%if) if test 0 = $pp_if_false; then
case "$*" in
true |1) pp_incr pp_if_true;;
false|0) pp_incr pp_if_false;;
*)
ifret=true
if pp_is_qualifier "$*"; then
pp_eval_qualifier "$*" || ifret=false
else
eval test "$@" || ifret=false
pp_debug "evaluating test $* -> $ifret"
fi
pp_incr pp_if_$ifret
;;
esac
else
pp_incr pp_if_false
fi;;
%else) test $# = 0 || pp_warn "ignoring argument to %else"
if test $pp_if_false -gt 1; then
: no change
elif test $pp_if_false = 1; then
pp_incr pp_if_true
pp_decr pp_if_false
elif test $pp_if_true = 0; then
pp_die "unmatched %else"
else
pp_incr pp_if_false
pp_decr pp_if_true
fi;;
%endif) test $# = 0 || pp_warn "ignoring argument to %endif"
if test $pp_if_false -gt 0; then
pp_decr pp_if_false
elif test $pp_if_true -gt 0; then
pp_decr pp_if_true
else
pp_die "unmatched %endif"
fi;;
*) pp_die "frontend_if: unknown cmd $ifcmd";;
esac
}
pp_frontend () {
typeset section newsection sed_word sed_ws line cpt svc
typeset section_enabled newsection_enabled s sed sed_candidate
section='%_initial'
newsection='%_initial'
section_enabled=:
newsection_enabled=:
sed_word="[a-zA-Z_][a-zA-Z_0-9]*"
sed_ws="[ ]"
#-- not all seds are created equal
sed=
for sed_candidate in ${PP_SED:-sed} /usr/xpg4/bin/sed; do
if echo 'foo' | $sed_candidate -ne '/^\(x\)*foo/p' | grep foo > /dev/null
then
sed="$sed_candidate"
break
fi
done
test -z "$sed" &&
pp_die "sed is broken on this system"
pp_lineno=0
#-- Note: this sed script should perform similar to pp_eval_qualifier()
$sed -e "/^#/s/.*//" \
-e "/^\\[!\\($sed_word,\\)*$pp_platform\\(,$sed_word\\)*\\]/s/.*//" \
-e "s/^\\[\\($sed_word,\\)*$pp_platform\\(,$sed_word\\)*\\]$sed_ws*//" \
-e "s/^\\[!\\($sed_word,\\)*$sed_word\\]$sed_ws*//" \
-e "/^\\[\\($sed_word,\\)*$sed_word\\]/s/.*//" \
-e "s/^%$sed_ws*/%/" \
-e "s/^$sed_ws/%\\\\&/" \
> $pp_wrkdir/frontend.tmp
#-- add an ignore section at the end to force section completion
echo '%ignore' >> $pp_wrkdir/frontend.tmp
echo >> $pp_wrkdir/frontend.tmp
exec 0<$pp_wrkdir/frontend.tmp
: > $pp_wrkdir/tmp
: > $pp_wrkdir/%fixup
while read -r line; do
#-- Convert leading double-% to single-%, or switch sections
pp_incr pp_lineno
pp_debug "line $pp_lineno: $line"
set -f
set -- $line
set +f
#pp_debug "line $pp_lineno: $*"
case "$line" in %*)
case "$1" in
%if|%else|%endif)
pp_debug "processing if directive $1"
pp_frontend_if "$@"
continue;;
esac
test 0 -ne $pp_if_false && continue # ignore lines %if'd out
case "$1" in
%set|%fixup|%ignore)
pp_debug "processing new section $1"
newsection="$1"; shift
newsection_enabled=:
if pp_is_qualifier "$1"; then
pp_eval_qualifier "$1" || newsection_enabled=false
shift
fi
test $# -eq 0 || pp_warn "ignoring extra arguments: $line"
continue;;
%pre|%post|%preun|%postup|%postun|%files|%depend|%check)
pp_debug "processing new component section $*"
s="$1"; shift
if test $# -eq 0 || pp_is_qualifier "$1"; then
cpt=run
else
cpt="$1"
shift
fi
newsection="$s.$cpt"
newsection_enabled=:
if test $# -gt 0 && pp_is_qualifier "$1"; then
pp_eval_qualifier "$1" || newsection_enabled=false
shift
fi
test $# -eq 0 ||
pp_warn "ignoring extra arguments: $line"
case "$cpt" in
run|dbg|doc|dev)
$newsection_enabled && pp_add_component "$cpt";;
x-*) :;; # useful for discarding stuff
*) pp_error "unknown component: $1 $cpt";;
esac
continue;;
%pp)
newsection="%ignore"; shift
if test $# -gt 0; then
pp_set_api_version "$1"
shift
else
pp_error "%pp: missing version"
fi
test $# -gt 0 &&
pp_error "%pp: too many arguments"
continue;;
%service)
pp_debug "processing new service section $1 $2"
s="$1"; shift
if test $# -eq 0 || pp_is_qualifier "$1"; then
pp_error "$s: service name required"
svc=unknown
else
svc="$1"; shift
fi
newsection="$s.$svc"
newsection_enabled=:
if test $# -gt 0 && pp_is_qualifier "$1"; then
pp_eval_qualifier "$1" || newsection_enabled=false
shift
fi
test $# -eq 0 ||
pp_warn "ignoring extra arguments: $line"
$newsection_enabled && pp_add_service "$svc"
continue;;
%\\*)
pp_debug "removing leading %\\"
line="${line#??}"
pp_debug " result is <$line>"
set -f
set -- $line
set +f
;;
%%*)
pp_debug "removing leading %"
line="${line#%}"
set -f
set -- $line
set +f
;;
%*)
pp_error "unknown section $1"
newsection='%ignore'
newsection_enabled=:
continue;;
esac;;
esac
test 0 != $pp_if_false && continue # ignore lines %if'd out
pp_debug "section=$section (enabled=$section_enabled) newsection=$newsection (enabled=$newsection_enabled)"
#-- finish processing a previous section
if test x"$newsection" != x""; then
$section_enabled && case "$section" in
%ignore|%_initial)
pp_debug "leaving ignored section $section"
: ignore # guaranteed to be the last section
;;
%set)
pp_debug "leaving $section: sourcing $pp_wrkdir/tmp"
$pp_opt_debug && cat $pp_wrkdir/tmp >&2
. $pp_wrkdir/tmp
: > $pp_wrkdir/tmp
;;
%pre.*|%preun.*|%post.*|%postup.*|%postun.*|%depend.*|%check.*|%service.*|%fixup)
pp_debug "leaving $section: substituting $pp_wrkdir/tmp"
# cat $pp_wrkdir/tmp >&2 # debugging
$pp_opt_debug && pp_substitute < $pp_wrkdir/tmp >&2
pp_substitute < $pp_wrkdir/tmp > $pp_wrkdir/tmp.sh
. $pp_wrkdir/tmp.sh >> $pp_wrkdir/$section ||
pp_error "shell error in $section"
rm -f $pp_wrkdir/tmp.sh
: > $pp_wrkdir/tmp
;;
esac
section="$newsection"
section_enabled="$newsection_enabled"
newsection=
fi
#-- ignore section content that is disabled
$section_enabled || continue
#-- process some lines in-place
case "$section" in
%_initial)
case "$line" in "") continue;; esac # ignore non-section blanks
pp_die "Ignoring text before % section introducer";;
%set|%pre.*|%preun.*|%post.*|%postup.*|%postun.*|%check.*|%service.*|%fixup)
pp_debug "appending line to \$pp_wrkdir/tmp"
echo "$line" >> $pp_wrkdir/tmp
;;
%files.*)
test $# -eq 0 && continue;
pp_files_expand "$@" >> $pp_wrkdir/$section
;;
%depend.*)
pp_debug "Adding explicit dependency $@ to $cpt"
echo "$@" >> $pp_wrkdir/%depend.$cpt
;;
esac
done
exec <&-
if test $pp_if_true != 0 -o $pp_if_false != 0; then
pp_die "missing %endif at end of file"
fi
pp_lineno=
pp_debug " name = $name"
pp_debug " version = $version"
pp_debug " summary = $summary"
pp_debug " description = $description"
pp_debug " copyright = $copyright"
pp_debug ""
pp_debug "\$pp_components: $pp_components"
pp_debug "\$pp_services: $pp_services"
}
pp_set_api_version() {
case "$1" in
1.0) : ;;
*) pp_error "This version of polypackage is too old";;
esac
}
pp_platform=
pp_set_platform () {
if test -n "$pp_opt_platform"; then
pp_contains "$pp_platforms" "$pp_opt_platform" ||
pp_die "$pp_opt_platform: unknown platform"
pp_platform="$pp_opt_platform"
else
uname_s=`uname -s 2>/dev/null`
pp_platform=
for p in $pp_platforms; do
pp_debug "probing for platform $p"
if eval pp_backend_${p}_detect "$uname_s"; then
pp_platform="$p"
break;
fi
done
test -z "$pp_platform" &&
pp_die "cannot detect platform (supported: $pp_platforms)"
fi
pp_debug "pp_platform = $pp_platform"
}
pp_expand_path=
pp_expand_test_usr_bin () {
awk '$1 == "/usr" || $2 == "/usr" {usr++}
$1 == "/bin" || $2 == "/bin" {bin++}
END { if (usr == 1 && bin == 1) exit(0); else exit(1); }'
}
pp_set_expand_converter_or_reexec () {
test -d /usr -a -d /bin ||
pp_die "missing /usr or /bin"
echo /usr /bin | pp_expand_test_usr_bin || pp_die "pp_expand_test_usr_bin?"
if (eval "echo /{usr,bin}" | pp_expand_test_usr_bin) 2>/dev/null; then
pp_expand_path=pp_expand_path_brace
elif (eval "echo /@(usr|bin)" | pp_expand_test_usr_bin) 2>/dev/null; then
pp_expand_path=pp_expand_path_at
else
test x"$pp_expand_rexec" != x"true" ||
pp_die "problem finding shell that can do brace expansion"
for shell in ksh ksh93 bash; do
if ($shell -c 'echo /{usr,bin}' |
pp_expand_test_usr_bin) 2>/dev/null ||
($shell -c 'echo /@(usr|bin)' |
pp_expand_test_usr_bin) 2>/dev/null
then
pp_debug "switching to shell $shell"
pp_expand_rexec=true exec $shell "$0" "$@"
fi
done
pp_die "cannot find a shell that does brace expansion"
fi
}
pp_expand_path_brace () {
typeset f
eval "for f in $1; do echo \"\$f\"; done|sort -u"
}
pp_expand_path_at () {
typeset f
eval "for f in `
echo "$1" | sed -e 's/{/@(/g' -e 's/}/)/g' -e 's/,/|/g'
`; do echo \"\$f\"; done|sort -u"
}
pp_shlib_suffix='.so*'
pp_model_init () {
#@ $pp_components: whitespace-delimited list of components seen in %files
pp_components=
#@ $pp_services: whitespace-delimited list of %service seen
pp_services=
rm -f $pp_wrkdir/%files.* \
$pp_wrkdir/%post.* \
$pp_wrkdir/%pre.* \
$pp_wrkdir/%preun.* \
$pp_wrkdir/%postup.* \
$pp_wrkdir/%postun.* \
$pp_wrkdir/%service.* \
$pp_wrkdir/%set \
$pp_wrkdir/%fixup
}
pp_have_component () {
pp_contains "$pp_components" "$1"
}
pp_have_all_components () {
pp_contains_all "$pp_components" "$@"
}
pp_add_component () {
pp_add_to_list 'pp_components' "$1"
}
pp_add_service () {
pp_add_to_list 'pp_services' "$1"
}
pp_service_init_vars () {
cmd=
pidfile=
stop_signal=15 # SIGTERM
user=root
group=
enable=yes # make it so the service starts on boot
optional=no # Whether installing this service is optional
pp_backend_init_svc_vars
}
pp_service_check_vars () {
test -n "$cmd" ||
pp_error "%service $1: cmd not defined"
case "$enable" in
yes|no) : ;;
*) pp_error "%service $1: \$enable must be set to yes or no";;
esac
}
pp_load_service_vars () {
pp_service_init_vars
. "$pp_wrkdir/%service.$1"
pp_service_check_vars "$1"
}
pp_files_expand () {
typeset _p _mode _group _owner _flags _path _optional _has_target _tree
typeset _path _file _tgt _m _o _g _f _type _lm _ll _lo _lg _ls _lx
typeset _ignore _a
test $# -eq 0 && return
pp_debug "pp_files_expand: path is: $1"
case "$1" in "#"*) return;; esac
_p="$1"; shift
pp_debug "pp_files_expand: other arguments: $*"
#-- the mode must be an octal number of at least three digits
_mode="="
_a=`eval echo \"$1\"`
case "$_a" in
*:*) :;;
-|=|[01234567][01234567][01234567]*) _mode="$_a"; shift;;
esac
#-- the owner:group field may have optional parts
_a=`eval echo \"$1\"`
case "$_a" in
*:*) _group=${_a#*:}; _owner=${_a%:*}; shift;;
=|-) _group=$_a; _owner=$_a; shift;;
*) _group=; _owner=;;
esac
#-- process the flags argument
_flags=
_optional=false
_has_target=false
_ignore=false
if test $# -gt 0; then
_a=`eval echo \"$1\"`
case ",$_a," in *,volatile,*) _flags="${_flags}v";; esac
case ",$_a," in *,optional,*) _optional=true;; esac
case ",$_a," in *,symlink,*) _has_target=true;; esac
case ",$_a," in *,ignore-others,*) _flags="${_flags}i";; esac
case ",$_a," in *,ignore,*) _ignore=true;; esac
shift
fi
#-- process the target argument
if $_has_target; then
test $# -ne 0 || pp_error "$_p: missing target"
_a=`eval echo \"$1\"`
_target="$_a"
shift
fi
pp_debug "pp_files_expand: $_mode|$_owner:$_group|$_flags|$_target|$*"
test $# -eq 0 || pp_error "$_p: too many arguments"
#-- process speciall suffixes
tree=
case "$_p" in
*"/**") _p="${_p%"/**"}"; tree="**";;
*".%so") _p="${_p%".%so"}$pp_shlib_suffix";;
esac
#-- expand the path using the shell glob
pp_debug "expanding .$_p ... with $pp_expand_path"
(cd ${pp_destdir} && $pp_expand_path ".$_p") > $pp_wrkdir/tmp.files.exp
#-- expand path/** by rewriting the glob output file
case "$tree" in
"") : ;;
"**")
pp_debug "expanding /** tree ..."
while read _path; do
_path="${_path#.}"
pp_find_recurse "$pp_destdir${_path%/}"
done < $pp_wrkdir/tmp.files.exp |
sort -u > $pp_wrkdir/tmp.files.exp2
mv $pp_wrkdir/tmp.files.exp2 $pp_wrkdir/tmp.files.exp
;;
esac
while read _path; do
_path="${_path#.}"
_file="${pp_destdir}${_path}"
_tgt=
_m="$_mode"
_o="${_owner:--}"
_g="${_group:--}"
_f="$_flags"
case "$_path" in
/*) :;;
*) pp_warn "$_path: inserting leading /"
_path="/$_path";; # ensure leading /
esac
#-- sanity checks
case "$_path" in
*/../*|*/..) pp_error "$_path: invalid .. in path";;
*/./*|*/.) pp_warn "$_path: invalid component . in path";;
*//*) pp_warn "$_path: redundant / in path";;
esac
#-- set the type based on the real file's type
if $_ignore; then
_type=f _m=_ _o=_ _g=_
elif test -h "$_file"; then
case "$_path" in
*/) pp_warn "$_path (symlink $_file): removing trailing /"
_path="${_path%/}"
;;
esac
_type=s
if test x"$_target" != x"=" -a -n "$_target"; then
_tgt="$_target"
pp_debug "symlink target is $_tgt"
else
_tgt=`pp_readlink "$_file"`;
test -z "$_tgt" && pp_error "can't readlink $_file"
case "$_tgt" in
${pp_destdir}/*)
pp_warn "stripped \$destdir from symlink ($_path)"
_tgt="${_tgt#$pp_destdir}";;
esac
fi
_m=777
elif test -d "$_file"; then
#-- display a warning if the user forgot the trailing /
case "$_path" in
*/) :;;
*) pp_warn "$_path (matching $_file): adding trailing /"
_path="$_path/";;
esac
_type=d
$_has_target && pp_error "$_file: not a symlink"
elif test -f "$_file"; then
case "$_path" in
*/) pp_warn "$_path (matching $_file): removing trailing /"
_path="${_path%/}"
;;
esac
_type=f
$_has_target && pp_error "$_file: not a symlink"
else
$_optional && continue
pp_error "$_file: missing"
_type=f
fi
#-- convert '=' shortcuts into mode/owner/group from ls
case ":$_m:$_o:$_g:" in *:=:*)
if LS_OPTIONS=--color=never /bin/ls -ld "$_file" \
> $pp_wrkdir/ls.tmp
then
read _lm _ll _lo _lg _ls _lx < $pp_wrkdir/ls.tmp
test x"$_m" = x"=" && _m=`pp_mode_from_ls "$_lm"`
test x"$_o" = x"=" && _o="$_lo"
test x"$_g" = x"=" && _g="$_lg"
else
pp_error "cannot read $_file"
test x"$_m" = x"=" && _m=-
test x"$_o" = x"=" && _o=-
test x"$_g" = x"=" && _g=-
fi
;;
esac
test -n "$_f" || _f=-
#-- sanity checks
test -n "$_type" || pp_die "_type empty"
test -n "$_path" || pp_die "_path empty"
test -n "$_m" || pp_die "_m empty"
test -n "$_o" || pp_die "_o empty"
test -n "$_g" || pp_die "_g empty"
#-- setuid/gid files must be given an explicit owner/group (or =)
case "$_o:$_g:$_m" in
-:*:[4657][1357]??|-:*:[4657]?[1357]?|-:*:[4657]??[1357])
pp_error "$_path: setuid file ($_m) missing explicit owner";;
*:-:[2367][1357]??|*:-:[2367]?[1357]?|*:-:[2367]??[1357])
pp_error "$_path: setgid file ($_m) missing explicit group";;
esac
# convert numeric uids into usernames; only works for /etc/passwd
case "$_o" in [0-9]*) _o=`pp_getpwuid $_o`;; esac
case "$_g" in [0-9]*) _g=`pp_getgrgid $_g`;; esac
pp_debug "$_type $_m $_o $_g $_f $_path" $_tgt
$_ignore || echo "$_type $_m $_o $_g $_f $_path" $_tgt
pp_note_file_used "$_path"
case "$_f" in *i*) echo "$_path" >> $pp_wrkdir/ign.files;; esac
done < $pp_wrkdir/tmp.files.exp
}
pp_files_check_duplicates () {
typeset _path
if test -s $pp_wrkdir/all.files; then
sort < $pp_wrkdir/all.files | uniq -d > $pp_wrkdir/duplicate.files
if test -f $pp_wrkdir/ign.awk; then
# Remove ignored files
mv $pp_wrkdir/duplicate.files $pp_wrkdir/duplicate.files.ign
sed -e 's/^/_ _ _ _ _ /' < $pp_wrkdir/duplicate.files.ign |
awk -f $pp_wrkdir/ign.awk |
sed -e 's/^_ _ _ _ _ //' > $pp_wrkdir/duplicate.files
fi
while read _path; do
pp_warn "$_path: file declared more than once"
done <$pp_wrkdir/duplicate.files
fi
}
pp_files_check_coverage () {
pp_find_recurse "$pp_destdir" | sort > $pp_wrkdir/coverage.avail
if test -s $pp_wrkdir/all.files; then
sort -u < $pp_wrkdir/all.files
else
:
fi > $pp_wrkdir/coverage.used
join -v1 $pp_wrkdir/coverage.avail $pp_wrkdir/coverage.used \
> $pp_wrkdir/coverage.not-packaged
if test -s $pp_wrkdir/coverage.not-packaged; then
pp_warn "The following files/directories were found but not packaged:"
sed -e 's,^, ,' < $pp_wrkdir/coverage.not-packaged >&2
fi
join -v2 $pp_wrkdir/coverage.avail $pp_wrkdir/coverage.used \
> $pp_wrkdir/coverage.not-avail
if test -s $pp_wrkdir/coverage.not-avail; then
pp_warn "The following files/directories were named but not found:"
sed -e 's,^, ,' < $pp_wrkdir/coverage.not-avail >&2
fi
}
pp_files_ignore_others () {
typeset p f
test -s $pp_wrkdir/ign.files || return
#-- for each file in ign.files, we remove it from all the
# other %files.* lists, except where it has an i flag.
# rather than scan each list multiple times, we build
# an awk script
pp_debug "stripping ignore files"
while read p; do
echo '$6 == "'"$p"'" && $5 !~ /i/ { next }'
done < $pp_wrkdir/ign.files > $pp_wrkdir/ign.awk
echo '{ print }' >> $pp_wrkdir/ign.awk
$pp_opt_debug && cat $pp_wrkdir/ign.awk
for f in $pp_wrkdir/%files.*; do
mv $f $f.ign
awk -f $pp_wrkdir/ign.awk < $f.ign > $f || pp_error "awk"
done
}
pp_service_scan_groups () {
typeset svc
#-- scan for "group" commands, and build a list of groups
pp_service_groups=
if test -n "$pp_services"; then
for svc in $pp_services; do
group=
. $pp_wrkdir/%service.$svc
if test -n "$group"; then
pp_contains "$pp_services" "$group" && pp_error \
"%service $svc: group name $group in use by a service"
pp_add_to_list 'pp_service_groups' "$group"
echo "$svc" >> $pp_wrkdir/%svcgrp.$group
fi
done
fi
}
pp_service_get_svc_group () {
(tr '\012' ' ' < $pp_wrkdir/%svcgrp.$1 ; echo) | sed -e 's/ $//'
}
for _sufx in _init '' _names _cleanup _install_script \
_init_svc_vars _function _probe _vas_platforms
do
eval "pp_backend$_sufx () { pp_debug pp_backend$_sufx; pp_backend_\${pp_platform}$_sufx \"\$@\"; }"
done
pp_platforms="$pp_platforms aix"
pp_backend_aix_detect () {
test x"$1" = x"AIX"
}
pp_backend_aix_init () {
pp_aix_detect_arch
pp_aix_detect_os
pp_aix_bosboot= # components that need bosboot
pp_aix_lang=en_US
pp_aix_copyright=
pp_aix_start_services_after_install=false
pp_aix_init_services_after_install=true
case "$pp_aix_os" in
*) pp_readlink_fn=pp_ls_readlink;; # XXX
esac
pp_aix_abis_seen=
}
pp_aix_detect_arch () {
pp_aix_arch_p=`uname -p 2>/dev/null`
case "$pp_aix_arch_p" in
"") pp_debug "can't get processor type from uname -p"
pp_aix_arch_p=powerpc
pp_aix_arch=R;; # guess (lsattr -l proc0 ??)
powerpc) pp_aix_arch=R;;
*) pp_aix_arch_p=intel
pp_aix_arch=I;; # XXX? verify
esac
case "`/usr/sbin/lsattr -El proc0 -a type -F value`" in
PowerPC_POWER*) pp_aix_arch_std=ppc64;;
PowerPC*) pp_aix_arch_std=ppc;;
*) pp_aix_arch_std=unknown;;
esac
}
pp_aix_detect_os () {
typeset r v
r=`uname -r`
v=`uname -v`
pp_aix_os=aix$v$r
}
pp_aix_version_fix () {
typeset v
v=`echo $1 | tr -c -d '[0-9].\012'`
if test x"$v" != x"$1"; then
pp_warn "stripped version '$1' to '$v'"
fi
case $v in
""|*..*|.*|*.) pp_error "malformed '$1'"
echo "0.0.0.0";;
*.*.*.*.*)
# 5 components are only valid for fileset updates, not base
# filesets (full packages). We trim 5+ components down to 4.
pp_warn "version '$1' has too many dots for AIX, truncating"
echo "$v" | cut -d. -f1-4;;
*.*.*.*) echo "$v";;
*.*.*) echo "$v.0";;
*.*) echo "$v.0.0";;
*) echo "$v.0.0.0";;
esac
}
pp_aix_select () {
case "$1" in
-user) op="";;
-root) op="!";;
*) pp_die "pp_aix_select: bad argument";;
esac
#pp_debug awk '$5 '$op' /^\/(usr|opt)(\/|$)/ { print; }'
#awk '$5 '$op' /^\/(usr|opt)(\/|$)/ { print; }'
awk $op'($6 ~ /^\/usr\// || $6 ~ /^\/opt\//) { print; }'
}
pp_aix_copy_root () {
typeset t m o g f p st target
while read t m o g f p st; do
case "$t" in
d) pp_create_dir_if_missing "$1${p%/}";;
f) pp_add_transient_file "$1$p"
pp_verbose ln "$pp_destdir$p" "$pp_destdir$1$p" ||
pp_error "can't link $p into $1";;
*) pp_warn "pp_aix_copy_root: filetype $t not handled";;
esac
done
}
pp_aix_size () {
typeset prefix t m o g f p st
prefix="$1"
while read t m o g f p st; do
case "$t" in f) du -a "$pp_destdir$p";; esac
done | sed -e 's!/[^/]*$!!' | sort +1 |
awk '{ if ($2 != d)
{ if (sz) print d,sz;
d=$2; sz=0 }
sz += $1; }
END { if (sz) print d,sz }' |
sed -n -e "s!^$pp_destdir!$prefix!p"
}
pp_aix_list () {
awk '{ print "." pfx $6; }' pfx="$1"
}
pp_aix_make_liblpp () {
typeset out dn fl f
out="$1"; shift
dn=`dirname "$2"`
fl=
for f
do
case "$f" in "$dn/"*) fl="$fl `basename $f`" ;;
*) pp_die "liblpp name $f not in $dn/";; esac
done
(cd "$dn" && pp_verbose ar -c -g -r "$out" $fl) || pp_error "ar error"
}
pp_aix_make_script () {
rm -f "$1"
echo "#!/bin/sh" > "$1"
cat >> "$1"
echo "exit 0" >> "$1"
chmod +x "$1"
}
pp_aix_inventory () {
typeset fileset t m o g f p st type
fileset="$1"
while read t m o g f p st; do
case "$p" in *:*) pp_error "path $p contains colon";; esac
echo "$p:"
case "$t" in
f) type=FILE; defm=644 ;;
s) type=SYMLINK; defm=777 ;;
d) type=DIRECTORY; defm=755 ;;
esac
echo " type = $type"
echo " class = inventory,apply,$fileset"
set -- `/bin/ls -ld "$pp_destdir$p" 2>/dev/null`
owner=$3 group=$4 size=$5
if test x"$m" = x"-"; then m="$defm"; fi
if test x"$o" = x"-"; then o="root"; fi
if test x"$g" = x"-"; then g="system"; fi
echo " owner = $o"
echo " group = $g"
case "$m" in ????)
m=`echo $m|sed -e 's/^1/TCB,/' \
-e 's/^[23]/TCB,SGID,/' \
-e 's/^[45]/TCB,SUID,/' \
-e 's/^[67]/TCB,SUID,SGID,/'`;; # vtx bit ignored
esac
echo " mode = $m"
case "$t" in
f) if test ! -f "$pp_destdir$p"; then
pp_error "$p: missing file"
fi
case "$flags" in
*v*)
echo " size = VOLATILE"
echo " checksum = VOLATILE"
;;
*)
if test -r "$pp_destdir$p"; then
echo " size = $size"
pp_verbose sum -r < "$pp_destdir$p" |
sed -e 's/.*/ checksum = "&"/'
fi
;;
esac;;
s)
echo " target = $st"
;;
esac
#-- Record ABI types seen
case "$t" in
f) if test -r "$pp_destdir$p"; then
case "`file "$pp_destdir$p"`" in
*"executable (RISC System/6000)"*) abi=ppc;;
*"64-bit XCOFF executable"*) abi=ppc64;;
*) abi=;;
esac
if test -n "$abi"; then
pp_add_to_list pp_aix_abis_seen $abi
fi
fi;;
esac
done
}
pp_aix_depend ()
{
if test -s "$1"; then
pp_warn "aix dependencies not implemented"
fi
}
pp_aix_add_service () {
typeset svc cmd_cmd cmd_arg f
svc="$1"
pp_load_service_vars $svc
set -- $cmd
cmd_cmd="$1"; shift
cmd_arg="$pp_aix_mkssys_cmd_args";
case "$stop_signal" in
HUP) stop_signal=1;;
INT) stop_signal=2;;
QUIT) stop_signal=3;;
KILL) stop_signal=9;;
TERM) stop_signal=15;;
USR1) stop_signal=30;;
USR2) stop_signal=31;;
"")
pp_error "%service $svc: stop_signal not set";;
[a-zA-Z]*)
pp_error "%service $svc: bad stop_signal ($stop_signal)";;
esac
test -z "$pidfile" || pp_error "aix requires empty pidfile (non daemon)"
pp_add_component run
if test "$user" = "root"; then
uid=0
else
uid="\"\`/usr/bin/id -u $user\`\""
fi
#-- add command text to create/remove the service
cat <<-. >> $pp_wrkdir/%post.$svc
svc=$svc
uid=0
cmd_cmd=$daemon
cmd_arg="$cmd_arg"
stop_signal=$stop_signal
force_signal=9
srcgroup="$pp_aix_mkssys_group"
lssrc -s \$svc > /dev/null 2>&1
if [ \$? -eq 0 ]; then
lssrc -s \$svc | grep "active" > /dev/null 2>&1
if [ \$? -eq 0 ]; then
stopsrc -s \$svc > /dev/null 2>&1
fi
rmsys -s \$svc > /dev/null 2>&1
fi
mkssys -s \$svc -u \$uid -p "\$cmd_cmd" \${cmd_arg:+-a "\$cmd_arg"} -S -n \$stop_signal -f 9 ${pp_aix_mkssys_args} \${srcgroup:+-G \$srcgroup}
.
#-- add code to start the service on reboot
${pp_aix_init_services_after_install} &&
cat <<-. >> $pp_wrkdir/%post.$svc
mkitab "\$svc:2:once:/usr/bin/startsrc -s \$svc" > /dev/null 2>&1
.
${pp_aix_start_services_after_install} &&
cat <<-. >> $pp_wrkdir/%post.$svc
startsrc -s \$svc
.
if [ -f "$pp_wrkdir/%post.run" ];then
cat $pp_wrkdir/%post.run >> $pp_wrkdir/%post.$svc
fi
mv $pp_wrkdir/%post.$svc $pp_wrkdir/%post.run
${pp_aix_init_services_after_install} &&
pp_prepend $pp_wrkdir/%preun.$svc <<-.
rmitab $svc
.
pp_prepend $pp_wrkdir/%preun.$svc <<-.
stopsrc -s $svc >/dev/null 2>&1
rmssys -s $svc
.
if [ -f "$pp_wrkdir/%preun.run" ];then
cat $pp_wrkdir/%preun.run >> $pp_wrkdir/%preun.$svc
fi
mv $pp_wrkdir/%preun.$svc $pp_wrkdir/%preun.run
}
pp_backend_aix () {
typeset briefex instuser instroot svc cmp outbff
typeset user_wrkdir root_wrkdir
typeset user_files root_files
test -n "$pp_destdir" ||
pp_error "AIX backend requires the '--destdir' option"
instuser="/usr/lpp/$name"
instroot="$instuser/inst_root"
pp_aix_bff_name=${pp_aix_bff_name:-$name}
# Here is the component mapping:
# run -> $pp_aix_bff_name.rte ('Run time environment')
# doc -> $pp_aix_bff_name.doc (non-standard)
# dev -> $pp_aix_bff_name.adt ('Application developer toolkit')
# dbg -> $pp_aix_bff_name.diag ('Diagnostics')
test `echo "$summary" | wc -c ` -gt 40 && pp_error "\$summary too long"
user_wrkdir=$pp_wrkdir/u
root_wrkdir=$pp_wrkdir/r
pp_verbose rm -rf $user_wrkdir $root_wrkdir
pp_verbose mkdir -p $user_wrkdir $root_wrkdir
for svc in $pp_services .; do
test . = "$svc" && continue
pp_aix_add_service $svc
done
{
echo "4 $pp_aix_arch I $name {"
for cmp in $pp_components; do
case "$cmp" in
run) ex=rte briefex="runtime";;
doc) ex=doc briefex="documentation";;
dev) ex=adt briefex="developer toolkit";;
dbg) ex=diag briefex="diagnostics";;
esac
user_files=$pp_wrkdir/%files.$cmp.u
root_files=$pp_wrkdir/%files.$cmp.r
pp_aix_select -user < $pp_wrkdir/%files.$cmp > $user_files
pp_aix_select -root < $pp_wrkdir/%files.$cmp > $root_files
# Default to USR only unless there are root files,
# or a post/pre/check script associated
content=U
if test -s $root_files \
-o -s $pp_wrkdir/%pre.$cmp \
-o -s $pp_wrkdir/%post.$cmp \
-o -s $pp_wrkdir/%preun.$cmp \
-o -s $pp_wrkdir/%check.$cmp
then
content=B
fi
if $pp_opt_debug; then
echo "$cmp USER %files:"
cat $user_files
echo "$cmp ROOT %files:"
cat $root_files
fi >&2
bosboot=N; pp_contains_any "$pp_aix_bosboot" $cmp && bosboot=b
echo $pp_aix_bff_name.$ex \
${pp_aix_version:-`pp_aix_version_fix "$version"`} \
1 $bosboot $content \
$pp_aix_lang "$summary $briefex"
echo "["
pp_aix_depend $pp_wrkdir/%depend.$cmp
echo "%"
# generate per-directory size information
pp_aix_size < $user_files
pp_aix_size $instroot < $root_files
pp_aix_list < $user_files > $user_wrkdir/$pp_aix_bff_name.$ex.al
pp_aix_list $instroot < $root_files >> $user_wrkdir/$pp_aix_bff_name.$ex.al
pp_aix_list < $root_files > $root_wrkdir/$pp_aix_bff_name.$ex.al
if $pp_opt_debug; then
echo "$cmp USER $pp_aix_bff_name.$ex.al:"
cat $user_wrkdir/$pp_aix_bff_name.$ex.al
echo "$cmp ROOT $pp_aix_bff_name.$ex.al:"
cat $root_wrkdir/$pp_aix_bff_name.$ex.al
fi >&2
pp_aix_inventory $pp_aix_bff_name.$ex < $user_files \
> $user_wrkdir/$pp_aix_bff_name.$ex.inventory
pp_aix_inventory $pp_aix_bff_name.$ex < $root_files \
> $root_wrkdir/$pp_aix_bff_name.$ex.inventory
if $pp_opt_debug; then
pp_debug "$cmp USER $pp_aix_bff_name.$ex.inventory:"
cat $user_wrkdir/$pp_aix_bff_name.$ex.inventory
pp_debug "$cmp ROOT $pp_aix_bff_name.$ex.inventory:"
cat $root_wrkdir/$pp_aix_bff_name.$ex.inventory
fi >&2
if test x"" != x"${pp_aix_copyright:-$copyright}"; then
echo "${pp_aix_copyright:-$copyright}" > $user_wrkdir/$pp_aix_bff_name.$ex.copyright
echo "${pp_aix_copyright:-$copyright}" > $root_wrkdir/$pp_aix_bff_name.$ex.copyright
fi
#-- assume that post/pre uninstall scripts only make
# sense when installed in a root context
if test -r $pp_wrkdir/%pre.$cmp; then
pp_aix_make_script $user_wrkdir/$pp_aix_bff_name.$ex.pre_i \
< $pp_wrkdir/%pre.$cmp
fi
if test -r $pp_wrkdir/%post.$cmp; then
pp_aix_make_script $root_wrkdir/$pp_aix_bff_name.$ex.post_i \
< $pp_wrkdir/%post.$cmp
fi
if test -r $pp_wrkdir/%preun.$cmp; then
pp_aix_make_script $root_wrkdir/$pp_aix_bff_name.$ex.unpost_i \
< $pp_wrkdir/%preun.$cmp
fi
# remove empty files
for f in $user_wrkdir/$pp_aix_bff_name.$ex.* $root_wrkdir/$pp_aix_bff_name.$ex.*; do
if test ! -s "$f"; then
pp_debug "removing empty $f"
rm -f "$f"
fi
done
# copy/link the root files so we can do an easy backup later
pp_aix_copy_root $instroot < $root_files
echo "%"
echo "]"
done
echo "}"
} > $pp_wrkdir/lpp_name
if $pp_opt_debug; then
echo "/lpp_name :"
cat $pp_wrkdir/lpp_name
fi >&2
#-- copy the /lpp_name file to the destdir
pp_add_transient_file /lpp_name
cp $pp_wrkdir/lpp_name $pp_destdir/lpp_name
#-- copy the liblpp.a files under destdir for packaging
(cd $user_wrkdir && pp_verbose ar -c -g -r liblpp.a $name.*) ||
pp_error "ar error"
if test -s $user_wrkdir/liblpp.a; then
pp_add_transient_file $instuser/liblpp.a
pp_verbose cp $user_wrkdir/liblpp.a $pp_destdir$instuser/liblpp.a ||
pp_error "cannot create user liblpp.a"
fi
(cd $root_wrkdir && pp_verbose ar -c -g -r liblpp.a $name.*) ||
pp_error "ar error"
if test -s $root_wrkdir/liblpp.a; then
pp_add_transient_file $instroot/liblpp.a
pp_verbose cp $root_wrkdir/liblpp.a $pp_destdir$instroot/liblpp.a ||
pp_error "cannot create root liblpp.a"
fi
{ echo ./lpp_name
test -s $user_wrkdir/liblpp.a && echo .$instuser/liblpp.a
test -s $root_wrkdir/liblpp.a && echo .$instroot/liblpp.a
cat $user_wrkdir/$name.*.al # includes the relocated root files!
} > $pp_wrkdir/bff.list
if test -n "$pp_aix_abis_seen" -a x"$pp_aix_arch_std" = x"auto"; then
case "$pp_aix_abis_seen" in
"ppc ppc64"|"ppc64 ppc")
pp_aix_arch_std=ppc64
;;
ppc|ppc64)
pp_aix_arch_std=$pp_aix_abis_seen
;;
*" "*)
pp_warn "multiple architectures detected: $pp_aix_abis_seen"
pp_aix_arch_std=unknown
;;
"")
pp_warn "no binary executables detected; using noarch"
pp_aix_arch_std=noarch
;;
*)
pp_warn "unknown architecture detected $pp_aix_abis_seen"
pp_aix_arch_std=$pp_aix_abis_seen
;;
esac
fi
. $pp_wrkdir/%fixup
outbff=`pp_backend_aix_names`
pp_debug "creating: $pp_wrkdir/$outbff"
(cd $pp_destdir && pp_verbose /usr/sbin/backup -i -q -p -f -) \
< $pp_wrkdir/bff.list \
> $pp_wrkdir/$outbff || pp_error "backup failed"
${SUDO:-sudo} /usr/sbin/installp -l -d $pp_wrkdir/$outbff
}
pp_backend_aix_cleanup () {
:
}
pp_backend_aix_names () {
echo "$name.${pp_aix_version:-`pp_aix_version_fix "$version"`}.bff"
}
pp_backend_aix_install_script () {
typeset pkgname platform
#
# The script should take a first argument being the
# operation; further arguments refer to components or services
#
# list-components -- lists components in the pkg
# install component... -- installs the components
# uninstall component... -- uninstalles the components
# list-services -- lists the services in the pkg
# start service... -- starts the name service
# stop service... -- stops the named services
# print-platform -- prints the platform group
#
pkgname="`pp_backend_aix_names`"
platform="`pp_backend_aix_probe`" # XXX should be derived from files
fsets=
for cmp in $pp_components; do
case "$cmp" in
run) ex=rte;;
doc) ex=doc;;
dev) ex=adt;;
dbg) ex=diag;;
esac
fsets="$fsets $name.$ex"
done
echo '#!/bin/sh'
pp_install_script_common
cat <<-.
cpt_to_fileset () {
test x"\$*" = x"all" &&
set -- $pp_components
for cpt
do
case "\$cpt" in
run) echo "$name.rte";;
doc) echo "$name.doc";;
dev) echo "$name.adt";;
dbg) echo "$name.diag";;
*) usage;;
esac
done
}
test \$# -eq 0 && usage
op="\$1"; shift
case "\$op" in
list-components)
test \$# -eq 0 || usage \$op
echo "$pp_components"
;;
list-services)
test \$# -eq 0 || usage \$op
echo "$pp_services"
;;
list-files)
test \$# -ge 1 || usage \$op
echo \${PP_PKGDESTDIR:-.}/$pkgname
;;
install)
test \$# -ge 1 || usage \$op
verbose /usr/sbin/installp -acX -V0 -F \
-d \${PP_PKGDESTDIR:-.}/$pkgname \
\`cpt_to_fileset "\$@"\`
;;
uninstall)
test \$# -ge 1 || usage \$op
verbose /usr/sbin/installp -u -e/dev/null \
-V0 \`cpt_to_fileset "\$@"\`
;;
start|stop)
test \$# -ge 1 || usage \$op
ec=0
for svc
do
verbose \${op}src -s \$svc || ec=1
done
exit \$ec
;;
print-platform)
echo "$platform"
;;
*)
usage;;
esac
.
}
pp_backend_aix_init_svc_vars () {
:
}
pp_backend_aix_probe () {
echo "${pp_aix_os}-${pp_aix_arch_std}"
}
pp_backend_aix_vas_platforms () {
case "${pp_aix_arch_std}" in
ppc*) :;;
*) pp_die "unknown architecture ${pp_aix_arch_std}";;
esac
case "${pp_aix_os}" in
aix43) echo "aix-43";;
aix51) echo "aix-51 aix-43";;
aix52) echo "aix-51 aix-43";;
aix53) echo "aix-53 aix-51 aix-43";;
aix61) echo "aix-53 aix-51 aix-43";;
*) pp_die "unknown system ${pp_aix_os}";;
esac
}
pp_backend_aix_function () {
case $1 in
pp_mkgroup) cat <<'.';;
/usr/sbin/lsgroup "$1" >/dev/null &&
return 0
echo "Creating group $1"
/usr/bin/mkgroup -A "$1"
.
pp_mkuser:depends) echo pp_mkgroup;;
pp_mkuser) cat <<'.';;
/usr/sbin/lsuser "$1" >/dev/null &&
return 0
pp_mkgroup "${2:-$1}" || return 1
echo "Creating user $1"
/usr/bin/mkuser \
login=false \
rlogin=false \
account_locked=true \
home="${3:-/nohome.$1}" \
pgrp="${2:-$1}" \
"$1"
.
pp_havelib) cat <<'.';;
case "$2" in
"") pp_tmp_name="lib$1.so";;
*.*.*) pp_tmp_name="lib$1.so.$2";;
*.*) pp_tmp_name="lib$1.so.$2.0";;
*) pp_tmp_name="lib$1.so.$2";;
esac
for pp_tmp_dir in `echo "/usr/lib:/lib${3:+:$3}" | tr : ' '`; do
test -r "$pp_tmp_dir/$pp_tmp_name" -a \
-r "$pp_tmp_dir/lib$1.so" && return 0
done
return 1
.
*) false;;
esac
}
pp_platforms="$pp_platforms sd"
pp_backend_sd_detect () {
test x"$1" = x"HP-UX"
}
pp_backend_sd_init () {
pp_sd_sudo=
pp_sd_startlevels=2
pp_sd_stoplevels=auto
pp_sd_config_file=
pp_sd_vendor=
pp_sd_vendor_tag=Quest
pp_sd_default_start=1 # config_file default start value
pp_readlink_fn=pp_ls_readlink # HPUX has no readlink
pp_sd_detect_os
}
pp_sd_detect_os () {
typeset revision
revision=`uname -r`
pp_sd_os="${revision#?.}"
test -z "$pp_sd_os" &&
pp_warn "cannot detect OS version"
pp_sd_os_std="hpux`echo $pp_sd_os | tr -d .`"
case "`uname -m`" in
9000/[678]??) pp_sd_arch_std=hppa;;
ia64) pp_sd_arch_std=ia64;;
*) pp_sd_arch_std=unknown;;
esac
}
pp_sd_write_files () {
typeset t m o g f p st line dm
while read t m o g f p st; do
line=" file"
case "$f" in *v*) line="$line -v";; esac # FIXME for uninstall
case $t in
f) dm=644;;
d) line="$line -t d"; p=${p%/}; dm=755;;
s) line="$line -t s";;
esac
test x"$o" = x"-" && o=root
test x"$g" = x"-" && g=sys
test x"$m" = x"-" && m=$dm
case $t in
s) echo "$line $st $p";;
*) echo "$line -o $o -g $g -m $m $pp_destdir$p $p";;
esac
done
}
pp_sd_service_group_script () {
typeset grp svcs scriptpath out
grp="$1"
svcs="$2"
scriptpath="/sbin/init.d/$grp"
out="$pp_destdir$scriptpath"
pp_add_file_if_missing $scriptpath run 755 || return 0
cat <<-. > $out
#!/sbin/sh
# generated by pp $pp_version
svcs="$svcs"
.
cat <<-'.' >> $out
#-- starts services in order.. stops them all if any break
pp_start () {
undo=
for svc in $svcs; do
/sbin/init.d/$svc start
case $? in
0|4)
undo="$svc $undo"
;;
*)
if test -n "$undo"; then
for svc in $undo; do
/sbin/init.d/$svc stop
done
return 1
fi
;;
esac
done
return 0
}
#-- stops services in reverse
pp_stop () {
reverse=
for svc in $svcs; do
reverse="$svc $reverse"
done
rc=0
for svc in $reverse; do
/sbin/init.d/$svc stop || rc=$?
done
return $rc
}
case $1 in
start_msg) echo "Starting $svcs";;
stop_msg) echo "Stopping $svcs";;
start) pp_start;;
stop) pp_stop;;
*) echo "usage: $0 {start|stop|start_msg|stop_msg}"
exit 1;;
esac
.
}
pp_sd_service_script () {
typeset svc config_file config_value scriptpath out
svc="$1"
scriptpath="/sbin/init.d/$svc"
config_file=${pp_sd_config_file:-/etc/rc.config.d/$svc}
sd_config_var=`echo run-$svc | tr '[a-z]-' '[A-Z]_'`
sd_config_value=${pp_sd_default_start:-0}
pp_load_service_vars "$svc"
test -n "$user" -a x"$user" != x"root" &&
cmd="SHELL=/usr/bin/sh /usr/bin/su $user -c \"exec `echo $cmd | sed -e 's,[$\\\`],\\&,g'`\""
if test -z "$pidfile"; then
pidfile="/var/run/$svc.pid"
cmd="$cmd & echo \$! > \$pidfile"
fi
pp_debug "config file is $config_file"
pp_add_file_if_missing $scriptpath run 755
pp_add_file_if_missing $config_file run 644 v
cat <<-. >> $pp_destdir$config_file
# Controls whether the $svc service is started
$sd_config_var=$sd_config_value
.
if test ! -f $pp_destdir$scriptpath; then
cat <<-. > $pp_destdir$scriptpath
#!/sbin/sh
# generated by pp $pp_version
svc="$svc"
pidfile="$pidfile"
config_file="$config_file"
pp_start () {
$cmd
}
pp_disabled () {
test \${$sd_config_var:-0} -eq 0
}
pp_stop () {
if test ! -s "$pidfile"; then
echo "Unable to stop $svc (no pid file)"
return 1
else
read pid < "$pidfile"
if kill -0 "$pid" 2>/dev/null; then
if kill -${stop_signal:-TERM} "$pid"; then
rm -f "$pidfile"
return 0
else
echo "Unable to stop $svc"
return 1
fi
else
rm -f "$pidfile"
return 0
fi
fi
}
pp_running () {
if test ! -s "$pidfile"; then
return 1
else
read pid < "$pidfile"
kill -0 "$pid" 2>/dev/null
fi
}
case $1 in
start_msg) echo "Starting the $svc service";;
stop_msg) echo "Stopping the $svc service";;
start)
if test -f "$config_file"; then
. $config_file
fi
if pp_disabled; then
exit 2
elif pp_running; then
echo "$svc already running";
exit 0
elif pp_start; then
echo "$svc started";
# rc(1M) says we should exit 4, but nobody expects it!
exit 0
else
exit 1
fi;;
stop) if pp_stop; then
echo "$svc stopped";
exit 0
else
exit 1
fi;;
*) echo "usage: $0 {start|stop|start_msg|stop_msg}"
exit 1;;
esac
.
fi
}
pp_sd_make_service () {
typeset level startpriority stoppriority startlevels stoplevels
typeset svc svcvar
svc="$1"
svcvar=`pp_makevar $svc`
# TODO: Figure out why this check is here
#-- don't do anything if the script exists
#if test -s "$pp_destdir/sbin/init.d/$svc"; then
# pp_error "$pp_destdir/sbin/init.d/$svc exists"
# return
#fi
# symlink the script, depending on the priorities chosen
eval startpriority='${pp_sd_startpriority_'$svcvar'}'
eval stoppriority='${pp_sd_stoppriority_'$svcvar'}'
test -z "$startpriority" && startpriority="${pp_sd_startpriority:-50}"
test -z "$stoppriority" && stoppriority="${pp_sd_stoppriority:-50}"
eval startlevels='${pp_sd_startlevels_'$svcvar'}'
test -z "$startlevels" && startlevels="$pp_sd_startlevels"
eval stoplevels='${pp_sd_stoplevels_'$svcvar'}'
test -z "$stoplevels" && stoplevels="$pp_sd_stoplevels"
# create the script and config file
pp_sd_service_script $svc
# fix the priority up
case "$startpriority" in
???) :;;
??) startpriority=0$startpriority;;
?) startpriority=00$startpriority;;
esac
case "$stoppriority" in
???) :;;
??) stoppriority=0$stoppriority;;
?) stoppriority=00$stoppriority;;
esac
if test x"$stoplevels" = x"auto"; then
stoplevels=
test -z "$startlevels" || for level in $startlevels; do
stoplevels="$stoplevels `expr $level - 1`"
done
fi
# create the symlinks
test -z "$startlevels" || for level in $startlevels; do
echo " file -t s" \
"/sbin/init.d/$svc" \
"/sbin/rc$level.d/S$startpriority$svc"
done
test -z "$stoplevels" || for level in $stoplevels; do
echo " file -t s" \
"/sbin/init.d/$svc" \
"/sbin/rc$level.d/K$stoppriority$svc"
done
}
pp_sd_control () {
typeset ctrl script
typeset cpt
ctrl="$1"; shift
cpt="$1"; shift
script="$pp_wrkdir/control.$ctrl.$cpt"
cat <<. >$script
.
cat "$@" >> $script
echo "exit 0" >> $script
/usr/bin/chmod +x $script
echo " $ctrl $script"
}
pp_backend_sd () {
typeset psf cpt svc outfile
psf=$pp_wrkdir/psf
echo "depot" > $psf
echo "layout_version 1.0" >>$psf
#-- vendor
cat <<. >>$psf
vendor
tag $pp_sd_vendor_tag
title "${pp_sd_vendor:-$vendor}"
end
product
tag $name
revision $version
vendor_tag $pp_sd_vendor_tag
is_patch false
title "$summary"
copyright "$copyright"
machine_type *
os_name HP-UX
os_release ?.11.*
os_version ?
directory /
is_locatable false
.
test -n "$description" \
&& echo $description > $pp_wrkdir/description \
&& cat <<. >> $psf
description < $pp_wrkdir/description
.
# make convenience service groups
if test -n "$pp_service_groups"; then
for grp in $pp_service_groups; do
pp_sd_service_group_script \
$grp "`pp_service_get_svc_group $grp`"
done
fi
for cpt in $pp_components; do
cat <<. >>$psf
fileset
tag ${pp_sd_fileset_tag:-$cpt}
title "${summary:-cpt}"
revision $version
.
#-- make sure services are shut down during uninstall
if test $cpt = run -a -n "$pp_services"; then
for svc in $pp_services; do
pp_prepend $pp_wrkdir/%preun.$cpt <<-.
/sbin/init.d/$svc stop
.
done
fi
#-- we put the post/preun code into configure/unconfigure
# and not postinstall/preremove, because configure/unconfigure
# scripts are run on the hosts where the package is installed,
# not loaded (a subtle difference).
test -s $pp_wrkdir/%pre.$cpt &&
pp_sd_control checkinstall $cpt $pp_wrkdir/%pre.$cpt >> $psf
test -s $pp_wrkdir/%post.$cpt &&
pp_sd_control configure $cpt $pp_wrkdir/%post.$cpt >> $psf
test -s $pp_wrkdir/%preun.$cpt &&
pp_sd_control unconfigure $cpt $pp_wrkdir/%preun.$cpt >> $psf
test -s $pp_wrkdir/%postun.$cpt &&
pp_sd_control postremove $cpt $pp_wrkdir/%postun.$cpt >> $psf
test -s $pp_wrkdir/%check.$cpt &&
pp_sd_control checkinstall $cpt $pp_wrkdir/%check.$cpt >> $psf
if test $cpt = run -a -n "$pp_services"; then
for svc in $pp_services; do
#-- service names are 10 chars max on hpux
case "$svc" in ???????????*)
pp_warn "service name '$svc' is too long for hpux";;
esac
pp_sd_make_service $svc >> $psf
done
#pp_sd_make_service_config
fi
pp_sd_write_files < $pp_wrkdir/%files.$cpt >> $psf
#-- end fileset clause
cat <<. >>$psf
end
.
done
#-- end product clause
cat <<. >>$psf
end
.
$pp_opt_debug && cat $psf >&2
test -s $pp_wrkdir/%fixup && . $pp_wrkdir/%fixup
outfile=`pp_backend_sd_names`
if pp_verbose ${pp_sd_sudo} /usr/sbin/swpackage \
-s $psf \
-x run_as_superuser=false \
-x media_type=tape \
@ $pp_wrkdir/$outfile
then
pp_verbose ${pp_sd_sudo} /usr/sbin/swlist -l file -s $pp_wrkdir/$outfile
else
pp_error "swpackage failed"
fi
}
pp_backend_sd_cleanup () {
:
}
pp_backend_sd_names () {
echo "$name-$version.$pp_sd_arch_std.depot"
}
pp_backend_sd_install_script () {
typeset pkgname platform
pkgname=`pp_backend_sd_names`
platform="`pp_backend_sd_probe`"
echo "#!/bin/sh"
pp_install_script_common
cat <<.
cpt_to_tags () {
test x"\$*" = x"all" && set -- $pp_components
for cpt
do
echo "$name.\$cpt"
done
}
test \$# -eq 0 && usage
op="\$1"; shift
case "\$op" in
list-components)
test \$# -eq 0 || usage \$op
echo "$pp_components"
;;
list-services)
test \$# -eq 0 || usage \$op
echo "$pp_services"
;;
list-files)
test \$# -ge 1 || usage \$op
echo \${PP_PKGDESTDIR:-.}/$pkgname
;;
install)
test \$# -ge 1 || usage \$op
verbose /usr/sbin/swinstall -x verbose=0 \
-s \${PP_PKGDESTDIR:-\`pwd\`}/$pkgname \
\`cpt_to_tags "\$@"\`
;;
uninstall)
test \$# -ge 1 || usage \$op
verbose /usr/sbin/swremove -x verbose=0 \
\`cpt_to_tags "\$@"\`
;;
start|stop)
test \$# -ge 1 || usage \$op
ec=0
for svc
do
verbose /sbin/init.d/\$svc \$op
[ \$? -eq 4 -o \$? -eq 0 ] || ec=1
done
exit \$ec
;;
print-platform)
echo "$platform"
;;
*)
usage
;;
esac
.
}
pp_backend_sd_probe () {
echo "${pp_sd_os_std}-${pp_sd_arch_std}"
}
pp_backend_sd_vas_platforms () {
case "`pp_backend_sd_probe`" in
hpux*-hppa) echo hpux-pa;;
hpux*-ia64) echo hpux-ia64 hpux-pa;;
*) pp_die "unknown system `pp_backend_sd_probe`";;
esac
}
pp_backend_sd_init_svc_vars () {
:
}
pp_backend_sd_function () {
case $1 in
pp_mkgroup) cat <<'.';;
/usr/sbin/groupmod "$1" 2>/dev/null ||
/usr/sbin/groupadd "$1"
.
pp_mkuser:depends) echo pp_mkgroup;;
pp_mkuser) cat <<'.';;
pp_mkgroup "${2:-$1}" || return 1
/usr/sbin/useradd \
-g "${2:-$1}" \
-d "${3:-/nonexistent}" \
-s "${4:-/bin/false}" \
"$1"
.
pp_havelib) cat <<'.';;
for pp_tmp_dir in `echo /usr/lib${3:+:$3} | tr : ' '`; do
test -r "$pp_tmp_dir/lib$1${2:+.$2}.sl" && return 0
done
return 1
.
*) false;;
esac
}
pp_platforms="$pp_platforms solaris"
pp_backend_solaris_detect () {
test x"$1" = x"SunOS"
}
pp_backend_solaris_init () {
pp_solaris_category=
pp_solaris_istates="s S 1 2 3" # run-states when install is ok
pp_solaris_rstates="s S 1 2 3" # run-states when remove is ok
pp_solaris_vendor=
pp_solaris_copyright=
pp_solaris_name=
pp_solaris_desc=
pp_solaris_package_arch=auto
pp_solaris_detect_os
pp_solaris_detect_arch
pp_solaris_init_svc
#-- readlink not reliably available on Solaris
pp_readlink_fn=pp_ls_readlink
}
pp_solaris_detect_os () {
typeset osrel
osrel=`/usr/bin/uname -r`
case "$osrel" in
5.[0-6]) pp_solaris_os="sol2${osrel#5.}";;
5.*) pp_solaris_os="sol${osrel#5.}";;
esac
test -z "$pp_solaris_os" &&
pp_warn "can't determine OS suffix from uname -r"
}
pp_solaris_detect_arch () {
pp_solaris_arch=`/usr/bin/optisa amd64 sparcv9 i386 sparc`
[ -z "$pp_solaris_arch" ] &&
pp_error "can't determine processor architecture"
case "$pp_solaris_arch" in
amd64) pp_solaris_arch_std=x86_64;;
i386) pp_solaris_arch_std=i386;;
sparcv9) pp_solaris_arch_std=sparc64;;
sparc) pp_solaris_arch_std=sparc;;
*) pp_solaris_arch_std=unknown;;
esac
}
pp_solaris_is_request_script_necessary () {
typeset has_optional_services
has_optional_services=no
for _svc in $pp_services; do
pp_load_service_vars $_svc
if test "$optional" = "yes"; then
has_optional_services=yes
fi
done
# If the package has no optional services and only one component, don't
# create a request script at all.
if test "$has_optional_services" = "no" &&
test `echo $pp_components | wc -w` -eq 1; then
return 1 # no
fi
return 0 # yes
}
pp_solaris_request () {
typeset _cmp _svc
#-- The common part of the request script contains the ask() function
# and resets the CLASSES list to empty
cat <<'.'
trap 'exit 3' 15
ask () {
ans=`ckyorn -d "$1" \
-p "Do you want to $2"` \
|| exit $?
case "$ans" in y*|Y*) return 0;; *) return 1;; esac
}
CLASSES=
.
#-- each of our components adds itself to the CLASSES list
for _cmp in $pp_components; do
case "$_cmp" in
run) :;;
doc) echo 'ask y "install the documentation files" &&';;
dev) echo 'ask y "install the development files" &&';;
dbg) echo 'ask n "install the diagnostic files" &&';;
esac
echo ' CLASSES="$CLASSES '$_cmp'"'
done
#-- the request script writes the CLASSES var to its output
cat <<'.'
echo "CLASSES=$CLASSES" > $1
.
if test -n "$pp_services"; then
echo 'SERVICES='
for _svc in $pp_services; do
pp_load_service_vars $_svc
if test "$enable" = "yes"; then
_default_prompt=y
else
_default_prompt=n
fi
if test "$optional" = "yes"; then
echo 'ask '$_default_prompt' "install '$_svc' service" &&'
fi
echo ' SERVICES="$SERVICES '$_svc'"'
done
echo 'echo "SERVICES=$SERVICES" >> $1'
fi
}
pp_solaris_procedure () {
cat <<.
#-- $2 for $1 component of $name
case " \$CLASSES " in *" $1 "*)
.
cat
cat <<.
;; esac
.
}
pp_solaris_depend () {
typeset _name _vers
while read _name _vers; do
if test -n "$_name"; then
echo "P $_name $_name"
test -n "$_vers" && echo " $_vers"
fi
done
}
pp_solaris_space() {
echo "$2:$3:$1" >> $pp_wrkdir/space.cumulative
}
pp_solaris_sum_space () {
if test -s $pp_wrkdir/space.cumulative; then
sort -t: +2 < $pp_wrkdir/space.cumulative |
awk -F: 'NR==1{n=$3}{if($3==n){b+=$1;i+=$2}else{print n" "b" "i;b=$1;i=$2;n=$3}}END{print n" "b" "i}' > $pp_wrkdir/space
fi
}
pp_solaris_proto () {
typeset t m o g f p st
typeset abi
while read t m o g f p st; do
if test x"$o" = x"-"; then
o="root"
fi
if test x"$g" = x"-"; then
g="bin"
fi
case "$t" in
f) test x"$m" = x"-" && m=444
case "$f" in
*v*) echo "v $1 $p=$pp_destdir$p $m $o $g";;
*) echo "f $1 $p=$pp_destdir$p $m $o $g";;
esac
if test -r "$pp_destdir$p"; then
#-- Use file to record ABI types seen
case "`file "$pp_destdir$p"`" in
*"ELF 32"*80386*) abi=i386;;
*"ELF 64"*AMD*) abi=x86_64;;
*"ELF 32"*SPARC*) abi=sparc;;
*"ELF 64"*SPARC*) abi=sparc64;;
*) abi=;;
esac
if test -n "$abi"; then
pp_add_to_list pp_solaris_abis_seen $abi
fi
fi
;;
d) test x"$m" = x"-" && m=555
echo "d $1 $p $m $o $g"
;;
s) test x"$m" = x"-" && m=777
test x"$m" = x"777" ||
pp_warn "$p: invalid mode $m for symlink, should be 777 or -"
echo "s $1 $p=$st $m $o $g"
;;
esac
done
}
pp_backend_solaris () {
typeset _cmp _svc _grp
prototype=$pp_wrkdir/prototype
: > $prototype
pkginfo=$pp_wrkdir/pkginfo
: > $pkginfo
echo "i pkginfo=$pkginfo" >> $prototype
case "${pp_solaris_name:-$name}" in
[0-9]*)
pp_error "Package name '${pp_solaris_name:-$name}'" \
"cannot start with a number"
;;
???????????????*)
pp_warn "Package name '${pp_solaris_name:-$name}'" \
"too long for Solaris 2.6 or 2.7 (max 9 characters)"
;;
??????????*)
pp_warn "Package name '${pp_solaris_name:-$name}'" \
"too long for 2.7 Solaris (max 9 characters)"
;;
esac
#-- generate the package info file
echo "VERSION=$version" >> $pkginfo
echo "PKG=${pp_solaris_name:-$name}" >> $pkginfo
echo "CLASSES=$pp_components" >> $pkginfo
echo "BASEDIR=/" >> $pkginfo
echo "NAME=$name $version" >> $pkginfo
echo "CATEGORY=${pp_solaris_category:-application}" >> $pkginfo
desc="${pp_solaris_desc:-$description}"
test -n "$desc" &&
echo "DESC=$desc" >> $pkginfo
test -n "$pp_solaris_rstates" &&
echo "RSTATES=$pp_solaris_rstates" >> $pkginfo
test -n "$pp_solaris_istates" &&
echo "ISTATES=$pp_solaris_istates" >> $pkginfo
test -n "${pp_solaris_vendor:-$vendor}" &&
echo "VENDOR=${pp_solaris_vendor:-$vendor}" >> $pkginfo
if test -n "${pp_solaris_copyright:-$copyright}"; then
echo "${pp_solaris_copyright:-$copyright}" > $pp_wrkdir/copyright
echo "i copyright=$pp_wrkdir/copyright" >> $prototype
fi
#-- scripts to run before and after install
: > $pp_wrkdir/postinstall
: > $pp_wrkdir/preremove
for _cmp in $pp_components; do
#-- add the preinstall scripts in definition order
if test -s $pp_wrkdir/%pre.$_cmp; then
pp_solaris_procedure $_cmp preinst < $pp_wrkdir/%pre.$_cmp \
>> $pp_wrkdir/preinstall
fi
#-- add the postinstall scripts in definition order
if test -s $pp_wrkdir/%post.$_cmp; then
pp_solaris_procedure $_cmp postinst < $pp_wrkdir/%post.$_cmp \
>> $pp_wrkdir/postinstall
fi
#-- add the preremove rules in reverse definition order
if test -s $pp_wrkdir/%preun.$_cmp; then
pp_solaris_procedure $_cmp preremove < $pp_wrkdir/%preun.$_cmp |
pp_prepend $pp_wrkdir/preremove
fi
#-- Add the check script in definition order
if test -s $pp_wrkdir/%check.$_cmp; then
pp_solaris_procedure $_cmp checkinstall \
< $pp_wrkdir/%check.$_cmp \
>> $pp_wrkdir/checkinstall
fi
#-- All dependencies are merged together for Solaris pkgs
test -s $pp_wrkdir/%depend.$_cmp &&
pp_solaris_depend < $pp_wrkdir/%depend.$_cmp > $pp_wrkdir/depend
done
if pp_solaris_is_request_script_necessary; then
pp_solaris_request > $pp_wrkdir/request
fi
test -n "$pp_services" &&
for _svc in $pp_services; do
pp_load_service_vars $_svc
pp_solaris_make_service $_svc
pp_solaris_install_service $_svc | pp_prepend $pp_wrkdir/postinstall
pp_prepend $pp_wrkdir/preremove <<-.
/etc/init.d/$_svc stop >/dev/null 2>/dev/null
.
done
test -n "$pp_service_groups" &&
for _grp in $pp_service_groups; do
pp_solaris_make_service_group \
$_grp "`pp_service_get_svc_group $_grp`"
done
#-- if installf was used; we need to indicate a termination
grep installf $pp_wrkdir/postinstall >/dev/null &&
echo 'installf -f $PKGINST' >> $pp_wrkdir/postinstall
pp_solaris_sum_space
# NB: pkginfo and copyright are added earlier
for f in compver depend space checkinstall \
preinstall request postinstall \
preremove postremove; do
if test -s $pp_wrkdir/$f; then
case $f in
*install|*remove|request)
# turn scripts into a proper shell scripts
mv $pp_wrkdir/$f $pp_wrkdir/$f.tmp
{ echo "#!/bin/sh";
echo "# $f script for ${pp_solaris_name:-$name}-$version"
cat $pp_wrkdir/$f.tmp
echo "exit 0"; } > $pp_wrkdir/$f
chmod +x $pp_wrkdir/$f
rm -f $pp_wrkdir/$f.tmp
;;
esac
if $pp_opt_debug; then
pp_debug "contents of $f:"
cat $pp_wrkdir/$f >&2
fi
echo "i $f=$pp_wrkdir/$f" >> $prototype
fi
done
#-- create the prototype file which lists the files to install
# do this as late as possible because files could be added
pp_solaris_abis_seen=
for _cmp in $pp_components; do
pp_solaris_proto $_cmp < $pp_wrkdir/%files.$_cmp
done >> $prototype
if test x"$pp_solaris_package_arch" = x"auto"; then
if pp_contains "$pp_solaris_abis_seen" sparc64; then
pp_solaris_package_arch_std="sparc64"
echo "ARCH=sparcv9" >> $pkginfo
elif pp_contains "$pp_solaris_abis_seen" sparc; then
pp_solaris_package_arch_std="sparc"
echo "ARCH=sparc" >> $pkginfo
elif pp_contains "$pp_solaris_abis_seen" x86_64; then
pp_solaris_package_arch_std="x86_64"
echo "ARCH=amd64" >> $pkginfo
elif pp_contains "$pp_solaris_abis_seen" i386; then
pp_solaris_package_arch_std="i386"
echo "ARCH=i386" >> $pkginfo
else
pp_warn "No ELF files found: not supplying an ARCH type"
pp_solaris_package_arch_std="noarch"
fi
else
pp_solaris_package_arch_std="$pp_solaris_package_arch"
echo "ARCH=$pp_solaris_package_arch" >> $pkginfo
fi
mkdir $pp_wrkdir/pkg
. $pp_wrkdir/%fixup
if $pp_opt_debug; then
echo "$pkginfo::"; cat $pkginfo
echo "$prototype::"; cat $prototype
fi >&2
pkgmk -a $pp_solaris_arch -d $pp_wrkdir/pkg \
-f $prototype || { error "pkgmk failed"; return; }
pkgtrans -s $pp_wrkdir/pkg \
$pp_wrkdir/`pp_backend_solaris_names` \
${pp_solaris_name:-$name} \
|| { error "pkgtrans failed"; return; }
}
pp_backend_solaris_cleanup () {
:
}
pp_backend_solaris_names () {
echo ${pp_solaris_name:-$name}-$version-${pp_solaris_package_arch_std:-$pp_solaris_arch}.pkg
}
pp_backend_solaris_install_script () {
typeset pkgname platform
platform="${pp_solaris_os:-solaris}-${pp_solaris_package_arch_std:-$pp_solaris_arch}"
echo "#! /sbin/sh"
pp_install_script_common
pkgname=`pp_backend_solaris_names`
cat <<.
tmpnocheck=/tmp/nocheck\$\$
tmpresponse=/tmp/response\$\$
trap 'rm -f \$tmpnocheck \$tmpresponse' 0
make_tmpfiles () {
cat <<-.. > \$tmpresponse
CLASSES=\$*
SERVICES=$pp_services
..
cat <<-.. > \$tmpnocheck
mail=
instance=overwrite
partial=nocheck
runlevel=nocheck
idepend=nocheck
rdepend=nocheck
space=nocheck
setuid=nocheck
conflict=nocheck
action=nocheck
basedir=default
..
}
test \$# -eq 0 && usage
op="\$1"; shift
case "\$op" in
list-components)
test \$# -eq 0 || usage \$op
echo "$pp_components"
;;
list-services)
test \$# -eq 0 || usage \$op
echo "$pp_services"
;;
list-files)
test \$# -ge 1 || usage \$op
echo \${PP_PKGDESTDIR:-.}/$pkgname
;;
install)
test \$# -ge 1 || usage \$op
make_tmpfiles "\$@"
verbose /usr/sbin/pkgadd -n -d \${PP_PKGDESTDIR:-.}/$pkgname \
-r \$tmpresponse \
-a \$tmpnocheck \
${pp_solaris_name:-$name}
;;
uninstall)
test \$# -ge 1 || usage \$op
make_tmpfiles "\$@"
verbose /usr/sbin/pkgrm -n \
-a \$tmpnocheck \
${pp_solaris_name:-$name}
;;
start|stop)
test \$# -ge 1 || usage \$op
ec=0
for svc
do
verbose /etc/init.d/\$svc \$op || ec=1
done
exit \$ec
;;
print-platform)
echo "$platform"
;;
*)
usage
;;
esac
.
}
pp_solaris_dynlib_depend () {
xargs ldd 2>/dev/null |
sed -e '/^[^ ]*:$/d' -e 's,.*=>[ ]*,,' -e 's,^[ ]*,,' |
sort -u |
grep -v '^/usr/platform/' | (
set -- ""; shift
while read p; do
set -- "$@" -p "$p"
if [ $# -gt 32 ]; then
echo "$# is $#" >&2
pkgchk -l "$@"
set -- ""; shift
fi
done
[ $# -gt 0 ] && pkgchk -l "$@"
)|
awk '/^Current status:/{p=0} p==1 {print $1} /^Referenced by/ {p=1}' |
sort -u |
xargs -l32 pkginfo -x |
awk 'NR % 2 == 1 { name=$1; } NR%2 == 0 { print name, $2 }'
}
pp_solaris_add_dynlib_depends () {
typeset tmp
tmp=$pp_wrkdir/tmp.dynlib
for _cmp in $pp_components; do
awk '{print destdir $6}' destdir="$pp_destdir" \
< $pp_wrkdir/%files.$_cmp |
pp_solaris_dynlib_depend > $tmp
if test -s $tmp; then
cat $tmp >> $pp_wrkdir/%depend.$_cmp
fi
rm -f $tmp
done
}
pp_backend_solaris_probe () {
echo "${pp_solaris_os}-${pp_solaris_arch_std}"
}
pp_backend_solaris_vas_platforms () {
case `pp_backend_solaris_probe` in
sol10-sparc* | sol9-sparc* | sol8-sparc*)
echo solaris8-sparc solaris7-sparc solaris26-sparc;;
sol7-sparc*) echo solaris7-sparc solaris26-sparc;;
sol26-sparc*) echo solaris26-sparc;;
sol8-*86) echo solaris8-x86;;
sol10-*86 | sol10-x86_64)
echo solaris10-x64 solaris8-x86;;
*) pp_die "unknown system `pp_backend_solaris_probe`";;
esac
}
pp_backend_solaris_function() {
case $1 in
pp_mkgroup) cat<<'.';;
/usr/sbin/groupmod "$1" 2>/dev/null && return 0
/usr/sbin/groupadd "$1"
.
pp_mkuser:depends) echo pp_mkgroup;;
pp_mkuser) cat<<'.';;
id "$1" >/dev/null 2>/dev/null && return 0
pp_mkgroup "${2:-$1}" || return 1
/usr/sbin/useradd \
-g "${2:-$1}" \
-d "${3:-/nonexistent}" \
-s "${4:-/bin/false}" \
"$1"
.
*) false;;
esac
}
pp_backend_solaris_init_svc_vars () {
pp_solaris_smf_category=
pp_solaris_service_shell=/sbin/sh
}
pp_solaris_init_svc () {
smf_category=${pp_solaris_smf_category:-application}
smf_version=1
smf_type=service
solaris_user=
solaris_stop_signal=
solaris_sysv_init_start=S70 # invocation order for start scripts
solaris_sysv_init_kill=K30 # invocation order for kill scripts
solaris_sysv_init_start_states="2" # states to install start link
solaris_sysv_init_kill_states="S 0 1" # states to install kill link
#