<commit_before># vim: set ts=4 sw=4 et:
#
setup_pkg_depends() {
    local pkg="$1" j _pkgdepname _pkgdep _rpkgname _depname _depver _replacement

    if [ -n "$pkg" ]; then
        # subpkg
        if declare -f ${pkg}_package >/dev/null; then
            ${pkg}_package
        fi
    fi

    for j in ${depends}; do
        _rpkgname="${j%\?*}"
        _depname="${j#*\?}"
        _pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_depname} 2>/dev/null)"
        if [ -z "${_pkgdepname}" ]; then
            _pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)"
        fi
        if [ -s ${XBPS_DISTDIR}/etc/virtual ]; then
            _replacement=$(egrep "^${_pkgdepname:-${_depname}}[[:blank:]]" ${XBPS_DISTDIR}/etc/virtual|cut -d ' ' -f2)
        elif [ -s ${XBPS_DISTDIR}/etc/defaults.virtual ]; 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"
            fi
            _pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_replacement} 2>/dev/null)"
            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
            if [ -z "${_pkgdepname}" ]; then
                _pkgdep="${_depname}>=0"
            else
                _pkgdep="${_depname}"
            fi
            run_depends+=" ${_pkgdep}"
        fi
    done
    for j in ${hostmakedepends}; do
        _depname="${j%\?*}"
        _depver=$(srcpkg_get_version ${_depname}) || exit $?
        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 -Ay <pkgname>
#
# Returns 0 if package already installed or installed successfully.
# Any other error number otherwise.
#
install_pkg_from_repos() {
    local pkg="$1" cross="$2" rval= tmplogf=

    mkdir -p $XBPS_STATEDIR
    tmplogf=${XBPS_STATEDIR}/xbps_${XBPS_TARGET_MACHINE}_bdep_${pkg}.log

    if [ -n "$cross" ]; then
        $XBPS_INSTALL_XCMD -IAyd "$pkg" >$tmplogf 2>&1
    else
        $XBPS_INSTALL_CMD -IAyd "$pkg" >$tmplogf 2>&1
    fi
    rval=$?
    if [ $rval -ne 0 -a $rval -ne 17 ]; then
        # 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.
        # ENODEV  (19): package depends on missing dependencies.
        # ENOTSUP (95): no repositories registered.
        #
        [ -z "$XBPS_KEEP_ALL" ] && remove_pkg_autodeps
        msg_red "$pkgver: failed to install '$1' dependency! (error $rval)\n"
        cat $tmplogf
        msg_error "Please see above for the real error, exiting...\n"
    fi
    [ $rval -eq 17 ] && rval=0
    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
<commit_msg>xbps-src: print detected file conflicts.<commit_after># vim: set ts=4 sw=4 et:
#
setup_pkg_depends() {
    local pkg="$1" j _pkgdepname _pkgdep _rpkgname _depname _depver _replacement

    if [ -n "$pkg" ]; then
        # subpkg
        if declare -f ${pkg}_package >/dev/null; then
            ${pkg}_package
        fi
    fi

    for j in ${depends}; do
        _rpkgname="${j%\?*}"
        _depname="${j#*\?}"
        _pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_depname} 2>/dev/null)"
        if [ -z "${_pkgdepname}" ]; then
            _pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)"
        fi
        if [ -s ${XBPS_DISTDIR}/etc/virtual ]; then
            _replacement=$(egrep "^${_pkgdepname:-${_depname}}[[:blank:]]" ${XBPS_DISTDIR}/etc/virtual|cut -d ' ' -f2)
        elif [ -s ${XBPS_DISTDIR}/etc/defaults.virtual ]; 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"
            fi
            _pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_replacement} 2>/dev/null)"
            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
            if [ -z "${_pkgdepname}" ]; then
                _pkgdep="${_depname}>=0"
            else
                _pkgdep="${_depname}"
            fi
            run_depends+=" ${_pkgdep}"
        fi
    done
    for j in ${hostmakedepends}; do
        _depname="${j%\?*}"
        _depver=$(srcpkg_get_version ${_depname}) || exit $?
        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 -Ay <pkgname>
#
# Returns 0 if package already installed or installed successfully.
# Any other error number otherwise.
#
install_pkg_from_repos() {
    local pkg="$1" cross="$2" rval= tmplogf=

    mkdir -p $XBPS_STATEDIR
    tmplogf=${XBPS_STATEDIR}/xbps_${XBPS_TARGET_MACHINE}_bdep_${pkg}.log

    if [ -n "$cross" ]; then
        $XBPS_INSTALL_XCMD -IAy "$pkg" >$tmplogf 2>&1
    else
        $XBPS_INSTALL_CMD -IAy "$pkg" >$tmplogf 2>&1
    fi
    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
        0|17) # success, check if there are errors.
           errortmpf=$(mktemp) || exit 1
           grep ^ERROR $tmplogf > $errortmpf
           [ -s $errortmpf ] && cat $errortmpf
           rm -f $errortmpf
           ;;
        *)
           [ -z "$XBPS_KEEP_ALL" ] && remove_pkg_autodeps
           msg_red "$pkgver: failed to install '$1' dependency! (error $rval)\n"
           cat $tmplogf
           rm -f $tmplogf
           msg_error "Please see above for the real error, exiting...\n"
           ;;
    esac
    [ $rval -eq 17 ] && rval=0
    rm -f $logtmpf
    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

{'fraction_non_alphanumeric': 0.1527187290221526, 'fraction_numerical': 0.011747594540165586, 'mean_word_length': 2.33918565558461, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2226108', 'n_tokens_mistral': 3221, 'n_tokens_neox': 3064, 'n_words': 739}