xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and its required package "base-chroot" for building packages via chroot. - moved xbps.d(5) conf files to `etc/xbps.d`. - renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`. - do not set `--repository` to any xbps command that supports it, xbps-src now simply populates `rootdir/etc/xbps.d` with correct settings (taking care of CHROOT_READY/IN_CHROOT). - Unless `-C` is set (to preserve builddir/destdir/autodeps), when entering to the chroot (if CHROOT_READY is set), xbps-src will clean up the masterdir and then perform a system update to always use a constant set of packages for that exact date. - Improved some normal/error msgs. - Includes support for `xbps>=0.58`. - common/hooks: switch to bsdtar. - base-chroot: - base-chroot-musl is gone, now unified for glibc/musl. - deps removed: gettext, mpfr, readline, texinfo, which, xz. - deps changed: tar -> bsdtar. Effectively this reduces dependencies in `base-chroot`, makes it unified for musl and glibc, switches xbps-src to use `bsdtar` rather than GNU `tar` and `xz`, gets rid of useless host dependencies like GNU gettext, texinfo, etc. I've been testing these changes for 1 month or so already, I was able to build from scratch `base-system` for both native and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
This commit is contained in:
parent
b714ffe390
commit
75eca1b03e
26 changed files with 325 additions and 356 deletions
107
xbps-src
107
xbps-src
|
@ -269,69 +269,10 @@ check_native_arch() {
|
|||
fi
|
||||
}
|
||||
|
||||
install_bbootstrap() {
|
||||
[ "$CHROOT_READY" ] && return
|
||||
if [ "$1" = "bootstrap" ]; then
|
||||
unset XBPS_TARGET_PKG XBPS_INSTALL_ARGS
|
||||
else
|
||||
XBPS_TARGET_PKG="$1"
|
||||
fi
|
||||
[ "$XBPS_SKIP_REMOTEREPOS" ] && unset XBPS_INSTALL_ARGS
|
||||
# binary bootstrap
|
||||
msg_normal "Installing bootstrap from binary package repositories...\n"
|
||||
# XBPS_TARGET_PKG == arch
|
||||
if [ "$XBPS_TARGET_PKG" ]; then
|
||||
_bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
|
||||
if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
|
||||
_subarch="-${XBPS_TARGET_PKG#*-}"
|
||||
fi
|
||||
fi
|
||||
mkdir -p $XBPS_MASTERDIR/var/db/xbps/keys
|
||||
cd $XBPS_MASTERDIR
|
||||
cp -f $XBPS_COMMONDIR/repo-keys/*.plist $XBPS_MASTERDIR/var/db/xbps/keys
|
||||
${_bootstrap_arch} $XBPS_INSTALL_CMD ${XBPS_INSTALL_ARGS:+-S $XBPS_INSTALL_ARGS} -y base-chroot${_subarch}
|
||||
if [ $? -ne 0 ]; then
|
||||
msg_error "Failed to install bootstrap packages!\n"
|
||||
fi
|
||||
# Reconfigure base-files to create dirs/symlinks.
|
||||
if xbps-query -r $XBPS_MASTERDIR base-files &>/dev/null; then
|
||||
XBPS_ARCH=$XBPS_TARGET_PKG xbps-reconfigure -r $XBPS_MASTERDIR -f base-files &>/dev/null
|
||||
fi
|
||||
|
||||
msg_normal "Installed bootstrap successfully!\n"
|
||||
chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
|
||||
chroot_check
|
||||
chroot_handler clean
|
||||
}
|
||||
|
||||
reconfigure_bootstrap_pkgs() {
|
||||
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 "Reconfiguring bootstrap packages...\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
|
||||
}
|
||||
|
||||
bootstrap_update() {
|
||||
[ -z "$CHROOT_READY" ] && return
|
||||
remove_pkg_autodeps
|
||||
msg_normal "xbps-src: cleaning up masterdir...\n"
|
||||
rm -rf $XBPS_MASTERDIR/builddir $XBPS_MASTERDIR/destdir
|
||||
msg_normal "xbps-src: updating $XBPS_MASTERDIR ...\n"
|
||||
${XBPS_INSTALL_CMD} ${XBPS_INSTALL_ARGS} -Syu
|
||||
return $?
|
||||
}
|
||||
|
||||
masterdir_zap() {
|
||||
rm -rf "$XBPS_MASTERDIR"
|
||||
mkdir -p "$XBPS_MASTERDIR"
|
||||
msg_normal "$XBPS_MASTERDIR masterdir cleaned up.\n"
|
||||
msg_normal "xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
|
||||
}
|
||||
|
||||
exit_func() {
|
||||
|
@ -347,7 +288,7 @@ exit_func() {
|
|||
|
||||
read_pkg() {
|
||||
if [ -z "${XBPS_TARGET_PKG}" ]; then
|
||||
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
|
||||
[ ! -r ./template ] && msg_error "xbps-src: missing build template in $(pwd).\n"
|
||||
XBPS_TARGET_PKG=${PWD##*/}
|
||||
fi
|
||||
setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
|
||||
|
@ -368,13 +309,13 @@ setup_distfiles_mirror() {
|
|||
[ "$scheme" != "file" ] && continue
|
||||
if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
|
||||
if [ ! -d "$path" ]; then
|
||||
msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
|
||||
msg_warn "xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
|
||||
continue
|
||||
fi
|
||||
mkdir -p "$XBPS_MASTERDIR/$path"
|
||||
XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
|
||||
else
|
||||
msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
|
||||
msg_warn "xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
@ -537,20 +478,20 @@ readonly XBPS_BUILDHELPERDIR=$XBPS_COMMONDIR/build-helper
|
|||
|
||||
if [ "$IN_CHROOT" ]; then
|
||||
readonly XBPS_UHELPER_CMD="xbps-uhelper"
|
||||
readonly XBPS_INSTALL_CMD="xbps-install --repository=$XBPS_REPOSITORY"
|
||||
readonly XBPS_QUERY_CMD="xbps-query --repository=$XBPS_REPOSITORY"
|
||||
readonly XBPS_INSTALL_CMD="xbps-install -c /host/repocache"
|
||||
readonly XBPS_QUERY_CMD="xbps-query -c /host/repocache"
|
||||
readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
|
||||
readonly XBPS_REMOVE_CMD="xbps-remove"
|
||||
readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
|
||||
readonly XBPS_CHECKVERS_CMD="xbps-checkvers"
|
||||
readonly XBPS_DESTDIR=/destdir
|
||||
readonly XBPS_BUILDDIR=/builddir
|
||||
else
|
||||
readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
|
||||
readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
|
||||
readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
|
||||
readonly XBPS_INSTALL_CMD="xbps-install -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
|
||||
readonly XBPS_QUERY_CMD="xbps-query -c $XBPS_HOSTDIR/repocache -r $XBPS_MASTERDIR"
|
||||
readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
|
||||
readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
|
||||
readonly XBPS_CHECKVERS_CMD="xbps-checkvers --repository=$XBPS_REPOSITORY"
|
||||
readonly XBPS_CHECKVERS_CMD="xbps-checkvers -r $XBPS_MASTERDIR"
|
||||
readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
|
||||
readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
|
||||
fi
|
||||
|
@ -687,46 +628,39 @@ for f in ${XBPS_SHUTILSDIR}/*.sh; do
|
|||
[ -r "$f" ] && . $f
|
||||
done
|
||||
|
||||
reconfigure_bootstrap_pkgs
|
||||
reconfigure_base_chroot
|
||||
|
||||
#
|
||||
# Main switch.
|
||||
#
|
||||
case "$XBPS_TARGET" in
|
||||
binary-bootstrap)
|
||||
install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
|
||||
install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
|
||||
;;
|
||||
bootstrap)
|
||||
# bootstrap from sources
|
||||
# base-chroot building on host
|
||||
# check for required host utils
|
||||
check_reqhost_utils bootstrap
|
||||
[[ $XBPS_MACHINE =~ musl ]] && subarch="-musl"
|
||||
[ ! -d $XBPS_SRCPKGDIR/base-chroot${subarch} ] && \
|
||||
msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot${subarch} directory!\n"
|
||||
bootstrap_vpkg=${XBPS_MASTERDIR}/etc/xbps.d/bootstrap-vpkgs.conf
|
||||
mkdir -p ${XBPS_MASTERDIR}/etc/xbps.d
|
||||
if [ ! -s ${bootstrap_vpkg} ]; then
|
||||
# Fool xbps to resolve dependencies.
|
||||
echo 'virtualpkg=libgcc:base-files' >> ${bootstrap_vpkg}
|
||||
echo 'virtualpkg=libstdc++:base-files' >> ${bootstrap_vpkg}
|
||||
fi
|
||||
(
|
||||
export XBPS_ARCH=$XBPS_MACHINE
|
||||
export XBPS_SKIP_REMOTEREPOS=1
|
||||
chroot_sync_repodata
|
||||
$XBPS_LIBEXECDIR/build.sh \
|
||||
base-chroot${subarch} base-chroot${subarch} $XBPS_TARGET || exit 1
|
||||
base-chroot base-chroot $XBPS_TARGET || exit 1
|
||||
) || exit 1
|
||||
[ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
|
||||
install_bbootstrap ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
|
||||
install_base_chroot ${XBPS_TARGET_PKG:=$XBPS_MACHINE}
|
||||
;;
|
||||
bootstrap-update)
|
||||
if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
|
||||
chroot_handler bootstrap-update
|
||||
else
|
||||
bootstrap_update
|
||||
chroot_sync_repodata
|
||||
update_base_chroot
|
||||
fi
|
||||
;;
|
||||
chroot)
|
||||
chroot_sync_repodata
|
||||
chroot_handler chroot dummy
|
||||
;;
|
||||
clean)
|
||||
|
@ -777,7 +711,8 @@ case "$XBPS_TARGET" in
|
|||
if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
|
||||
chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
|
||||
else
|
||||
[ -z "$XBPS_KEEP_ALL" -a -z "$XBPS_SKIP_DEPS" ] && remove_pkg_autodeps
|
||||
chroot_sync_repodata
|
||||
update_base_chroot
|
||||
$XBPS_LIBEXECDIR/build.sh $XBPS_TARGET_PKG $XBPS_TARGET_PKG \
|
||||
$XBPS_TARGET $XBPS_CROSS_BUILD || exit $?
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue