#!/bin/sh # --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/runit/djb-config # Copyright (C) 2004 - 2022 The T2 SDE Project # Copyright (C) 1998 - 2003 ROCK Linux Project # # This Copyright note is generated by scripts/Create-CopyPatch, # 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 version 2. # --- T2-COPYRIGHT-NOTE-END --- # e.g. $1: admin mail net ... # $2: $sbindir $bindir # pkg_djb_hierarchy=$1 pkg_djb_altdir=${2:-$root/$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 } pkg_djb_safecopy() { local source="$( echo "${1#$root}/$3" | tr -s '/' ) " local target="$( echo "${2#$root}/$3" | tr -s '/' ) " echo "`pwd`: '$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= local package=$1 local altdir=$2 if [ "$pkg_djb_packagedir" ]; then echo 'Copying commands to package directory...' mkdir -p $pkg_djb_packagedir/$package/$pkg-$ver/command for x in `cat ./package/commands`; do pkg_djb_safecopy ./command \ $pkg_djb_packagedir/$package/$pkg-$ver/command $x done echo "Creating symlink $pkg -> $pkg-$ver..." ln -svnf $pkg-$ver $pkg_djb_packagedir/$package/$pkg 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=$altdir y=pkg_djb_safecopy fi if [ "$pkg_djb_packagedir" ]; then djb_source_dir=$pkg_djb_packagedir/$package/$pkg-$ver/command else djb_source_dir=./command fi for x in `cat package/commands`; do $y $djb_source_dir $pkg_djb_commanddir $x done # usr/local is evil :) #if [ "$pkg_djb_compatdir" ]; then # echo "Making compatibility links in $pkg_djb_compatdir..." # mkdir -p $pkg_djb_compatdir # for i in `cat package/commands`; do # pkg_djb_safelink $pkg_djb_packagedir/$package/$pkg-$ver/command \ # $pkg_djb_compatdir $i # done #fi } # 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 mkdir -p $docdir else # $pkg_djb_* includes $root, $docdir doesn't. docpkg=$root/$docdir docdir=$root/$docdir fi mkdir -p $docpkg # ./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 }