/[gentoo-x86]/eclass/portability.eclass
Gentoo

Contents of /eclass/portability.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sun Sep 18 17:33:44 2005 UTC (9 years, 1 month ago) by flameeyes
Branch: MAIN
Added portability eclass with seq() function to replace seq command. Make eutils use the new seq command for enewuser/enewgroup.

1 flameeyes 1.1 # Copyright 1999-2005 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3     # $Header: $
4     #
5     # Author: Diego Pettenò <flameeyes@gentoo.org>
6     #
7     # This eclass is created to avoid using non-portable GNUisms inside ebuilds
8     #
9     # NB: If you add anything, please comment it!
10    
11     # treecopy orig1 orig2 orig3 .... dest
12     #
13     # mimic cp --parents copy, but working on BSD userland as well
14     treecopy() {
15     dest=${!#}
16     files_count=$#
17    
18     while(( $# > 1 )); do
19     dirstruct=$(dirname "$1")
20     mkdir -p "${dest}/${dirstruct}"
21     cp -pPR "$1" "${dest}/${dirstruct}"
22    
23     shift
24     done
25     }
26    
27     # seq min max
28     #
29     # compatibility function that mimes seq command if not available
30     seq() {
31     local p
32     p=$(type -P seq)
33    
34     case $# in
35     1)
36     min=1
37     max=$1
38     step=1
39     ;;
40     2)
41     min=$1
42     max=$2
43     step=1
44     ;;
45     3)
46     min=$1
47     max=$3
48     step=$2
49     ;;
50     *)
51     die "seq called with wrong parameters number"
52     esac
53    
54     if [[ -z "${p}" ]]; then
55     local reps
56     # BSD userland
57     if [[ ${step} != 0 ]]; then
58     reps=$(( ($max-$min) / $step +1 ))
59     else
60     reps=0
61     fi
62    
63     jot $reps $min $max $step
64     else
65     "${p}" $min $step $max
66     fi
67     }
68    
69     # Gets the linker flag to link to dlopen() function
70     dlopen_lib() {
71     if [[ ${ELIBC} != *BSD ]]; then
72     echo "-ldl"
73     fi
74     }

  ViewVC Help
Powered by ViewVC 1.1.20