Simplify chroot helper and fix a minor glitch in stow_pkg().
--HG-- extra : convert_revision : a84053dacf4768c9a7b8b6d2d8e4548902f8a97e
This commit is contained in:
parent
0a71559ee4
commit
c50c3cab2a
|
@ -34,12 +34,15 @@ else
|
||||||
echo "==> Entering into the chroot on $XBPS_MASTERDIR."
|
echo "==> Entering into the chroot on $XBPS_MASTERDIR."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for f in bin sbin tmp var sys proc dev xbps xbps_builddir xbps_destdir; do
|
REQDIRS="bin sbin tmp var sys proc dev xbps xbps_builddir \
|
||||||
|
xbps_destdir xbps_srcdistdir"
|
||||||
|
for f in ${REQDIRS}; do
|
||||||
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
|
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
|
||||||
done
|
done
|
||||||
unset f
|
unset f REQDIRS
|
||||||
|
|
||||||
for f in sys proc dev xbps xbps_builddir xbps_destdir; do
|
REQFS="sys proc dev xbps xbps_builddir xbps_destdir xbps_srcdistdir"
|
||||||
|
for f in ${REQFS}; do
|
||||||
if [ ! -f $XBPS_MASTERDIR/.${f}_mount_bind_done ]; then
|
if [ ! -f $XBPS_MASTERDIR/.${f}_mount_bind_done ]; then
|
||||||
echo -n "=> Mounting $f in chroot... "
|
echo -n "=> Mounting $f in chroot... "
|
||||||
local blah=
|
local blah=
|
||||||
|
@ -47,6 +50,7 @@ for f in sys proc dev xbps xbps_builddir xbps_destdir; do
|
||||||
xbps) blah=$XBPS_DISTRIBUTIONDIR;;
|
xbps) blah=$XBPS_DISTRIBUTIONDIR;;
|
||||||
xbps_builddir) blah=$XBPS_BUILDDIR;;
|
xbps_builddir) blah=$XBPS_BUILDDIR;;
|
||||||
xbps_destdir) blah=$XBPS_DESTDIR;;
|
xbps_destdir) blah=$XBPS_DESTDIR;;
|
||||||
|
xbps_srcdistdir) blah=$XBPS_SRCDISTDIR;;
|
||||||
*) blah=/$f;;
|
*) blah=/$f;;
|
||||||
esac
|
esac
|
||||||
mount --bind $blah $XBPS_MASTERDIR/$f
|
mount --bind $blah $XBPS_MASTERDIR/$f
|
||||||
|
@ -64,7 +68,7 @@ echo "XBPS_DISTRIBUTIONDIR=/xbps" > $XBPS_MASTERDIR/etc/xbps.conf
|
||||||
echo "XBPS_MASTERDIR=/" >> $XBPS_MASTERDIR/etc/xbps.conf
|
echo "XBPS_MASTERDIR=/" >> $XBPS_MASTERDIR/etc/xbps.conf
|
||||||
echo "XBPS_DESTDIR=/xbps_destdir" >> $XBPS_MASTERDIR/etc/xbps.conf
|
echo "XBPS_DESTDIR=/xbps_destdir" >> $XBPS_MASTERDIR/etc/xbps.conf
|
||||||
echo "XBPS_BUILDDIR=/xbps_builddir" >> $XBPS_MASTERDIR/etc/xbps.conf
|
echo "XBPS_BUILDDIR=/xbps_builddir" >> $XBPS_MASTERDIR/etc/xbps.conf
|
||||||
echo "XBPS_SRCDISTDIR=/xbps/srcdistdir" >> $XBPS_MASTERDIR/etc/xbps.conf
|
echo "XBPS_SRCDISTDIR=/xbps_srcdistdir" >> $XBPS_MASTERDIR/etc/xbps.conf
|
||||||
echo "XBPS_CFLAGS=\"$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/etc/xbps.conf
|
echo "XBPS_CFLAGS=\"$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/etc/xbps.conf
|
||||||
echo "XBPS_CXXFLAGS=\"\$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/etc/xbps.conf
|
echo "XBPS_CXXFLAGS=\"\$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/etc/xbps.conf
|
||||||
if [ -n "$XBPS_MAKEJOBS" ]; then
|
if [ -n "$XBPS_MAKEJOBS" ]; then
|
||||||
|
@ -79,44 +83,23 @@ rebuild_ldso_cache()
|
||||||
echo " done."
|
echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
configure_chroot_pkg()
|
chroot_pkg_handler()
|
||||||
{
|
{
|
||||||
local pkg="$1"
|
local action="$1"
|
||||||
|
local pkg="$2"
|
||||||
|
|
||||||
[ -z "$pkg" ] && return 1
|
[ -z "$action" -o -z "$pkg" ] && return 1
|
||||||
|
|
||||||
|
[ "$action" != "configure" -a "$action" != "build" -a \
|
||||||
|
"$action" != "install" -a "$action" != "chroot" ] && return 1
|
||||||
|
|
||||||
rebuild_ldso_cache
|
rebuild_ldso_cache
|
||||||
env in_chroot=yes chroot $XBPS_MASTERDIR /xbps/xbps.sh configure $pkg
|
if [ "$action" = "chroot" ]; then
|
||||||
echo "==> Exiting from the chroot on $XBPS_MASTERDIR."
|
env in_chroot=yes chroot $XBPS_MASTERDIR /bin/bash
|
||||||
}
|
else
|
||||||
|
env in_chroot=yes chroot $XBPS_MASTERDIR /xbps/xbps.sh \
|
||||||
build_chroot_pkg()
|
$action $pkg
|
||||||
{
|
fi
|
||||||
local pkg="$1"
|
|
||||||
|
|
||||||
[ -z "$pkg" ] && return 1
|
|
||||||
|
|
||||||
rebuild_ldso_cache
|
|
||||||
env in_chroot=yes chroot $XBPS_MASTERDIR /xbps/xbps.sh build $pkg
|
|
||||||
echo "==> Exiting from the chroot on $XBPS_MASTERDIR."
|
|
||||||
}
|
|
||||||
|
|
||||||
install_chroot_pkg()
|
|
||||||
{
|
|
||||||
local pkg="$1"
|
|
||||||
|
|
||||||
[ -z "$pkg" ] && return 1
|
|
||||||
|
|
||||||
rebuild_ldso_cache
|
|
||||||
env in_chroot=yes chroot $XBPS_MASTERDIR /xbps/xbps.sh install $pkg
|
|
||||||
echo "==> Exiting from the chroot on $XBPS_MASTERDIR."
|
|
||||||
umount_chroot_fs
|
|
||||||
}
|
|
||||||
|
|
||||||
enter_chroot()
|
|
||||||
{
|
|
||||||
rebuild_ldso_cache
|
|
||||||
env in_chroot=yes chroot $XBPS_MASTERDIR /bin/bash
|
|
||||||
echo "==> Exiting from the chroot on $XBPS_MASTERDIR."
|
echo "==> Exiting from the chroot on $XBPS_MASTERDIR."
|
||||||
umount_chroot_fs
|
umount_chroot_fs
|
||||||
}
|
}
|
||||||
|
@ -126,7 +109,7 @@ umount_chroot_fs()
|
||||||
local fs=
|
local fs=
|
||||||
local dir=
|
local dir=
|
||||||
|
|
||||||
for fs in sys proc dev xbps xbps_builddir xbps_destdir; do
|
for fs in ${REQFS}; do
|
||||||
[ ! -f $XBPS_MASTERDIR/.${fs}_mount_bind_done ] && continue
|
[ ! -f $XBPS_MASTERDIR/.${fs}_mount_bind_done ] && continue
|
||||||
echo -n "=> Unmounting $fs from chroot... "
|
echo -n "=> Unmounting $fs from chroot... "
|
||||||
umount -f $XBPS_MASTERDIR/$fs
|
umount -f $XBPS_MASTERDIR/$fs
|
||||||
|
@ -139,7 +122,7 @@ umount_chroot_fs()
|
||||||
unset fs
|
unset fs
|
||||||
done
|
done
|
||||||
|
|
||||||
for dir in xbps xbps_builddir xbps_destdir; do
|
for dir in xbps xbps_builddir xbps_destdir xbps_srcdistdir; do
|
||||||
[ -d $XBPS_MASTERDIR/$dir ] && rmdir $XBPS_MASTERDIR/$dir
|
[ -d $XBPS_MASTERDIR/$dir ] && rmdir $XBPS_MASTERDIR/$dir
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
10
xbps.sh
10
xbps.sh
|
@ -1233,7 +1233,7 @@ install_pkg()
|
||||||
|
|
||||||
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
|
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
|
||||||
run_file $XBPS_TMPLHELPDIR/chroot.sh
|
run_file $XBPS_TMPLHELPDIR/chroot.sh
|
||||||
install_chroot_pkg $curpkgn
|
chroot_pkg_handler install $curpkgn
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1403,7 +1403,7 @@ stow_pkg()
|
||||||
|
|
||||||
cd $XBPS_DESTDIR/$pkgname-$version || exit 1
|
cd $XBPS_DESTDIR/$pkgname-$version || exit 1
|
||||||
find . > $flist
|
find . > $flist
|
||||||
sed -i -e "s|^.$||g;s|^./||g" $flist
|
sed -i -e "s|^.$||g;s|^./||g;s|.xbps-filelist||g" $flist
|
||||||
cp -ar . $XBPS_MASTERDIR
|
cp -ar . $XBPS_MASTERDIR
|
||||||
mv -f $flist $XBPS_DESTDIR/$pkgname-$version/.xbps-filelist
|
mv -f $flist $XBPS_DESTDIR/$pkgname-$version/.xbps-filelist
|
||||||
|
|
||||||
|
@ -1506,7 +1506,7 @@ build)
|
||||||
setup_tmpl $2
|
setup_tmpl $2
|
||||||
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
|
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
|
||||||
run_file $XBPS_TMPLHELPDIR/chroot.sh
|
run_file $XBPS_TMPLHELPDIR/chroot.sh
|
||||||
build_chroot_pkg $2
|
chroot_pkg_handler build $2
|
||||||
umount_chroot_fs
|
umount_chroot_fs
|
||||||
else
|
else
|
||||||
fetch_distfiles $2
|
fetch_distfiles $2
|
||||||
|
@ -1521,13 +1521,13 @@ build)
|
||||||
;;
|
;;
|
||||||
chroot)
|
chroot)
|
||||||
run_file $XBPS_TMPLHELPDIR/chroot.sh
|
run_file $XBPS_TMPLHELPDIR/chroot.sh
|
||||||
enter_chroot
|
chroot_pkg_handler chroot dummy
|
||||||
;;
|
;;
|
||||||
configure)
|
configure)
|
||||||
setup_tmpl $2
|
setup_tmpl $2
|
||||||
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
|
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
|
||||||
run_file $XBPS_TMPLHELPDIR/chroot.sh
|
run_file $XBPS_TMPLHELPDIR/chroot.sh
|
||||||
configure_chroot_pkg $2
|
chroot_pkg_handler configure $2
|
||||||
umount_chroot_fs
|
umount_chroot_fs
|
||||||
else
|
else
|
||||||
fetch_distfiles $2
|
fetch_distfiles $2
|
||||||
|
|
Loading…
Reference in New Issue