public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Diego 'Flameeyes' Pettenò" <flameeyes@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev] [RFC] Portability eclass
Date: Fri, 16 Sep 2005 17:42:58 +0200	[thread overview]
Message-ID: <200509161743.07528@enterprise.flameeyes.is-a-geek.org> (raw)


[-- 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 --]

             reply	other threads:[~2005-09-16 15:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-16 15:42 Diego 'Flameeyes' Pettenò [this message]
2005-09-16 15:59 ` [gentoo-dev] [RFC] Portability eclass 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ò

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200509161743.07528@enterprise.flameeyes.is-a-geek.org \
    --to=flameeyes@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox