summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@gentoo.org>2005-09-18 17:33:44 +0000
committerDiego Elio Pettenò <flameeyes@gentoo.org>2005-09-18 17:33:44 +0000
commit90cd17d830477bedf80a2def84a5f4f8901da935 (patch)
treead006033230eb6c212c5fe2c9fd38560e5102480 /eclass
parentStable on ppc64 (bug #105805) (diff)
downloadhistorical-90cd17d830477bedf80a2def84a5f4f8901da935.tar.gz
historical-90cd17d830477bedf80a2def84a5f4f8901da935.tar.bz2
historical-90cd17d830477bedf80a2def84a5f4f8901da935.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')
-rw-r--r--eclass/eutils.eclass16
-rw-r--r--eclass/portability.eclass75
2 files changed, 80 insertions, 11 deletions
diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
index 347a3c9bcc46..3f63db4c420b 100644
--- a/eclass/eutils.eclass
+++ b/eclass/eutils.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.196 2005/09/06 01:59:22 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.197 2005/09/18 17:33:44 flameeyes Exp $
#
# Author: Martin Schlemmer <azarah@gentoo.org>
#
@@ -9,7 +9,7 @@
#
# NB: If you add anything, please comment it!
-inherit multilib
+inherit multilib portability
DEPEND="!bootstrap? ( sys-devel/patch )"
# sys-apps/shadow is needed for useradd, etc, bug #94745.
@@ -479,13 +479,7 @@ enewuser() {
euid="next"
fi
if [[ ${euid} == "next" ]] ; then
- local pwrange
- if [[ ${USERLAND} == "BSD" ]] ; then
- pwrange=$(jot 898 101)
- else
- pwrange=$(seq 101 999)
- fi
- for euid in ${pwrange} ; do
+ for euid in $(seq 101 999) ; do
[[ -z $(egetent passwd ${euid}) ]] && break
done
fi
@@ -679,7 +673,7 @@ enewgroup() {
# If we need the next available
case ${egid} in
*[!0-9]*) # Non numeric
- for egid in `jot 898 101`; do
+ for egid in $(seq 101 999); do
[ -z "`egetent group ${egid}`" ] && break
done
esac
@@ -688,7 +682,7 @@ enewgroup() {
elif [[ "${USERLAND}" == "BSD" ]] ; then
case ${egid} in
*[!0-9]*) # Non numeric
- for egid in `jot 898 101`; do
+ for egid in $(seq 101 999); do
[ -z "`egetent group ${egid}`" ] && break
done
esac
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
+}
+