If nobody finds problem in the attached eclass, I'm going to commit this 
tonight or tomorrow.
The first function is a drop-in replacement for cp --parent (that doesn't work 
on BSD userland), the second one is a commodity function to symlink commands 
and manpages at once (as done by bsdtar and other packages).

If we'll find other functions needed for portability's sake, they'll probably 
going to be there, too.

Comments?
-- 
Diego "Flameeyes" Pettenò
Gentoo Developer - http://dev.gentoo.org/~flameeyes/
(Gentoo/FreeBSD, Video, Gentoo/AMD64, Sound, PAM)
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
#
# Author: Diego Pettenò <[EMAIL PROTECTED]>
#
# This eclass is created to avoid using non-portable GNUisms inside ebuilds
#
# NB:  If you add anything, please comment it!

# treecopy orig1 orig2 orig3 .... dest
#
# mimic cp --parents copy, but working on BSD userland as well
treecopy() {
        dest=$(eval "echo \${$#}")
        files_count=$#

        for (( i=1; ${i} < ${files_count}; i=$((${i}+1)) )); do
                dirstruct=$(dirname "$1")
                mkdir -p "${dest}/${dirstruct}"
                cp -pPR "$1" "${dest}/${dirstruct}"

                shift
        done
}

# symcmd oldcmd newcmd [mansection]
#
# Symlinks a given command to a new one, useful to shade a package that is
# the default provider of a command in a given userland.
# When mansection is specified, also the manpage with basename(oldcmd) is
# symlinked to basename(newcmd).
symcmd() {
        dosym ${newcmd} ${oldcmd} || die "symlink failed"

        if [[ -n "$3" ]]; then
                dosym ${oldcmd}.$3.gz /usr/share/man/man$3/${newcmd}.$3.gz
        fi
}

Attachment: pgp4iTKElrDby.pgp
Description: PGP signature

Reply via email to