xbps-src: multiple performance improvements.

- use xbps-checkvers(1) to resolve dependencies.
- all dependencies are installed at once for the host and target.
- the `show-build-deps` target is now much faster.
- the `update-bulk/show-repo-updates` targets are now much faster.
- the `update-sys/show-sys-updates` targets are now much faster.
- the `bootstrap` target now works on musl hosts.
- simplified some loops.
- use cut(1) rather than awk(1) where applicable.
- multiple random changes to improve performance.

Based on work started by @Duncaen on https://github.com/void-linux/void-packages/pull/12433

Close https://github.com/void-linux/void-packages/pull/12433
Close https://github.com/void-linux/void-packages/pull/11282
This commit is contained in:
Juan RP 2019-07-03 19:36:22 +02:00 committed by Jürgen Buchmüller
parent 7801a8cef8
commit 2a4e178e35
13 changed files with 401 additions and 602 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ masterdir*
hostdir* hostdir*
etc/conf etc/conf
etc/virtual etc/virtual
.xbps-checkvers.plist

View File

@ -32,16 +32,16 @@ genpkg() {
_preserve=${preserve:+-p} _preserve=${preserve:+-p}
if [ -s ${PKGDESTDIR}/rdeps ]; then if [ -s ${PKGDESTDIR}/rdeps ]; then
_deps="$(cat ${PKGDESTDIR}/rdeps)" _deps="$(<${PKGDESTDIR}/rdeps)"
fi fi
if [ -s ${PKGDESTDIR}/shlib-provides ]; then if [ -s ${PKGDESTDIR}/shlib-provides ]; then
_shprovides="$(cat ${PKGDESTDIR}/shlib-provides)" _shprovides="$(<${PKGDESTDIR}/shlib-provides)"
fi fi
if [ -s ${PKGDESTDIR}/shlib-requires ]; then if [ -s ${PKGDESTDIR}/shlib-requires ]; then
_shrequires="$(cat ${PKGDESTDIR}/shlib-requires)" _shrequires="$(<${PKGDESTDIR}/shlib-requires)"
fi fi
if [ -s ${XBPS_STATEDIR}/gitrev ]; then if [ -s ${XBPS_STATEDIR}/gitrev ]; then
_gitrevs="$(cat ${XBPS_STATEDIR}/gitrev)" _gitrevs="$(<${XBPS_STATEDIR}/gitrev)"
fi fi
# Stripping whitespaces # Stripping whitespaces

View File

@ -5,7 +5,7 @@
# - Generates shlib-requires file for xbps-create(1) # - Generates shlib-requires file for xbps-create(1)
add_rundep() { add_rundep() {
local dep="$1" i= rpkgdep= _depname= _rdeps= found= local dep="$1" i= rpkgdep= _depname= found=
_depname="$($XBPS_UHELPER_CMD getpkgdepname ${dep} 2>/dev/null)" _depname="$($XBPS_UHELPER_CMD getpkgdepname ${dep} 2>/dev/null)"
if [ -z "${_depname}" ]; then if [ -z "${_depname}" ]; then
@ -68,26 +68,19 @@ hook() {
exec < $depsftmp exec < $depsftmp
while read f; do while read f; do
lf=${f#${PKGDESTDIR}} lf=${f#${PKGDESTDIR}}
if [ "${skiprdeps/${lf}/}" != "${skiprdeps}" ]; then if [ "${skiprdeps/${lf}/}" != "${skiprdeps}" ]; then
msg_normal "Skipping dependency scan for ${lf}\n" msg_normal "Skipping dependency scan for ${lf}\n"
continue continue
fi fi
case "$(file -bi "$f")" in case "$(file -bi "$f")" in
application/x-*executable*|application/x-sharedlib*) application/x-*executable*|application/x-sharedlib*)
for nlib in $($OBJDUMP -p "$f"|grep NEEDED|awk '{print $2}'); do for nlib in $($OBJDUMP -p "$f"|grep NEEDED|awk '{print $2}'); do
if [ -z "$verify_deps" ]; then [ -z "$verify_deps" ] && verify_deps="$nlib" && continue
verify_deps="$nlib" found=0
continue
fi
for j in ${verify_deps}; do for j in ${verify_deps}; do
[ "$j" != "$nlib" ] && continue [[ $j == $nlib ]] && found=1 && break
found_dup=1
break
done done
if [ -z "$found_dup" ]; then [[ $found -eq 0 ]] && verify_deps="$verify_deps $nlib"
verify_deps="$verify_deps $nlib"
fi
unset found_dup
done done
;; ;;
esac esac
@ -97,13 +90,13 @@ hook() {
# #
# Add required run time packages by using required shlibs resolved # Add required run time packages by using required shlibs resolved
# above, the mapping is done thru the mapping_shlib_binpkg.txt file. # above, the mapping is done thru the common/shlibs file.
# #
for f in ${verify_deps}; do for f in ${verify_deps}; do
unset _f j rdep _rdep rdepcnt soname _pkgname _rdepver found unset _f j rdep _rdep rdepcnt soname _pkgname _rdepver found
_f=$(echo "$f"|sed -E 's|\+|\\+|g') _f=$(echo "$f"|sed -E 's|\+|\\+|g')
rdep="$(grep -E "^${_f}[[:blank:]]+.*$" $mapshlibs|awk '{print $2}')" rdep="$(grep -E "^${_f}[[:blank:]]+.*$" $mapshlibs|cut -d ' ' -f2)"
rdepcnt="$(grep -E "^${_f}[[:blank:]]+.*$" $mapshlibs|awk '{print $2}'|wc -l)" rdepcnt="$(grep -E "^${_f}[[:blank:]]+.*$" $mapshlibs|cut -d ' ' -f2|wc -l)"
if [ -z "$rdep" ]; then if [ -z "$rdep" ]; then
# Ignore libs by current pkg # Ignore libs by current pkg
soname=$(find ${PKGDESTDIR} -name "$f") soname=$(find ${PKGDESTDIR} -name "$f")
@ -121,15 +114,9 @@ hook() {
_pkgname=$($XBPS_UHELPER_CMD getpkgname "$j") _pkgname=$($XBPS_UHELPER_CMD getpkgname "$j")
# if there's a SONAME matching pkgname, use it. # if there's a SONAME matching pkgname, use it.
for x in ${pkgname} ${subpackages}; do for x in ${pkgname} ${subpackages}; do
if [ "${_pkgname}" = "${x}" ]; then [[ $_pkgname == $x ]] && found=1 && break
found=1
break
fi
done done
if [ -n "$found" ]; then [[ $found ]] && _rdep=$j && break
_rdep=$j
break
fi
done done
if [ -z "${_rdep}" ]; then if [ -z "${_rdep}" ]; then
# otherwise pick up the first one. # otherwise pick up the first one.

View File

@ -119,7 +119,7 @@ hook() {
msg_red "${pkgver}: SONAME bump detected: ${libname}.so.${conflictRev} -> ${libname}.so.${rev}\n" msg_red "${pkgver}: SONAME bump detected: ${libname}.so.${conflictRev} -> ${libname}.so.${rev}\n"
msg_red "${pkgver}: please update common/shlibs with this line: \"${libname}.so.${rev} ${pkgver}\"\n" msg_red "${pkgver}: please update common/shlibs with this line: \"${libname}.so.${rev} ${pkgver}\"\n"
msg_red "${pkgver}: all reverse dependencies should also be revbumped to be rebuilt against ${libname}.so.${rev}:\n" msg_red "${pkgver}: all reverse dependencies should also be revbumped to be rebuilt against ${libname}.so.${rev}:\n"
_revdeps=$($XBPS_QUERY_XCMD -Rs ${libname}.so -p shlib-requires|awk '{print $1}') _revdeps=$($XBPS_QUERY_XCMD -Rs ${libname}.so -p shlib-requires|cut -d ' ' -f1)
for x in ${_revdeps}; do for x in ${_revdeps}; do
msg_red " ${x%:}\n" msg_red " ${x%:}\n"
done done
@ -128,7 +128,7 @@ hook() {
# Try to match provided shlibs in virtual packages. # Try to match provided shlibs in virtual packages.
for f in ${provides}; do for f in ${provides}; do
_vpkgname="$($XBPS_UHELPER_CMD getpkgname ${f} 2>/dev/null)" _vpkgname="$($XBPS_UHELPER_CMD getpkgname ${f} 2>/dev/null)"
_spkgname="$(grep "^${filename}" $mapshlibs | awk '{print $2}')" _spkgname="$(grep "^${filename}" $mapshlibs | cut -d ' ' -f2)"
_libpkgname="$($XBPS_UHELPER_CMD getpkgname ${_spkgname} 2>/dev/null)" _libpkgname="$($XBPS_UHELPER_CMD getpkgname ${_spkgname} 2>/dev/null)"
if [ -z "${_spkgname}" -o -z "${_libpkgname}" ]; then if [ -z "${_spkgname}" -o -z "${_libpkgname}" ]; then
continue continue

View File

@ -43,10 +43,6 @@ if [ "$PKGNAME" != "$XBPS_TARGET_PKG" -o -z "$XBPS_SKIP_DEPS" ]; then
install_pkg_deps $PKGNAME $XBPS_TARGET_PKG pkg $XBPS_CROSS_BUILD $XBPS_CROSS_PREPARE || exit $? install_pkg_deps $PKGNAME $XBPS_TARGET_PKG pkg $XBPS_CROSS_BUILD $XBPS_CROSS_PREPARE || exit $?
fi fi
if [ -z "$XBPS_CROSS_PREPARE" ]; then
install_cross_pkg $XBPS_CROSS_BUILD || exit $?
fi
# Fetch distfiles after installing required dependencies, # Fetch distfiles after installing required dependencies,
# because some of them might be required for do_fetch(). # because some of them might be required for do_fetch().
$XBPS_LIBEXECDIR/xbps-src-dofetch.sh $SOURCEPKG $XBPS_CROSS_BUILD || exit 1 $XBPS_LIBEXECDIR/xbps-src-dofetch.sh $SOURCEPKG $XBPS_CROSS_BUILD || exit 1

View File

@ -1,9 +1,9 @@
# vim: set ts=4 sw=4 et: # vim: set ts=4 sw=4 et:
# #
setup_pkg_depends() { setup_pkg_depends() {
local pkg="$1" j _pkgdepname _pkgdep _rpkgname _depname _depver _replacement local pkg="$1" out="$2" j _rpkgname _depname foo _deps
if [ -n "$pkg" ]; then if [[ $pkg ]]; then
# subpkg # subpkg
if declare -f ${pkg}_package >/dev/null; then if declare -f ${pkg}_package >/dev/null; then
${pkg}_package ${pkg}_package
@ -13,85 +13,65 @@ setup_pkg_depends() {
for j in ${depends}; do for j in ${depends}; do
_rpkgname="${j%\?*}" _rpkgname="${j%\?*}"
_depname="${j#*\?}" _depname="${j#*\?}"
_pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_depname} 2>/dev/null)" if [[ ${_rpkgname} == virtual ]]; then
if [ -z "${_pkgdepname}" ]; then if [ -s ${XBPS_DISTDIR}/etc/virtual ]; then
_pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)" foo=$(egrep "^${_depname}[[:blank:]]" ${XBPS_DISTDIR}/etc/virtual|cut -d ' ' -f2)
fi elif [ -s ${XBPS_DISTDIR}/etc/defaults.virtual ]; then
if [ -s ${XBPS_DISTDIR}/etc/virtual ]; then foo=$(egrep "^${_depname}[[:blank:]]" ${XBPS_DISTDIR}/etc/defaults.virtual|cut -d ' ' -f2)
_replacement=$(egrep "^${_pkgdepname:-${_depname}}[[:blank:]]" ${XBPS_DISTDIR}/etc/virtual|cut -d ' ' -f2) fi
elif [ -s ${XBPS_DISTDIR}/etc/defaults.virtual ]; then if [ -z "$foo" ]; then
_replacement=$(egrep "^${_pkgdepname:-${_depname}}[[:blank:]]" ${XBPS_DISTDIR}/etc/defaults.virtual|cut -d ' ' -f2)
fi
if [ "${_rpkgname}" = "virtual" ]; then
if [ -z "${_replacement}" ]; then
msg_error "$pkgver: failed to resolve virtual dependency for '$j' (missing from etc/virtual)\n" msg_error "$pkgver: failed to resolve virtual dependency for '$j' (missing from etc/virtual)\n"
fi fi
_pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_replacement} 2>/dev/null)" _deps+="$foo "
if [ -z "${_pkgdepname}" ]; then
_pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_replacement} 2>/dev/null)"
fi
if [ -z "${_pkgdepname}" ]; then
_pkgdepname="${_replacement}>=0"
fi
run_depends+=" ${_depname}?${_pkgdepname}"
#echo "Adding dependency virtual: ${_depname}?${_pkgdepname}"
else else
if [ -z "${_pkgdepname}" ]; then foo="$($XBPS_UHELPER_CMD getpkgdepname ${_depname} 2>/dev/null)"
_pkgdep="${_depname}>=0" if [ -z "$foo" ]; then
else foo="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)"
_pkgdep="${_depname}" [ -z "$foo" ] && foo="${_depname}"
fi fi
run_depends+=" ${_pkgdep}" _deps+="$foo "
fi fi
run_depends+="${_depname} "
done done
for j in ${hostmakedepends}; do
_depname="${j%\?*}" [[ $out && $_deps ]] && echo "$_deps"
_depver=$(srcpkg_get_version ${_depname}) || exit $? return 0
host_build_depends+=" ${_depname}-${_depver}"
done
if [ -n "$XBPS_CHECK_PKGS" ]; then
for j in ${checkdepends}; do
_depname="${j%\?*}"
_depver=$(srcpkg_get_version ${_depname}) || exit $?
host_check_depends+=" ${_depname}-${_depver}"
done
fi
for j in ${makedepends}; do
_depname="${j%\?*}"
_depver=$(srcpkg_get_version ${_depname}) || exit $?
build_depends+=" ${_depname}-${_depver}"
done
} }
# Install a required package dependency, like:
# #
# xbps-install -IAy <pkgname> # Install required package dependencies, like:
#
# xbps-install -AIy <pkgs>
#
# -A automatic mode
# -I to ignore file conflicts
# -y yes
# #
# Returns 0 if package already installed or installed successfully. # Returns 0 if package already installed or installed successfully.
# Any other error number otherwise. # Any other error number otherwise.
# #
# SUCCESS (0): package installed successfully.
# ENOENT (2): package missing in repositories.
# ENXIO (6): package depends on invalid dependencies.
# EAGAIN (11): package conflicts.
# EEXIST (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
# ENODEV (19): package depends on missing dependencies.
# ENOTSUP (95): no repositories registered.
#
install_pkg_from_repos() { install_pkg_from_repos() {
local pkg="$1" cross="$2" rval= tmplogf= local cross="$1" rval tmplogf cmd
shift
[ $# -eq 0 ] && return 0
mkdir -p $XBPS_STATEDIR mkdir -p $XBPS_STATEDIR
tmplogf=${XBPS_STATEDIR}/xbps_${XBPS_TARGET_MACHINE}_bdep_${pkg}.log tmplogf=${XBPS_STATEDIR}/xbps_${XBPS_TARGET_MACHINE}_bdep_${pkg}.log
if [ -n "$cross" ]; then cmd=$XBPS_INSTALL_CMD
$XBPS_INSTALL_XCMD -IAy "$pkg" >$tmplogf 2>&1 [[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
else $cmd ${XBPS_SKIP_REMOTEREPOS:+-i} -AIy "$@" >$tmplogf 2>&1
$XBPS_INSTALL_CMD -IAy "$pkg" >$tmplogf 2>&1
fi
rval=$? rval=$?
# xbps-install can return:
#
# SUCCESS (0): package installed successfully.
# ENOENT (2): package missing in repositories.
# ENXIO (6): package depends on invalid dependencies.
# EAGAIN (11): package conflicts.
# EEXIST (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
# ENODEV (19): package depends on missing dependencies.
# ENOTSUP (95): no repositories registered.
#
case "$rval" in case "$rval" in
0) # success, check if there are errors. 0) # success, check if there are errors.
errortmpf=$(mktemp) || exit 1 errortmpf=$(mktemp) || exit 1
@ -111,39 +91,6 @@ install_pkg_from_repos() {
return $rval return $rval
} }
#
# Returns 0 if pkgpattern in $1 is matched against current installed
# package, 1 if no match and 2 if not installed.
#
check_pkgdep_matched() {
local pkg="$1" checkver="$2" cross="$3" uhelper= pkgn= iver=
[ "$build_style" = "meta" ] && return 2
[ -z "$pkg" ] && return 255
pkgn="$($XBPS_UHELPER_CMD getpkgdepname ${pkg} 2>/dev/null)"
if [ -z "$pkgn" ]; then
pkgn="$($XBPS_UHELPER_CMD getpkgname ${pkg} 2>/dev/null)"
fi
[ -z "$pkgn" ] && return 255
if [ -n "$cross" ]; then
uhelper="$XBPS_UHELPER_XCMD"
else
uhelper="$XBPS_UHELPER_CMD"
fi
iver="$($uhelper $checkver $pkgn)"
if [ $? -eq 0 -a -n "$iver" ]; then
$XBPS_UHELPER_CMD pkgmatch "${pkgn}-${iver}" "${pkg}"
[ $? -eq 1 ] && return 0
else
return 2
fi
return 1
}
# #
# Returns 0 if pkgpattern in $1 is installed and greater than current # Returns 0 if pkgpattern in $1 is installed and greater than current
# installed package, otherwise 1. # installed package, otherwise 1.
@ -156,12 +103,8 @@ check_installed_pkg() {
pkgn="$($XBPS_UHELPER_CMD getpkgname ${pkg})" pkgn="$($XBPS_UHELPER_CMD getpkgname ${pkg})"
[ -z "$pkgn" ] && return 2 [ -z "$pkgn" ] && return 2
if [ -n "$cross" ]; then uhelper=$XBPS_UHELPER_CMD
uhelper="$XBPS_UHELPER_XCMD" [[ $cross ]] && uhelper=$XBPS_UHELPER_XCMD
else
uhelper="$XBPS_UHELPER_CMD"
fi
iver="$($uhelper version $pkgn)" iver="$($uhelper version $pkgn)"
if [ $? -eq 0 -a -n "$iver" ]; then if [ $? -eq 0 -a -n "$iver" ]; then
$XBPS_CMPVER_CMD "${pkgn}-${iver}" "${pkg}" $XBPS_CMPVER_CMD "${pkgn}-${iver}" "${pkg}"
@ -171,42 +114,20 @@ check_installed_pkg() {
return 1 return 1
} }
srcpkg_get_version() {
local pkg="$1"
# Run this in a sub-shell to avoid polluting our env.
(
unset XBPS_BINPKG_EXISTS
setup_pkg $pkg || exit $?
echo "${version}_${revision}"
) || msg_error "$pkgver: failed to transform dependency $pkg\n"
}
srcpkg_get_pkgver() {
local pkg="$1"
# Run this in a sub-shell to avoid polluting our env.
(
unset XBPS_BINPKG_EXISTS
setup_pkg $pkg || exit $?
echo "${sourcepkg}-${version}_${revision}"
) || msg_error "$pkgver: failed to transform dependency $pkg\n"
}
# #
# Installs all dependencies required by a package. # Build all dependencies required to build and run.
# #
install_pkg_deps() { install_pkg_deps() {
local pkg="$1" targetpkg="$2" target="$3" cross="$4" cross_prepare="$5" local pkg="$1" targetpkg="$2" target="$3" cross="$4" cross_prepare="$5"
local rval _realpkg _vpkg _curpkg curpkgdepname pkgn iver local _vpkg curpkgdepname
local i j found rundep repo style local i j found style
local -a host_binpkg_deps check_binpkg_deps binpkg_deps local -a host_binpkg_deps binpkg_deps
local -a host_missing_deps check_missing_deps missing_deps missing_rdeps local -a host_missing_deps missing_deps missing_rdeps
[ -z "$pkgname" ] && return 2 [ -z "$pkgname" ] && return 2
[ -z "$XBPS_CHECK_PKGS" ] && unset checkdepends
setup_pkg_depends [[ $build_style ]] && style=" [$build_style]"
[ -n "$build_style" ] && style=" [$build_style]"
for s in $build_helper; do for s in $build_helper; do
style+=" [$s]" style+=" [$s]"
@ -218,197 +139,151 @@ install_pkg_deps() {
msg_normal "$pkgver: building${style} ...\n" msg_normal "$pkgver: building${style} ...\n"
fi fi
if [ -z "$build_depends" -a -z "$host_build_depends" -a -z "$host_check_depends" -a -z "$run_depends" ]; then
return 0
fi
# #
# Host build dependencies. # Host build dependencies.
# #
for i in ${host_build_depends}; do if [[ ${hostmakedepends} ]]; then
_realpkg=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null) while read -r _depname _deprepover _depver _subpkg _repourl; do
check_pkgdep_matched "$i" version _vpkg=${_subpkg}-${_depver}
local rval=$? # binary package found in a repo
if [ $rval -eq 0 ]; then if [[ ${_depver} == ${_deprepover} ]]; then
echo " [host] ${i}: installed." echo " [host] ${_vpkg}: found (${_repourl})"
continue host_binpkg_deps+=("${_vpkg}")
elif [ $rval -eq 1 ]; then
iver=$($XBPS_UHELPER_CMD version ${_realpkg})
if [ $? -eq 0 -a -n "$iver" ]; then
echo " [host] ${i}: installed $iver (virtualpkg)."
continue continue
else
echo " [host] ${i}: unresolved build dependency!"
return 1
fi fi
else # binary package not found
repo=$($XBPS_QUERY_CMD -R -prepository ${i} 2>/dev/null) if [[ $_depname != $_subpkg ]]; then
if [ -n "${repo}" ]; then # subpkg, check if it's a subpkg of itself
echo " [host] ${i}: found ($repo)" found=0
host_binpkg_deps+=("${i}") for f in ${subpackages}; do
continue if [[ ${_subpkg} == ${f} ]]; then
else found=1
echo " [host] ${i}: not found." break
if [ -z "$cross" ]; then
if [ "${_realpkg}" = "$targetpkg" ]; then
msg_error "${pkg}: [host] build loop detected: ${_realpkg} <-> ${targetpkg} [depends on itself]\n"
elif [ "${_realpkg}" = "$pkg" ]; then
msg_error "${pkg}: [host] build loop detected: $pkg <-> ${_realpkg}\n"
fi fi
done
if [[ $found -eq 1 ]]; then
echo " [host] ${_vpkg}: not found (subpkg, ignored)"
else
echo " [host] ${_vpkg}: not found"
host_missing_deps+=("$_vpkg")
fi fi
else
echo " [host] ${_vpkg}: not found"
host_missing_deps+=("$_vpkg")
fi fi
fi done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${hostmakedepends})
host_missing_deps+=("${i}") fi
done
# #
# Host check dependencies. # Host check dependencies.
# #
for i in ${host_check_depends}; do if [[ ${checkdepends} ]] && [[ $XBPS_CHECK_PKGS ]]; then
_realpkg="$($XBPS_UHELPER_CMD getpkgname $i 2>/dev/null)" while read -r _depname _deprepover _depver _subpkg _repourl; do
check_pkgdep_matched "$i" version _vpkg=${_subpkg}-${_depver}
local rval=$? # binary package found in a repo
if [ $rval -eq 0 ]; then if [[ ${_depver} == ${_deprepover} ]]; then
echo " [check] ${i}: installed." echo " [check] ${_vpkg}: found (${_repourl})"
continue host_binpkg_deps+=("${_vpkg}")
elif [ $rval -eq 1 ]; then
iver=$($XBPS_UHELPER_CMD version ${_realpkg})
if [ $? -eq 0 -a -n "$iver" ]; then
echo " [check] ${i}: installed $iver (virtualpkg)."
continue continue
else
echo " [check] ${i}: unresolved check dependency!"
return 1
fi fi
else # binary package not found
repo=$($XBPS_QUERY_CMD -R -prepository ${i} 2>/dev/null) if [[ $_depname != $_subpkg ]]; then
if [ -n "${repo}" ]; then # subpkg, check if it's a subpkg of itself
echo " [check] ${i}: found ($repo)" found=0
check_binpkg_deps+=("${i}") for f in ${subpackages}; do
continue if [[ ${_subpkg} == ${f} ]]; then
else found=1
echo " [check] ${i}: not found." break
if [ "${_realpkg}" = "$targetpkg" ]; then fi
msg_error "${pkg}: [check] build loop detected: ${_realpkg} <-> ${targetpkg} [depends on itself]!\n" done
elif [ "${_realpkg}" = "$pkg" ]; then if [[ $found -eq 1 ]]; then
msg_error "${pkg}: [check] build loop detected: $pkg <-> ${_realpkg}\n" echo " [check] ${_vpkg}: not found (subpkg, ignored)"
else
echo " [check] ${_vpkg}: not found"
host_missing_deps+=("$_vpkg")
fi fi
else
echo " [check] ${_vpkg}: not found"
host_missing_deps+=("$_vpkg")
fi fi
fi done < <($XBPS_CHECKVERS_CMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${checkdepends})
check_missing_deps+=("${i}") fi
done
# #
# Target build dependencies. # Target build dependencies.
# #
for i in ${build_depends}; do if [[ ${makedepends} ]]; then
_realpkg="$($XBPS_UHELPER_CMD getpkgname $i 2>/dev/null)" while read -r _depname _deprepover _depver _subpkg _repourl; do
# Check if dependency is a subpkg, if it is, ignore it. _vpkg=${_subpkg}-${_depver}
unset found # binary package found in a repo
for j in ${subpackages}; do if [[ ${_depver} == ${_deprepover} ]]; then
[ "$j" = "${_realpkg}" ] && found=1 && break echo " [target] ${_vpkg}: found (${_repourl})"
done binpkg_deps+=("${_vpkg}")
[ -n "$found" ] && continue
check_pkgdep_matched "${i}" version $cross
local rval=$?
if [ $rval -eq 0 ]; then
echo " [target] ${i}: installed."
continue
elif [ $rval -eq 1 ]; then
iver=$($XBPS_UHELPER_XCMD version ${_realpkg})
if [ $? -eq 0 -a -n "$iver" ]; then
echo " [target] ${i}: installed $iver (virtualpkg)."
continue continue
else
echo " [target] ${i}: unresolved build dependency!"
return 1
fi fi
else # binary package not found
repo=$($XBPS_QUERY_XCMD -R -prepository ${i} 2>/dev/null) if [[ $_depname != $_subpkg ]]; then
if [ -n "${repo}" ]; then # subpkg, check if it's a subpkg of itself
echo " [target] ${i}: found ($repo)" found=0
binpkg_deps+=("${i}") for f in ${subpackages}; do
continue if [[ ${_subpkg} == ${f} ]]; then
else found=1
echo " [target] ${i}: not found." break
if [ "${_realpkg}" = "$targetpkg" ]; then fi
msg_error "${pkg}: [target] build loop detected: ${_realpkg} <-> ${targetpkg} [depends on itself]\n" done
elif [ "${_realpkg}" = "$pkg" ]; then if [[ $found -eq 1 ]]; then
msg_error "${pkg}: [target] build loop detected: $pkg <-> ${_realpkg}\n" echo " [target] ${_vpkg}: not found (subpkg, ignored)"
else
echo " [target] ${_vpkg}: not found"
missing_deps+=("$_vpkg")
fi fi
else
echo " [target] ${_vpkg}: not found"
missing_deps+=("$_vpkg")
fi fi
fi done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm ${makedepends})
missing_deps+=("${i}") fi
done
# #
# Target run time dependencies # Target run time dependencies
# #
for i in ${run_depends}; do if [[ ${depends} ]]; then
_realpkg="${i%\?*}" _deps=$(setup_pkg_depends "" 1)
_curpkg="${_realpkg}" while read -r _depname _deprepover _depver _subpkg _repourl; do
_vpkg="${i#*\?}" _vpkg=${_subpkg}-${_depver}
if [ "${_realpkg}" != "${_vpkg}" ]; then # binary package found in a repo
_realpkg="${_vpkg}" if [[ ${_depver} == ${_deprepover} ]]; then
else echo " [runtime] ${_vpkg}: found (${_repourl})"
unset _curpkg
fi
pkgn=$($XBPS_UHELPER_CMD getpkgdepname "${_realpkg}")
if [ -z "$pkgn" ]; then
pkgn=$($XBPS_UHELPER_CMD getpkgname "${_realpkg}")
if [ -z "$pkgn" ]; then
msg_error "$pkgver: invalid runtime dependency: ${_realpkg}\n"
fi
fi
# Check if dependency is a subpkg, if it is, ignore it.
unset found
for j in ${subpackages}; do
[ "$j" = "${pkgn}" ] && found=1 && break
done
[ -n "$found" ] && continue
_props=$($XBPS_QUERY_XCMD -R -ppkgver,repository ${_realpkg} 2>/dev/null)
if [ -n "${_props}" ]; then
set -- ${_props}
$XBPS_UHELPER_CMD pkgmatch ${1} "${_realpkg}"
if [ $? -eq 1 ]; then
if [ -n "${_curpkg}" ]; then
echo " [runtime] ${_curpkg}:${_realpkg} (virtual dependency): found $1 ($2)"
else
echo " [runtime] ${_realpkg}: found $1 ($2)"
fi
shift 2
continue continue
else fi
if [ -n "${_curpkg}" ]; then # binary package not found
echo " [runtime] ${_curpkg}:${_realpkg} (virtual dependency): not found." if [[ $_depname != $_subpkg ]]; then
# subpkg, check if it's a subpkg of itself
found=0
for f in ${subpackages}; do
if [[ ${_subpkg} == ${f} ]]; then
found=1
break
fi
done
if [[ $found -eq 1 ]]; then
echo " [runtime] ${_vpkg}: not found (subpkg, ignored)"
else else
echo " [runtime] ${_realpkg}: not found." echo " [runtime] ${_vpkg}: not found"
missing_rdeps+=("$_vpkg")
fi fi
fi
shift 2
else
if [ -n "${_curpkg}" ]; then
echo " [runtime] ${_curpkg}:${_realpkg} (virtual dependency): not found."
else else
echo " [runtime] ${_realpkg}: not found." echo " [runtime] ${_vpkg}: not found"
missing_rdeps+=("$_vpkg")
fi fi
fi done < <($XBPS_CHECKVERS_XCMD ${XBPS_SKIP_REMOTEREPOS:+-i} -D $XBPS_DISTDIR -sm $_deps)
if [ "${_realpkg}" = "$targetpkg" ]; then unset _deps
msg_error "${pkg}: [run] build loop detected: ${_realpkg} <-> ${targetpkg} [depends on itself]\n" fi
elif [ "${_realpkg}" = "$pkg" ]; then
msg_error "${pkg}: [run] build loop detected: $pkg <-> ${_realpkg}\n"
fi
missing_rdeps+=("${_realpkg}")
done
if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
for i in ${host_missing_deps[@]}; do for i in ${host_missing_deps[@]}; do
msg_error "dep ${i} not found: -1 passed: instructed not to build\n" msg_error "dep ${i} not found: -1 passed: instructed not to build\n"
done done
for i in ${check_missing_deps[@]}; do
msg_error "dep ${i} not found: -1 passed: instructed not to build\n"
done
for i in ${missing_rdeps[@]}; do for i in ${missing_rdeps[@]}; do
msg_error "dep ${i} not found: -1 passed: instructed not to build\n" msg_error "dep ${i} not found: -1 passed: instructed not to build\n"
done done
@ -429,18 +304,6 @@ install_pkg_deps() {
host_binpkg_deps+=("$i") host_binpkg_deps+=("$i")
done done
# Missing check dependencies, build from srcpkgs.
for i in ${check_missing_deps[@]}; do
# packages not found in repos, install from source.
(
curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
setup_pkg $curpkgdepname
exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 \
$XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target || exit $?
) || exit $?
check_binpkg_deps+=("$i")
done
# Missing target dependencies, build from srcpkgs. # Missing target dependencies, build from srcpkgs.
for i in ${missing_deps[@]}; do for i in ${missing_deps[@]}; do
# packages not found in repos, install from source. # packages not found in repos, install from source.
@ -471,22 +334,25 @@ install_pkg_deps() {
) || exit $? ) || exit $?
done done
if [ "$pkg" != "$targetpkg" ]; then if [[ ${host_binpkg_deps} ]]; then
msg_normal "$pkg: building${style} (dependency of $targetpkg) ...\n" if [ -z "$XBPS_QUIET" ]; then
# normal messages in bold
[[ $NOCOLORS ]] || printf "\033[1m"
echo "=> $pkgver: installing host dependencies: ${host_binpkg_deps[@]} ..."
[[ $NOCOLORS ]] || printf "\033[m"
fi
install_pkg_from_repos "" "${host_binpkg_deps[@]}"
fi fi
for i in ${host_binpkg_deps[@]}; do if [[ ${binpkg_deps} ]]; then
msg_normal "$pkgver: installing host dependency '$i' ...\n" if [ -z "$XBPS_QUIET" ]; then
install_pkg_from_repos "${i}" # normal messages in bold
done [[ $NOCOLORS ]] || printf "\033[1m"
echo "=> $pkgver: installing target dependencies: ${binpkg_deps[@]} ..."
[[ $NOCOLORS ]] || printf "\033[m"
fi
install_pkg_from_repos "$cross" "${binpkg_deps[@]}"
fi
for i in ${check_binpkg_deps[@]}; do return 0
msg_normal "$pkgver: installing check dependency '$i' ...\n"
install_pkg_from_repos "${i}"
done
for i in ${binpkg_deps[@]}; do
msg_normal "$pkgver: installing target dependency '$i' ...\n"
install_pkg_from_repos "$i" $cross
done
} }

View File

@ -1,36 +1,11 @@
# vim: set ts=4 sw=4 et: # vim: set ts=4 sw=4 et:
bulk_getlink() {
local p="${1##*/}"
local target="$(readlink $XBPS_SRCPKGDIR/$p)"
if [ $? -eq 0 -a -n "$target" ]; then
p=$target
fi
echo $p
}
bulk_sortdeps() { bulk_sortdeps() {
local _pkgs _pkg pkgs pkg found f x tmpf local _pkgs _pkg pkgs pkg found f x tmpf
_pkgs="$@" pkgs="$@"
# Iterate over the list and make sure that only real pkgs are
# added to our pkglist.
for pkg in ${_pkgs}; do
found=0
f=$(bulk_getlink $pkg)
for x in ${pkgs}; do
if [ "$x" = "${f}" ]; then
found=1
break
fi
done
if [ $found -eq 0 ]; then
pkgs+="${f} "
fi
done
tmpf=$(mktemp) || exit 1 tmpf=$(mktemp) || exit 1
# Now make the real dependency graph of all pkgs to build. # Now make the real dependency graph of all pkgs to build.
# Perform a topological sort of all pkgs but only with build dependencies # Perform a topological sort of all pkgs but only with build dependencies
# that are found in previous step. # that are found in previous step.
@ -38,16 +13,11 @@ bulk_sortdeps() {
_pkgs="$(./xbps-src show-build-deps $pkg 2>/dev/null)" _pkgs="$(./xbps-src show-build-deps $pkg 2>/dev/null)"
found=0 found=0
for x in ${_pkgs}; do for x in ${_pkgs}; do
_pkg=$(bulk_getlink $x)
for f in ${pkgs}; do for f in ${pkgs}; do
if [ "${f}" != "${_pkg}" ]; then [[ $f == $x ]] && found=1 && echo "${pkg} ${f}" >> $tmpf
continue
fi
found=1
echo "${pkg} ${f}" >> $tmpf
done done
done done
[ $found -eq 0 ] && echo "${pkg} ${pkg}" >> $tmpf [[ $found -eq 0 ]] && echo "${pkg} ${pkg}" >> $tmpf
done done
tsort $tmpf|tac tsort $tmpf|tac
rm -f $tmpf rm -f $tmpf
@ -63,7 +33,7 @@ bulk_build() {
msg_error "xbps-src: cannot find xbps-checkvers(8) command!\n" msg_error "xbps-src: cannot find xbps-checkvers(8) command!\n"
fi fi
bulk_sortdeps "$(xbps-checkvers ${1} --distdir=$XBPS_DISTDIR | awk '{print $2}')" bulk_sortdeps "$(xbps-checkvers -f '%n' ${1} --distdir=$XBPS_DISTDIR)"
} }
bulk_update() { bulk_update() {

View File

@ -169,7 +169,7 @@ chroot_handler() {
[ -z "$action" -a -z "$pkg" ] && return 1 [ -z "$action" -a -z "$pkg" ] && return 1
case "$action" in case "$action" in
fetch|extract|patch|build|check|configure|install|install-destdir|pkg|build-pkg|bootstrap-update|chroot) fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
chroot_prepare || return $? chroot_prepare || return $?
chroot_init || return $? chroot_init || return $?
chroot_sync_repos || return $? chroot_sync_repos || return $?
@ -181,30 +181,13 @@ chroot_handler() {
$XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" /bin/xbps-shell $XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" /bin/xbps-shell
rv=$? rv=$?
else else
[ -n "$XBPS_CROSS_BUILD" ] && arg="$arg -a $XBPS_CROSS_BUILD"
[ -n "$XBPS_KEEP_ALL" ] && arg="$arg -C"
[ -n "$NOCOLORS" ] && arg="$arg -L"
[ -n "$XBPS_BUILD_FORCEMODE" ] && arg="$arg -f"
[ -n "$XBPS_MAKEJOBS" ] && arg="$arg -j$XBPS_MAKEJOBS"
[ -n "$XBPS_DEBUG_PKGS" ] && arg="$arg -g"
[ -n "$XBPS_CHECK_PKGS" ] && arg="$arg -Q"
[ -n "$XBPS_BUILD_ONLY_ONE_PKG" ] && arg="$arg -1"
[ -n "$XBPS_QUIET" ] && arg="$arg -q"
[ -n "$XBPS_SKIP_DEPS" ] && arg="$arg -I"
[ -n "$XBPS_ALT_REPOSITORY" ] && arg="$arg -r $XBPS_ALT_REPOSITORY"
[ -n "$XBPS_USE_GIT_REVS" ] && arg="$arg -G"
[ -n "$XBPS_PKG_OPTIONS" ] && arg="$arg -o $XBPS_PKG_OPTIONS"
[ -n "$XBPS_TEMP_MASTERDIR" ] && arg="$arg -t -C"
[ -n "$XBPS_BINPKG_EXISTS" ] && arg="$arg -E"
action="$arg $action"
env -i -- PATH="/usr/bin" SHELL=/bin/sh \ env -i -- PATH="/usr/bin" SHELL=/bin/sh \
HOME=/tmp IN_CHROOT=1 LC_COLLATE=C LANG=en_US.UTF-8 \ HOME=/tmp IN_CHROOT=1 LC_COLLATE=C LANG=en_US.UTF-8 \
SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \ SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \
XBPS_ALLOW_CHROOT_BREAKOUT="$XBPS_ALLOW_CHROOT_BREAKOUT" \ XBPS_ALLOW_CHROOT_BREAKOUT="$XBPS_ALLOW_CHROOT_BREAKOUT" \
$XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \ $XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \
$XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" \ $XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" \
/void-packages/xbps-src $action $pkg /void-packages/xbps-src $XBPS_OPTIONS $action $pkg
rv=$? rv=$?
fi fi

View File

@ -294,7 +294,7 @@ setup_pkg() {
XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE" XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD" XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE" XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers --repository=$XBPS_REPOSITORY"
else else
export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE} export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
@ -307,7 +307,7 @@ setup_pkg() {
XBPS_REMOVE_XCMD="$XBPS_REMOVE_CMD" XBPS_REMOVE_XCMD="$XBPS_REMOVE_CMD"
XBPS_RINDEX_XCMD="$XBPS_RINDEX_CMD" XBPS_RINDEX_XCMD="$XBPS_RINDEX_CMD"
XBPS_UHELPER_XCMD="$XBPS_UHELPER_CMD" XBPS_UHELPER_XCMD="$XBPS_UHELPER_CMD"
XBPS_CHECKVERS_XCMD="$XBPS_CHECKVERS_CMD"
fi fi
export XBPS_INSTALL_XCMD XBPS_QUERY_XCMD XBPS_RECONFIGURE_XCMD \ export XBPS_INSTALL_XCMD XBPS_QUERY_XCMD XBPS_RECONFIGURE_XCMD \
@ -402,7 +402,7 @@ setup_pkg() {
arch="$XBPS_TARGET_MACHINE" arch="$XBPS_TARGET_MACHINE"
fi fi
if [ -n "$XBPS_BINPKG_EXISTS" ]; then if [ -n "$XBPS_BINPKG_EXISTS" ]; then
if [ "$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then if [ "$($XBPS_QUERY_XCMD -i -R -ppkgver $pkgver 2>/dev/null)" = "$pkgver" ]; then
exit_and_cleanup exit_and_cleanup
fi fi
fi fi
@ -556,17 +556,17 @@ setup_pkg() {
wrksrc="$XBPS_BUILDDIR/$wrksrc" wrksrc="$XBPS_BUILDDIR/$wrksrc"
fi fi
if [ "$cross" -a "$nocross" -a "z$show_problems" != "zignore-problems" ]; then if [ "$cross" -a "$nocross" -a "$show_problems" != "ignore-problems" ]; then
msg_red "$pkgver: cannot be cross compiled, exiting...\n" msg_red "$pkgver: cannot be cross compiled, exiting...\n"
msg_red "$pkgver: $nocross\n" msg_red "$pkgver: $nocross\n"
exit 2 exit 2
elif [ "$broken" -a "z$show_problems" != "zignore-problems" ]; then elif [ "$broken" -a "$show_problems" != "ignore-problems" ]; then
msg_red "$pkgver: cannot be built, it's currently broken; see the build log:\n" msg_red "$pkgver: cannot be built, it's currently broken; see the build log:\n"
msg_red "$pkgver: $broken\n" msg_red "$pkgver: $broken\n"
exit 2 exit 2
fi fi
if [ -n "$restricted" -a -z "$XBPS_ALLOW_RESTRICTED" -a "z$show_problems" != "zignore-problems" ]; then if [ -n "$restricted" -a -z "$XBPS_ALLOW_RESTRICTED" -a "$show_problems" != "ignore-problems" ]; then
msg_red "$pkgver: does not allow redistribution of sources/binaries (restricted license).\n" msg_red "$pkgver: does not allow redistribution of sources/binaries (restricted license).\n"
msg_red "If you really need this software, run 'echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf'\n" msg_red "If you really need this software, run 'echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf'\n"
exit 2 exit 2
@ -575,9 +575,7 @@ setup_pkg() {
export XBPS_STATEDIR="${XBPS_BUILDDIR}/.xbps-${sourcepkg}" export XBPS_STATEDIR="${XBPS_BUILDDIR}/.xbps-${sourcepkg}"
export XBPS_WRAPPERDIR="${XBPS_STATEDIR}/wrappers" export XBPS_WRAPPERDIR="${XBPS_STATEDIR}/wrappers"
if [ -n "$bootstrap" -a -z "$CHROOT_READY" -o -n "$IN_CHROOT" ]; then mkdir -p $XBPS_STATEDIR $XBPS_WRAPPERDIR
mkdir -p $XBPS_WRAPPERDIR
fi
source_file $XBPS_COMMONDIR/environment/build-style/${build_style}.sh source_file $XBPS_COMMONDIR/environment/build-style/${build_style}.sh

View File

@ -24,11 +24,12 @@ remove_pkg_cross_deps() {
prepare_cross_sysroot() { prepare_cross_sysroot() {
local cross="$1" local cross="$1"
local statefile="$XBPS_MASTERDIR/.xbps-${cross}-done"
[ -z "$cross" -o "$cross" = "" ] && return 0 [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
# Check for cross-vpkg-dummy available for the target arch, otherwise build it. # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
pkg_available 'cross-vpkg-dummy>=0.30_1' $cross pkg_available 'cross-vpkg-dummy>=0.31_1' $cross
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
$XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $? $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy cross-vpkg-dummy pkg $cross init || return $?
fi fi
@ -40,7 +41,7 @@ prepare_cross_sysroot() {
errlog=$(mktemp) || exit 1 errlog=$(mktemp) || exit 1
$XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
rval=$? rval=$?
if [ $rval -ne 0 -a $rval -ne 17 ]; then if [ $rval -ne 0 ]; then
msg_red "failed to install cross-vpkg-dummy (error $rval)\n" msg_red "failed to install cross-vpkg-dummy (error $rval)\n"
cat $errlog cat $errlog
rm -f $errlog rm -f $errlog
@ -48,11 +49,15 @@ prepare_cross_sysroot() {
fi fi
rm -f $errlog rm -f $errlog
# Create top level symlinks in sysroot. # Create top level symlinks in sysroot.
XBPS_ARCH=$XBPS_TARGET_MACHINE xbps-reconfigure -r $XBPS_CROSS_BASE -f base-directories base-files &>/dev/null XBPS_ARCH=$XBPS_TARGET_MACHINE xbps-reconfigure -r $XBPS_CROSS_BASE -f base-files &>/dev/null
# Create a sysroot/include and sysroot/lib symlink just in case. # Create a sysroot/include and sysroot/lib symlink just in case.
ln -s usr/include ${XBPS_CROSS_BASE}/include ln -s usr/include ${XBPS_CROSS_BASE}/include
ln -s usr/lib ${XBPS_CROSS_BASE}/lib ln -s usr/lib ${XBPS_CROSS_BASE}/lib
install_cross_pkg $cross || return 1
touch -f $statefile
return 0 return 0
} }

View File

@ -54,6 +54,10 @@ remove_pkg_autodeps() {
$XBPS_RECONFIGURE_CMD -a >> $tmplogf 2>&1 $XBPS_RECONFIGURE_CMD -a >> $tmplogf 2>&1
echo yes | $XBPS_REMOVE_CMD -Ryod >> $tmplogf 2>&1 echo yes | $XBPS_REMOVE_CMD -Ryod >> $tmplogf 2>&1
rval=$? rval=$?
if [ $rval -eq 0 ]; then
echo yes | $XBPS_REMOVE_CMD -Ryod >> $tmplogf 2>&1
rval=$?
fi
if [ $rval -ne 0 ]; then if [ $rval -ne 0 ]; then
msg_red "${pkgver:-xbps-src}: failed to remove autodeps: (returned $rval)\n" msg_red "${pkgver:-xbps-src}: failed to remove autodeps: (returned $rval)\n"

View File

@ -61,44 +61,22 @@ show_avail() {
} }
show_pkg_build_depends() { show_pkg_build_depends() {
local f x _pkgname _srcpkg _dep found result local f x _pkgname _srcpkg found result
local _deps="$1" local _deps="$1"
result=$(mktemp) || exit 1 result=$(mktemp) || exit 1
# build time deps # build time deps
for f in ${_deps}; do for f in ${_deps}; do
# ignore virtual deps
local _rpkg="${f%\?*}"
local _vpkg="${f#*\?}"
# ignore virtual dependencies # ignore virtual dependencies
if [ "${_rpkg}" != "${_vpkg}" ]; then [[ ${f%\?*} != ${f#*\?} ]] && f=${f#*\?}
f="${_vpkg}"
fi
unset found unset found
# check for subpkgs # check for subpkgs
for x in ${subpackages}; do for x in ${subpackages}; do
_pkgname="$($XBPS_UHELPER_CMD getpkgdepname $f 2>/dev/null)" [[ $f == $x ]] && found=1 && break
if [ -z "${_pkgname}" ]; then
_pkgname="$($XBPS_UHELPER_CMD getpkgname $f 2>/dev/null)"
fi
if [ "${_pkgname}" = "$x" ]; then
found=1
break
fi
done done
if [ -n "$found" ]; then [[ $found ]] && continue
continue _pkgname=${f/-32bit}
fi
_pkgname="$($XBPS_UHELPER_CMD getpkgdepname $f 2>/dev/null)"
if [ -z "${_pkgname}" ]; then
_pkgname="$($XBPS_UHELPER_CMD getpkgname $f 2>/dev/null)"
fi
if [ -z "${_pkgname}" ]; then
_pkgname="$f"
fi
_pkgname=${_pkgname/-32bit}
_srcpkg=$(readlink -f ${XBPS_SRCPKGDIR}/${_pkgname}) _srcpkg=$(readlink -f ${XBPS_SRCPKGDIR}/${_pkgname})
_srcpkg=${_srcpkg##*/} _srcpkg=${_srcpkg##*/}
echo "${_srcpkg}" >> $result echo "${_srcpkg}" >> $result
@ -108,18 +86,15 @@ show_pkg_build_depends() {
} }
show_pkg_build_deps() { show_pkg_build_deps() {
setup_pkg_depends show_pkg_build_depends "${hostmakedepends} ${makedepends} $(setup_pkg_depends '' 1)"
show_pkg_build_depends "${host_build_depends} ${build_depends} ${run_depends}"
} }
show_pkg_hostmakedepends() { show_pkg_hostmakedepends() {
setup_pkg_depends show_pkg_build_depends "${hostmakedepends}"
show_pkg_build_depends "${host_build_depends}"
} }
show_pkg_makedepends() { show_pkg_makedepends() {
setup_pkg_depends show_pkg_build_depends "${makedepends}"
show_pkg_build_depends "${build_depends}"
} }
show_pkg_build_options() { show_pkg_build_options() {

324
xbps-src
View File

@ -1,8 +1,6 @@
#!/bin/bash #!/bin/bash
# vim: set ts=4 sw=4 et: # vim: set ts=4 sw=4 et:
readonly PROGNAME="${0##*/}"
print_cross_targets() { print_cross_targets() {
local f local f
for f in common/cross-profiles/*.sh; do for f in common/cross-profiles/*.sh; do
@ -210,7 +208,7 @@ _EOF
check_reqhost_utils() { check_reqhost_utils() {
local broken local broken
[ -n "$IN_CHROOT" ] && return 0 [ "$IN_CHROOT" ] && return 0
for f in ${REQHOST_UTILS}; do for f in ${REQHOST_UTILS}; do
if ! command -v ${f} &>/dev/null; then if ! command -v ${f} &>/dev/null; then
@ -218,7 +216,7 @@ check_reqhost_utils() {
broken=1 broken=1
fi fi
done done
[ -n "$broken" ] && exit 1 [ "$broken" ] && exit 1
[ -z "$1" ] && return 0 [ -z "$1" ] && return 0
for f in ${REQHOST_UTILS_BOOTSTRAP}; do for f in ${REQHOST_UTILS_BOOTSTRAP}; do
@ -227,24 +225,7 @@ check_reqhost_utils() {
broken=1 broken=1
fi fi
done done
[ -n "$broken" ] && exit 1 [ "$broken" ] && exit 1
}
check_config_vars() {
if [ -s "$XBPS_CONFIG_FILE" ]; then
. $XBPS_CONFIG_FILE &>/dev/null
fi
if [ -z "$XBPS_MASTERDIR" ]; then
export XBPS_MASTERDIR="${XBPS_DISTDIR}/masterdir"
fi
if [ -z "$XBPS_HOSTDIR" ]; then
export XBPS_HOSTDIR="${XBPS_DISTDIR}/hostdir"
[ ! -d $XBPS_HOSTDIR ] && mkdir -p $XBPS_HOSTDIR
fi
if [ -d "$XBPS_MASTERDIR" -a ! -w "$XBPS_MASTERDIR" ]; then
echo "ERROR: not enough perms for masterdir $XBPS_MASTERDIR."
exit 1
fi
} }
check_build_requirements() { check_build_requirements() {
@ -264,20 +245,42 @@ check_build_requirements() {
fi fi
} }
chroot_check() {
if [ -f $XBPS_MASTERDIR/.xbps_chroot_init -o "$XBPS_CHROOT_CMD" = "ethereal" ]; then
export CHROOT_READY=1
fi
}
check_native_arch() {
if [ "$CHROOT_READY" ]; then
if [ -s $XBPS_MASTERDIR/.xbps_chroot_init ]; then
export XBPS_ARCH=$(<$XBPS_MASTERDIR/.xbps_chroot_init)
else
export XBPS_ARCH=$(xbps-uhelper arch)
fi
else
LDD=$(ldd --version 2>&1|head -1)
if [[ $LDD == *musl* ]]; then
export XBPS_ARCH=${XBPS_MACHINE%-musl}-musl
else
# XBPS_ARCH == $(uname -m)
export XBPS_ARCH=$(uname -m)
fi
fi
}
install_bbootstrap() { install_bbootstrap() {
[ -n "$CHROOT_READY" ] && return [ "$CHROOT_READY" ] && return
if [ "$1" = "bootstrap" ]; then if [ "$1" = "bootstrap" ]; then
unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
else else
XBPS_TARGET_PKG="$1" XBPS_TARGET_PKG="$1"
fi fi
if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then [ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
unset XBPS_INSTALL_ARGS
fi
# binary bootstrap # binary bootstrap
msg_normal "Installing bootstrap from binary package repositories...\n" msg_normal "Installing bootstrap from binary package repositories...\n"
# XBPS_TARGET_PKG == arch # XBPS_TARGET_PKG == arch
if [ -n "$XBPS_TARGET_PKG" ]; then if [ "$XBPS_TARGET_PKG" ]; then
_bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG" _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
_subarch="-${XBPS_TARGET_PKG#*-}" _subarch="-${XBPS_TARGET_PKG#*-}"
@ -308,17 +311,15 @@ reconfigure_bootstrap_pkgs() {
# Reconfigure ca-certificates. # Reconfigure ca-certificates.
msg_normal "Reconfiguring bootstrap packages...\n" msg_normal "Reconfiguring bootstrap packages...\n"
for f in ${pkgs}; do for f in ${pkgs}; do
if xbps-query $f &>/dev/null; then if $XBPS_QUERY_CMD $f &>/dev/null; then
xbps-reconfigure -f $f $XBPS_RECONFIGURE_CMD -f $f
fi fi
done done
touch -f $statefile touch -f $statefile
} }
bootstrap_update() { bootstrap_update() {
if [ -z "$CHROOT_READY" ]; then [ -z "$CHROOT_READY" ] && return
return
fi
remove_pkg_autodeps remove_pkg_autodeps
msg_normal "xbps-src: cleaning up masterdir...\n" msg_normal "xbps-src: cleaning up masterdir...\n"
rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
@ -347,7 +348,7 @@ masterdir_zap() {
exit_func() { exit_func() {
wait wait
if [ -n "$sourcepkg" ]; then if [ "$sourcepkg" ]; then
remove_pkg $XBPS_CROSS_BUILD remove_pkg $XBPS_CROSS_BUILD
fi fi
if [ -z "$IN_CHROOT" ]; then if [ -z "$IN_CHROOT" ]; then
@ -390,14 +391,17 @@ setup_distfiles_mirror() {
done done
} }
readonly XBPS_VERSION_REQ="0.55"
readonly XBPS_VERSION=$(xbps-uhelper -V|awk '{print $2}')
readonly XBPS_SRC_VERSION="113"
export XBPS_MACHINE=$(xbps-uhelper arch)
# #
# main() # main()
# #
readonly PROGNAME="${0##*/}"
readonly XBPS_VERSION_REQ="0.55"
XBPS_VERSION=$(xbps-uhelper -V)
XBPS_VERSION=${XBPS_VERSION%%API*}
XBPS_VERSION=${XBPS_VERSION##*:}
readonly XBPS_SRC_VERSION="113"
export XBPS_MACHINE=$(xbps-uhelper -C /dev/null arch)
XBPS_OPTIONS= XBPS_OPTIONS=
XBPS_OPTSTRING="1a:CEfgGhH:iIj:Lm:No:qQr:tV" XBPS_OPTSTRING="1a:CEfgGhH:iIj:Lm:No:qQr:tV"
@ -407,26 +411,26 @@ eval set -- $(getopt "$XBPS_OPTSTRING" "$@");
while getopts "$XBPS_OPTSTRING" opt; do while getopts "$XBPS_OPTSTRING" opt; do
case $opt in case $opt in
1) export XBPS_BUILD_ONLY_ONE_PKG=yes; XBPS_OPTIONS+=" -1";; 1) export XBPS_BUILD_ONLY_ONE_PKG=yes; XBPS_OPTIONS+=" -1";;
a) readonly XBPS_CROSS_BUILD="$OPTARG"; XBPS_OPTIONS+=" -a $OPTARG";; a) export XBPS_CROSS_BUILD="$OPTARG"; XBPS_OPTIONS+=" -a $OPTARG";;
C) readonly XBPS_KEEP_ALL=1; XBPS_OPTIONS+=" -C";; C) export XBPS_KEEP_ALL=1; XBPS_OPTIONS+=" -C";;
E) export XBPS_BINPKG_EXISTS=1; XBPS_OPTIONS+=" -E";; E) export XBPS_BINPKG_EXISTS=1; XBPS_OPTIONS+=" -E";;
f) readonly XBPS_BUILD_FORCEMODE=1; XBPS_OPTIONS+=" -f";; f) export XBPS_BUILD_FORCEMODE=1; XBPS_OPTIONS+=" -f";;
G) readonly XBPS_USE_GIT_REVS=1; XBPS_OPTIONS+=" -G";; G) export XBPS_USE_GIT_REVS=1; XBPS_OPTIONS+=" -G";;
g) readonly XBPS_DEBUG_PKGS=1; XBPS_OPTIONS+=" -g";; g) export XBPS_DEBUG_PKGS=1; XBPS_OPTIONS+=" -g";;
H) readonly XBPS_HOSTDIR="$(readlink -f $OPTARG 2>/dev/null)"; XBPS_OPTIONS+=" -H $XBPS_HOSTDIR";; H) export XBPS_HOSTDIR="$(readlink -f $OPTARG 2>/dev/null)"; XBPS_OPTIONS+=" -H $XBPS_HOSTDIR";;
h) usage && exit 0;; h) usage && exit 0;;
i) export XBPS_INFORMATIVE_RUN=1; XBPS_OPTIONS+=" -i";; i) export XBPS_INFORMATIVE_RUN=1; XBPS_OPTIONS+=" -i";;
I) readonly XBPS_SKIP_DEPS=1; XBPS_OPTIONS+=" -I";; I) export XBPS_SKIP_DEPS=1; XBPS_OPTIONS+=" -I";;
j) export XBPS_MAKEJOBS="$OPTARG"; XBPS_OPTIONS+=" -j $OPTARG";; j) export XBPS_MAKEJOBS="$OPTARG"; XBPS_OPTIONS+=" -j $OPTARG";;
L) export NOCOLORS=1; XBPS_OPTIONS+=" -L";; L) export NOCOLORS=1; XBPS_OPTIONS+=" -L";;
m) readonly XBPS_MASTERDIR=$(readlink -f $OPTARG 2>/dev/null); XBPS_OPTIONS+=" -m $XBPS_MASTERDIR";; m) export XBPS_MASTERDIR=$(readlink -f $OPTARG 2>/dev/null); XBPS_OPTIONS+=" -m $XBPS_MASTERDIR";;
N) readonly XBPS_SKIP_REMOTEREPOS=1; XBPS_OPTIONS+=" -N";; N) export XBPS_SKIP_REMOTEREPOS=1; XBPS_OPTIONS+=" -N";;
o) readonly XBPS_PKG_OPTIONS="$OPTARG"; XBPS_OPTIONS+=" -o $OPTARG";; o) export XBPS_PKG_OPTIONS="$OPTARG"; XBPS_OPTIONS+=" -o $OPTARG";;
q) export XBPS_QUIET=1; XBPS_OPTIONS+=" -q";; q) export XBPS_QUIET=1; XBPS_OPTIONS+=" -q";;
Q) export XBPS_CHECK_PKGS=1; XBPS_OPTIONS+=" -Q";; Q) export XBPS_CHECK_PKGS=1; XBPS_OPTIONS+=" -Q";;
r) readonly XBPS_ALT_REPOSITORY="$OPTARG"; XBPS_OPTIONS+=" -r $OPTARG";; r) export XBPS_ALT_REPOSITORY="$OPTARG"; XBPS_OPTIONS+=" -r $OPTARG";;
t) export XBPS_TEMP_MASTERDIR=1; XBPS_OPTIONS+=" -t -C";; t) export XBPS_TEMP_MASTERDIR=1; XBPS_OPTIONS+=" -t -C";;
V) echo $XBPS_SRC_VERSION && exit 0;; V) echo "xbps-src-$XBPS_SRC_VERSION $(xbps-uhelper -V)" && exit 0;;
--) shift; break;; --) shift; break;;
esac esac
done done
@ -437,10 +441,11 @@ shift $(($OPTIND - 1))
# Check if stdout is a tty; if false disable colors. # Check if stdout is a tty; if false disable colors.
test -t 1 || export NOCOLORS=1 test -t 1 || export NOCOLORS=1
# http://no-color.org # http://no-color.org
if [ -n "${NO_COLOR+x}" ]; then if [ "${NO_COLOR+x}" ]; then
export NOCOLORS=1 export NOCOLORS=1
fi fi
# sane umask
umask 022 umask 022
# #
@ -456,22 +461,13 @@ readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
check_reqhost_utils check_reqhost_utils
# Try using chroot-git then git from the host system #
if command -v chroot-git &>/dev/null; then # Set XBPS_CONFIG_FILE, XBPS_DISTDIR, XBPS_MASTERDIR
XBPS_GIT_CMD=$(command -v chroot-git) # and XBPS_HOSTDIR.
elif command -v git &>/dev/null; then #
XBPS_GIT_CMD=$(command -v git) if [ "$IN_CHROOT" ]; then
else
echo "neither chroot-git or git are available in your system!"
exit 1
fi
readonly XBPS_GIT_CMD
if [ -n "$IN_CHROOT" ]; then
readonly XBPS_CONFIG_FILE=/etc/xbps/xbps-src.conf readonly XBPS_CONFIG_FILE=/etc/xbps/xbps-src.conf
readonly XBPS_DISTDIR=/void-packages readonly XBPS_DISTDIR=/void-packages
# needed before call to check_config_vars
readonly XBPS_MASTERDIR=/ readonly XBPS_MASTERDIR=/
readonly XBPS_HOSTDIR=/host readonly XBPS_HOSTDIR=/host
else else
@ -491,18 +487,37 @@ else
elif [ -s $HOME/.xbps-src.conf ]; then elif [ -s $HOME/.xbps-src.conf ]; then
# ... fallback to ~/.xbps-src.conf otherwise. # ... fallback to ~/.xbps-src.conf otherwise.
readonly XBPS_CONFIG_FILE=$HOME/.xbps-src.conf readonly XBPS_CONFIG_FILE=$HOME/.xbps-src.conf
. $XBPS_CONFIG_FILE
fi fi
fi fi
# Read settings from config file
[ -s "$XBPS_CONFIG_FILE" ] && . $XBPS_CONFIG_FILE &>/dev/null
# # if XBPS_MASTERDIR unset, defaults to $XBPS_DISTDIR/masterdir.
# Check configuration vars before anyting else, and set defaults vars. : ${XBPS_MASTERDIR:=$XBPS_DISTDIR/masterdir}
#
check_config_vars
for f in $XBPS_DISTDIR/common/xbps-src/shutils/*.sh; do # if XBPS_HOSTDIR unset, defaults to $XBPS_DISTDIR/hostdir.
[ -r $f ] && . $f : ${XBPS_HOSTDIR:=$XBPS_DISTDIR/hostdir}
done
mkdir -p $XBPS_MASTERDIR $XBPS_HOSTDIR
if [ -d "$XBPS_MASTERDIR" -a ! -w "$XBPS_MASTERDIR" ]; then
echo "ERROR: can't write to masterdir $XBPS_MASTERDIR."
exit 1
elif [ -d "$XBPS_HOSTDIR" -a ! -w "$XBPS_HOSTDIR" ]; then
echo "ERROR: can't write to hostdir: $XBPS_HOSTDIR."
exit 1
fi
# Try using chroot-git then git from the host system
if command -v chroot-git &>/dev/null; then
XBPS_GIT_CMD=$(command -v chroot-git)
elif command -v git &>/dev/null; then
XBPS_GIT_CMD=$(command -v git)
else
echo "neither chroot-git or git are available in your system!"
exit 1
fi
readonly XBPS_GIT_CMD
if [ -n "$XBPS_HOSTDIR" ]; then if [ -n "$XBPS_HOSTDIR" ]; then
export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs
@ -516,80 +531,62 @@ fi
if [ -z "$XBPS_ALT_REPOSITORY" ]; then if [ -z "$XBPS_ALT_REPOSITORY" ]; then
pushd "$PWD" &>/dev/null pushd "$PWD" &>/dev/null
cd $XBPS_DISTDIR cd $XBPS_DISTDIR
if [ -n "$IN_CHROOT" ]; then _gitbranch="$($XBPS_GIT_CMD symbolic-ref --short HEAD 2>/dev/null)"
_gitbranch="$(chroot-git symbolic-ref --short HEAD 2>/dev/null)" if [ "${_gitbranch}" -a "${_gitbranch}" != "master" ]; then
else
_gitbranch="$($XBPS_GIT_CMD symbolic-ref --short HEAD 2>/dev/null)"
fi
if [ -n "${_gitbranch}" -a "${_gitbranch}" != "master" ]; then
export XBPS_ALT_REPOSITORY="${_gitbranch}" export XBPS_ALT_REPOSITORY="${_gitbranch}"
export XBPS_REPOSITORY="${XBPS_REPOSITORY}/${_gitbranch}" export XBPS_REPOSITORY="${XBPS_REPOSITORY}/${_gitbranch}"
if [ -z "$IN_CHROOT" ]; then
msg_normal "Using \`$XBPS_REPOSITORY\' as local repository.\n"
fi
fi fi
popd &>/dev/null popd &>/dev/null
else else
export XBPS_REPOSITORY="${XBPS_REPOSITORY}/${XBPS_ALT_REPOSITORY}" export XBPS_REPOSITORY="${XBPS_REPOSITORY}/${XBPS_ALT_REPOSITORY}"
if [ -z "$IN_CHROOT" ]; then
msg_normal "Using \`$XBPS_REPOSITORY\' as local repository.\n"
fi
fi fi
if [ -n "$IN_CHROOT" ]; then readonly XBPS_SRCPKGDIR=$XBPS_DISTDIR/srcpkgs
readonly XBPS_COMMONDIR=$XBPS_DISTDIR/common
readonly XBPS_SHUTILSDIR=$XBPS_COMMONDIR/xbps-src/shutils
readonly XBPS_TRIGGERSDIR=$XBPS_SRCPKGDIR/xbps-triggers/files
readonly XBPS_CROSSPFDIR=$XBPS_COMMONDIR/cross-profiles
readonly XBPS_BUILDSTYLEDIR=$XBPS_COMMONDIR/build-style
readonly XBPS_LIBEXECDIR=$XBPS_COMMONDIR/xbps-src/libexec
readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
if [ "$IN_CHROOT" ]; then
readonly XBPS_UHELPER_CMD="xbps-uhelper" readonly XBPS_UHELPER_CMD="xbps-uhelper"
readonly XBPS_INSTALL_CMD="xbps-install" readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
readonly XBPS_QUERY_CMD="xbps-query" readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
readonly XBPS_RINDEX_CMD="xbps-rindex"
readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure" readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
readonly XBPS_REMOVE_CMD="xbps-remove" readonly XBPS_REMOVE_CMD="xbps-remove"
readonly XBPS_SRCPKGDIR=/void-packages/srcpkgs readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
readonly XBPS_COMMONDIR=/void-packages/common
readonly XBPS_DESTDIR=/destdir readonly XBPS_DESTDIR=/destdir
readonly XBPS_BUILDDIR=/builddir readonly XBPS_BUILDDIR=/builddir
readonly XBPS_SHUTILSDIR=$XBPS_COMMONDIR/xbps-src/shutils
readonly XBPS_TRIGGERSDIR=$XBPS_SRCPKGDIR/xbps-triggers/files
readonly XBPS_CROSSPFDIR=$XBPS_COMMONDIR/cross-profiles
readonly XBPS_BUILDSTYLEDIR=$XBPS_COMMONDIR/build-style
readonly XBPS_LIBEXECDIR=$XBPS_COMMONDIR/xbps-src/libexec
readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
else else
readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR" readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
readonly XBPS_INSTALL_CMD="xbps-install -C /dev/null -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR" readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
readonly XBPS_QUERY_CMD="xbps-query -C /dev/null -c $XBPS_HOSTDIR/repocache -i --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR" readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
readonly XBPS_RINDEX_CMD="xbps-rindex"
readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR" readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR" readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
readonly XBPS_SRCPKGDIR=$XBPS_DISTDIR/srcpkgs readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
readonly XBPS_COMMONDIR=$XBPS_DISTDIR/common
readonly XBPS_SHUTILSDIR=$XBPS_COMMONDIR/xbps-src/shutils
readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
readonly XBPS_TRIGGERSDIR=$XBPS_SRCPKGDIR/xbps-triggers/files
readonly XBPS_CROSSPFDIR=$XBPS_COMMONDIR/cross-profiles
readonly XBPS_BUILDSTYLEDIR=$XBPS_COMMONDIR/build-style
readonly XBPS_LIBEXECDIR=$XBPS_COMMONDIR/xbps-src/libexec
readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
fi fi
readonly XBPS_RINDEX_CMD="xbps-rindex"
readonly XBPS_FETCH_CMD="xbps-fetch" readonly XBPS_FETCH_CMD="xbps-fetch"
readonly XBPS_DIGEST_CMD="xbps-digest" readonly XBPS_DIGEST_CMD="xbps-digest"
readonly XBPS_CMPVER_CMD="xbps-uhelper cmpver" readonly XBPS_CMPVER_CMD="xbps-uhelper cmpver"
readonly XBPS_TARGET="$1" readonly XBPS_TARGET="$1"
if [ -n "$2" ]; then if [ "$2" ]; then
XBPS_TARGET_PKG="${2##*/}" XBPS_TARGET_PKG="${2##*/}"
fi fi
chroot_check() { # Check for CHROOT_READY and set up XBPS_ARCH environment var for xbps.
if [ -f $XBPS_MASTERDIR/.xbps_chroot_init -o "$XBPS_CHROOT_CMD" = "ethereal" ]; then
export CHROOT_READY=1
fi
}
chroot_check chroot_check
check_native_arch
# Reconfigure pkgs for 32bit on x86_64 and reexec itself.
# XXX: how about 32bit userland on 64bit CPUs? (ppc, arm, etc).
if [ -z "$XBPS_REINIT" -a -s $XBPS_MASTERDIR/.xbps_chroot_init ]; then if [ -z "$XBPS_REINIT" -a -s $XBPS_MASTERDIR/.xbps_chroot_init ]; then
export XBPS_ARCH=${XBPS_ARCH:-$(cat $XBPS_MASTERDIR/.xbps_chroot_init)} export XBPS_ARCH=${XBPS_ARCH:-$(<$XBPS_MASTERDIR/.xbps_chroot_init)}
if [[ $XBPS_MACHINE == x86_64* ]] && [[ $XBPS_ARCH == i686* ]]; then if [[ $XBPS_MACHINE == x86_64* ]] && [[ $XBPS_ARCH == i686* ]]; then
# reconfigure pkgs via linux32 # reconfigure pkgs via linux32
linux32 xbps-reconfigure -r ${XBPS_MASTERDIR} -a &>/dev/null linux32 xbps-reconfigure -r ${XBPS_MASTERDIR} -a &>/dev/null
@ -598,20 +595,21 @@ if [ -z "$XBPS_REINIT" -a -s $XBPS_MASTERDIR/.xbps_chroot_init ]; then
exec linux32 $0 ${XBPS_OPTIONS} $@ exec linux32 $0 ${XBPS_OPTIONS} $@
fi fi
fi fi
if [ -n "$XBPS_ARCH" ]; then if [ "$XBPS_ARCH" ]; then
export XBPS_MACHINE=$XBPS_ARCH export XBPS_MACHINE=$XBPS_ARCH
fi fi
# At this point if XBPS_TARGET_MACHINE isn't defined we assume
# it's a native build.
if [ -z "$XBPS_TARGET_MACHINE" ]; then if [ -z "$XBPS_TARGET_MACHINE" ]; then
export XBPS_TARGET_MACHINE=${XBPS_ARCH:=$XBPS_MACHINE} export XBPS_TARGET_MACHINE=$XBPS_MACHINE
fi fi
export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
XBPS_SRCPKGDIR XBPS_COMMONDIR XBPS_BUILDDIR XBPS_REPO_DELTAS \ XBPS_SRCPKGDIR XBPS_COMMONDIR XBPS_BUILDDIR \
XBPS_REPOSITORY XBPS_ALT_REPOSITORY XBPS_SRCDISTDIR XBPS_DIGEST_CMD \ XBPS_REPOSITORY XBPS_ALT_REPOSITORY XBPS_SRCDISTDIR XBPS_DIGEST_CMD \
XBPS_UHELPER_CMD XBPS_INSTALL_CMD XBPS_QUERY_CMD XBPS_BUILD_ONLY_ONE_PKG \ XBPS_UHELPER_CMD XBPS_INSTALL_CMD XBPS_QUERY_CMD XBPS_BUILD_ONLY_ONE_PKG \
XBPS_RINDEX_CMD XBPS_RECONFIGURE_CMD XBPS_REMOVE_CMD \ XBPS_RINDEX_CMD XBPS_RECONFIGURE_CMD XBPS_REMOVE_CMD XBPS_CHECKVERS_CMD \
XBPS_CMPVER_CMD XBPS_FETCH_CMD XBPS_VERSION XBPS_APIVER XBPS_BUILDSTYLEDIR \ XBPS_CMPVER_CMD XBPS_FETCH_CMD XBPS_VERSION XBPS_BUILDSTYLEDIR \
XBPS_CPPFLAGS XBPS_CFLAGS XBPS_CXXFLAGS XBPS_FFLAGS XBPS_LDFLAGS \ XBPS_CPPFLAGS XBPS_CFLAGS XBPS_CXXFLAGS XBPS_FFLAGS XBPS_LDFLAGS \
XBPS_MAKEJOBS XBPS_BUILD_FORCEMODE XBPS_USE_GIT_REVS XBPS_DEBUG_PKGS \ XBPS_MAKEJOBS XBPS_BUILD_FORCEMODE XBPS_USE_GIT_REVS XBPS_DEBUG_PKGS \
XBPS_CHECK_PKGS XBPS_CCACHE XBPS_DISTCC XBPS_DISTCC_HOSTS XBPS_SKIP_DEPS \ XBPS_CHECK_PKGS XBPS_CCACHE XBPS_DISTCC XBPS_DISTCC_HOSTS XBPS_SKIP_DEPS \
@ -629,7 +627,7 @@ for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do
unset val unset val
done done
# A temporary masterdir requires xbps-uchroot(8) and -O to use overlayfs # A temporary masterdir requires xbps-uchroot(1) and -O to use overlayfs
# on tmpfs (available with xbps-0.45). # on tmpfs (available with xbps-0.45).
if [ -z "$IN_CHROOT" -a -n "$XBPS_TEMP_MASTERDIR" ]; then if [ -z "$IN_CHROOT" -a -n "$XBPS_TEMP_MASTERDIR" ]; then
export XBPS_CHROOT_CMD="uchroot" export XBPS_CHROOT_CMD="uchroot"
@ -640,31 +638,35 @@ fi
# #
if [ -z "$IN_CHROOT" ]; then if [ -z "$IN_CHROOT" ]; then
# In non chroot case always prefer host tools. # In non chroot case always prefer host tools.
MYPATH="$XBPS_MASTERDIR/usr/bin:$XBPS_MASTERDIR/usr/sbin" export PATH="$PATH:$XBPS_MASTERDIR/usr/bin"
export PATH="$PATH:$MYPATH" fi
else
MYPATH="/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" #
export PATH="$MYPATH" # Set up ccache
if [ -n "$XBPS_CCACHE" ]; then #
CCACHEPATH="/usr/lib/ccache/bin" if [ "$XBPS_CCACHE" ]; then
export CCACHE_DIR="$XBPS_HOSTDIR/ccache" export CCACHEPATH="/usr/lib/ccache/bin"
# Avoid not using cached files just due to compiler mtime export CCACHE_DIR="$XBPS_HOSTDIR/ccache"
# changes when e.g. bootstrapping # Avoid not using cached files just due to compiler mtime
export CCACHE_COMPILERCHECK=content CCACHE_COMPRESS=1 # changes when e.g. bootstrapping
export PATH="$CCACHEPATH:$PATH" export CCACHE_COMPILERCHECK=content CCACHE_COMPRESS=1
mkdir -p $CCACHE_DIR export PATH="$CCACHEPATH:$PATH"
fi mkdir -p $CCACHE_DIR
if [ -n "$XBPS_DISTCC" ]; then fi
if [ -n "$XBPS_CCACHE" ]; then
export CCACHE_PREFIX="/usr/bin/distcc" #
else # Set up distcc
DISTCCPATH="/usr/lib/distcc/bin" #
export PATH="$DISTCCPATH:$PATH" if [ "$XBPS_DISTCC" ]; then
fi if [ "$XBPS_CCACHE" ]; then
export DISTCC_DIR="$XBPS_HOSTDIR/distcc-${XBPS_CROSS_BUILD:-${XBPS_MACHINE}}" export CCACHE_PREFIX="/usr/bin/distcc"
export DISTCC_HOSTS="$XBPS_DISTCC_HOSTS" else
mkdir -p $DISTCC_DIR DISTCCPATH="/usr/lib/distcc/bin"
export PATH="$DISTCCPATH:$PATH"
fi fi
export DISTCC_DIR="$XBPS_HOSTDIR/distcc-${XBPS_CROSS_BUILD:-${XBPS_MACHINE}}"
export DISTCC_HOSTS="$XBPS_DISTCC_HOSTS"
mkdir -p $DISTCC_DIR
fi fi
check_build_requirements check_build_requirements
@ -675,6 +677,12 @@ if [ -z "$IN_CHROOT" ]; then
setup_distfiles_mirror setup_distfiles_mirror
fi fi
fi fi
#
# Read funcs from helpers
#
for f in ${XBPS_SHUTILSDIR}/*.sh; do
[ -r "$f" ] && . $f
done
reconfigure_bootstrap_pkgs reconfigure_bootstrap_pkgs
@ -689,18 +697,24 @@ case "$XBPS_TARGET" in
# bootstrap from sources # bootstrap from sources
# check for required host utils # check for required host utils
check_reqhost_utils bootstrap check_reqhost_utils bootstrap
[ ! -d $XBPS_SRCPKGDIR/base-chroot ] && \ [[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot directory!\n" [ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
if [ ! -s ${bootstrap_vpkg} ]; then if [ ! -s ${bootstrap_vpkg} ]; then
# Fool xbps to resolve dependencies. # Fool xbps to resolve dependencies.
echo 'virtualpkg=libgcc-4.4.0_1:base-files' >> ${bootstrap_vpkg} echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
echo 'virtualpkg=libstdc++-4.4.0_1:base-files' >> ${bootstrap_vpkg} echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
fi fi
$XBPS_LIBEXECDIR/build.sh base-chroot base-chroot $XBPS_TARGET || exit 1 (
export XBPS_ARCH=$XBPS_MACHINE
export XBPS_SKIP_REMOTEREPOS=1
$XBPS_LIBEXECDIR/build.sh \
base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
) || exit 1
[ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
install_bbootstrap bootstrap install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
;; ;;
bootstrap-update) bootstrap-update)
if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
@ -857,7 +871,7 @@ case "$XBPS_TARGET" in
bulk_build bulk_build
;; ;;
show-sys-updates) show-sys-updates)
bulk_build -i bulk_build -I
;; ;;
sort-dependencies) sort-dependencies)
bulk_sortdeps ${@/$XBPS_TARGET/} bulk_sortdeps ${@/$XBPS_TARGET/}
@ -866,7 +880,7 @@ case "$XBPS_TARGET" in
bulk_update bulk_update
;; ;;
update-sys) update-sys)
bulk_update -i bulk_update -I
;; ;;
update-check) update-check)
read_pkg ignore-problems read_pkg ignore-problems