public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [RFC] Portability eclass
@ 2005-09-16 15:42 Diego 'Flameeyes' Pettenò
  2005-09-16 15:59 ` Mike Frysinger
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Diego 'Flameeyes' Pettenò @ 2005-09-16 15:42 UTC (permalink / raw
  To: gentoo-dev


[-- Attachment #1.1: Type: text/plain, Size: 576 bytes --]

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)

[-- Attachment #1.2: portability.eclass --]
[-- Type: text/plain, Size: 1105 bytes --]

# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
#
# Author: Diego Pettenò <flameeyes@gentoo.org>
#
# 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 #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-09-17 13:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-16 15:42 [gentoo-dev] [RFC] Portability eclass Diego 'Flameeyes' Pettenò
2005-09-16 15:59 ` Mike Frysinger
2005-09-16 16:33   ` Diego 'Flameeyes' Pettenò
2005-09-16 17:21     ` Chris Gianelloni
2005-09-16 17:28     ` Mike Frysinger
2005-09-16 17:36       ` Diego 'Flameeyes' Pettenò
2005-09-16 17:59         ` warnera6
2005-09-16 19:12         ` Mike Frysinger
2005-09-16 16:16 ` Martin Schlemmer
2005-09-16 17:07   ` Diego 'Flameeyes' Pettenò
2005-09-17 13:01 ` Diego 'Flameeyes' Pettenò

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox