xbps-src: added suport for XBPS_CACHEDIR in configuration file.

XBPS_CACHEDIR will be bind mounted as read/write in target masterdir
into /cachedir. This directory must have read/write perms for the user
running xbps-src.
This commit is contained in:
Juan RP 2011-06-26 01:45:12 +02:00
parent 2bbfbc658f
commit 8b40d5cd68
4 changed files with 25 additions and 6 deletions

View file

@ -4,7 +4,8 @@
# #
# Directory where the xbps-src GIT repository is stored. This is # Directory where the xbps-src GIT repository is stored. This is
# required to be mounted in the chroot. # required to be mounted in the chroot. You shouldn't need to modify this
# one unless your vanilla/xbps-templates repo has been moved to another path.
# #
XBPS_DISTRIBUTIONDIR=@@XBPS_DISTRIBDIR@@ XBPS_DISTRIBUTIONDIR=@@XBPS_DISTRIBDIR@@
@ -13,6 +14,12 @@ XBPS_DISTRIBUTIONDIR=@@XBPS_DISTRIBDIR@@
# #
XBPS_MASTERDIR=$XBPS_DISTRIBUTIONDIR/masterdir XBPS_MASTERDIR=$XBPS_DISTRIBUTIONDIR/masterdir
#
# Cache directory for downloaded binary packages; it's bind mounted
# to $XBPS_MASTERDIR/cachedir for chroot operations.
#
#XBPS_CACHEDIR=/path/to/cachedir/with/user/permissions/to/write
# #
# Compilation flags for cc and c++. # Compilation flags for cc and c++.
# #

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#- #-
# Copyright (c) 2010 Juan Romero Pardines. # Copyright (c) 2010-2011 Juan Romero Pardines.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,8 +31,11 @@ HANDLER="$1"
if [ -n "${MASTERDIR}" ]; then if [ -n "${MASTERDIR}" ]; then
export XBPS_MASTERDIR="${MASTERDIR}" export XBPS_MASTERDIR="${MASTERDIR}"
fi fi
if [ -n "${CACHEDIR}" ]; then
export XBPS_CACHEDIR="${CACHEDIR}"
fi
REQFS="sys proc dev xbps" REQFS="sys proc dev xbps cachedir"
mount_chroot_fs() mount_chroot_fs()
{ {
@ -50,6 +53,10 @@ mount_chroot_fs()
blah=${XBPS_DISTRIBUTIONDIR} blah=${XBPS_DISTRIBUTIONDIR}
dowrite="-w" dowrite="-w"
;; ;;
cachedir)
blah=${XBPS_CACHEDIR}
dowrite="-w"
;;
*) blah=/${f};; *) blah=/${f};;
esac esac
[ ! -d ${blah} ] && echo "failed." && continue [ ! -d ${blah} ] && echo "failed." && continue
@ -60,7 +67,7 @@ mount_chroot_fs()
echo 1 > ${XBPS_MASTERDIR}/.${f}_mount_bind_done echo 1 > ${XBPS_MASTERDIR}/.${f}_mount_bind_done
echo "done." echo "done."
else else
echo "FAILED!!!!!" echo "FAILED!"
exit 1 exit 1
fi fi
else else

View file

@ -31,14 +31,16 @@ trap "_umount && return $?" 0 INT QUIT TERM
_mount() _mount()
{ {
MASTERDIR="${XBPS_MASTERDIR}" ${sudo_cmd} \ MASTERDIR="${XBPS_MASTERDIR}" CACHEDIR="${XBPS_CACHEDIR}" \
${sudo_cmd} \
@@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper mount @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper mount
return $? return $?
} }
_umount() _umount()
{ {
MASTERDIR="${XBPS_MASTERDIR}" ${sudo_cmd} \ MASTERDIR="${XBPS_MASTERDIR}" CACHEDIR="${XBPS_CACHEDIR}" \
${sudo_cmd} \
@@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount
return $? return $?
} }

View file

@ -65,6 +65,9 @@ set_defvars()
if [ -n "$xver" ]; then if [ -n "$xver" ]; then
# XBPS utils >= 0.9.0. # XBPS utils >= 0.9.0.
xbps_conf="-C $XBPS_MASTERDIR/usr/local/etc/xbps-conf.plist" xbps_conf="-C $XBPS_MASTERDIR/usr/local/etc/xbps-conf.plist"
if [ -n "$XBPS_CACHEDIR" ]; then
xbps_conf="$xbps_conf -c $XBPS_CACHEDIR"
fi
fi fi
export XBPS_PKGDB_CMD="xbps-uhelper.static -r $XBPS_MASTERDIR" export XBPS_PKGDB_CMD="xbps-uhelper.static -r $XBPS_MASTERDIR"
export XBPS_BIN_CMD="xbps-bin.static $xbps_conf -r $XBPS_MASTERDIR" export XBPS_BIN_CMD="xbps-bin.static $xbps_conf -r $XBPS_MASTERDIR"