aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'worker_modules/gkbuild.sh')
-rw-r--r--worker_modules/gkbuild.sh121
1 files changed, 93 insertions, 28 deletions
diff --git a/worker_modules/gkbuild.sh b/worker_modules/gkbuild.sh
index 20de263..101d5d0 100644
--- a/worker_modules/gkbuild.sh
+++ b/worker_modules/gkbuild.sh
@@ -1,11 +1,37 @@
#!/bin/bash
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
__module_main() {
_gkbuild_main
}
+_disable_distcc() {
+ if [[ -z "${DISABLE_DISTCC}" ]] || ! isTrue "${DISABLE_DISTCC}"
+ then
+ return
+ fi
+
+ if [[ "$(tc-getCC)" != *distcc* ]] && [[ "$(tc-getCXX)" != *distcc* ]]
+ then
+ return
+ fi
+
+ print_warning 3 "distcc usage for ${P} is known to cause problems; Limiting to localhost ..."
+ export DISTCC_HOSTS=localhost
+
+ # We must ensure that parallel jobs aren't set higher than
+ # available processing units which would kill the system now
+ # that we limited distcc usage to localhost
+ local MAKEOPTS_USER=$(makeopts_jobs)
+ local MAKEOPTS_MAX=$(get_nproc)
+ if [[ ${MAKEOPTS_USER} -gt ${MAKEOPTS_MAX} ]]
+ then
+ print_warning 3 "MAKEOPTS for ${P} adjusted to -j${MAKEOPTS_MAX} due to disabled distcc support ..."
+ export MAKEOPTS="-j${MAKEOPTS_MAX}"
+ fi
+}
+
# Remove occurrences of strings from variable given in $1
# Strings removed are matched as globs, so for example
# '-O*' would remove -O1, -O2 etc.
@@ -68,6 +94,8 @@ _gkbuild_main() {
fi
done
+ _disable_distcc
+
local current_phase=
for current_phase in ${all_phases}
do
@@ -81,19 +109,22 @@ _gkbuild_main() {
case "${current_phase}" in
src_compile)
print_info 2 "$(get_indent 2)${P}: >> Compiling source ..."
+ cd "${S}" || die "Failed to chdir to '${S}'!"
;;
src_configure)
print_info 2 "$(get_indent 2)${P}: >> Configuring source ..."
- declare -ga CONFIGUREOPTS
+ cd "${S}" || die "Failed to chdir to '${S}'!"
;;
src_install)
print_info 2 "$(get_indent 2)${P}: >> Install to DESTDIR ..."
+ cd "${S}" || die "Failed to chdir to '${S}'!"
;;
src_prepare)
print_info 2 "$(get_indent 2)${P}: >> Preparing source ..."
+ cd "${S}" || die "Failed to chdir to '${S}'!"
;;
src_unpack)
@@ -166,7 +197,7 @@ _gkbuild_main() {
then
found_dyn_files=$(scanelf -E ET_DYN "${executable_files_to_scan[@]}" 2>/dev/null)
fi
-
+
if [[ -n "${found_dyn_files}" ]]
then
print_error 1 "Found the following dynamically linked programs:"
@@ -178,8 +209,24 @@ _gkbuild_main() {
unset found_dyn_files
fi
- tar -caf "${GKPKG_BINPKG}" . \
- || die "Failed to create binpkg of ${P} in '${GKPKG_BINPKG}'!"
+ local -a tar_cmd=( "$(get_tar_cmd "${GKPKG_BINPKG}")" )
+ tar_cmd+=( '.' )
+
+ print_info 3 "COMMAND: ${tar_cmd[*]}" 1 0 1
+ eval "${tar_cmd[@]}" || die "Failed to create binpkg of ${P} in '${GKPKG_BINPKG}'!"
+
+ if [ -n "${DU_COMMAND}" ]
+ then
+ print_info 5 "Final size of build root: $(get_du "${BROOT}")"
+ print_info 5 "Final size of build directory: $(get_du "${S}")"
+ print_info 5 "Final size of installed tree: $(get_du "${D}")"
+ fi
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if [ ! -f "${TEMP}/.no_cleanup" ]
+ then
+ rm -rf "${WORKDIR}"
+ fi
}
_initialize() {
@@ -244,11 +291,8 @@ _initialize() {
die "Unable to build ${P}: '${GK_SHARE}/gkbuilds/${PN}.gkbuild' does NOT exist!"
fi
- source "${GKBUILD}" \
- || die "Failed to source '${GKBUILD}'!"
-
- declare -gr WORKDIR=$(mktemp -d -p "${TEMP}" ${PN}.XXXXXXXX 2>/dev/null)
- [ -z "${WORKDIR}" ] && die "mktemp failed!"
+ declare -gr WORKDIR="${TEMP}/${PN}"
+ mkdir "${WORKDIR}" || die "Failed to create '${WORKDIR}'!"
declare -gr BROOT="${WORKDIR}/buildroot"
mkdir "${BROOT}" || die "Failed to create '${BROOT}'!"
@@ -279,13 +323,15 @@ _initialize() {
S="${WORKDIR}/${GKPKG_SRCDIR}"
+ source "${GKBUILD}" \
+ || die "Failed to source '${GKBUILD}'!"
+
# Some tools like eltpatch (libtoolize) depend on these variables
export S D
if [[ -n "${GKPKG_DEPS}" ]]
then
- # GKPKG_DEPS is ${ARRAY[*]} value (single word), not ${ARRAY[@]} (separate word)!
- GKPKG_DEPS=( ${GKPKG_DEPS} )
+ IFS=';' read -r -a GKPKG_DEPS <<< "${GKPKG_DEPS}"
local GKPKG_DEP=
for GKPKG_DEP in "${GKPKG_DEPS[@]}"
do
@@ -295,13 +341,14 @@ _initialize() {
fi
print_info 2 "$(get_indent 2)${P}: >> Unpacking required binpkg '${GKPKG_DEP}' ..."
- tar -xaf "${GKPKG_DEP}" -C "${BROOT}" \
+ "${TAR_COMMAND}" -xaf "${GKPKG_DEP}" -C "${BROOT}" \
|| die "Unable to build ${P}: Failed to extract required binpkg '${GKPKG_DEP}' to '${BROOT}'!"
done
unset GKPKG_DEP
append-cflags -I"${BROOT}"/usr/include
append-cppflags -I"${BROOT}"/usr/include
+ append-cxxflags -I"${BROOT}"/usr/include
append-ldflags -L"${BROOT}"/usr/lib
fi
@@ -318,7 +365,7 @@ _initialize() {
# https://git.dereferenced.org/pkgconf/pkgconf/issues/30
unset PKG_CONFIG_PATH PKG_CONFIG_DIR LIBRARY_PATH
- export PKG_CONFIG_LIBDIR=\${SYSROOT}/usr/lib/pkgconfig
+ export PKG_CONFIG_LIBDIR=\${SYSROOT}/usr/lib/pkgconfig:\${SYSROOT}/usr/share/pkgconfig
export PKG_CONFIG_SYSROOT_DIR=\${SYSROOT}
exec pkg-config "\$@"
@@ -332,8 +379,6 @@ _initialize() {
}
_src_compile() {
- cd "${S}" || die "Failed to chdir to '${S}'!"
-
if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]
then
gkmake V=1
@@ -341,8 +386,6 @@ _src_compile() {
}
_src_configure() {
- cd "${S}" || die "Failed to chdir to '${S}'!"
-
if [[ -x ${GKCONF_SOURCE:-.}/configure ]]
then
gkconf
@@ -350,8 +393,6 @@ _src_configure() {
}
_src_install() {
- cd "${S}" || die "Failed to chdir to '${S}'!"
-
if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]
then
gkmake V=1 DESTDIR="${D}" install
@@ -359,9 +400,8 @@ _src_install() {
}
_src_prepare() {
- cd "${S}" || die "Failed to chdir to '${S}'!"
-
# let's try to be smart and run autoreconf only when needed
+ # when no value was set in gkbuild
local want_autoreconf=${WANT_AUTORECONF}
# by default always run libtoolize
@@ -385,10 +425,11 @@ _src_prepare() {
-exec cksum {} + | sort -k2
}
- if $(uses_autoconf) && ! isTrue "${want_autoreconf}"
+ if [ -z "${want_autoreconf}" ] && $(uses_autoconf)
then
local checksum=$(at_checksum)
fi
+
if [[ -d "${patchdir}" ]]
then
local silent="-s "
@@ -426,11 +467,11 @@ _src_prepare() {
print_info 2 "$(get_indent 2)${P}: >> No patches found in '$patchdir'; Skipping ..."
fi
- if $(uses_autoconf) && ! isTrue "${want_autoreconf}"
+ if [ -z "${want_autoreconf}" ] && $(uses_autoconf)
then
if [[ ${checksum} != $(at_checksum) ]]
then
- print_info 3 "$(get_indent 2)${P}: >> Will autoreconfigure due applied patches ..."
+ print_info 3 "$(get_indent 2)${P}: >> Will autoreconfigure due to applied patches ..."
want_autoreconf=yes
fi
fi
@@ -448,7 +489,7 @@ _src_prepare() {
_src_unpack() {
cd "${WORKDIR}" || die "Failed to chdir to '${WORKDIR}'!"
- tar -xaf "${GKPKG_SRCTAR}" \
+ "${TAR_COMMAND}" -xaf "${GKPKG_SRCTAR}" \
|| die "Failed to unpack '${GKPKG_SRCTAR}' to '${WORKDIR}'!"
}
@@ -591,6 +632,10 @@ gkautomake() {
# Wrapper for autoreconf.
# Will die when command will exit with nonzero exit status.
gkautoreconf() {
+ # >autoconf-2.69 will call gtkdocize when used in macros
+ # when called with --install parameter.
+ local -x GTKDOCIZE=true
+
gkexec "autoreconf --force --install ${*}"
}
@@ -603,6 +648,21 @@ gkconf() {
: ${GKCONF_SOURCE:=.}
if [ -x "${GKCONF_SOURCE}/configure" ]
then
+ local pid=${BASHPID}
+ local x
+
+ if [ -e "/usr/share/gnuconfig/" ]
+ then
+ find "${WORKDIR}" -type f '(' \
+ -name config.guess -o -name config.sub ')' -print0 | \
+ while read -r -d $'\0' x ; do
+ print_info 3 "$(get_indent 2)${P}: >> Updating ${x/${WORKDIR}\/} with /usr/share/gnuconfig/${x##*/} ..."
+ # Make sure we do this atomically incase we're run in parallel. #487478
+ cp -f /usr/share/gnuconfig/"${x##*/}" "${x}.${pid}"
+ mv -f "${x}.${pid}" "${x}"
+ done
+ fi
+
local -a conf_args=()
local conf_help=$("${GKCONF_SOURCE}/configure" --help 2>/dev/null)
@@ -623,7 +683,7 @@ gkconf() {
fi
if [[ ${conf_help} == *--with-sysroot* ]]; then
- conf_args+=( --with-sysroot="${BROOT}/usr:${SYSROOT}" )
+ conf_args+=( "--with-sysroot='${BROOT}/usr:${SYSROOT}'" )
fi
# Handle arguments containing quoted whitespace (see bug #457136).
@@ -664,7 +724,12 @@ gkconf() {
gklibtoolize() {
type -P eltpatch &>/dev/null || die "eltpatch not found; is app-portage/elt-patches installed?"
- gkexec "ELT_LOGDIR=\"${T}\" LD=\"$(tc-getLD)\" eltpatch ${*}"
+ local command=( "ELT_LOGDIR='${T}'" )
+ command+=( "LD='$(tc-getLD)'" )
+ command+=( "eltpatch" )
+ command+=( "${@}" )
+
+ gkexec "${command[*]}"
}
# @FUNCTION: gkmake