diff options
author | Diego Elio Pettenò <flameeyes@gentoo.org> | 2005-09-18 17:33:44 +0000 |
---|---|---|
committer | Diego Elio Pettenò <flameeyes@gentoo.org> | 2005-09-18 17:33:44 +0000 |
commit | 7b5293563ba146a6a34746ff461c6b1a75674395 (patch) | |
tree | b6a5f0dcff1f874a0a48aa11146e2590a4087780 /eclass/portability.eclass | |
parent | Stable on ppc64 (bug #105805) (diff) | |
download | gentoo-2-7b5293563ba146a6a34746ff461c6b1a75674395.tar.gz gentoo-2-7b5293563ba146a6a34746ff461c6b1a75674395.tar.bz2 gentoo-2-7b5293563ba146a6a34746ff461c6b1a75674395.zip |
Added portability eclass with seq() function to replace seq command. Make eutils use the new seq command for enewuser/enewgroup.
Diffstat (limited to 'eclass/portability.eclass')
-rw-r--r-- | eclass/portability.eclass | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/eclass/portability.eclass b/eclass/portability.eclass new file mode 100644 index 000000000000..a83e35441482 --- /dev/null +++ b/eclass/portability.eclass @@ -0,0 +1,75 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.1 2005/09/18 17:33:44 flameeyes Exp $ +# +# 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=${!#} + files_count=$# + + while(( $# > 1 )); do + dirstruct=$(dirname "$1") + mkdir -p "${dest}/${dirstruct}" + cp -pPR "$1" "${dest}/${dirstruct}" + + shift + done +} + +# seq min max +# +# compatibility function that mimes seq command if not available +seq() { + local p + p=$(type -P seq) + + case $# in + 1) + min=1 + max=$1 + step=1 + ;; + 2) + min=$1 + max=$2 + step=1 + ;; + 3) + min=$1 + max=$3 + step=$2 + ;; + *) + die "seq called with wrong parameters number" + esac + + if [[ -z "${p}" ]]; then + local reps + # BSD userland + if [[ ${step} != 0 ]]; then + reps=$(( ($max-$min) / $step +1 )) + else + reps=0 + fi + + jot $reps $min $max $step + else + "${p}" $min $step $max + fi +} + +# Gets the linker flag to link to dlopen() function +dlopen_lib() { + if [[ ${ELIBC} != *BSD ]]; then + echo "-ldl" + fi +} + |