diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2013-10-25 07:07:50 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2013-10-25 07:18:11 +0000 |
commit | 0c02afc69441095eba819cbe572b74c45de878b8 (patch) | |
tree | e07594a56b41cde64cdb29ee0b3fc4cae60c9b82 /abuild.in | |
parent | 7a447caf05ec70c35c9df4d5211b9dd3828e6b6a (diff) | |
download | abuild-0c02afc69441095eba819cbe572b74c45de878b8.tar.gz abuild-0c02afc69441095eba819cbe572b74c45de878b8.tar.bz2 abuild-0c02afc69441095eba819cbe572b74c45de878b8.tar.xz abuild-0c02afc69441095eba819cbe572b74c45de878b8.zip |
abuild: move various functions to the shared functions.sh
specifically, every script that reads/parses ./APKBUILD needs to set
CARCH.
Diffstat (limited to 'abuild.in')
-rwxr-xr-x | abuild.in | 104 |
1 files changed, 17 insertions, 87 deletions
@@ -11,54 +11,32 @@ sysconfdir=@sysconfdir@ abuildrepo_base=@abuildrepo@ datadir=@datadir@ -program=${0##*/} abuild_path=$(readlink -f $0) +if ! [ -f "$datadir/functions.sh" ]; then + echo "$datadir/functions.sh: not found" >&2 + exit 1 +fi +. "$datadir/functions.sh" + # defaults BUILD_BASE="build-base" -FAKEROOT=${FAKEROOT:-"fakeroot"} -: ${SUDO_APK:=abuild-apk} -: ${APK:=apk} -: ${ADDUSER:=abuild-adduser} -: ${ADDGROUP:=abuild-addgroup} +: ${FAKEROOT:="fakeroot"} +: ${SUDO_APK:="abuild-apk"} +: ${APK:="apk"} +: ${ADDUSER:="abuild-adduser"} +: ${ADDGROUP:="abuild-addgroup"} apk_opt_wait="--wait 30" -# read config -ABUILD_CONF=${ABUILD_CONF:-"$sysconfdir/abuild.conf"} -[ -f "$ABUILD_CONF" ] && . "$ABUILD_CONF" - -default_colors() { - NORMAL="\033[1;0m" - STRONG="\033[1;1m" - RED="\033[1;31m" - GREEN="\033[1;32m" - YELLOW="\033[1;33m" - BLUE="\033[1;34m" -} - -monochrome() { - NORMAL="" - STRONG="" - RED="" - GREEN="" - YELLOW="" - BLUE="" -} - -#colors -if [ -n "$USE_COLORS" ]; then - default_colors -fi - # run optional log command for remote logging logcmd() { ${ABUILD_LOG_CMD:-true} "$@" return 0 } -# functions +# we override the default msg, warning and error as we want the pkgname msg() { [ -n "$quiet" ] && return 0 local prompt="$GREEN>>>${NORMAL}" @@ -67,12 +45,6 @@ msg() { printf "${prompt} ${name}${fake}: %s\n" "$1" >&2 } -msg2() { - [ -n "$quiet" ] && return 0 - # ">>> %s" - printf " %s\n" "$1" >&2 -} - warning() { local prompt="${YELLOW}>>> WARNING:${NORMAL}" local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}" @@ -80,11 +52,6 @@ warning() { printf "${prompt} ${name}${fake}: %s\n" "$1" >&2 } -warning2() { - # ">>> WARNING: - printf " %s\n" "$1" >&2 -} - error() { local prompt="${RED}>>> ERROR:${NORMAL}" local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}" @@ -93,17 +60,6 @@ error() { logcmd "ERROR: $pkgname: $1" } -error2() { - # ">>> ERROR: - printf " %s\n" "$1" >&2 -} - -set_xterm_title() { - if [ "$TERM" = xterm ] && [ -n "$USE_COLORS" ]; then - printf "\033]0;$1\007" >&2 - fi -} - cross_compiling() { test "$CBUILD" != "$CHOST" -a -n "$CBUILDROOT" } @@ -1862,30 +1818,11 @@ snapshot() { fi } -hostspec_to_arch() { - case "$1" in - arm*-*-*-*eabi) echo "armel" ;; - arm*-*-*-*eabihf) echo "armhf" ;; - i[0-9]86-*-*-*) echo "x86" ;; - x86_64-*-*-*) echo "x86_64" ;; - *) echo "unknown" ;; - esac -} - -hostspec_to_libc() { - case "$1" in - *-*-*-uclibc*) echo "uclibc" ;; - *-*-*-musl*) echo "musl" ;; - *-*-*-gnu*) echo "eglibc" ;; - *) echo "uclibc" ;; - esac -} - usage() { - echo "$program $abuild_ver" - echo "usage: $program [options] [-i PKG] [-P REPODEST] [-p PKGDEST]" + echo "$prog $abuild_ver" + echo "usage: $prog [options] [-i PKG] [-P REPODEST] [-p PKGDEST]" echo " [-s SRCDEST] [cmd] ..." - echo " $program [-c] -n PKGNAME[-PKGVER]" + echo " $prog [-c] -n PKGNAME[-PKGVER]" echo "Options:" echo " -c Enable colored output" echo " -d Disable dependency checking" @@ -1932,7 +1869,7 @@ unset force unset recursive while getopts "cdfFhi:kimnp:P:qrRs:u" opt; do case $opt in - 'c') default_colors + 'c') enable_colors color_opt="-c";; 'd') nodeps=1;; 'f') force="-f";; @@ -1940,7 +1877,7 @@ while getopts "cdfFhi:kimnp:P:qrRs:u" opt; do 'h') usage;; 'i') install_after="$install_after $OPTARG";; 'k') keep="-k";; - 'm') monochrome + 'm') disable_colors color_opt="-m";; 'n') die "Use newapkbuild to create new aports";; 'p') PKGDEST=$OPTARG;; @@ -1975,13 +1912,6 @@ repo=${repo##*/} SRCDEST=${SRCDEST:-$startdir} PKGDEST=${PKGDEST:-$startdir} -[ -z "$CBUILD" ] && CBUILD="$CHOST" -[ -z "$CTARGET" ] && CTARGET="$CHOST" -[ -z "$CARCH" ] && CARCH="$(hostspec_to_arch $CHOST)" -[ -z "$CLIBC" ] && CLIBC="$(hostspec_to_libc $CHOST)" -[ -z "$CTARGET_ARCH" ] && CTARGET_ARCH="$(hostspec_to_arch $CTARGET)" -[ -z "$CTARGET_LIBC" ] && CTARGET_LIBC="$(hostspec_to_libc $CTARGET)" - # set a default CC : ${CC:=gcc} export CC |