Init, adding corrade,magnum,magnum-plugins,magnum-integration,magnum-extras, and magnum-examples 2025.47_1
This commit is contained in:
440
common/xbps-src/shutils/build_dependencies.sh
Normal file
440
common/xbps-src/shutils/build_dependencies.sh
Normal file
@@ -0,0 +1,440 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
#
|
||||
setup_pkg_depends() {
|
||||
local pkg="$1" out="$2" with_subpkgs="$3" j _rpkgname _depname _pkgname foo _deps collected
|
||||
|
||||
if [[ $pkg ]]; then
|
||||
# subpkg
|
||||
if declare -f ${pkg}_package >/dev/null; then
|
||||
${pkg}_package
|
||||
fi
|
||||
elif [[ $with_subpkgs ]]; then
|
||||
collected="${depends}"
|
||||
for pkg in $subpackages; do
|
||||
[[ $pkg ]] || continue
|
||||
${pkg}_package
|
||||
collected+=" ${depends}"
|
||||
done
|
||||
depends="${collected}"
|
||||
fi
|
||||
|
||||
for j in ${depends}; do
|
||||
_rpkgname="${j%\?*}"
|
||||
_depname="${j#*\?}"
|
||||
if [[ ${_rpkgname} == virtual ]]; then
|
||||
_pkgname=$(xbps-uhelper getpkgname $_depname 2>/dev/null)
|
||||
[ -z "$_pkgname" ] && _pkgname="$_depname"
|
||||
if [ -s ${XBPS_DISTDIR}/etc/virtual ]; then
|
||||
foo=$(grep -E "^${_pkgname}[[:blank:]]" ${XBPS_DISTDIR}/etc/virtual|cut -d ' ' -f2)
|
||||
elif [ -s ${XBPS_DISTDIR}/etc/defaults.virtual ]; then
|
||||
foo=$(grep -E "^${_pkgname}[[:blank:]]" ${XBPS_DISTDIR}/etc/defaults.virtual|cut -d ' ' -f2)
|
||||
fi
|
||||
if [ -z "$foo" ]; then
|
||||
msg_error "$pkgver: failed to resolve virtual dependency for '$j' (missing from etc/virtual)\n"
|
||||
fi
|
||||
[[ $out ]] && echo "$foo"
|
||||
else
|
||||
foo="$($XBPS_UHELPER_CMD getpkgdepname ${_depname} 2>/dev/null)"
|
||||
if [ -z "$foo" ]; then
|
||||
foo="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)"
|
||||
[ -z "$foo" ] && foo="${_depname}"
|
||||
fi
|
||||
[[ $out ]] && echo "$foo"
|
||||
fi
|
||||
run_depends+="${_depname} "
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#
|
||||
# Install required package dependencies, like:
|
||||
#
|
||||
# xbps-install -Ay <pkgs>
|
||||
#
|
||||
# -A automatic mode
|
||||
# -y yes
|
||||
#
|
||||
# Returns 0 if package already installed or installed successfully.
|
||||
# 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.
|
||||
# EBUSY (16): package 'xbps' needs to be updated.
|
||||
# EEXIST (17): file conflicts in transaction (XBPS_FLAG_IGNORE_FILE_CONFLICTS unset)
|
||||
# ENODEV (19): package depends on missing dependencies.
|
||||
# ENOTSUP (95): no repositories registered.
|
||||
# -1 (255): unexpected error.
|
||||
|
||||
install_pkg_from_repos() {
|
||||
local cross="$1" target="$2" rval tmplogf cmd
|
||||
shift 2
|
||||
|
||||
[ $# -eq 0 ] && return 0
|
||||
|
||||
mkdir -p $XBPS_STATEDIR
|
||||
tmplogf=${XBPS_STATEDIR}/xbps_${XBPS_TARGET_MACHINE}_bdep_${pkg}.log
|
||||
|
||||
cmd=$XBPS_INSTALL_CMD
|
||||
[[ $cross ]] && cmd=$XBPS_INSTALL_XCMD
|
||||
$cmd -Ay "$@" >$tmplogf 2>&1
|
||||
rval=$?
|
||||
|
||||
case "$rval" in
|
||||
0) # 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 $target dependencies! (error $rval)\n"
|
||||
cat $tmplogf
|
||||
rm -f $tmplogf
|
||||
msg_error "Please see above for the real error, exiting...\n"
|
||||
;;
|
||||
esac
|
||||
rm -f $tmplogf
|
||||
return $rval
|
||||
}
|
||||
|
||||
#
|
||||
# Returns 0 if pkgpattern in $1 is installed and greater than current
|
||||
# installed package, otherwise 1.
|
||||
#
|
||||
check_installed_pkg() {
|
||||
local pkg="$1" cross="$2" uhelper= pkgn= iver=
|
||||
|
||||
[ -z "$pkg" ] && return 2
|
||||
|
||||
pkgn="$($XBPS_UHELPER_CMD getpkgname ${pkg})"
|
||||
[ -z "$pkgn" ] && return 2
|
||||
|
||||
uhelper=$XBPS_UHELPER_CMD
|
||||
[[ $cross ]] && uhelper=$XBPS_UHELPER_XCMD
|
||||
iver="$($uhelper version $pkgn)"
|
||||
if [ $? -eq 0 -a -n "$iver" ]; then
|
||||
$XBPS_CMPVER_CMD "${pkgn}-${iver}" "${pkg}"
|
||||
[ $? -eq 0 -o $? -eq 1 ] && return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
#
|
||||
# Return 0 if we will skip the check step
|
||||
#
|
||||
skip_check_step() {
|
||||
[ -z "$XBPS_CHECK_PKGS" ] ||
|
||||
[ "$XBPS_CROSS_BUILD" ] ||
|
||||
[ "$make_check" = ci-skip -a "$XBPS_BUILD_ENVIRONMENT" = void-packages-ci ] ||
|
||||
[ "$make_check" = extended -a "$XBPS_CHECK_PKGS" != full ] ||
|
||||
[ "$make_check" = no ]
|
||||
}
|
||||
|
||||
#
|
||||
# Build all dependencies required to build and run.
|
||||
#
|
||||
install_pkg_deps() {
|
||||
local pkg="$1" targetpkg="$2" target="$3" cross="$4" cross_prepare="$5"
|
||||
local _vpkg curpkgdepname
|
||||
local i j found style
|
||||
local templates=""
|
||||
|
||||
local -a host_binpkg_deps binpkg_deps
|
||||
local -a host_missing_deps missing_deps missing_rdeps
|
||||
|
||||
[ -z "$pkgname" ] && return 2
|
||||
skip_check_step && unset checkdepends
|
||||
|
||||
if [[ $build_style ]] || [[ $build_helper ]]; then
|
||||
style=" with"
|
||||
fi
|
||||
|
||||
[[ $build_style ]] && style+=" [$build_style]"
|
||||
|
||||
for s in $build_helper; do
|
||||
style+=" [$s]"
|
||||
done
|
||||
|
||||
if [ "$pkg" != "$targetpkg" ]; then
|
||||
msg_normal "$pkgver: building${style} (dependency of $targetpkg) for $XBPS_TARGET_MACHINE...\n"
|
||||
else
|
||||
msg_normal "$pkgver: building${style} for $XBPS_TARGET_MACHINE...\n"
|
||||
fi
|
||||
|
||||
#
|
||||
# Host build dependencies.
|
||||
#
|
||||
if [[ ${hostmakedepends} ]]; then
|
||||
templates=""
|
||||
# check validity
|
||||
for f in ${hostmakedepends}; do
|
||||
if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
|
||||
templates+=" $f"
|
||||
continue
|
||||
fi
|
||||
local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
|
||||
if [ "$_repourl" ]; then
|
||||
echo " [host] ${f}: found (${_repourl})"
|
||||
host_binpkg_deps+=("$f")
|
||||
continue
|
||||
fi
|
||||
msg_error "$pkgver: host dependency '$f' does not exist!\n"
|
||||
done
|
||||
while read -r _depname _deprepover _depver _subpkg _repourl; do
|
||||
_vpkg=${_subpkg}-${_depver}
|
||||
# binary package found in a repo
|
||||
if [[ ${_depver} == ${_deprepover} ]]; then
|
||||
echo " [host] ${_vpkg}: found (${_repourl})"
|
||||
host_binpkg_deps+=("${_vpkg}")
|
||||
continue
|
||||
fi
|
||||
# binary package 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 ]] && [[ -z "$cross" ]]; then
|
||||
echo " [host] ${_vpkg}: not found (subpkg, ignored)"
|
||||
else
|
||||
echo " [host] ${_vpkg}: not found"
|
||||
host_missing_deps+=("$_vpkg")
|
||||
fi
|
||||
else
|
||||
echo " [host] ${_vpkg}: not found"
|
||||
host_missing_deps+=("$_vpkg")
|
||||
fi
|
||||
done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm $templates)
|
||||
fi
|
||||
|
||||
#
|
||||
# Host check dependencies.
|
||||
#
|
||||
if [[ ${checkdepends} ]]; then
|
||||
templates=""
|
||||
# check validity
|
||||
for f in ${checkdepends}; do
|
||||
if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
|
||||
templates+=" $f"
|
||||
continue
|
||||
fi
|
||||
local _repourl=$($XBPS_QUERY_CMD -R -prepository "$f" 2>/dev/null)
|
||||
if [ "$_repourl" ]; then
|
||||
echo " [host] ${f}: found (${_repourl})"
|
||||
host_binpkg_deps+=("$f")
|
||||
continue
|
||||
fi
|
||||
msg_error "$pkgver: check dependency '$f' does not exist!\n"
|
||||
done
|
||||
while read -r _depname _deprepover _depver _subpkg _repourl; do
|
||||
_vpkg=${_subpkg}-${_depver}
|
||||
# binary package found in a repo
|
||||
if [[ ${_depver} == ${_deprepover} ]]; then
|
||||
echo " [check] ${_vpkg}: found (${_repourl})"
|
||||
host_binpkg_deps+=("${_vpkg}")
|
||||
continue
|
||||
fi
|
||||
# binary package 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 " [check] ${_vpkg}: not found (subpkg, ignored)"
|
||||
else
|
||||
echo " [check] ${_vpkg}: not found"
|
||||
host_missing_deps+=("$_vpkg")
|
||||
fi
|
||||
else
|
||||
echo " [check] ${_vpkg}: not found"
|
||||
host_missing_deps+=("$_vpkg")
|
||||
fi
|
||||
done < <($XBPS_CHECKVERS_CMD -D $XBPS_DISTDIR -sm ${templates})
|
||||
fi
|
||||
|
||||
#
|
||||
# Target build dependencies.
|
||||
#
|
||||
if [[ ${makedepends} ]]; then
|
||||
templates=""
|
||||
# check validity
|
||||
for f in ${makedepends}; do
|
||||
if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
|
||||
templates+=" $f"
|
||||
continue
|
||||
fi
|
||||
local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
|
||||
if [ "$_repourl" ]; then
|
||||
echo " [target] ${f}: found (${_repourl})"
|
||||
binpkg_deps+=("$f")
|
||||
continue
|
||||
fi
|
||||
msg_error "$pkgver: target dependency '$f' does not exist!\n"
|
||||
done
|
||||
while read -r _depname _deprepover _depver _subpkg _repourl; do
|
||||
_vpkg=${_subpkg}-${_depver}
|
||||
# binary package found in a repo
|
||||
if [[ ${_depver} == ${_deprepover} ]]; then
|
||||
echo " [target] ${_vpkg}: found (${_repourl})"
|
||||
binpkg_deps+=("${_vpkg}")
|
||||
continue
|
||||
fi
|
||||
# binary package 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
|
||||
msg_error "[target] ${_vpkg}: target dependency '${_subpkg}' is a subpackage of $pkgname\n"
|
||||
else
|
||||
echo " [target] ${_vpkg}: not found"
|
||||
missing_deps+=("$_vpkg")
|
||||
fi
|
||||
else
|
||||
echo " [target] ${_vpkg}: not found"
|
||||
missing_deps+=("$_vpkg")
|
||||
fi
|
||||
done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
|
||||
fi
|
||||
|
||||
#
|
||||
# Target run time dependencies
|
||||
#
|
||||
local _cleandeps=$(setup_pkg_depends "" 1 1) || exit 1
|
||||
if [[ ${_cleandeps} ]]; then
|
||||
templates=""
|
||||
for f in ${_cleandeps}; do
|
||||
if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
|
||||
templates+=" $f"
|
||||
continue
|
||||
fi
|
||||
local _repourl=$($XBPS_QUERY_XCMD -R -prepository "$f" 2>/dev/null)
|
||||
if [ "$_repourl" ]; then
|
||||
echo " [target] ${f}: found (${_repourl})"
|
||||
continue
|
||||
fi
|
||||
msg_error "$pkgver: target dependency '$f' does not exist!\n"
|
||||
done
|
||||
while read -r _depname _deprepover _depver _subpkg _repourl; do
|
||||
_vpkg=${_subpkg}-${_depver}
|
||||
# binary package found in a repo
|
||||
if [[ ${_depver} == ${_deprepover} ]]; then
|
||||
echo " [runtime] ${_vpkg}: found (${_repourl})"
|
||||
continue
|
||||
fi
|
||||
# binary package 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
|
||||
echo " [runtime] ${_vpkg}: not found"
|
||||
missing_rdeps+=("$_vpkg")
|
||||
fi
|
||||
elif [[ ${_depname} == ${pkgname} ]]; then
|
||||
echo " [runtime] ${_vpkg}: not found (self, ignored)"
|
||||
else
|
||||
echo " [runtime] ${_vpkg}: not found"
|
||||
missing_rdeps+=("$_vpkg")
|
||||
fi
|
||||
done < <($XBPS_CHECKVERS_XCMD -D $XBPS_DISTDIR -sm $templates)
|
||||
fi
|
||||
|
||||
if [ -n "$XBPS_BUILD_ONLY_ONE_PKG" ]; then
|
||||
for i in ${host_missing_deps[@]}; do
|
||||
msg_error "dep ${i} not found: -1 passed: instructed not to build\n"
|
||||
done
|
||||
for i in ${missing_rdeps[@]}; do
|
||||
msg_error "dep ${i} not found: -1 passed: instructed not to build\n"
|
||||
done
|
||||
for i in ${missing_deps[@]}; do
|
||||
msg_error "dep ${i} not found: -1 passed: instructed not to build\n"
|
||||
done
|
||||
fi
|
||||
|
||||
# Missing host dependencies, build from srcpkgs.
|
||||
for i in ${host_missing_deps[@]}; do
|
||||
# packages not found in repos, install from source.
|
||||
(
|
||||
curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
|
||||
setup_pkg $curpkgdepname
|
||||
# do not check when building dependencies, except for "full" (-K)
|
||||
[ "$XBPS_CHECK_PKGS" == full ] || unset XBPS_CHECK_PKGS
|
||||
exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 XBPS_DEPENDS_CHAIN="$XBPS_DEPENDS_CHAIN, $sourcepkg(host)" \
|
||||
$XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross_prepare || exit $?
|
||||
) || exit $?
|
||||
host_binpkg_deps+=("$i")
|
||||
done
|
||||
|
||||
# Missing target dependencies, build from srcpkgs.
|
||||
for i in ${missing_deps[@]}; do
|
||||
# packages not found in repos, install from source.
|
||||
(
|
||||
|
||||
curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
|
||||
setup_pkg $curpkgdepname $cross
|
||||
# do not check when building dependencies, except for "full" (-K)
|
||||
[ "$XBPS_CHECK_PKGS" == full ] || unset XBPS_CHECK_PKGS
|
||||
exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 XBPS_DEPENDS_CHAIN="$XBPS_DEPENDS_CHAIN, $sourcepkg(${cross:-host})" \
|
||||
$XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
|
||||
) || exit $?
|
||||
binpkg_deps+=("$i")
|
||||
done
|
||||
|
||||
# Target runtime missing dependencies, build from srcpkgs.
|
||||
for i in ${missing_rdeps[@]}; do
|
||||
# packages not found in repos, install from source.
|
||||
(
|
||||
curpkgdepname=$($XBPS_UHELPER_CMD getpkgdepname "$i" 2>/dev/null)
|
||||
if [ -z "$curpkgdepname" ]; then
|
||||
curpkgdepname=$($XBPS_UHELPER_CMD getpkgname "$i" 2>/dev/null)
|
||||
if [ -z "$curpkgdepname" ]; then
|
||||
curpkgdepname="$i"
|
||||
fi
|
||||
fi
|
||||
setup_pkg $curpkgdepname $cross
|
||||
# do not check when building dependencies, except for "full" (-K)
|
||||
[ "$XBPS_CHECK_PKGS" == full ] || unset XBPS_CHECK_PKGS
|
||||
exec env XBPS_DEPENDENCY=1 XBPS_BINPKG_EXISTS=1 XBPS_DEPENDS_CHAIN="$XBPS_DEPENDS_CHAIN, $sourcepkg(${cross:-host})" \
|
||||
$XBPS_LIBEXECDIR/build.sh $sourcepkg $pkg $target $cross $cross_prepare || exit $?
|
||||
) || exit $?
|
||||
done
|
||||
|
||||
if [[ ${host_binpkg_deps} ]]; then
|
||||
msg_normal "$pkgver: installing host dependencies: ${host_binpkg_deps[*]} ...\n"
|
||||
install_pkg_from_repos "" host "${host_binpkg_deps[@]}"
|
||||
fi
|
||||
|
||||
if [[ ${binpkg_deps} ]]; then
|
||||
msg_normal "$pkgver: installing target dependencies: ${binpkg_deps[*]} ...\n"
|
||||
install_pkg_from_repos "$cross" target "${binpkg_deps[@]}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
127
common/xbps-src/shutils/bulk.sh
Normal file
127
common/xbps-src/shutils/bulk.sh
Normal file
@@ -0,0 +1,127 @@
|
||||
# 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() {
|
||||
local _pkgs _pkg pkgs pkg found f x tmpf
|
||||
|
||||
_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
|
||||
# Now make the real dependency graph of all pkgs to build.
|
||||
# Perform a topological sort of all pkgs but only with build dependencies
|
||||
# that are found in previous step.
|
||||
for pkg in ${pkgs}; do
|
||||
_pkgs="$($XBPS_DISTDIR/xbps-src show-build-deps $pkg 2>/dev/null)"
|
||||
found=0
|
||||
for x in ${_pkgs}; do
|
||||
_pkg=$(bulk_getlink $x)
|
||||
for f in ${pkgs}; do
|
||||
if [ "${f}" != "${_pkg}" ]; then
|
||||
continue
|
||||
fi
|
||||
found=1
|
||||
echo "${pkg} ${f}" >> $tmpf
|
||||
done
|
||||
done
|
||||
[ $found -eq 0 ] && echo "${pkg} ${pkg}" >> $tmpf
|
||||
done
|
||||
tsort $tmpf|tac
|
||||
rm -f $tmpf
|
||||
}
|
||||
|
||||
bulk_build() {
|
||||
local bulk_build_cmd="$1"
|
||||
local NPROCS=$(($(nproc)*2))
|
||||
local NRUNNING=0
|
||||
|
||||
if [ "$XBPS_CROSS_BUILD" ]; then
|
||||
source ${XBPS_COMMONDIR}/cross-profiles/${XBPS_CROSS_BUILD}.sh
|
||||
export XBPS_ARCH=${XBPS_TARGET_MACHINE}
|
||||
fi
|
||||
if ! command -v xbps-checkvers &>/dev/null; then
|
||||
msg_error "xbps-src: cannot find xbps-checkvers(1) command!\n"
|
||||
fi
|
||||
|
||||
# Compare installed pkg versions vs srcpkgs
|
||||
case "$bulk_build_cmd" in
|
||||
installed)
|
||||
bulk_sortdeps $(xbps-checkvers -f '%n' -I -D "$XBPS_DISTDIR")
|
||||
return $?
|
||||
;;
|
||||
local)
|
||||
bulk_sortdeps $(xbps-checkvers -f '%n' -i -R "${XBPS_REPOSITORY}/bootstrap" -R "${XBPS_REPOSITORY}" -R "${XBPS_REPOSITORY}/nonfree" -D "$XBPS_DISTDIR")
|
||||
return $?
|
||||
;;
|
||||
esac
|
||||
|
||||
# compare repo pkg versions vs srcpkgs
|
||||
for f in $(xbps-checkvers -f '%n' -D $XBPS_DISTDIR); do
|
||||
if [ $NRUNNING -eq $NPROCS ]; then
|
||||
NRUNNING=0
|
||||
wait
|
||||
fi
|
||||
NRUNNING=$((NRUNNING+1))
|
||||
(
|
||||
setup_pkg $f $XBPS_TARGET_MACHINE &>/dev/null
|
||||
if show_avail &>/dev/null; then
|
||||
echo "$f"
|
||||
fi
|
||||
) &
|
||||
done
|
||||
wait
|
||||
return $?
|
||||
}
|
||||
|
||||
bulk_update() {
|
||||
local bulk_update_cmd="$1" pkgs f rval
|
||||
|
||||
pkgs="$(bulk_build "${bulk_update_cmd}")"
|
||||
[[ -z $pkgs ]] && return 0
|
||||
|
||||
msg_normal "xbps-src: the following packages must be rebuilt and updated:\n"
|
||||
for f in ${pkgs}; do
|
||||
echo " $f"
|
||||
done
|
||||
for f in ${pkgs}; do
|
||||
XBPS_TARGET_PKG=$f
|
||||
read_pkg
|
||||
msg_normal "xbps-src: building ${pkgver} ...\n"
|
||||
if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
|
||||
chroot_handler pkg $XBPS_TARGET_PKG
|
||||
else
|
||||
$XBPS_LIBEXECDIR/build.sh $f $f pkg $XBPS_CROSS_BUILD
|
||||
fi
|
||||
if [ $? -eq 1 ]; then
|
||||
msg_error "xbps-src: failed to build $pkgver pkg!\n"
|
||||
fi
|
||||
done
|
||||
if [ -n "$pkgs" -a "$bulk_update_cmd" == installed ]; then
|
||||
echo
|
||||
msg_normal "xbps-src: updating your system, confirm to proceed...\n"
|
||||
${XBPS_SUCMD} "xbps-install --repository=$XBPS_REPOSITORY/bootstrap --repository=$XBPS_REPOSITORY --repository=$XBPS_REPOSITORY/nonfree -u ${pkgs//[$'\n']/ }" || return 1
|
||||
fi
|
||||
}
|
||||
338
common/xbps-src/shutils/chroot.sh
Normal file
338
common/xbps-src/shutils/chroot.sh
Normal file
@@ -0,0 +1,338 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
install_base_chroot() {
|
||||
local _bootstrap_arch _target_arch="$1"
|
||||
[ "$CHROOT_READY" ] && return
|
||||
if [ "$_target_arch" = "bootstrap" ]; then
|
||||
_target_arch=""
|
||||
unset XBPS_INSTALL_ARGS
|
||||
fi
|
||||
# binary bootstrap
|
||||
msg_normal "xbps-src: installing base-chroot...\n"
|
||||
if [ -n "$_target_arch" ]; then
|
||||
_bootstrap_arch="env XBPS_TARGET_ARCH=$_target_arch"
|
||||
fi
|
||||
(export XBPS_MACHINE="$_target_arch" XBPS_ARCH="$_target_arch"; chroot_sync_repodata)
|
||||
${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS} -y base-chroot
|
||||
if [ $? -ne 0 ]; then
|
||||
msg_error "xbps-src: failed to install base-chroot!\n"
|
||||
fi
|
||||
# Reconfigure base-files to create dirs/symlinks.
|
||||
if xbps-query -r $XBPS_MASTERDIR base-files &>/dev/null; then
|
||||
XBPS_ARCH="$_target_arch" xbps-reconfigure -r $XBPS_MASTERDIR -f base-files &>/dev/null
|
||||
fi
|
||||
|
||||
msg_normal "xbps-src: installed base-chroot successfully!\n"
|
||||
chroot_prepare "$_target_arch" || msg_error "xbps-src: failed to initialize chroot!\n"
|
||||
chroot_check
|
||||
chroot_handler clean
|
||||
}
|
||||
|
||||
reconfigure_base_chroot() {
|
||||
local statefile="$XBPS_MASTERDIR/.xbps_chroot_configured"
|
||||
local pkgs="glibc-locales ca-certificates"
|
||||
[ -z "$IN_CHROOT" -o -e $statefile ] && return 0
|
||||
# Reconfigure ca-certificates.
|
||||
msg_normal "xbps-src: reconfiguring base-chroot...\n"
|
||||
for f in ${pkgs}; do
|
||||
if xbps-query -r $XBPS_MASTERDIR $f &>/dev/null; then
|
||||
xbps-reconfigure -r $XBPS_MASTERDIR -f $f
|
||||
fi
|
||||
done
|
||||
touch -f $statefile
|
||||
}
|
||||
|
||||
update_base_chroot() {
|
||||
local keep_all_force=$1
|
||||
[ -z "$CHROOT_READY" ] && return
|
||||
msg_normal "xbps-src: updating software in $XBPS_MASTERDIR masterdir...\n"
|
||||
# no need to sync repodata, chroot_sync_repodata() does it for us.
|
||||
if $(${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -nu|grep -q xbps); then
|
||||
${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu xbps || msg_error "xbps-src: failed to update xbps!\n"
|
||||
fi
|
||||
${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -yu || msg_error "xbps-src: failed to update base-chroot!\n"
|
||||
msg_normal "xbps-src: cleaning up $XBPS_MASTERDIR masterdir...\n"
|
||||
[ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
|
||||
[ -z "$XBPS_KEEP_ALL" -a -z "$keep_all_force" ] && rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
|
||||
}
|
||||
|
||||
# FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
|
||||
# It is set in common/build-profiles/bootstrap.sh but lost somewhere?
|
||||
chroot_init() {
|
||||
mkdir -p $XBPS_MASTERDIR/etc/xbps
|
||||
|
||||
: ${XBPS_CONFIG_FILE:=/dev/null}
|
||||
cat > $XBPS_MASTERDIR/etc/xbps/xbps-src.conf <<_EOF
|
||||
# Generated configuration file by xbps-src, DO NOT EDIT!
|
||||
$(grep -E '^XBPS_.*' "$XBPS_CONFIG_FILE")
|
||||
XBPS_MASTERDIR=/
|
||||
XBPS_CFLAGS="$XBPS_CFLAGS"
|
||||
XBPS_CXXFLAGS="$XBPS_CXXFLAGS"
|
||||
XBPS_FFLAGS="$XBPS_FFLAGS"
|
||||
XBPS_CPPFLAGS="$XBPS_CPPFLAGS"
|
||||
XBPS_LDFLAGS="$XBPS_LDFLAGS"
|
||||
XBPS_HOSTDIR=/host
|
||||
# End of configuration file.
|
||||
_EOF
|
||||
|
||||
# Create custom script to start the chroot bash shell.
|
||||
cat > $XBPS_MASTERDIR/bin/xbps-shell <<_EOF
|
||||
#!/bin/sh
|
||||
|
||||
XBPS_SRC_VERSION="$XBPS_SRC_VERSION"
|
||||
|
||||
. /etc/xbps/xbps-src.conf
|
||||
|
||||
PATH=/void-packages:/usr/bin
|
||||
|
||||
exec env -i -- SHELL=/bin/sh PATH="\$PATH" DISTCC_HOSTS="\$XBPS_DISTCC_HOSTS" DISTCC_DIR="/host/distcc" \
|
||||
${XBPS_ARCH+XBPS_ARCH=$XBPS_ARCH} ${XBPS_CHECK_PKGS+XBPS_CHECK_PKGS=$XBPS_CHECK_PKGS} \
|
||||
CCACHE_DIR="/host/ccache" IN_CHROOT=1 LC_COLLATE=C LANG=en_US.UTF-8 TERM=linux HOME="/tmp" \
|
||||
PS1="[\u@$XBPS_MASTERDIR \W]$ " /bin/bash +h "\$@"
|
||||
_EOF
|
||||
|
||||
chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
|
||||
cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
|
||||
return 0
|
||||
}
|
||||
|
||||
chroot_prepare() {
|
||||
local f=
|
||||
|
||||
if [ -f $XBPS_MASTERDIR/.xbps_chroot_init ]; then
|
||||
return 0
|
||||
elif [ ! -f $XBPS_MASTERDIR/bin/bash ]; then
|
||||
msg_error "Bootstrap not installed in $XBPS_MASTERDIR, can't continue.\n"
|
||||
fi
|
||||
|
||||
# Some software expects /etc/localtime to be a symbolic link it can read to
|
||||
# determine the name of the time zone, so set up the expected link
|
||||
# structure.
|
||||
ln -sf ../usr/share/zoneinfo/UTC $XBPS_MASTERDIR/etc/localtime
|
||||
|
||||
for f in dev sys tmp proc host boot; do
|
||||
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
|
||||
done
|
||||
|
||||
# Copy /etc/passwd and /etc/group from base-files.
|
||||
cp -f $XBPS_SRCPKGDIR/base-files/files/passwd $XBPS_MASTERDIR/etc
|
||||
echo "$(whoami):x:$(id -u):$(id -g):$(whoami) user:/tmp:/bin/xbps-shell" \
|
||||
>> $XBPS_MASTERDIR/etc/passwd
|
||||
cp -f $XBPS_SRCPKGDIR/base-files/files/group $XBPS_MASTERDIR/etc
|
||||
echo "$(whoami):x:$(id -g):" >> $XBPS_MASTERDIR/etc/group
|
||||
|
||||
# Copy /etc/hosts from base-files.
|
||||
cp -f $XBPS_SRCPKGDIR/base-files/files/hosts $XBPS_MASTERDIR/etc
|
||||
|
||||
# Prepare default locale: en_US.UTF-8.
|
||||
if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
|
||||
printf '%s\n' \
|
||||
'C.UTF-8 UTF-8' \
|
||||
'en_US.UTF-8 UTF-8' \
|
||||
>> ${XBPS_MASTERDIR}/etc/default/libc-locales
|
||||
fi
|
||||
|
||||
touch -f $XBPS_MASTERDIR/.xbps_chroot_init
|
||||
[ -n "$1" ] && echo $1 >> $XBPS_MASTERDIR/.xbps_chroot_init
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
chroot_handler() {
|
||||
local action="$1" pkg="$2" rv=0 arg= _envargs=
|
||||
|
||||
[ -z "$action" -a -z "$pkg" ] && return 1
|
||||
|
||||
if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
|
||||
return 0
|
||||
fi
|
||||
if [ ! -d $XBPS_MASTERDIR/void-packages ]; then
|
||||
mkdir -p $XBPS_MASTERDIR/void-packages
|
||||
fi
|
||||
|
||||
case "$action" in
|
||||
fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot|clean)
|
||||
chroot_prepare || return $?
|
||||
chroot_init || return $?
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$action" = "chroot" ]; then
|
||||
$XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \
|
||||
$XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" /bin/xbps-shell
|
||||
rv=$?
|
||||
else
|
||||
env -i -- PATH="/usr/bin:$PATH" SHELL=/bin/sh \
|
||||
HOME=/tmp IN_CHROOT=1 LC_COLLATE=C LANG=en_US.UTF-8 \
|
||||
${http_proxy:+http_proxy="${http_proxy}"} \
|
||||
${https_proxy:+https_proxy="${https_proxy}"} \
|
||||
${ftp_proxy:+ftp_proxy="${ftp_proxy}"} \
|
||||
${all_proxy:+all_proxy="${all_proxy}"} \
|
||||
${no_proxy:+no_proxy="${no_proxy}"} \
|
||||
${HTTP_PROXY:+HTTP_PROXY="${HTTP_PROXY}"} \
|
||||
${HTTPS_PROXY:+HTTPS_PROXY="${HTTPS_PROXY}"} \
|
||||
${FTP_PROXY:+FTP_PROXY="${FTP_PROXY}"} \
|
||||
${SOCKS_PROXY:+SOCKS_PROXY="${SOCKS_PROXY}"} \
|
||||
${NO_PROXY:+NO_PROXY="${NO_PROXY}"} \
|
||||
${HTTP_PROXY_AUTH:+HTTP_PROXY_AUTH="${HTTP_PROXY_AUTH}"} \
|
||||
${FTP_RETRIES:+FTP_RETRIES="${FTP_RETRIES}"} \
|
||||
SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \
|
||||
XBPS_GIT_REVS="$XBPS_GIT_REVS" \
|
||||
XBPS_ALLOW_CHROOT_BREAKOUT="$XBPS_ALLOW_CHROOT_BREAKOUT" \
|
||||
XBPS_TEMP_MASTERDIR="$XBPS_TEMP_MASTERDIR" \
|
||||
${XBPS_ALT_REPOSITORY:+XBPS_ALT_REPOSITORY=$XBPS_ALT_REPOSITORY} \
|
||||
$XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \
|
||||
$XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" \
|
||||
/void-packages/xbps-src $XBPS_OPTIONS $action $pkg
|
||||
rv=$?
|
||||
fi
|
||||
|
||||
return $rv
|
||||
}
|
||||
|
||||
chroot_sync_repodata() {
|
||||
local f= hostdir= confdir= crossconfdir=
|
||||
|
||||
# always start with an empty xbps.d
|
||||
confdir=$XBPS_MASTERDIR/etc/xbps.d
|
||||
crossconfdir=$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
|
||||
|
||||
[ -d $confdir ] && rm -rf $confdir
|
||||
[ -d $crossconfdir ] && rm -rf $crossconfdir
|
||||
|
||||
if [ -d $XBPS_DISTDIR/etc/xbps.d/custom ]; then
|
||||
mkdir -p $confdir $crossconfdir
|
||||
cp -f $XBPS_DISTDIR/etc/xbps.d/custom/*.conf $confdir
|
||||
cp -f $XBPS_DISTDIR/etc/xbps.d/custom/*.conf $crossconfdir
|
||||
fi
|
||||
if [ "$CHROOT_READY" ]; then
|
||||
hostdir=/host
|
||||
else
|
||||
hostdir=$XBPS_HOSTDIR
|
||||
fi
|
||||
|
||||
# Update xbps alternative repository if set.
|
||||
mkdir -p $confdir
|
||||
if [ -n "$XBPS_ALT_REPOSITORY" ]; then
|
||||
cat <<- ! > $confdir/00-repository-alt-local.conf
|
||||
repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/bootstrap
|
||||
repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}
|
||||
repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree
|
||||
repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/debug
|
||||
!
|
||||
if [ "$XBPS_MACHINE" = "x86_64" ]; then
|
||||
cat <<- ! >> $confdir/00-repository-alt-local.conf
|
||||
repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/bootstrap
|
||||
repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib
|
||||
repository=$hostdir/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree
|
||||
!
|
||||
fi
|
||||
else
|
||||
rm -f $confdir/00-repository-alt-local.conf
|
||||
fi
|
||||
|
||||
# Disable 00-repository-main.conf from share/xbps.d (part of xbps)
|
||||
ln -s /dev/null $confdir/00-repository-main.conf
|
||||
|
||||
# Generate xbps.d(5) configuration files for repositories
|
||||
sed -e "s,/host,$hostdir,g" ${XBPS_DISTDIR}/etc/xbps.d/repos-local.conf \
|
||||
> $confdir/10-repository-local.conf
|
||||
|
||||
# Install multilib conf for local repos if it exists for the architecture
|
||||
if [ -s "${XBPS_DISTDIR}/etc/xbps.d/repos-local-${XBPS_MACHINE}-multilib.conf" ]; then
|
||||
install -Dm644 ${XBPS_DISTDIR}/etc/xbps.d/repos-local-${XBPS_MACHINE}-multilib.conf \
|
||||
$confdir/12-repository-local-multilib.conf
|
||||
fi
|
||||
|
||||
# mirror_sed is a sed script: nop by default
|
||||
local mirror_sed
|
||||
if [ -n "$XBPS_MIRROR" ]; then
|
||||
# when XBPS_MIRROR is set, mirror_sed rewrites remote repos
|
||||
mirror_sed="s|^repository=http.*/current|repository=${XBPS_MIRROR}|"
|
||||
fi
|
||||
|
||||
if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
|
||||
rm -f $confdir/*remote*
|
||||
else
|
||||
if [ -s "${XBPS_DISTDIR}/etc/xbps.d/repos-remote-${XBPS_MACHINE}.conf" ]; then
|
||||
# If per-architecture base remote repo config exists, use that
|
||||
sed -e "$mirror_sed" ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-${XBPS_MACHINE}.conf \
|
||||
> $confdir/20-repository-remote.conf
|
||||
else
|
||||
# Otherwise use generic base for musl or glibc
|
||||
local suffix=
|
||||
case "$XBPS_MACHINE" in
|
||||
*-musl) suffix="-musl";;
|
||||
esac
|
||||
sed -e "$mirror_sed" ${XBPS_DISTDIR}/etc/xbps.d/repos-remote${suffix}.conf \
|
||||
> $confdir/20-repository-remote.conf
|
||||
fi
|
||||
# Install multilib conf for remote repos if it exists for the architecture
|
||||
if [ -s "${XBPS_DISTDIR}/etc/xbps.d/repos-remote-${XBPS_MACHINE}-multilib.conf" ]; then
|
||||
sed -e "$mirror_sed" ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-${XBPS_MACHINE}-multilib.conf \
|
||||
> $confdir/22-repository-remote-multilib.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "syslog=false" > $confdir/00-xbps-src.conf
|
||||
echo "staging=true" >> $confdir/00-xbps-src.conf
|
||||
|
||||
# Copy host repos to the cross root.
|
||||
if [ -n "$XBPS_CROSS_BUILD" ]; then
|
||||
rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
|
||||
mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
|
||||
# Disable 00-repository-main.conf from share/xbps.d (part of xbps)
|
||||
ln -s /dev/null $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/00-repository-main.conf
|
||||
# copy xbps.d files from host for local repos
|
||||
cp ${XBPS_MASTERDIR}/etc/xbps.d/*local*.conf \
|
||||
$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
|
||||
if [ "$XBPS_SKIP_REMOTEREPOS" ]; then
|
||||
rm -f $crossconfdir/*remote*
|
||||
else
|
||||
# Same general logic as above, just into cross root, and no multilib
|
||||
if [ -s "${XBPS_DISTDIR}/etc/xbps.d/repos-remote-${XBPS_TARGET_MACHINE}.conf" ]; then
|
||||
sed -e "$mirror_sed" ${XBPS_DISTDIR}/etc/xbps.d/repos-remote-${XBPS_TARGET_MACHINE}.conf \
|
||||
> $crossconfdir/20-repository-remote.conf
|
||||
else
|
||||
local suffix=
|
||||
case "$XBPS_TARGET_MACHINE" in
|
||||
*-musl) suffix="-musl"
|
||||
esac
|
||||
sed -e "$mirror_sed" ${XBPS_DISTDIR}/etc/xbps.d/repos-remote${suffix}.conf \
|
||||
> $crossconfdir/20-repository-remote.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "syslog=false" > $crossconfdir/00-xbps-src.conf
|
||||
echo "staging=true" >> $crossconfdir/00-xbps-src.conf
|
||||
fi
|
||||
|
||||
|
||||
# Copy xbps repository keys to the masterdir.
|
||||
mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
|
||||
cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
|
||||
if [ -n "$(shopt -s nullglob; echo "$XBPS_DISTDIR"/etc/repo-keys/*.plist)" ]; then
|
||||
cp -f "$XBPS_DISTDIR"/etc/repo-keys/*.plist "$XBPS_MASTERDIR"/var/db/xbps/keys
|
||||
fi
|
||||
|
||||
# Make sure to sync index for remote repositories.
|
||||
if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
|
||||
msg_normal "xbps-src: updating repositories for host ($XBPS_MACHINE)...\n"
|
||||
$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -S
|
||||
fi
|
||||
|
||||
if [ -n "$XBPS_CROSS_BUILD" ]; then
|
||||
# Copy host keys to the target rootdir.
|
||||
mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
|
||||
cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
|
||||
$XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
|
||||
# Make sure to sync index for remote repositories.
|
||||
if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
|
||||
msg_normal "xbps-src: updating repositories for target ($XBPS_TARGET_MACHINE)...\n"
|
||||
env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
|
||||
$XBPS_INSTALL_CMD $XBPS_INSTALL_ARGS -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
752
common/xbps-src/shutils/common.sh
Normal file
752
common/xbps-src/shutils/common.sh
Normal file
@@ -0,0 +1,752 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
# A portable abstraction for stat(1)
|
||||
#
|
||||
# The stat(1) command has different syntaxes between GNU flavor
|
||||
# and BSD flavor; implementations generally follow one or the other
|
||||
#
|
||||
if ! stat -c "%s" / > /dev/null 2>&1; then
|
||||
# BSD stat
|
||||
|
||||
stat_size() {
|
||||
stat -f %z "$1"
|
||||
}
|
||||
|
||||
stat_inode() {
|
||||
stat -f %i "$1"
|
||||
}
|
||||
|
||||
stat_mtime() {
|
||||
stat -f %m "$1"
|
||||
}
|
||||
else
|
||||
# GNU stat
|
||||
|
||||
stat_size() {
|
||||
stat -c %s "$1"
|
||||
}
|
||||
|
||||
stat_inode() {
|
||||
stat -c %i "$1"
|
||||
}
|
||||
|
||||
stat_mtime() {
|
||||
stat -c %Y "$1"
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
run_func() {
|
||||
local func="$1" desc="$2" funcname="$3" restoretrap= logpipe= logfile= teepid=
|
||||
|
||||
: ${funcname:=$func}
|
||||
|
||||
logpipe=$(mktemp -u -p ${XBPS_STATEDIR} ${pkgname}_${XBPS_CROSS_BUILD}_XXXXXXXX.logpipe) || exit 1
|
||||
logfile=${XBPS_STATEDIR}/${pkgname}_${XBPS_CROSS_BUILD}_${funcname}.log
|
||||
|
||||
msg_normal "${pkgver:-xbps-src}: running ${desc:-${func}} ...\n"
|
||||
|
||||
set -E
|
||||
restoretrap=$(trap -p ERR)
|
||||
trap 'error_func $funcname $LINENO' ERR
|
||||
|
||||
mkfifo "$logpipe"
|
||||
tee "$logfile" < "$logpipe" &
|
||||
teepid=$!
|
||||
|
||||
$func &>"$logpipe"
|
||||
|
||||
wait $teepid
|
||||
rm "$logpipe"
|
||||
|
||||
eval "$restoretrap"
|
||||
set +E
|
||||
}
|
||||
|
||||
ch_wrksrc() {
|
||||
cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
|
||||
if [ -n "$build_wrksrc" ]; then
|
||||
cd "$build_wrksrc" || \
|
||||
msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
|
||||
fi
|
||||
}
|
||||
|
||||
# runs {pre,do,post}_X tripplets
|
||||
run_step() {
|
||||
local step_name="$1" optional_step="$2" skip_post_hook="$3"
|
||||
|
||||
ch_wrksrc
|
||||
run_pkg_hooks "pre-$step_name"
|
||||
|
||||
# Run pre_* Phase
|
||||
if declare -f "pre_$step_name" >/dev/null; then
|
||||
ch_wrksrc
|
||||
run_func "pre_$step_name"
|
||||
fi
|
||||
|
||||
ch_wrksrc
|
||||
# Run do_* Phase
|
||||
if declare -f "do_$step_name" >/dev/null; then
|
||||
run_func "do_$step_name"
|
||||
elif [ -n "$build_style" ]; then
|
||||
if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
|
||||
. $XBPS_BUILDSTYLEDIR/${build_style}.sh
|
||||
if declare -f "do_$step_name" >/dev/null; then
|
||||
run_func "do_$step_name"
|
||||
elif [ ! "$optional_step" ]; then
|
||||
msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
|
||||
fi
|
||||
else
|
||||
msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
|
||||
fi
|
||||
elif [ ! "$optional_step" ]; then
|
||||
msg_error "$pkgver: cannot find do_$step_name()!\n"
|
||||
fi
|
||||
|
||||
# Run do_ phase hooks
|
||||
run_pkg_hooks "do-$step_name"
|
||||
|
||||
# Run post_* Phase
|
||||
if declare -f "post_$step_name" >/dev/null; then
|
||||
ch_wrksrc
|
||||
run_func "post_$step_name"
|
||||
fi
|
||||
|
||||
if ! [ "$skip_post_hook" ]; then
|
||||
ch_wrksrc
|
||||
run_pkg_hooks "post-$step_name"
|
||||
fi
|
||||
}
|
||||
|
||||
error_func() {
|
||||
local err=$?
|
||||
local src=
|
||||
local i=
|
||||
[ -n "$1" -a -n "$2" ] || exit 1;
|
||||
|
||||
msg_red "$pkgver: $1: '${BASH_COMMAND}' exited with $err\n"
|
||||
for ((i=1;i<${#FUNCNAME[@]};i++)); do
|
||||
src=${BASH_SOURCE[$i]}
|
||||
src=${src#$XBPS_DISTDIR/}
|
||||
msg_red " in ${FUNCNAME[$i]}() at $src:${BASH_LINENO[$i-1]}\n"
|
||||
[ "${FUNCNAME[$i]}" = "$1" ] && break;
|
||||
done
|
||||
exit 1
|
||||
}
|
||||
|
||||
exit_and_cleanup() {
|
||||
local rval=$1
|
||||
|
||||
if [ -n "$XBPS_TEMP_MASTERDIR" -a "$XBPS_TEMP_MASTERDIR" != "1" ]; then
|
||||
rm -rf "$XBPS_TEMP_MASTERDIR"
|
||||
fi
|
||||
exit ${rval:=0}
|
||||
}
|
||||
|
||||
msg_red() {
|
||||
# error messages in bold/red
|
||||
[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[31m"
|
||||
printf >&2 "=> ERROR: $@"
|
||||
[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
|
||||
}
|
||||
|
||||
msg_red_nochroot() {
|
||||
[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[31m"
|
||||
printf >&2 "$@"
|
||||
[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
|
||||
}
|
||||
|
||||
msg_error() {
|
||||
msg_red "$@"
|
||||
[ -n "$XBPS_INFORMATIVE_RUN" ] || exit 1
|
||||
}
|
||||
|
||||
msg_warn() {
|
||||
# warn messages in bold/yellow
|
||||
[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[33m"
|
||||
printf >&2 "=> WARNING: $@"
|
||||
[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
|
||||
}
|
||||
|
||||
msg_warn_nochroot() {
|
||||
[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[33m"
|
||||
printf >&2 "=> WARNING: $@"
|
||||
[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
|
||||
}
|
||||
|
||||
msg_normal() {
|
||||
if [ -z "$XBPS_QUIET" ]; then
|
||||
# normal messages in bright bold white
|
||||
if [ "$XBPS_BUILD_ENVIRONMENT" = "void-packages-ci" ]; then
|
||||
# Github CI considers '1m' to be just a font bold
|
||||
[ -n "$NOCOLORS" ] || printf "\033[97m\033[1m"
|
||||
else
|
||||
[ -n "$NOCOLORS" ] || printf "\033[1m"
|
||||
fi
|
||||
printf "=> $@"
|
||||
[ -n "$NOCOLORS" ] || printf "\033[m"
|
||||
fi
|
||||
}
|
||||
|
||||
msg_verbose() {
|
||||
if [ -n "$XBPS_VERBOSE" ]; then
|
||||
printf >&2 "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
report_broken() {
|
||||
if [ "$show_problems" = "ignore-problems" ]; then
|
||||
return
|
||||
fi
|
||||
if [ -z "$XBPS_IGNORE_BROKENNESS" ]; then
|
||||
for line in "$@"; do
|
||||
msg_red "$line"
|
||||
done
|
||||
exit 2
|
||||
elif [ "$XBPS_IGNORE_BROKENNESS" != reported ]; then
|
||||
for line in "$@"; do
|
||||
msg_warn "$line"
|
||||
done
|
||||
XBPS_IGNORE_BROKENNESS=reported
|
||||
fi
|
||||
}
|
||||
|
||||
msg_normal_append() {
|
||||
if [ "$XBPS_BUILD_ENVIRONMENT" = "void-packages-ci" ]; then
|
||||
# Github CI considers '1m' to be just a font bold
|
||||
[ -n "$NOCOLORS" ] || printf "\033[97m\033[1m"
|
||||
else
|
||||
[ -n "$NOCOLORS" ] || printf "\033[1m"
|
||||
fi
|
||||
printf "$@"
|
||||
[ -n "$NOCOLORS" ] || printf "\033[m"
|
||||
}
|
||||
|
||||
set_build_options() {
|
||||
local f j pkgopts _pkgname
|
||||
local -A options
|
||||
|
||||
if [ -z "$build_options" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
for f in ${build_options}; do
|
||||
# Select build options from conf
|
||||
export XBPS_CURRENT_PKG=${pkgname}
|
||||
pkgopts="$(
|
||||
. $XBPS_CONFIG_FILE 2>/dev/null
|
||||
var="XBPS_PKG_OPTIONS_${XBPS_CURRENT_PKG//[^A-Za-z0-9_]/_}"
|
||||
echo ${!var:-${XBPS_PKG_OPTIONS}}
|
||||
)"
|
||||
unset XBPS_CURRENT_PKG
|
||||
|
||||
# If pkg options were set in config(s), merge them with command line
|
||||
if [ -n "$XBPS_ARG_PKG_OPTIONS" ]; then
|
||||
if [ -n "$pkgopts" ]; then
|
||||
pkgopts+=",$XBPS_ARG_PKG_OPTIONS"
|
||||
else
|
||||
pkgopts="$XBPS_ARG_PKG_OPTIONS"
|
||||
fi
|
||||
fi
|
||||
|
||||
OIFS="$IFS"; IFS=','
|
||||
for j in ${pkgopts}; do
|
||||
case "$j" in
|
||||
"$f") options[$j]=1 ;;
|
||||
"~$f") options[${j#\~}]=0 ;;
|
||||
esac
|
||||
done
|
||||
IFS="$OIFS"
|
||||
done
|
||||
|
||||
for f in ${build_options_default}; do
|
||||
[[ -z "${options[$f]}" ]] && options[$f]=1
|
||||
done
|
||||
|
||||
# Prepare final options.
|
||||
for f in ${build_options}; do
|
||||
if [[ ${options[$f]} -eq 1 ]]; then
|
||||
eval export build_option_${f}=1
|
||||
else
|
||||
eval unset build_option_${f}
|
||||
fi
|
||||
done
|
||||
|
||||
# Re-read pkg template to get conditional vars.
|
||||
if [ -z "$XBPS_BUILD_OPTIONS_PARSED" ]; then
|
||||
source_file $XBPS_SRCPKGDIR/$pkgname/template
|
||||
XBPS_BUILD_OPTIONS_PARSED=1
|
||||
unset PKG_BUILD_OPTIONS
|
||||
set_build_options
|
||||
unset XBPS_BUILD_OPTIONS_PARSED
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Sort pkg build options alphabetically.
|
||||
export PKG_BUILD_OPTIONS=$(
|
||||
for f in ${build_options}; do
|
||||
[[ "${options[$f]}" -eq 1 ]] || printf '~'
|
||||
printf '%s\n' "$f"
|
||||
done | sort | tr -s '\n' ' '
|
||||
)
|
||||
}
|
||||
|
||||
source_file() {
|
||||
local f="$1"
|
||||
|
||||
if [ ! -f "$f" -o ! -r "$f" ]; then
|
||||
return 0
|
||||
fi
|
||||
if ! source "$f"; then
|
||||
msg_error "xbps-src: failed to read $f!\n"
|
||||
fi
|
||||
}
|
||||
|
||||
run_pkg_hooks() {
|
||||
local phase="$1" hookn f
|
||||
|
||||
eval unset -f hook
|
||||
for f in ${XBPS_COMMONDIR}/hooks/${phase}/*.sh; do
|
||||
[ ! -r $f ] && continue
|
||||
hookn=${f##*/}
|
||||
hookn=${hookn%.sh}
|
||||
. $f
|
||||
run_func hook "$phase hook: $hookn" ${phase}_${hookn}
|
||||
done
|
||||
}
|
||||
|
||||
unset_package_funcs() {
|
||||
local f
|
||||
|
||||
for f in $(typeset -F); do
|
||||
case "$f" in
|
||||
*_package)
|
||||
unset -f "$f"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
get_endian() {
|
||||
local arch="${1%-*}"
|
||||
|
||||
case "$arch" in
|
||||
aarch64) echo "le";;
|
||||
armv5tel) echo "le";;
|
||||
armv6l) echo "le";;
|
||||
armv7l) echo "le";;
|
||||
i686) echo "le";;
|
||||
mipsel*) echo "le";;
|
||||
mips*) echo "be";;
|
||||
ppc*le) echo "le";;
|
||||
ppc*) echo "be";;
|
||||
x86_64) echo "le";;
|
||||
riscv64) echo "le";;
|
||||
esac
|
||||
}
|
||||
|
||||
get_libc() {
|
||||
local arch="${1%-*}"
|
||||
|
||||
if [ "${arch}" = "$1" ]; then
|
||||
echo "glibc"
|
||||
else
|
||||
echo "${1#${arch}-}"
|
||||
fi
|
||||
}
|
||||
|
||||
get_wordsize() {
|
||||
local arch="${1%-*}"
|
||||
|
||||
case "$arch" in
|
||||
aarch64) echo "64";;
|
||||
armv5tel) echo "32";;
|
||||
armv6l) echo "32";;
|
||||
armv7l) echo "32";;
|
||||
i686) echo "32";;
|
||||
mipsel*) echo "32";;
|
||||
mips*) echo "32";;
|
||||
ppc64*) echo "64";;
|
||||
ppc*) echo "32";;
|
||||
x86_64) echo "64";;
|
||||
riscv64) echo "64";;
|
||||
esac
|
||||
}
|
||||
|
||||
get_no_atomic8() {
|
||||
local arch="${1%-*}"
|
||||
|
||||
case "$arch" in
|
||||
armv5tel) echo "yes";;
|
||||
armv6l) echo "yes";;
|
||||
mips*) echo "yes";;
|
||||
ppcle) echo "yes";;
|
||||
ppc) echo "yes";;
|
||||
esac
|
||||
}
|
||||
|
||||
get_subpkgs() {
|
||||
local f
|
||||
|
||||
for f in $(typeset -F); do
|
||||
case "$f" in
|
||||
*_package)
|
||||
echo "${f%_package}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
setup_pkg() {
|
||||
local pkg="$1" cross="$2" show_problems="$3"
|
||||
local basepkg val _vars f dbgflags extrarepo
|
||||
|
||||
[ -z "$pkg" ] && return 1
|
||||
basepkg=${pkg%-32bit}
|
||||
|
||||
# Start with a sane environment
|
||||
unset -v PKG_BUILD_OPTIONS XBPS_CROSS_CFLAGS XBPS_CROSS_CXXFLAGS XBPS_CROSS_FFLAGS XBPS_CROSS_CPPFLAGS XBPS_CROSS_LDFLAGS XBPS_TARGET_QEMU_MACHINE
|
||||
unset -v subpackages run_depends build_depends host_build_depends
|
||||
|
||||
unset_package_funcs
|
||||
|
||||
if [ -n "$cross" ]; then
|
||||
source_file $XBPS_CROSSPFDIR/${cross}.sh
|
||||
|
||||
_vars="TARGET_MACHINE CROSS_TRIPLET CROSS_CFLAGS CROSS_CXXFLAGS CROSS_FFLAGS TARGET_QEMU_MACHINE"
|
||||
for f in ${_vars}; do
|
||||
eval val="\$XBPS_$f"
|
||||
if [ -z "$val" ]; then
|
||||
echo "ERROR: XBPS_$f is not defined!"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
export XBPS_CROSS_BASE=/usr/$XBPS_CROSS_TRIPLET
|
||||
export XBPS_TARGET_QEMU_MACHINE
|
||||
|
||||
XBPS_INSTALL_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_INSTALL_CMD -c /host/repocache-$XBPS_TARGET_MACHINE -r $XBPS_CROSS_BASE"
|
||||
XBPS_QUERY_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_QUERY_CMD -c /host/repocache-$XBPS_TARGET_MACHINE -r $XBPS_CROSS_BASE"
|
||||
XBPS_RECONFIGURE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RECONFIGURE_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_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 -r $XBPS_CROSS_BASE"
|
||||
else
|
||||
export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
|
||||
unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
|
||||
unset XBPS_CROSS_CFLAGS XBPS_CROSS_CXXFLAGS XBPS_CROSS_CPPFLAGS
|
||||
unset XBPS_CROSS_RUSTFLAGS XBPS_CROSS_RUST_TARGET
|
||||
|
||||
XBPS_INSTALL_XCMD="$XBPS_INSTALL_CMD"
|
||||
XBPS_QUERY_XCMD="$XBPS_QUERY_CMD"
|
||||
XBPS_RECONFIGURE_XCMD="$XBPS_RECONFIGURE_CMD"
|
||||
XBPS_REMOVE_XCMD="$XBPS_REMOVE_CMD"
|
||||
XBPS_RINDEX_XCMD="$XBPS_RINDEX_CMD"
|
||||
XBPS_UHELPER_XCMD="$XBPS_UHELPER_CMD"
|
||||
XBPS_CHECKVERS_XCMD="$XBPS_CHECKVERS_CMD"
|
||||
fi
|
||||
|
||||
export XBPS_ENDIAN=$(get_endian ${XBPS_MACHINE})
|
||||
export XBPS_TARGET_ENDIAN=$(get_endian ${XBPS_TARGET_MACHINE})
|
||||
export XBPS_LIBC=$(get_libc ${XBPS_MACHINE})
|
||||
export XBPS_TARGET_LIBC=$(get_libc ${XBPS_TARGET_MACHINE})
|
||||
export XBPS_WORDSIZE=$(get_wordsize ${XBPS_MACHINE})
|
||||
export XBPS_TARGET_WORDSIZE=$(get_wordsize ${XBPS_TARGET_MACHINE})
|
||||
export XBPS_NO_ATOMIC8=$(get_no_atomic8 ${XBPS_MACHINE})
|
||||
export XBPS_TARGET_NO_ATOMIC8=$(get_no_atomic8 ${XBPS_TARGET_MACHINE})
|
||||
|
||||
export XBPS_INSTALL_XCMD XBPS_QUERY_XCMD XBPS_RECONFIGURE_XCMD \
|
||||
XBPS_REMOVE_XCMD XBPS_RINDEX_XCMD XBPS_UHELPER_XCMD
|
||||
|
||||
# Source all sourcepkg environment setup snippets.
|
||||
# Source all subpkg environment setup snippets.
|
||||
for f in ${XBPS_COMMONDIR}/environment/setup-subpkg/*.sh; do
|
||||
source_file "$f"
|
||||
done
|
||||
for f in ${XBPS_COMMONDIR}/environment/setup/*.sh; do
|
||||
source_file "$f"
|
||||
done
|
||||
|
||||
if [ ! -f ${XBPS_SRCPKGDIR}/${basepkg}/template ]; then
|
||||
msg_error "xbps-src: nonexistent file: ${XBPS_SRCPKGDIR}/${basepkg}/template\n"
|
||||
fi
|
||||
if [ -n "$cross" ]; then
|
||||
export CROSS_BUILD="$cross"
|
||||
source_file ${XBPS_SRCPKGDIR}/${basepkg}/template
|
||||
else
|
||||
unset CROSS_BUILD
|
||||
source_file ${XBPS_SRCPKGDIR}/${basepkg}/template
|
||||
fi
|
||||
|
||||
|
||||
# Check if required vars weren't set.
|
||||
_vars="pkgname version short_desc revision homepage license"
|
||||
for f in ${_vars}; do
|
||||
eval val="\$$f"
|
||||
if [ -z "$val" -o -z "$f" ]; then
|
||||
msg_error "\"$f\" not set on $pkgname template.\n"
|
||||
fi
|
||||
done
|
||||
|
||||
# Check if version is valid.
|
||||
case "$version" in
|
||||
*-*) msg_error "version contains invalid character: -\n";;
|
||||
*_*) msg_error "version contains invalid character: _\n";;
|
||||
esac
|
||||
case "$version" in
|
||||
*[0-9]*) : good ;;
|
||||
*) msg_error "version must contain at least one digit.\n";;
|
||||
esac
|
||||
|
||||
# Check if base-chroot is already installed.
|
||||
if [ -z "$bootstrap" -a -z "$CHROOT_READY" -a "z$show_problems" != "zignore-problems" ]; then
|
||||
msg_red "${pkg} is not a bootstrap package and cannot be built without bootstrapping first.\n"
|
||||
msg_normal "binary bootstrapping for ${XBPS_MACHINE} in ${XBPS_MASTERDIR}...\n"
|
||||
install_base_chroot "$XBPS_MACHINE"
|
||||
fi
|
||||
|
||||
sourcepkg="${pkgname}"
|
||||
if [ -z "$subpackages" ]; then
|
||||
subpackages="$(get_subpkgs)"
|
||||
fi
|
||||
|
||||
if [ -h $XBPS_SRCPKGDIR/$basepkg ]; then
|
||||
# Source all subpkg environment setup snippets.
|
||||
for f in ${XBPS_COMMONDIR}/environment/setup-subpkg/*.sh; do
|
||||
source_file "$f"
|
||||
done
|
||||
pkgname=$pkg
|
||||
if ! declare -f ${basepkg}_package >/dev/null; then
|
||||
msg_error "$pkgname: missing ${basepkg}_package() function!\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
pkgver="${pkg}-${version}_${revision}"
|
||||
|
||||
# If build_style is unset, a do_install() function must be defined.
|
||||
if [ -z "$build_style" ]; then
|
||||
# Check that at least do_install() is defined.
|
||||
if [ "$metapackage" != yes ] && ! declare -f do_install >/dev/null && [ "${pkgname}" = "${sourcepkg}" ]; then
|
||||
msg_error "$pkgver: missing do_install() function!\n"
|
||||
fi
|
||||
elif [ "$build_style" = meta ]; then
|
||||
msg_error "$pkgver: build_style=meta is deprecated, replace with metapackage=yes\n"
|
||||
fi
|
||||
|
||||
for x in ${hostmakedepends} ${makedepends} ${checkdepends}; do
|
||||
if [[ $x = *[\<\>]* || $x =~ -[^-_]*[0-9][^-_]*_[0-9_]+$ ]]; then
|
||||
msg_error "$pkgver: specifying version in build dependency '$x' is invalid, template version is used always\n"
|
||||
fi
|
||||
done
|
||||
|
||||
FILESDIR=$XBPS_SRCPKGDIR/$sourcepkg/files
|
||||
PATCHESDIR=$XBPS_SRCPKGDIR/$sourcepkg/patches
|
||||
DESTDIR=${XBPS_DESTDIR}/${XBPS_CROSS_TRIPLET:+${XBPS_CROSS_TRIPLET}/}/${sourcepkg}-${version}
|
||||
PKGDESTDIR=${XBPS_DESTDIR}/${XBPS_CROSS_TRIPLET:+$XBPS_CROSS_TRIPLET/}${pkg}-${version}
|
||||
|
||||
export XBPS_ORIG_MAKEJOBS=${XBPS_ORIG_MAKEJOBS:=$XBPS_MAKEJOBS}
|
||||
if [ -n "$disable_parallel_build" ]; then
|
||||
XBPS_MAKEJOBS=1
|
||||
fi
|
||||
makejobs="-j$XBPS_MAKEJOBS"
|
||||
if [ -n "$XBPS_BINPKG_EXISTS" ]; then
|
||||
local extraflags=""
|
||||
if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
|
||||
extraflags="-i"
|
||||
# filter out remote repositories
|
||||
for repo in $(xbps-query -L | awk '{ print $2 }' | grep '^/host/'); do
|
||||
extraflags+=" --repository=$repo"
|
||||
done
|
||||
fi
|
||||
local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver $extraflags 2>/dev/null)"
|
||||
if [ "$_binpkgver" = "$pkgver" ]; then
|
||||
if [ -z "$XBPS_DEPENDENCY" ]; then
|
||||
local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
|
||||
msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
|
||||
fi
|
||||
exit_and_cleanup
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$XBPS_DEBUG_PKGS" -o "$repository" = "nonfree" ]; then
|
||||
nodebug=yes
|
||||
fi
|
||||
# -g is required to build -dbg packages.
|
||||
if [ -z "$nodebug" ]; then
|
||||
dbgflags="-g"
|
||||
fi
|
||||
|
||||
# build profile is used always in order to expose the host triplet,
|
||||
# but the compiler flags from it are only used when not crossing
|
||||
if [ -z "$CHROOT_READY" ]; then
|
||||
source_file ${XBPS_COMMONDIR}/build-profiles/bootstrap.sh
|
||||
else
|
||||
source_file ${XBPS_COMMONDIR}/build-profiles/${XBPS_MACHINE}.sh
|
||||
fi
|
||||
|
||||
set_build_options
|
||||
|
||||
export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
|
||||
export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
|
||||
export FFLAGS="$XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS $dbgflags"
|
||||
export CPPFLAGS="$XBPS_CPPFLAGS $XBPS_CROSS_CPPFLAGS $CPPFLAGS"
|
||||
export LDFLAGS="$XBPS_LDFLAGS $XBPS_CROSS_LDFLAGS $LDFLAGS"
|
||||
|
||||
export BUILD_CC="cc"
|
||||
export BUILD_CXX="c++"
|
||||
export BUILD_CPP="cpp"
|
||||
export BUILD_FC="gfortran"
|
||||
export BUILD_LD="ld"
|
||||
export BUILD_CFLAGS="$XBPS_CFLAGS"
|
||||
export BUILD_CXXFLAGS="$XBPS_CXXFLAGS"
|
||||
export BUILD_CPPFLAGS="$XBPS_CPPFLAGS"
|
||||
export BUILD_LDFLAGS="$XBPS_LDFLAGS"
|
||||
export BUILD_FFLAGS="$XBPS_FFLAGS"
|
||||
|
||||
export CC_FOR_BUILD="cc"
|
||||
export CXX_FOR_BUILD="g++"
|
||||
export CPP_FOR_BUILD="cpp"
|
||||
export FC_FOR_BUILD="gfortran"
|
||||
export LD_FOR_BUILD="ld"
|
||||
export PKG_CONFIG_FOR_BUILD="/usr/bin/pkg-config"
|
||||
export CFLAGS_FOR_BUILD="$XBPS_CFLAGS"
|
||||
export CXXFLAGS_FOR_BUILD="$XBPS_CXXFLAGS"
|
||||
export CPPFLAGS_FOR_BUILD="$XBPS_CPPFLAGS"
|
||||
export LDFLAGS_FOR_BUILD="$XBPS_LDFLAGS"
|
||||
export FFLAGS_FOR_BUILD="$XBPS_FFLAGS"
|
||||
|
||||
if [ -n "$cross" ]; then
|
||||
# Regular tools names
|
||||
export CC="${XBPS_CROSS_TRIPLET}-gcc"
|
||||
export CXX="${XBPS_CROSS_TRIPLET}-c++"
|
||||
export CPP="${XBPS_CROSS_TRIPLET}-cpp"
|
||||
export FC="${XBPS_CROSS_TRIPLET}-gfortran"
|
||||
export GCC="$CC"
|
||||
export LD="${XBPS_CROSS_TRIPLET}-ld"
|
||||
export AR="${XBPS_CROSS_TRIPLET}-ar"
|
||||
export AS="${XBPS_CROSS_TRIPLET}-as"
|
||||
export RANLIB="${XBPS_CROSS_TRIPLET}-ranlib"
|
||||
export STRIP="${XBPS_CROSS_TRIPLET}-strip"
|
||||
export OBJDUMP="${XBPS_CROSS_TRIPLET}-objdump"
|
||||
export OBJCOPY="${XBPS_CROSS_TRIPLET}-objcopy"
|
||||
export NM="${XBPS_CROSS_TRIPLET}-nm"
|
||||
export READELF="${XBPS_CROSS_TRIPLET}-readelf"
|
||||
export PKG_CONFIG="${XBPS_CROSS_TRIPLET}-pkg-config"
|
||||
# Target tools
|
||||
export CC_target="$CC"
|
||||
export CXX_target="$CXX"
|
||||
export CPP_target="$CPP"
|
||||
export GCC_target="$GCC"
|
||||
export FC_target="$FC"
|
||||
export LD_target="$LD"
|
||||
export AR_target="$AR"
|
||||
export AS_target="$AS"
|
||||
export RANLIB_target="$RANLIB"
|
||||
export STRIP_target="$STRIP"
|
||||
export OBJDUMP_target="$OBJDUMP"
|
||||
export OBJCOPY_target="$OBJCOPY"
|
||||
export NM_target="$NM"
|
||||
export READELF_target="$READELF"
|
||||
# Target flags
|
||||
export CFLAGS_target="$CFLAGS"
|
||||
export CXXFLAGS_target="$CXXFLAGS"
|
||||
export CPPFLAGS_target="$CPPFLAGS"
|
||||
export LDFLAGS_target="$LDFLAGS"
|
||||
export FFLAGS_target="$FFLAGS"
|
||||
# Host tools
|
||||
export CC_host="cc"
|
||||
export CXX_host="g++"
|
||||
export CPP_host="cpp"
|
||||
export GCC_host="$CC_host"
|
||||
export FC_host="gfortran"
|
||||
export LD_host="ld"
|
||||
export AR_host="ar"
|
||||
export AS_host="as"
|
||||
export RANLIB_host="ranlib"
|
||||
export STRIP_host="strip"
|
||||
export OBJDUMP_host="objdump"
|
||||
export OBJCOPY_host="objcopy"
|
||||
export NM_host="nm"
|
||||
export READELF_host="readelf"
|
||||
# Host flags
|
||||
export CFLAGS_host="$XBPS_CFLAGS"
|
||||
export CXXFLAGS_host="$XBPS_CXXFLAGS"
|
||||
export CPPFLAGS_host="$XBPS_CPPFLAGS"
|
||||
export LDFLAGS_host="$XBPS_LDFLAGS"
|
||||
export FFLAGS_host="$XBPS_FFLAGS"
|
||||
# Rust flags which are passed to rustc
|
||||
export RUSTFLAGS="$XBPS_CROSS_RUSTFLAGS"
|
||||
# Rust target, which differs from our triplets
|
||||
export RUST_TARGET="$XBPS_CROSS_RUST_TARGET"
|
||||
# Rust build, which is the host system, may also differ
|
||||
export RUST_BUILD="$XBPS_RUST_TARGET"
|
||||
else
|
||||
# Target flags from build-profile
|
||||
export CFLAGS="$XBPS_TARGET_CFLAGS $CFLAGS"
|
||||
export CXXFLAGS="$XBPS_TARGET_CXXFLAGS $CXXFLAGS"
|
||||
export FFLAGS="$XBPS_TARGET_FFLAGS $FFLAGS"
|
||||
export CPPFLAGS="$XBPS_TARGET_CPPFLAGS $CPPFLAGS"
|
||||
export LDFLAGS="$XBPS_TARGET_LDFLAGS $LDFLAGS"
|
||||
# Tools
|
||||
export CC="cc"
|
||||
export CXX="g++"
|
||||
export CPP="cpp"
|
||||
export GCC="$CC"
|
||||
export FC="gfortran"
|
||||
export LD="ld"
|
||||
export AR="ar"
|
||||
export AS="as"
|
||||
export RANLIB="ranlib"
|
||||
export STRIP="strip"
|
||||
export OBJDUMP="objdump"
|
||||
export OBJCOPY="objcopy"
|
||||
export NM="nm"
|
||||
export READELF="readelf"
|
||||
export PKG_CONFIG="pkg-config"
|
||||
export RUST_TARGET="$XBPS_RUST_TARGET"
|
||||
export RUST_BUILD="$XBPS_RUST_TARGET"
|
||||
# Unset cross evironment variables
|
||||
unset CC_target CXX_target CPP_target GCC_target FC_target LD_target AR_target AS_target
|
||||
unset RANLIB_target STRIP_target OBJDUMP_target OBJCOPY_target NM_target READELF_target
|
||||
unset CFLAGS_target CXXFLAGS_target CPPFLAGS_target LDFLAGS_target FFLAGS_target
|
||||
unset CC_host CXX_host CPP_host GCC_host FC_host LD_host AR_host AS_host
|
||||
unset RANLIB_host STRIP_host OBJDUMP_host OBJCOPY_host NM_host READELF_host
|
||||
unset CFLAGS_host CXXFLAGS_host CPPFLAGS_host LDFLAGS_host FFLAGS_host
|
||||
unset RUSTFLAGS
|
||||
fi
|
||||
|
||||
# Setup some specific package vars.
|
||||
wrksrc="$XBPS_BUILDDIR/${sourcepkg}-${version}"
|
||||
|
||||
if [ "$cross" -a "$nocross" ]; then
|
||||
report_broken \
|
||||
"$pkgver: cannot be cross compiled...\n" \
|
||||
"$pkgver: $nocross\n"
|
||||
elif [ "$broken" ]; then
|
||||
report_broken \
|
||||
"$pkgver: cannot be built, it's currently broken; see the build log:\n" \
|
||||
"$pkgver: $broken\n"
|
||||
fi
|
||||
|
||||
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 "If you really need this software, run 'echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf'\n"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
export XBPS_STATEDIR="${XBPS_BUILDDIR}/.xbps-${sourcepkg}"
|
||||
export XBPS_WRAPPERDIR="${XBPS_STATEDIR}/wrappers"
|
||||
|
||||
mkdir -p $XBPS_STATEDIR $XBPS_WRAPPERDIR
|
||||
|
||||
source_file $XBPS_COMMONDIR/environment/build-style/${build_style}.sh
|
||||
|
||||
# Source all build-helper files that are defined
|
||||
for f in $build_helper; do
|
||||
if [ ! -r $XBPS_BUILDHELPERDIR/${f}.sh ]; then
|
||||
msg_error "$pkgver: cannot find build helper $XBPS_BUILDHELPERDIR/${f}.sh!\n"
|
||||
fi
|
||||
. $XBPS_BUILDHELPERDIR/${f}.sh
|
||||
done
|
||||
}
|
||||
81
common/xbps-src/shutils/consistency_check.sh
Normal file
81
common/xbps-src/shutils/consistency_check.sh
Normal file
@@ -0,0 +1,81 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
consistency_check_existing () {
|
||||
while IFS=" " read -r dep origname deplabel; do
|
||||
[ -f "$XBPS_SRCPKGDIR/$dep/template" ] && continue
|
||||
case "$deplabel" in
|
||||
makedepends|hostmakedepends|checkdepends)
|
||||
msg_warn "unsatisfied $deplabel in $origname: $dep does not exist\n";
|
||||
;;
|
||||
*) printf "%s %s %s\n" "$dep" "$origname" "$deplabel" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
consistency_convert_pkgname () {
|
||||
local origname= pkgname version= revision=
|
||||
while IFS=" " read -r dep origname deplabel; do
|
||||
case "$deplabel" in
|
||||
makedepends|hostmakedepends|checkdepends)
|
||||
printf "%s %s %s\n" "$dep" "$origname" "$deplabel"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
case "$dep" in
|
||||
*\<*|*\>*|*=*)
|
||||
printf "%s %s %s\n" "$dep" "$origname" "$deplabel"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
if pkgname=$(xbps-uhelper getpkgname "$dep" 2> /dev/null) && \
|
||||
version=$(xbps-uhelper getpkgversion "$dep" 2> /dev/null) && \
|
||||
revision=$(xbps-uhelper getpkgrevision "$dep" 2> /dev/null); then
|
||||
printf "%s %s %s\n" "${pkgname}>=${version}_${revision}" "$origname" "$deplabel"
|
||||
else
|
||||
printf "%s %s %s\n" "$dep>=0" "$origname" "$deplabel"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
consistency_check_smart () {
|
||||
local pkgname= depdef= dep=
|
||||
while IFS=" " read -r depdef origname deplabel; do
|
||||
case "$deplabel" in
|
||||
makedepends|hostmakedepends|checkdepends)
|
||||
printf "%s %s %s\n" "$depdef" "$origname" "$deplabel"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
dep=$(xbps-uhelper getpkgdepname "$depdef")
|
||||
|
||||
if [ ! -f "$XBPS_SRCPKGDIR/$dep/template" ]; then
|
||||
msg_warn "unsatisfied $deplabel in $origname: $dep does not exist\n";
|
||||
continue
|
||||
fi
|
||||
(
|
||||
XBPS_TARGET_PKG=$dep
|
||||
read_pkg
|
||||
xbps-uhelper pkgmatch "$depdef" "${pkgname}-${version}_${revision}" && return
|
||||
msg_red "unsatisfied $deplabel in $origname: $dep is $version, but required is $depdef\n";
|
||||
)
|
||||
done
|
||||
}
|
||||
|
||||
consistency_check() {
|
||||
local pkg= pkgname=
|
||||
for pkg in "$XBPS_SRCPKGDIR"/*/template; do
|
||||
pkg=${pkg%/*}
|
||||
XBPS_TARGET_PKG=${pkg##*/}
|
||||
(
|
||||
read_pkg
|
||||
[ "$depends" ] && printf "%s $pkgname depends\n" $depends
|
||||
[ "$conflicts" ] && printf "%s $pkgname conflicts\n" $conflicts
|
||||
[ -L "$XBPS_SRCPKGDIR/$XBPS_TARGET_PKG" ] && return
|
||||
[ "$makedepends" ] && printf "%s $pkgname makedepends\n" $makedepends
|
||||
[ "$hostmakedepends" ] && printf "%s $pkgname hostmakedepends\n" $hostmakedepends
|
||||
[ "$checkdepends" ] && printf "%s $pkgname checkdepends\n" $checkdepends
|
||||
)
|
||||
done | grep -v "^virtual?" | sed "s/^[^ ]*?//" | consistency_check_existing | \
|
||||
consistency_convert_pkgname | consistency_check_smart
|
||||
}
|
||||
136
common/xbps-src/shutils/cross.sh
Normal file
136
common/xbps-src/shutils/cross.sh
Normal file
@@ -0,0 +1,136 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
remove_pkg_cross_deps() {
|
||||
local rval= tmplogf= prevs=0
|
||||
[ -z "$XBPS_CROSS_BUILD" ] && return 0
|
||||
|
||||
cd $XBPS_MASTERDIR || return 1
|
||||
msg_normal "${pkgver:-xbps-src}: removing autocrossdeps, please wait...\n"
|
||||
tmplogf=$(mktemp) || exit 1
|
||||
|
||||
if [ -z "$XBPS_REMOVE_XCMD" ]; then
|
||||
source_file $XBPS_CROSSPFDIR/${XBPS_CROSS_BUILD}.sh
|
||||
XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-remove -r /usr/$XBPS_CROSS_TRIPLET"
|
||||
fi
|
||||
|
||||
$XBPS_REMOVE_XCMD -Ryo > $tmplogf 2>&1
|
||||
rval=$?
|
||||
while [ $rval -eq 0 ]; do
|
||||
local curs=$(stat_size $tmplogf)
|
||||
if [ $curs -eq $prevs ]; then
|
||||
break
|
||||
fi
|
||||
prevs=$curs
|
||||
$XBPS_REMOVE_XCMD -Ryo >> $tmplogf 2>&1
|
||||
rval=$?
|
||||
done
|
||||
|
||||
if [ $rval -ne 0 ]; then
|
||||
msg_red "${pkgver:-xbps-src}: failed to remove autocrossdeps:\n"
|
||||
cat $tmplogf && rm -f $tmplogf
|
||||
msg_error "${pkgver:-xbps-src}: cannot continue!\n"
|
||||
fi
|
||||
rm -f $tmplogf
|
||||
}
|
||||
|
||||
prepare_cross_sysroot() {
|
||||
local cross="$1"
|
||||
local statefile="$XBPS_MASTERDIR/.xbps-${cross}-done"
|
||||
|
||||
[ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
|
||||
|
||||
# Check if the cross pkg is installed in host.
|
||||
check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
|
||||
[ $? -eq 0 ] && return 0
|
||||
|
||||
# Check if the cross compiler pkg is available in repos, otherwise build it.
|
||||
pkg_available cross-${XBPS_CROSS_TRIPLET}
|
||||
rval=$?
|
||||
if [ $rval -eq 0 ]; then
|
||||
$XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
|
||||
fi
|
||||
|
||||
# Check if cross-vpkg-dummy is installed.
|
||||
check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
|
||||
[ $? -eq 0 ] && return 0
|
||||
|
||||
# Check for cross-vpkg-dummy available for the target arch, otherwise build it.
|
||||
pkg_available 'cross-vpkg-dummy>=0.34_1' $cross
|
||||
if [ $? -eq 0 ]; then
|
||||
$XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
|
||||
fi
|
||||
|
||||
msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
|
||||
errlog=$(mktemp) || exit 1
|
||||
$XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
|
||||
rval=$?
|
||||
if [ $rval -ne 0 ]; then
|
||||
msg_red "failed to install cross-vpkg-dummy (error $rval)\n"
|
||||
cat $errlog
|
||||
rm -f $errlog
|
||||
msg_error "cannot continue due to errors above\n"
|
||||
fi
|
||||
rm -f $errlog
|
||||
# Create top level symlinks in sysroot.
|
||||
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.
|
||||
ln -s usr/include ${XBPS_CROSS_BASE}/include
|
||||
ln -s usr/lib ${XBPS_CROSS_BASE}/lib
|
||||
|
||||
touch -f $statefile
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
install_cross_pkg() {
|
||||
local cross="$1" rval errlog
|
||||
|
||||
[ -z "$cross" -o "$cross" = "" ] && return 0
|
||||
|
||||
# Check if installed.
|
||||
check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
|
||||
[ $? -eq 0 ] && return 0
|
||||
|
||||
# Check if the cross compiler pkg is available in repos, otherwise build it.
|
||||
pkg_available cross-${XBPS_CROSS_TRIPLET}
|
||||
rval=$?
|
||||
if [ $rval -eq 0 ]; then
|
||||
$XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
|
||||
fi
|
||||
|
||||
errlog=$(mktemp) || exit 1
|
||||
msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
|
||||
$XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
|
||||
rval=$?
|
||||
if [ $rval -ne 0 -a $rval -ne 17 ]; then
|
||||
msg_red "failed to install cross-${XBPS_CROSS_TRIPLET} (error $rval)\n"
|
||||
cat $errlog
|
||||
rm -f $errlog
|
||||
msg_error "cannot continue due to errors above\n"
|
||||
fi
|
||||
rm -f $errlog
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
remove_cross_pkg() {
|
||||
local cross="$1" rval
|
||||
|
||||
[ -z "$cross" -o "$cross" = "" ] && return 0
|
||||
|
||||
source_file ${XBPS_CROSSPFDIR}/${cross}.sh
|
||||
|
||||
if [ -z "$CHROOT_READY" ]; then
|
||||
echo "ERROR: chroot mode not activated (install a bootstrap)."
|
||||
exit 1
|
||||
elif [ -z "$IN_CHROOT" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
msg_normal "Removing cross pkg: cross-${XBPS_CROSS_TRIPLET} ...\n"
|
||||
$XBPS_REMOVE_CMD -Ry cross-${XBPS_CROSS_TRIPLET} &>/dev/null
|
||||
rval=$?
|
||||
if [ $rval -ne 0 ]; then
|
||||
msg_error "failed to remove cross-${XBPS_CROSS_TRIPLET} (error $rval)\n"
|
||||
fi
|
||||
}
|
||||
137
common/xbps-src/shutils/pkgtarget.sh
Normal file
137
common/xbps-src/shutils/pkgtarget.sh
Normal file
@@ -0,0 +1,137 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
check_existing_pkg() {
|
||||
local arch= curpkg=
|
||||
if [ -z "$XBPS_PRESERVE_PKGS" ] || [ "$XBPS_BUILD_FORCEMODE" ]; then
|
||||
return
|
||||
fi
|
||||
arch=$XBPS_TARGET_MACHINE
|
||||
curpkg=$XBPS_REPOSITORY/$repository/$pkgver.$arch.xbps
|
||||
if [ -e $curpkg ]; then
|
||||
msg_warn "$pkgver: skipping build due to existing $curpkg\n"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
check_pkg_arch() {
|
||||
local cross="$1" _arch f match nonegation
|
||||
|
||||
if [ -n "$archs" ]; then
|
||||
if [ -n "$cross" ]; then
|
||||
_arch="$XBPS_TARGET_MACHINE"
|
||||
elif [ -n "$XBPS_ARCH" ]; then
|
||||
_arch="$XBPS_ARCH"
|
||||
else
|
||||
_arch="$XBPS_MACHINE"
|
||||
fi
|
||||
set -f
|
||||
for f in ${archs}; do
|
||||
set +f
|
||||
nonegation=${f##\~*}
|
||||
f=${f#\~}
|
||||
case "${_arch}" in
|
||||
$f) match=1; break ;;
|
||||
esac
|
||||
done
|
||||
if [ -z "$nonegation" -a -n "$match" ] || [ -n "$nonegation" -a -z "$match" ]; then
|
||||
report_broken "${pkgname}-${version}_${revision}: this package cannot be built for ${_arch}.\n"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Returns 1 if pkg is available in xbps repositories, 0 otherwise.
|
||||
pkg_available() {
|
||||
local pkg="$1" cross="$2" pkgver
|
||||
|
||||
if [ -n "$cross" ]; then
|
||||
pkgver=$($XBPS_QUERY_XCMD -R -ppkgver "${pkg}" 2>/dev/null)
|
||||
else
|
||||
pkgver=$($XBPS_QUERY_CMD -R -ppkgver "${pkg}" 2>/dev/null)
|
||||
fi
|
||||
|
||||
if [ -z "$pkgver" ]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
remove_pkg_autodeps() {
|
||||
local rval= tmplogf= errlogf= prevs=
|
||||
|
||||
cd $XBPS_MASTERDIR || return 1
|
||||
msg_normal "${pkgver:-xbps-src}: removing autodeps, please wait...\n"
|
||||
tmplogf=$(mktemp) || exit 1
|
||||
errlogf=$(mktemp) || exit 1
|
||||
|
||||
remove_pkg_cross_deps
|
||||
$XBPS_RECONFIGURE_CMD -a >> $tmplogf 2>&1
|
||||
prevs=$(stat_size $tmplogf)
|
||||
echo yes | $XBPS_REMOVE_CMD -Ryod 2>> $errlogf 1>> $tmplogf
|
||||
rval=$?
|
||||
while [ $rval -eq 0 ]; do
|
||||
local curs=$(stat_size $tmplogf)
|
||||
if [ $curs -eq $prevs ]; then
|
||||
break
|
||||
fi
|
||||
prevs=$curs
|
||||
echo yes | $XBPS_REMOVE_CMD -Ryod 2>> $errlogf 1>> $tmplogf
|
||||
rval=$?
|
||||
done
|
||||
|
||||
if [ $rval -ne 0 ]; then
|
||||
msg_red "${pkgver:-xbps-src}: failed to remove autodeps: (returned $rval)\n"
|
||||
cat $tmplogf && rm -f $tmplogf
|
||||
cat $errlogf && rm -f $errlogf
|
||||
msg_error "${pkgver:-xbps-src}: cannot continue!\n"
|
||||
fi
|
||||
rm -f $tmplogf
|
||||
rm -f $errlogf
|
||||
}
|
||||
|
||||
remove_pkg_wrksrc() {
|
||||
if [ -d "$wrksrc" ]; then
|
||||
msg_normal "$pkgver: cleaning build directory...\n"
|
||||
rm -rf "$wrksrc" 2>/dev/null || chmod -R +wX "$wrksrc" # Needed to delete Go Modules
|
||||
rm -rf "$wrksrc"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_pkg_statedir() {
|
||||
if [ -d "$XBPS_STATEDIR" ]; then
|
||||
rm -rf "$XBPS_STATEDIR"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_pkg() {
|
||||
local cross="$1" _destdir f
|
||||
|
||||
[ -z $pkgname ] && msg_error "nonexistent package, aborting.\n"
|
||||
|
||||
if [ -n "$cross" ]; then
|
||||
_destdir="$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET"
|
||||
else
|
||||
_destdir="$XBPS_DESTDIR"
|
||||
fi
|
||||
|
||||
[ ! -d ${_destdir} ] && return
|
||||
|
||||
for f in ${sourcepkg} ${subpackages}; do
|
||||
if [ -d "${_destdir}/${f}-${version}" ]; then
|
||||
msg_normal "$f: removing files from destdir...\n"
|
||||
rm -rf ${_destdir}/${f}-${version}
|
||||
fi
|
||||
if [ -d "${_destdir}/${f}-dbg-${version}" ]; then
|
||||
msg_normal "$f: removing dbg files from destdir...\n"
|
||||
rm -rf ${_destdir}/${f}-dbg-${version}
|
||||
fi
|
||||
if [ -d "${_destdir}/${f}-32bit-${version}" ]; then
|
||||
msg_normal "$f: removing 32bit files from destdir...\n"
|
||||
rm -rf ${_destdir}/${f}-32bit-${version}
|
||||
fi
|
||||
rm -f ${XBPS_STATEDIR}/${f}_${cross}_subpkg_install_done
|
||||
rm -f ${XBPS_STATEDIR}/${f}_${cross}_prepkg_done
|
||||
done
|
||||
rm -f ${XBPS_STATEDIR}/${sourcepkg}_${cross}_install_done
|
||||
rm -f ${XBPS_STATEDIR}/${sourcepkg}_${cross}_pre_install_done
|
||||
rm -f ${XBPS_STATEDIR}/${sourcepkg}_${cross}_post_install_done
|
||||
}
|
||||
85
common/xbps-src/shutils/purge_distfiles.sh
Normal file
85
common/xbps-src/shutils/purge_distfiles.sh
Normal file
@@ -0,0 +1,85 @@
|
||||
# Scan srcpkgs/*/template for hashes and distfiles to determine
|
||||
# obsolete sources/by_sha256 files and their corresponding
|
||||
# sources/<pkgname>-<version> files that can be purged
|
||||
|
||||
|
||||
purge_distfiles() {
|
||||
readonly HASHLEN=64
|
||||
if [ -z "$XBPS_SRCDISTDIR" ]; then
|
||||
msg_error "The variable \$XBPS_SRCDISTDIR is not set."
|
||||
exit 1
|
||||
fi
|
||||
#
|
||||
# Scan all templates for their current distfiles and checksums (hashes)
|
||||
#
|
||||
declare -A my_hashes
|
||||
templates=($(find srcpkgs -mindepth 1 -maxdepth 1 -type d -printf "srcpkgs/%f/template\n"))
|
||||
max=${#templates[@]}
|
||||
cur=0
|
||||
if [ -z "$max" ]; then
|
||||
msg_error "No srcpkgs/*/template files found. Wrong working directory?"
|
||||
exit 1
|
||||
fi
|
||||
percent=-1
|
||||
for template in ${templates[@]}; do
|
||||
pkg=${template#*/}
|
||||
pkg=${pkg%/*}
|
||||
if [ ! -L "srcpkgs/$pkg" ]; then
|
||||
checksum="$(grep -Ehrow [0-9a-f]{$HASHLEN} ${template}|sort|uniq|tr '\n' ' ')"
|
||||
read -a _my_hashes <<< ${checksum}
|
||||
i=0
|
||||
while [ -n "${_my_hashes[$i]}" ]; do
|
||||
hash="${_my_hashes[$i]}"
|
||||
[ -z "${my_hashes[$hash]}" ] && my_hashes[$hash]=$template
|
||||
i=$((i + 1))
|
||||
done
|
||||
fi
|
||||
cur=$((cur + 1))
|
||||
pnew=$((100 * cur / max))
|
||||
if [ $pnew -ne $percent ]; then
|
||||
percent=$pnew
|
||||
printf "\rScanning templates : %3d%% (%d/%d)" $percent $cur $max
|
||||
fi
|
||||
done
|
||||
echo
|
||||
echo "Number of hashes : ${#my_hashes[@]}"
|
||||
|
||||
#
|
||||
# Collect inodes of all distfiles in $XBPS_SRCDISTDIR
|
||||
#
|
||||
declare -A inodes
|
||||
distfiles=($XBPS_SRCDISTDIR/*/*)
|
||||
max=${#distfiles[@]}
|
||||
if [ -z "$max" ]; then
|
||||
msg_error "No distfiles files found in '$XBPS_SRCDISTDIR'"
|
||||
exit 1
|
||||
fi
|
||||
cur=0
|
||||
percent=-1
|
||||
for distfile in ${distfiles[@]}; do
|
||||
inode=$(stat_inode "$distfile")
|
||||
if [ -z "${inodes[$inode]}" ]; then
|
||||
inodes[$inode]="$distfile"
|
||||
else
|
||||
inodes[$inode]+="|$distfile"
|
||||
fi
|
||||
cur=$((cur + 1))
|
||||
pnew=$((100 * cur / max))
|
||||
if [ $pnew -ne $percent ]; then
|
||||
percent=$pnew
|
||||
printf "\rCollecting inodes : %3d%% (%d/%d)" $percent $cur $max
|
||||
fi
|
||||
done
|
||||
echo
|
||||
|
||||
hashes=($XBPS_SRCDISTDIR/by_sha256/*)
|
||||
for file in ${hashes[@]}; do
|
||||
hash_distfile=${file##*/}
|
||||
hash=${hash_distfile:0:$HASHLEN}
|
||||
[ -n "${my_hashes[$hash]}" ] && continue
|
||||
inode=$(stat_inode "$file")
|
||||
echo "Obsolete $hash (inode: $inode)"
|
||||
( IFS="|"; for f in ${inodes[$inode]}; do rm -vf "$f"; rmdir "${f%/*}" 2>/dev/null; done )
|
||||
done
|
||||
echo "Done."
|
||||
}
|
||||
165
common/xbps-src/shutils/show.sh
Normal file
165
common/xbps-src/shutils/show.sh
Normal file
@@ -0,0 +1,165 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
show_pkg() {
|
||||
show_pkg_var "pkgname" "$pkgname"
|
||||
show_pkg_var "version" "$version"
|
||||
show_pkg_var "revision" "$revision"
|
||||
show_pkg_var "distfiles" "$distfiles" 1
|
||||
show_pkg_var "checksum" "$checksum" 1
|
||||
show_pkg_var "archs" "$archs" 1
|
||||
show_pkg_var "maintainer" "${maintainer}"
|
||||
show_pkg_var "Upstream URL" "$homepage"
|
||||
show_pkg_var "License(s)" "${license//,/ }" 1
|
||||
show_pkg_var "Changelog" "$changelog"
|
||||
show_pkg_var "build_style" "$build_style"
|
||||
show_pkg_var "build_helper" "$build_helper" 1
|
||||
show_pkg_var "configure_args" "$configure_args" 1
|
||||
show_pkg_var "short_desc" "$short_desc"
|
||||
show_pkg_var "subpackages" "$subpackages" 1
|
||||
set -f
|
||||
show_pkg_var "conf_files" "$conf_files" 1
|
||||
set +f
|
||||
show_pkg_var "replaces" "$replaces" 1
|
||||
show_pkg_var "provides" "$provides" 1
|
||||
show_pkg_var "conflicts" "$conflicts" 1
|
||||
local OIFS="$IFS"
|
||||
IFS=','
|
||||
for var in $1; do
|
||||
IFS=$OIFS
|
||||
if [ ${var} != ${var/'*'} ]
|
||||
then
|
||||
var="${var/'*'}"
|
||||
show_pkg_var "$var" "${!var//$'\n'/' '}"
|
||||
else
|
||||
show_pkg_var "$var" "${!var}" 1
|
||||
fi
|
||||
done
|
||||
IFS="$OIFS"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
show_pkg_var() {
|
||||
local _sep i=
|
||||
local _label="$1"
|
||||
local _value="$2"
|
||||
local _always_split="$3"
|
||||
if [ -n "$_value" ] && [ -n "$_label" ]; then
|
||||
# on short labels, use more padding so everything lines up
|
||||
if [ "${#_label}" -lt 7 ]; then
|
||||
_sep=" "
|
||||
else
|
||||
_sep=" "
|
||||
fi
|
||||
if [ -n "$_always_split" ] || [[ "$_value" =~ $'\n' ]]; then
|
||||
set -f
|
||||
for i in ${_value}; do
|
||||
[ -n "$i" ] && echo "${_label}:${_sep}${i}"
|
||||
done
|
||||
set +f
|
||||
else
|
||||
echo "${_label}:${_sep}${_value}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
show_pkg_deps() {
|
||||
[ -f "${XBPS_STATEDIR}/${pkgname}-rdeps" ] && cat "${XBPS_STATEDIR}/${pkgname}-rdeps"
|
||||
}
|
||||
|
||||
show_pkg_files() {
|
||||
[ -d ${PKGDESTDIR} ] && find ${PKGDESTDIR} -print
|
||||
}
|
||||
|
||||
show_avail() {
|
||||
check_pkg_arch "$XBPS_CROSS_BUILD" 2>/dev/null
|
||||
}
|
||||
|
||||
show_eval_dep() {
|
||||
local f x _pkgname _srcpkg found
|
||||
local _dep="${1%-32bit}"
|
||||
local _host="$2"
|
||||
if [ -z "$CROSS_BUILD" ] || [ -z "$_host" ]; then
|
||||
# ignore dependency on itself
|
||||
[[ $_dep == $sourcepkg ]] && return
|
||||
fi
|
||||
if [ ! -f $XBPS_SRCPKGDIR/$_dep/template ]; then
|
||||
msg_error "$pkgver: dependency '$_dep' does not exist!\n"
|
||||
fi
|
||||
# ignore virtual dependencies
|
||||
[[ ${_dep%\?*} != ${_dep#*\?} ]] && _dep=${_dep#*\?}
|
||||
unset found
|
||||
# check for subpkgs
|
||||
for x in ${subpackages}; do
|
||||
[[ $_dep == $x ]] && found=1 && break
|
||||
done
|
||||
[[ $found ]] && return
|
||||
_srcpkg=$(readlink -f ${XBPS_SRCPKGDIR}/${_dep})
|
||||
_srcpkg=${_srcpkg##*/}
|
||||
echo $_srcpkg
|
||||
}
|
||||
|
||||
show_pkg_build_depends() {
|
||||
local f result
|
||||
local _deps="$1"
|
||||
local _hostdeps="$2"
|
||||
|
||||
result=$(mktemp) || exit 1
|
||||
|
||||
# build time deps
|
||||
for f in ${_deps}; do
|
||||
show_eval_dep $f "" >> $result
|
||||
done
|
||||
for f in ${_hostdeps}; do
|
||||
show_eval_dep $f "hostdep" >> $result
|
||||
done
|
||||
sort -u $result
|
||||
rm -f $result
|
||||
}
|
||||
|
||||
show_pkg_build_deps() {
|
||||
local build_depends="${makedepends} $(setup_pkg_depends '' 1 1)"
|
||||
skip_check_step || build_depends+=" ${checkdepends}"
|
||||
show_pkg_build_depends "${build_depends}" "${hostmakedepends}"
|
||||
}
|
||||
|
||||
show_pkg_hostmakedepends() {
|
||||
show_pkg_build_depends "" "${hostmakedepends}"
|
||||
}
|
||||
|
||||
show_pkg_makedepends() {
|
||||
show_pkg_build_depends "${makedepends}" ""
|
||||
}
|
||||
|
||||
show_pkg_checkdepends() {
|
||||
show_pkg_build_depends "${checkdepends}" ""
|
||||
}
|
||||
|
||||
show_pkg_build_options() {
|
||||
local f
|
||||
|
||||
[ -z "$PKG_BUILD_OPTIONS" ] && return 0
|
||||
|
||||
source $XBPS_COMMONDIR/options.description
|
||||
msg_normal "$pkgver: the following build options are set:\n"
|
||||
for f in ${PKG_BUILD_OPTIONS}; do
|
||||
local opt="${f#\~}"
|
||||
local descref="desc_option_${opt}"
|
||||
local desc="${!descref-Enable support for $opt}"
|
||||
if [[ ${f:0:1} == '~' ]]; then
|
||||
echo " $opt: $desc (OFF)"
|
||||
else
|
||||
printf " "
|
||||
msg_normal_append "$opt: "
|
||||
printf "$desc (ON)\n"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
show_pkg_shlib_provides() {
|
||||
[ -f "${XBPS_STATEDIR}/${pkgname}-shlib-provides" ] && cat "${XBPS_STATEDIR}/${pkgname}-shlib-provides"
|
||||
}
|
||||
|
||||
show_pkg_shlib_requires() {
|
||||
[ -f "${XBPS_STATEDIR}/${pkgname}-shlib-requires" ] && cat "${XBPS_STATEDIR}/${pkgname}-shlib-requires"
|
||||
}
|
||||
253
common/xbps-src/shutils/update_check.sh
Normal file
253
common/xbps-src/shutils/update_check.sh
Normal file
@@ -0,0 +1,253 @@
|
||||
# vim: set ts=4 sw=4 et ft=bash :
|
||||
|
||||
update_check() {
|
||||
local i p url pkgurlname rx found_version consider
|
||||
local update_override=$XBPS_SRCPKGDIR/$XBPS_TARGET_PKG/update
|
||||
local original_pkgname=$pkgname
|
||||
local pkgname=$sourcepkg
|
||||
local urlpfx urlsfx
|
||||
local -A fetchedurls
|
||||
|
||||
local curlargs=(
|
||||
-A "xbps-src-update-check/$XBPS_SRC_VERSION"
|
||||
--max-time 10 --compressed -Lsk
|
||||
)
|
||||
|
||||
pkgname=${pkgname#kf6-}
|
||||
|
||||
# XBPS_UPDATE_CHECK_VERBOSE is the old way to show verbose messages
|
||||
[ "$XBPS_UPDATE_CHECK_VERBOSE" ] && XBPS_VERBOSE="$XBPS_UPDATE_CHECK_VERBOSE"
|
||||
|
||||
if [ -r $update_override ]; then
|
||||
. $update_override
|
||||
msg_verbose "using $XBPS_TARGET_PKG/update overrides\n"
|
||||
if [ -n "$disabled" ]; then
|
||||
msg_verbose "update-check DISABLED for $original_pkgname: $disabled\n"
|
||||
return 0
|
||||
fi
|
||||
elif [ -z "$distfiles" ]; then
|
||||
msg_verbose "NO DISTFILES found for $original_pkgname\n"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! type curl >/dev/null 2>&1; then
|
||||
echo "ERROR: cannot find \`curl' executable!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
export LC_ALL=C
|
||||
|
||||
if [ -z "$site" ]; then
|
||||
case "$distfiles" in
|
||||
# special case those sites provide better source elsewhere
|
||||
*ftp.gnome.org*|*download.gnome.org*) ;;
|
||||
*archive.xfce.org*) ;;
|
||||
*)
|
||||
printf '%s\n' "$homepage" ;;
|
||||
esac
|
||||
for i in $distfiles; do
|
||||
printf '%s\n' "${i%/*}/"
|
||||
done
|
||||
else
|
||||
printf '%s\n' "$site"
|
||||
fi |
|
||||
# filter loop: if version are "folder" name based,
|
||||
# substitute original url by every folder based ones (expand)
|
||||
while IFS= read -r url; do
|
||||
# default case: don't rewrite url
|
||||
printf '%s\n' "$url"
|
||||
if [ "$single_directory" ]; then
|
||||
continue
|
||||
fi
|
||||
rx=
|
||||
urlpfx="${url}"
|
||||
urlsfx=
|
||||
dirpfx=
|
||||
case "$url" in
|
||||
*.voidlinux.*|\
|
||||
*sourceforge.net/sourceforge*|\
|
||||
*code.google.com*|*googlecode*|\
|
||||
*launchpad.net*|\
|
||||
*cpan.*|\
|
||||
*pythonhosted.org*|*pypi.org/project/*|\
|
||||
*github.com*|\
|
||||
*//gitlab.*|\
|
||||
*bitbucket.org*|\
|
||||
*ftp.gnome.org*|*download.gnome.org*|\
|
||||
*archive.xfce.org*|\
|
||||
*kernel.org/pub/linux/kernel/*|\
|
||||
*cran.r-project.org/src/contrib*|\
|
||||
*rubygems.org*|\
|
||||
*crates.io*|\
|
||||
*codeberg.org*|\
|
||||
*hg.sr.ht*|\
|
||||
*software.sil.org*|\
|
||||
*git.sr.ht*)
|
||||
continue
|
||||
;;
|
||||
*)
|
||||
vdpfx=${vdprefix:-"|v|\\Q$pkgname\\E"}
|
||||
vdsfx=${vdsuffix:-"|\\.x"}
|
||||
match=$(grep -Po "^[^/]+//[^/]+(/.+)?/($vdpfx)(?=[-_.0-9]*[0-9](?<!\\Q$pkgname\\E)($vdsfx)/)" <<< "$url")
|
||||
if [ "$?" = 0 ]; then
|
||||
urlpfx="${match%/*}/"
|
||||
dirpfx="${match##*/}"
|
||||
urlsfx="${url#$urlpfx}"
|
||||
urlsfx="${urlsfx#*/}"
|
||||
case "$urlpfx" in
|
||||
*download.qt.io*) urlpfx="${urlpfx%/*/}/" ;;
|
||||
esac
|
||||
rx="href=[\"']?(\\Q$urlpfx\\E)?\\.?/?\\K\\Q$dirpfx\\E[-_.0-9]*[0-9]($vdsfx)[\"'/]"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [ "$rx" ]; then
|
||||
# substitute url if needed
|
||||
msg_verbose "(folder) fetching $urlpfx and scanning with $rx\n"
|
||||
skipdirs=
|
||||
curl "${curlargs[@]}" "$urlpfx" |
|
||||
grep -Po -i "$rx" |
|
||||
# sort -V places 1.1/ before 1/, but 1A/ before 1.1A/
|
||||
sed -e 's:$:A:' -e 's:/A$:A/:' | sort -Vru |
|
||||
sed -e 's:A/$:/A:' -e 's:A$::' |
|
||||
case "$urlpfx" in
|
||||
*download.qt.io*)
|
||||
while IFS= read -r newver; do
|
||||
printf '%s\n' "${urlpfx}${newver}"
|
||||
done
|
||||
;;
|
||||
*)
|
||||
while IFS= read -r newver; do
|
||||
newurl="${urlpfx}${newver}${urlsfx}"
|
||||
if [ "$newurl" = "$url" ]; then
|
||||
skipdirs=yes
|
||||
fi
|
||||
if [ -z "$skipdirs" ]; then
|
||||
printf '%s\n' "$newurl"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done |
|
||||
while IFS= read -r url; do
|
||||
rx=
|
||||
if [ -z "$site" ]; then
|
||||
case "$url" in
|
||||
*sourceforge.net/sourceforge*)
|
||||
pkgurlname="$(printf %s "$url" | cut -d/ -f5)"
|
||||
url="https://sourceforge.net/projects/$pkgurlname/rss?limit=200";;
|
||||
*code.google.com*|*googlecode*)
|
||||
url="https://code.google.com/p/$pkgname/downloads/list";;
|
||||
*launchpad.net*)
|
||||
pkgurlname="$(printf %s "$url" | cut -d/ -f4)"
|
||||
url="https://launchpad.net/$pkgurlname/+download";;
|
||||
*cpan.*)
|
||||
pkgname=${pkgname#perl-};;
|
||||
*pythonhosted.org*|*pypi.org/project/*)
|
||||
pkgname=${pkgname#python-}
|
||||
pkgname=${pkgname#python3-}
|
||||
rx="(?<=${pkgname//-/[-_]}-)[0-9.]+(post[0-9]*)?(?=(([.]tar|-cp|-py)))"
|
||||
url="https://pypi.org/simple/$pkgname";;
|
||||
*github.com*)
|
||||
pkgurlname="$(printf %s "$url" | cut -d/ -f4,5)"
|
||||
url="https://github.com/$pkgurlname/tags"
|
||||
rx='/archive/refs/tags/(\Q'"$pkgname"'\E|[-_v])*\K[\d.]+(?=\.tar\.gz")';;
|
||||
*//gitlab.*|*code.videolan.org*)
|
||||
case "$url" in
|
||||
*/-/*) pkgurlname="$(printf %s "$url" | sed -e 's%/-/.*%%g; s%/$%%')";;
|
||||
*) pkgurlname="$(printf %s "$url" | cut -d / -f 1-5)";;
|
||||
esac
|
||||
url="$pkgurlname/-/tags"
|
||||
rx='/archive/[^/]+/\Q'"$pkgname"'\E-v?\K[\d.]+(?=\.tar\.gz)';;
|
||||
*bitbucket.org*)
|
||||
pkgurlname="$(printf %s "$url" | cut -d/ -f4,5)"
|
||||
url="https://bitbucket.org/$pkgurlname/downloads"
|
||||
rx='/(get|downloads)/(v?|\Q'"$pkgname"'\E-)?\K[\d.]+(?=\.tar)';;
|
||||
*ftp.gnome.org*|*download.gnome.org*)
|
||||
rx='(?<=LATEST-IS-)([0-24-9]|3\.[0-9]*[02468]|[4-9][0-9]+)\.[0-9.]*[0-9](?=\")'
|
||||
url="https://download.gnome.org/sources/$pkgname/cache.json";;
|
||||
*archive.xfce.org*)
|
||||
rx='\Q'"$pkgname"'\E-\K((([4-9]|([1-9][0-9]+))\.[0-9]*[02468]\.[0-9.]*[0-9])|([0-3]\.[0-9.]*))(?=.tar)'
|
||||
url="https://archive.xfce.org/feeds/project/$pkgname" ;;
|
||||
*kernel.org/pub/linux/kernel/*)
|
||||
rx=linux-'\K'${version%.*}'\.[\d.]+(?=\.tar\.xz)';;
|
||||
*cran.r-project.org/src/contrib*)
|
||||
rx='\b\Q'"${pkgname#R-cran-}"'\E_\K\d+(\.\d+)*(-\d+)?(?=\.tar)';;
|
||||
*rubygems.org*)
|
||||
url="https://rubygems.org/gems/${pkgname#ruby-}"
|
||||
rx='href="/gems/'${pkgname#ruby-}'/versions/\K[\d.]*(?=")' ;;
|
||||
*crates.io*)
|
||||
url="https://crates.io/api/v1/crates/${pkgname#rust-}"
|
||||
rx='/crates/'${pkgname#rust-}'/\K[0-9.]*(?=/download)' ;;
|
||||
*codeberg.org*)
|
||||
pkgurlname="$(printf %s "$url" | cut -d/ -f4,5)"
|
||||
url="https://codeberg.org/$pkgurlname/tags"
|
||||
rx='/archive/(v-?|\Q'"$pkgname"'\E-)?\K[\d.]+(?=\.tar\.gz)' ;;
|
||||
*hg.sr.ht*)
|
||||
pkgurlname="$(printf %s "$url" | cut -d/ -f4,5)"
|
||||
url="https://hg.sr.ht/$pkgurlname/tags"
|
||||
rx='/archive/(v?|\Q'"$pkgname"'\E-)?\K[\d.]+(?=\.tar\.gz")';;
|
||||
*git.sr.ht*)
|
||||
pkgurlname="$(printf %s "$url" | cut -d/ -f4,5)"
|
||||
url="https://git.sr.ht/$pkgurlname/refs/rss.xml"
|
||||
rx='<guid>\Q'"${url%/*}"'\E/(v-?|\Q'"$pkgname"'\E-)?\K[\d.]+(?=</guid>)' ;;
|
||||
*pkgs.fedoraproject.org*)
|
||||
url="https://pkgs.fedoraproject.org/repo/pkgs/$pkgname" ;;
|
||||
*software.sil.org/downloads/*)
|
||||
pkgurlname=$(printf '%s\n' "$url" | cut -d/ -f6)
|
||||
url="https://software.sil.org/$pkgurlname/download/"
|
||||
pkgname="${pkgname#font-}"
|
||||
pkgname="${pkgname#sil-}"
|
||||
_pkgname="${pkgname//-/}"
|
||||
rx="($_pkgname|${_pkgname}SIL)[_-]\K[0-9.]+(?=\.tar|\.zip)" ;;
|
||||
*software.sil.org/*)
|
||||
pkgname="${pkgname#font-}"
|
||||
pkgname="${pkgname#sil-}"
|
||||
_pkgname="${pkgname//-/}"
|
||||
rx="($_pkgname|${_pkgname}SIL)[_-]\K[0-9.]+(?=\.tar|\.zip)" ;;
|
||||
*download.qt.io*)
|
||||
rx="((?<=href=\")[0-9.]+(?=/\">[0-9.]+/)|(?<=$pkgname-)[0-9.]+(?=\.tar))";;
|
||||
esac
|
||||
fi
|
||||
|
||||
rx=${pattern:-$rx}
|
||||
rx=${rx:-'(?<!-)\b\Q'"$pkgname"'\E[-_]?((src|source)[-_])?v?\K([^-/_\s]*?\d[^-/_\s]*?)(?=(?:[-_.](?:src|source|orig))?\.(?:[jt]ar|shar|t[bglx]z|tbz2|zip))\b'}
|
||||
|
||||
if [ "${fetchedurls[$url]}" ]; then
|
||||
msg_verbose "already fetched $url\n"
|
||||
continue
|
||||
fi
|
||||
|
||||
msg_verbose "fetching $url and scanning with $rx\n"
|
||||
curl "${curlargs[@]}" -H 'Accept: text/html,application/xhtml+xml,application/xml,text/plain,application/rss+xml' "$url" |
|
||||
grep -Po -i "$rx"
|
||||
fetchedurls[$url]=yes
|
||||
done |
|
||||
tr _ . |
|
||||
sort -Vu |
|
||||
{
|
||||
grep . || echo "NO VERSION found for $original_pkgname" 1>&2
|
||||
} |
|
||||
while IFS= read -r found_version; do
|
||||
msg_verbose "found version $found_version\n"
|
||||
consider=true
|
||||
p="$ignore "
|
||||
while [ -n "$p" ]; do
|
||||
i=${p%% *}
|
||||
p=${p#* }
|
||||
case "$found_version" in
|
||||
$i)
|
||||
consider=false
|
||||
msg_verbose "ignored $found_version due to $i\n"
|
||||
esac
|
||||
done
|
||||
if $consider; then
|
||||
xbps-uhelper cmpver "$original_pkgname-${version}_1" \
|
||||
"$original_pkgname-$(printf %s "$found_version" | tr - .)_1"
|
||||
if [ $? = 255 ]; then
|
||||
echo "${original_pkgname}-${version} -> ${original_pkgname}-${found_version}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
12
common/xbps-src/shutils/update_hash_cache.sh
Normal file
12
common/xbps-src/shutils/update_hash_cache.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
update_hash_cache() {
|
||||
local cache="$XBPS_SRCDISTDIR/by_sha256"
|
||||
local distfile curfile
|
||||
mkdir -p "$cache"
|
||||
find "$XBPS_SRCDISTDIR" -type f | grep -v by_sha256 | while read -r distfile; do
|
||||
cksum=$($XBPS_DIGEST_CMD "$distfile")
|
||||
curfile="${distfile##*/}"
|
||||
ln -vf "$distfile" "${cache}/${cksum}_${curfile}"
|
||||
done
|
||||
}
|
||||
Reference in New Issue
Block a user