#!/bin/sh # --- SDE-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: package/.../runit/djb-config # Copyright (C) 2008 The OpenSDE Project # Copyright (C) 2004 - 2006 The T2 SDE Project # Copyright (C) 1998 - 2003 Clifford Wolf # # More information can be found in the files COPYING and README. # # 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; version 2 of the License. A copy of the # GNU General Public License can be found in the file COPYING. # --- SDE-COPYRIGHT-NOTE-END --- # e.g. $1: admin mail net ... # $2: $sbindir $bindir # pkg_djb_hierarchy=$1 pkg_djb_altdir=${2:-$bindir} # $logdir if [ "${localstatedir%$pkg}" != "$localstatedir" ]; then logdir=$localstatedir/log else logdir=$localstatedir/log/$pkg fi # $sysconfdir if [ "${sysconfdir%$pkg}" == "$sysconfdir" ]; then sysconfdir=$sysconfdir/$pkg fi if [ -z "$pkg_djb_hierarchy" ]; then abort "djb-config: must specify hierarchy /package/\$hierarchy." fi srcdir="$pkg_djb_hierarchy/$pkg-$ver" if [ "$createdocs" != "0" ]; then createdocs=0 hook_add postdoc 2 'pkg_djb_installdoc $pkg_djb_hierarchy' fi # custmain # custmain="pkg_djb_main" pkg_djb_main() { hook_eval premake ./package/compile hook_eval inmake pkg_djb_installpackage $pkg_djb_hierarchy $pkg_djb_altdir hook_eval postmake } # FIXME: join pkg_djb_safecopy and pkg_djb_safelink pkg_djb_safecopy() { local source="$( echo "${1#$root}/$3" | tr -s '/' ) " local target="$( echo "${2#$root}/$3" | tr -s '/' ) " echo "'$source' -> '$target'" cp -vfp $source ${root}$target } pkg_djb_safelink() { local source="$( echo "${1#$root}/$3" | tr -s '/' ) " local target="$( echo "${2#$root}/$3" | tr -s '/' ) " echo "create symbolic link '$source' to '$target'" ln -snvf $source ${root}$target } pkg_djb_substitute() { sed \ -e "s,D_commanddir,$pkg_djb_commanddir,g" \ -e "s,D_servicedir,$pkg_djb_servicedir,g" \ -e "s,D_logdir,$logdir,g" \ $1 } # installs the package in DJB way if requested # pkg_djb_installpackage() { # requires ./package/commands # and files in ./command local x= y= cmddir= local package=$1 local altdir=$2 # FIXME: rework to loop over ./package/commands just once if [ "$pkg_djb_packagedir" ]; then cmddir="$pkg_djb_packagedir/$package/$pkg-$ver/command" echo 'Copying commands to package directory...' mkdir -p "$cmddir" for x in `cat ./package/commands`; do pkg_djb_safecopy ./command "$cmddir" $x done echo "Creating symlink $pkg -> $pkg-$ver..." ln -svnf $pkg-$ver $pkg_djb_packagedir/$package/$pkg else cmddir="./command" fi if [ "$pkg_djb_commanddir" ]; then echo "Making command links in $pkg_djb_commanddir..." y=pkg_djb_safelink else echo 'Copying commands to $altdir...' pkg_djb_commanddir=$root/$altdir y=pkg_djb_safecopy fi mkdir -p $pkg_djb_commanddir for x in `cat package/commands`; do $y $cmddir $pkg_djb_commanddir $x done } # installs documentation to package directory or $docdir as requested # pkg_djb_installdoc() { local x package=$1 local docpkg echo 'Copying documentation....' if [ "$pkg_djb_packagedir" ]; then docpkg=$pkg_djb_packagedir/$package/$pkg-$ver/package docdir=$pkg_djb_packagedir/$package/$pkg-$ver/doc else # $pkg_djb_* includes $root, $docdir doesn't. docpkg=$root/$docdir fi mkdir -p $docpkg $docdir # ./package for x in `ls ./package`; do case $x in compile|install*|upgrade) /bin/true ;; *) cp -vf ./package/$x $docpkg ;; esac done # ./doc if [ -d doc ]; then cp -rLv ./doc/* $docdir fi # ./man if [ -d man ]; then echo "Installing man pages ... " for x in $( cd man; ls -1 *.[1-9] | sed -e 's,.*\.\([1-9]\),\1,g' | sort -u ); do gzip -9 ./man/*.$x cp -vf ./man/*.$x.gz $root/$mandir/man$x/ done fi }