2014-04-09 14:40:27 +00:00
|
|
|
# vim: set ts=4 sw=4 et:
|
2014-03-22 11:31:42 +00:00
|
|
|
|
2017-03-08 16:28:31 +00:00
|
|
|
# FIXME: $XBPS_FFLAGS is not set when chroot_init() is run
|
|
|
|
# It is set in common/build-profiles/bootstrap.sh but lost somewhere?
|
2014-03-22 11:31:42 +00:00
|
|
|
chroot_init() {
|
2014-12-22 10:28:52 +00:00
|
|
|
mkdir -p $XBPS_MASTERDIR/etc/xbps
|
|
|
|
|
2019-06-12 22:29:49 +00:00
|
|
|
cat > $XBPS_MASTERDIR/etc/xbps/xbps-src.conf <<_EOF
|
2014-03-22 11:31:42 +00:00
|
|
|
# Generated configuration file by xbps-src, DO NOT EDIT!
|
2019-06-12 22:29:49 +00:00
|
|
|
$(grep -E '^XBPS_.*' "$XBPS_CONFIG_FILE")
|
2014-03-22 11:31:42 +00:00
|
|
|
XBPS_MASTERDIR=/
|
|
|
|
XBPS_CFLAGS="$XBPS_CFLAGS"
|
|
|
|
XBPS_CXXFLAGS="$XBPS_CXXFLAGS"
|
2017-03-08 16:28:31 +00:00
|
|
|
XBPS_FFLAGS="-fPIC -pipe"
|
2014-03-22 11:31:42 +00:00
|
|
|
XBPS_CPPFLAGS="$XBPS_CPPFLAGS"
|
|
|
|
XBPS_LDFLAGS="$XBPS_LDFLAGS"
|
2014-06-30 10:03:56 +00:00
|
|
|
XBPS_HOSTDIR=/host
|
2019-06-12 22:29:49 +00:00
|
|
|
# End of configuration file.
|
2014-03-22 11:31:42 +00:00
|
|
|
_EOF
|
2014-04-09 14:40:27 +00:00
|
|
|
|
|
|
|
# Create custom script to start the chroot bash shell.
|
|
|
|
cat > $XBPS_MASTERDIR/bin/xbps-shell <<_EOF
|
2014-03-22 11:31:42 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
XBPS_SRC_VERSION="$XBPS_SRC_VERSION"
|
|
|
|
|
|
|
|
. /etc/xbps/xbps-src.conf
|
|
|
|
|
2019-07-02 17:14:56 +00:00
|
|
|
PATH=/void-packages:/usr/bin
|
2014-03-22 11:31:42 +00:00
|
|
|
|
2019-06-12 22:37:59 +00:00
|
|
|
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" \
|
2014-04-09 14:40:27 +00:00
|
|
|
PS1="[\u@$XBPS_MASTERDIR \W]$ " /bin/bash +h
|
2014-03-22 11:31:42 +00:00
|
|
|
_EOF
|
2019-06-12 22:37:59 +00:00
|
|
|
|
2014-04-09 14:40:27 +00:00
|
|
|
chmod 755 $XBPS_MASTERDIR/bin/xbps-shell
|
|
|
|
|
|
|
|
cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
|
|
|
|
|
|
|
|
# Update xbps alternative repository if set.
|
2014-12-22 10:15:44 +00:00
|
|
|
mkdir -p $XBPS_MASTERDIR/etc/xbps.d
|
2014-04-09 14:40:27 +00:00
|
|
|
if [ -n "$XBPS_ALT_REPOSITORY" ]; then
|
|
|
|
( \
|
|
|
|
echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}"; \
|
|
|
|
echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/nonfree"; \
|
2014-12-30 07:23:42 +00:00
|
|
|
echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/debug"; \
|
2014-12-22 10:15:44 +00:00
|
|
|
) > $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
|
2014-12-30 07:23:42 +00:00
|
|
|
if [ "$XBPS_MACHINE" = "x86_64" ]; then
|
|
|
|
( \
|
|
|
|
echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib"; \
|
|
|
|
echo "repository=/host/binpkgs/${XBPS_ALT_REPOSITORY}/multilib/nonfree"; \
|
|
|
|
) >> $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
|
|
|
|
fi
|
2014-04-09 14:40:27 +00:00
|
|
|
else
|
2014-12-22 10:15:44 +00:00
|
|
|
rm -f $XBPS_MASTERDIR/etc/xbps.d/00-repository-alternative.conf
|
2014-04-09 14:40:27 +00:00
|
|
|
fi
|
2014-03-22 11:31:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
chroot_prepare() {
|
2014-04-09 14:40:27 +00:00
|
|
|
local f=
|
2014-03-22 11:31:42 +00:00
|
|
|
|
2014-04-09 14:40:27 +00:00
|
|
|
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
|
2014-03-22 11:31:42 +00:00
|
|
|
|
2014-04-09 14:40:27 +00:00
|
|
|
# Create some required files.
|
2017-12-16 16:52:17 +00:00
|
|
|
if [ -f /etc/localtime ]; then
|
|
|
|
cp -f /etc/localtime $XBPS_MASTERDIR/etc
|
|
|
|
elif [ -f /usr/share/zoneinfo/UTC ]; then
|
|
|
|
cp -f /usr/share/zoneinfo/UTC $XBPS_MASTERDIR/etc/localtime
|
|
|
|
fi
|
2014-03-22 11:31:42 +00:00
|
|
|
|
2014-04-09 14:40:27 +00:00
|
|
|
for f in dev sys proc host boot; do
|
|
|
|
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
|
|
|
|
done
|
2014-03-22 11:31:42 +00:00
|
|
|
|
2014-04-09 14:40:27 +00:00
|
|
|
# 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
|
2014-03-22 11:31:42 +00:00
|
|
|
|
2014-04-09 14:40:27 +00:00
|
|
|
# Copy /etc/hosts from base-files.
|
|
|
|
cp -f $XBPS_SRCPKGDIR/base-files/files/hosts $XBPS_MASTERDIR/etc
|
2014-03-22 11:31:42 +00:00
|
|
|
|
2014-12-22 10:15:44 +00:00
|
|
|
mkdir -p $XBPS_MASTERDIR/etc/xbps.d
|
2014-12-22 10:24:58 +00:00
|
|
|
echo "syslog=false" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
|
|
|
|
echo "cachedir=/host/repocache" >> $XBPS_MASTERDIR/etc/xbps.d/xbps.conf
|
2015-02-27 22:00:55 +00:00
|
|
|
ln -sf /dev/null $XBPS_MASTERDIR/etc/xbps.d/00-repository-main.conf
|
2014-03-22 11:31:42 +00:00
|
|
|
|
2014-04-09 14:40:27 +00:00
|
|
|
# Prepare default locale: en_US.UTF-8.
|
2018-02-20 14:35:35 +00:00
|
|
|
if [ -s ${XBPS_MASTERDIR}/etc/default/libc-locales ]; then
|
2014-04-09 14:40:27 +00:00
|
|
|
echo 'en_US.UTF-8 UTF-8' >> ${XBPS_MASTERDIR}/etc/default/libc-locales
|
|
|
|
fi
|
2014-03-22 11:31:42 +00:00
|
|
|
|
2014-04-09 14:40:27 +00:00
|
|
|
touch -f $XBPS_MASTERDIR/.xbps_chroot_init
|
|
|
|
[ -n "$1" ] && echo $1 >> $XBPS_MASTERDIR/.xbps_chroot_init
|
2014-03-22 11:31:42 +00:00
|
|
|
|
2014-04-09 14:40:27 +00:00
|
|
|
return 0
|
2014-03-22 11:31:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
chroot_sync_repos() {
|
2014-04-09 14:40:27 +00:00
|
|
|
local f=
|
|
|
|
|
|
|
|
# Copy xbps configuration files to the masterdir.
|
2017-10-19 09:38:14 +00:00
|
|
|
install -Dm644 ${XBPS_DISTDIR}/etc/xbps.conf \
|
|
|
|
${XBPS_MASTERDIR}/etc/xbps.d/00-xbps-src.conf
|
2015-03-13 08:53:12 +00:00
|
|
|
install -Dm644 ${XBPS_DISTDIR}/etc/repos-local.conf \
|
2014-12-22 10:15:44 +00:00
|
|
|
${XBPS_MASTERDIR}/etc/xbps.d/10-repository-local.conf
|
2015-03-13 08:53:12 +00:00
|
|
|
install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote.conf \
|
2014-12-22 10:15:44 +00:00
|
|
|
${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
|
2014-04-09 14:40:27 +00:00
|
|
|
|
2014-06-10 07:22:18 +00:00
|
|
|
if [ "$XBPS_MACHINE" = "x86_64" ]; then
|
2015-03-13 08:53:12 +00:00
|
|
|
install -Dm644 ${XBPS_DISTDIR}/etc/repos-local-x86_64.conf \
|
2014-12-22 10:15:44 +00:00
|
|
|
${XBPS_MASTERDIR}/etc/xbps.d/12-repository-local-x86_64.conf
|
2015-03-13 08:53:12 +00:00
|
|
|
install -Dm644 ${XBPS_DISTDIR}/etc/repos-remote-x86_64.conf \
|
2014-12-22 10:15:44 +00:00
|
|
|
${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
|
2014-06-10 07:22:18 +00:00
|
|
|
fi
|
|
|
|
|
2019-07-02 17:14:56 +00:00
|
|
|
# if -N is set, get rid of remote repos from x86_64 (glibc).
|
2014-04-09 14:40:27 +00:00
|
|
|
if [ -n "$XBPS_SKIP_REMOTEREPOS" ]; then
|
2014-12-22 10:15:44 +00:00
|
|
|
rm -f ${XBPS_MASTERDIR}/etc/xbps.d/20-repository-remote.conf
|
|
|
|
rm -f ${XBPS_MASTERDIR}/etc/xbps.d/22-repository-remote-x86_64.conf
|
2014-04-09 14:40:27 +00:00
|
|
|
fi
|
|
|
|
|
2014-06-06 14:29:50 +00:00
|
|
|
# Copy host repos to the cross root.
|
|
|
|
if [ -n "$XBPS_CROSS_BUILD" ]; then
|
2015-03-23 15:05:17 +00:00
|
|
|
rm -rf $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
|
|
|
|
mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
|
2014-12-22 10:15:44 +00:00
|
|
|
cp ${XBPS_MASTERDIR}/etc/xbps.d/*.conf \
|
2015-03-23 15:05:17 +00:00
|
|
|
$XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d
|
|
|
|
rm -f $XBPS_MASTERDIR/$XBPS_CROSS_BASE/etc/xbps.d/*-x86_64.conf
|
2014-06-10 07:36:58 +00:00
|
|
|
fi
|
|
|
|
|
2015-03-09 08:52:35 +00:00
|
|
|
if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
|
|
|
|
# Make sure to sync index for remote repositories.
|
2015-07-12 06:24:04 +00:00
|
|
|
xbps-install -r $XBPS_MASTERDIR -S
|
2015-03-05 20:44:22 +00:00
|
|
|
fi
|
|
|
|
|
2014-06-10 07:36:58 +00:00
|
|
|
if [ -n "$XBPS_CROSS_BUILD" ]; then
|
|
|
|
# Copy host keys to the target rootdir.
|
2015-03-23 15:05:17 +00:00
|
|
|
mkdir -p $XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
|
2017-05-24 18:02:46 +00:00
|
|
|
cp $XBPS_MASTERDIR/var/db/xbps/keys/*.plist \
|
2015-03-23 15:05:17 +00:00
|
|
|
$XBPS_MASTERDIR/$XBPS_CROSS_BASE/var/db/xbps/keys
|
2015-03-12 17:49:21 +00:00
|
|
|
# Make sure to sync index for remote repositories.
|
2015-03-23 15:05:17 +00:00
|
|
|
if [ -z "$XBPS_SKIP_REMOTEREPOS" ]; then
|
2017-06-04 23:48:19 +00:00
|
|
|
env -- XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE \
|
2015-07-12 06:24:04 +00:00
|
|
|
xbps-install -r $XBPS_MASTERDIR/$XBPS_CROSS_BASE -S
|
2015-03-12 17:49:21 +00:00
|
|
|
fi
|
2014-06-06 14:29:50 +00:00
|
|
|
fi
|
|
|
|
|
2014-04-09 14:40:27 +00:00
|
|
|
return 0
|
2014-03-22 11:31:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
chroot_handler() {
|
2015-04-09 16:57:41 +00:00
|
|
|
local action="$1" pkg="$2" rv=0 arg= _envargs=
|
2014-04-09 14:40:27 +00:00
|
|
|
|
2014-11-10 10:57:46 +00:00
|
|
|
if [ -n "$IN_CHROOT" -o -z "$CHROOT_READY" ]; then
|
2015-01-04 11:14:14 +00:00
|
|
|
return 0
|
2014-11-08 10:07:40 +00:00
|
|
|
fi
|
2014-10-11 09:02:57 +00:00
|
|
|
if [ ! -d $XBPS_MASTERDIR/void-packages ]; then
|
|
|
|
mkdir -p $XBPS_MASTERDIR/void-packages
|
2014-04-09 14:40:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
[ -z "$action" -a -z "$pkg" ] && return 1
|
|
|
|
|
|
|
|
case "$action" in
|
2019-07-10 17:48:54 +00:00
|
|
|
fetch|extract|patch|configure|build|check|install|pkg|bootstrap-update|chroot)
|
2014-04-09 14:40:27 +00:00
|
|
|
chroot_prepare || return $?
|
|
|
|
chroot_init || return $?
|
2015-03-09 08:52:35 +00:00
|
|
|
chroot_sync_repos || return $?
|
2014-04-09 14:40:27 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ "$action" = "chroot" ]; then
|
2015-04-09 16:57:41 +00:00
|
|
|
$XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \
|
|
|
|
$XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" /bin/xbps-shell
|
2015-03-12 17:56:14 +00:00
|
|
|
rv=$?
|
2014-04-09 14:40:27 +00:00
|
|
|
else
|
2019-07-07 07:04:12 +00:00
|
|
|
env -i -- PATH="/usr/bin:$PATH" SHELL=/bin/sh \
|
2015-09-15 06:15:13 +00:00
|
|
|
HOME=/tmp IN_CHROOT=1 LC_COLLATE=C LANG=en_US.UTF-8 \
|
2016-03-01 17:27:16 +00:00
|
|
|
SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \
|
2019-02-26 20:23:11 +00:00
|
|
|
XBPS_ALLOW_CHROOT_BREAKOUT="$XBPS_ALLOW_CHROOT_BREAKOUT" \
|
2015-04-09 16:57:41 +00:00
|
|
|
$XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \
|
|
|
|
$XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" \
|
2019-07-10 17:48:54 +00:00
|
|
|
/void-packages/xbps-src $XBPS_OPTIONS $action $pkg
|
2015-03-12 17:56:14 +00:00
|
|
|
rv=$?
|
2014-04-09 14:40:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
return $rv
|
2014-03-22 11:31:42 +00:00
|
|
|
}
|