xbps-src: make -B flag build binpkgs for required pkg deps.

This commit is contained in:
Juan RP 2011-07-18 11:36:48 +02:00
parent 0b348a677c
commit e22c565811
5 changed files with 52 additions and 43 deletions

View File

@ -26,16 +26,6 @@
HANDLER="$1" HANDLER="$1"
. @@XBPS_INSTALL_ETCDIR@@/xbps-src.conf
if [ -n "${MASTERDIR}" ]; then
export XBPS_MASTERDIR="${MASTERDIR}"
fi
if [ -n "${HOSTDIR}" ]; then
export XBPS_HOSTDIR="${HOSTDIR}"
fi
REQFS="sys proc dev xbps host" REQFS="sys proc dev xbps host"
mount_chroot_fs() mount_chroot_fs()
@ -43,42 +33,42 @@ mount_chroot_fs()
local cnt f blah dowrite local cnt f blah dowrite
for f in ${REQFS}; do for f in ${REQFS}; do
if [ ! -f ${XBPS_MASTERDIR}/.${f}_mount_bind_done ]; then if [ ! -f ${MASTERDIR}/.${f}_mount_bind_done ]; then
unset dowrite unset dowrite
echo -n "=> Mounting /${f} in chroot... " echo -n "=> Mounting /${f} in chroot... "
if [ ! -d ${XBPS_MASTERDIR}/${f} ]; then if [ ! -d ${MASTERDIR}/${f} ]; then
mkdir -p ${XBPS_MASTERDIR}/${f} mkdir -p ${MASTERDIR}/${f}
fi fi
case ${f} in case ${f} in
xbps) xbps)
blah=${XBPS_DISTRIBUTIONDIR} blah=${DISTRIBUTIONDIR}
dowrite="-w" dowrite="-w"
;; ;;
host) host)
blah=${XBPS_HOSTDIR} blah=${HOSTDIR}
dowrite="-w" dowrite="-w"
;; ;;
*) blah=/${f};; *) blah=/${f};;
esac esac
if [ -z "$XBPS_HOSTDIR" -a "$f" = "host" ]; then if [ -z "$HOSTDIR" -a "$f" = "host" ]; then
echo "unset, ignoring." echo "unset, ignoring."
continue continue
fi fi
[ ! -d ${blah} ] && echo "failed." && continue [ ! -d ${blah} ] && echo "failed." && continue
@@XBPS_INSTALL_LIBEXECDIR@@/capmount \ @@XBPS_INSTALL_LIBEXECDIR@@/capmount \
${dowrite} ${blah} ${XBPS_MASTERDIR}/${f} \ ${dowrite} ${blah} ${MASTERDIR}/${f} \
2>/dev/null 2>/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo 1 > ${XBPS_MASTERDIR}/.${f}_mount_bind_done echo 1 > ${MASTERDIR}/.${f}_mount_bind_done
echo "done." echo "done."
else else
echo "FAILED!" echo "FAILED!"
exit 1 exit 1
fi fi
else else
cnt=$(cat ${XBPS_MASTERDIR}/.${f}_mount_bind_done) cnt=$(cat ${MASTERDIR}/.${f}_mount_bind_done)
cnt=$((${cnt} + 1)) cnt=$((${cnt} + 1))
echo ${cnt} > ${XBPS_MASTERDIR}/.${f}_mount_bind_done echo ${cnt} > ${MASTERDIR}/.${f}_mount_bind_done
fi fi
done done
} }
@ -88,17 +78,17 @@ umount_chroot_fs()
local fs dir cnt local fs dir cnt
for fs in ${REQFS}; do for fs in ${REQFS}; do
[ ! -f ${XBPS_MASTERDIR}/.${fs}_mount_bind_done ] && continue [ ! -f ${MASTERDIR}/.${fs}_mount_bind_done ] && continue
cnt=$(cat ${XBPS_MASTERDIR}/.${fs}_mount_bind_done) cnt=$(cat ${MASTERDIR}/.${fs}_mount_bind_done)
if [ ${cnt} -gt 1 ]; then if [ ${cnt} -gt 1 ]; then
cnt=$((${cnt} - 1)) cnt=$((${cnt} - 1))
echo ${cnt} > ${XBPS_MASTERDIR}/.${fs}_mount_bind_done echo ${cnt} > ${MASTERDIR}/.${fs}_mount_bind_done
else else
echo -n "=> Unmounting ${fs} from chroot... " echo -n "=> Unmounting ${fs} from chroot... "
@@XBPS_INSTALL_LIBEXECDIR@@/capumount \ @@XBPS_INSTALL_LIBEXECDIR@@/capumount \
${XBPS_MASTERDIR} ${fs} 2>/dev/null ${MASTERDIR} ${fs} 2>/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rm -f ${XBPS_MASTERDIR}/.${fs}_mount_bind_done rm -f ${MASTERDIR}/.${fs}_mount_bind_done
echo "done." echo "done."
else else
echo "FAILED!!!" echo "FAILED!!!"
@ -113,6 +103,11 @@ if [ $# -ne 1 ]; then
exit 1 exit 1
fi fi
if [ -z "$MASTERDIR" -o -z "$DISTRIBUTIONDIR" ]; then
echo "$0: MASTERDIR or DISTRIBUTIONDIR unset, can't continue."
exit 1
fi
case "${HANDLER}" in case "${HANDLER}" in
mount) mount_chroot_fs;; mount) mount_chroot_fs;;
umount) umount_chroot_fs;; umount) umount_chroot_fs;;

View File

@ -25,14 +25,16 @@
_mount() _mount()
{ {
MASTERDIR="${XBPS_MASTERDIR}" HOSTDIR="${XBPS_HOSTDIR}" ${sudo_cmd} \ MASTERDIR="${XBPS_MASTERDIR}" DISTRIBUTIONDIR="${XBPS_DISTRIBUTIONDIR}" \
HOSTDIR="${XBPS_HOSTDIR}" ${sudo_cmd} \
@@XBPS_INSTALL_LIBEXECDIR@@/chroot-helper mount @@XBPS_INSTALL_LIBEXECDIR@@/chroot-helper mount
return $? return $?
} }
_umount() _umount()
{ {
MASTERDIR="${XBPS_MASTERDIR}" HOSTDIR="${XBPS_HOSTDIR}" ${sudo_cmd} \ MASTERDIR="${XBPS_MASTERDIR}" DISTRIBUTIONDIR="${XBPS_DISTRIBUTIONDIR}" \
HOSTDIR="${XBPS_HOSTDIR}" ${sudo_cmd} \
@@XBPS_INSTALL_LIBEXECDIR@@/chroot-helper umount @@XBPS_INSTALL_LIBEXECDIR@@/chroot-helper umount
return $? return $?
} }
@ -231,8 +233,7 @@ create_busybox_links()
cd ${lbindir} || return 1 cd ${lbindir} || return 1
for f in $(${XBPS_MASTERDIR}/bin/busybox --list); do for f in $(${XBPS_MASTERDIR}/bin/busybox --list); do
if [ "$f" = "tar" -o "$f" = "xz" -o \ if [ "$f" = "tar" -o "$f" = "sh" -o "$f" = "xz" ]; then
"$f" = "bzip2" -o "$f" = "gzip" -o "$f" = "sh" ]; then
continue continue
fi fi
ln -s ../../../bin/busybox $f ln -s ../../../bin/busybox $f
@ -313,12 +314,13 @@ xbps_chroot_handler()
[ -n "$KEEP_WRKSRC" ] && arg="$arg -C" [ -n "$KEEP_WRKSRC" ] && arg="$arg -C"
[ -n "$KEEP_AUTODEPS" ] && arg="$arg -K" [ -n "$KEEP_AUTODEPS" ] && arg="$arg -K"
[ -n "$DESTDIR_ONLY_INSTALL" ] && arg="$arg -D" [ -n "$DESTDIR_ONLY_INSTALL" ] && arg="$arg -D"
[ -n "$BUILD_BINPKG" ] && arg="$arg -B"
action="$arg $action" action="$arg $action"
env in_chroot=1 IN_CHROOT=1 LANG=C _ORIGINPKG="$pkg" \ env in_chroot=1 IN_CHROOT=1 LANG=C _ORIGINPKG="$pkg" \
PATH=$PATH:/usr/local/bin \ PATH=$PATH:/usr/local/bin \
${chroot_cmd} $XBPS_MASTERDIR sh -c \ ${chroot_cmd} $XBPS_MASTERDIR sh -c \
"cd /xbps/srcpkgs/$pkg && xbps-src $action" || rv=$? "xbps-src $action $pkg" || rv=$?
fi fi
msg_normal "Exiting from the chroot on $XBPS_MASTERDIR.\n" msg_normal "Exiting from the chroot on $XBPS_MASTERDIR.\n"

View File

@ -1,5 +1,5 @@
#- #-
# Copyright (c) 2008-2010 Juan Romero Pardines. # Copyright (c) 2008-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
@ -47,6 +47,7 @@ binpkg_cleanup()
{ {
local pkgdir="$1" binpkg="$2" local pkgdir="$1" binpkg="$2"
[ -z "$pkgdir" -o -z "$binpkg" ] && return 1
msg_red "\nInterrupted! removing $binpkg file!\n" msg_red "\nInterrupted! removing $binpkg file!\n"
rm -f $pkgdir/$binpkg rm -f $pkgdir/$binpkg
exit 1 exit 1
@ -106,7 +107,6 @@ xbps_make_binpkg_real()
done done
[ -n "$XBPS_COMPRESS_LEVEL" ] && clevel="-$XBPS_COMPRESS_LEVEL" [ -n "$XBPS_COMPRESS_LEVEL" ] && clevel="-$XBPS_COMPRESS_LEVEL"
[ ! -d $pkgdir ] && mkdir -p $pkgdir [ ! -d $pkgdir ] && mkdir -p $pkgdir
# Remove binpkg if interrupted... # Remove binpkg if interrupted...
@ -117,12 +117,13 @@ xbps_make_binpkg_real()
tar --exclude "var/db/xbps/metadata/*/flist" \ tar --exclude "var/db/xbps/metadata/*/flist" \
-cpf - ${mfiles} ${dirs} | \ -cpf - ${mfiles} ${dirs} | \
$XBPS_COMPRESS_CMD ${clevel} -qf > $pkgdir/$binpkg $XBPS_COMPRESS_CMD ${clevel} -qf > $pkgdir/$binpkg
if [ $? -eq 0 ]; then rval=$?
if [ $rval -eq 0 ]; then
msg_normal_append "done.\n" msg_normal_append "done.\n"
else else
rm -f $pkgdir/$binpkg rm -f $pkgdir/$binpkg
msg_normal_append "failed!\n" msg_normal_append "failed!\n"
fi fi
return $? return $rval
} }

View File

@ -123,6 +123,15 @@ install_pkg()
remove_tmpl_wrksrc $wrksrc remove_tmpl_wrksrc $wrksrc
fi fi
autoremove_pkg_dependencies $KEEP_AUTODEPS autoremove_pkg_dependencies $KEEP_AUTODEPS
# Build binary package and update local repo index if
# -B is set.
if [ -n "$BUILD_BINPKG" ]; then
xbps_make_binpkg
[ $? -ne 0 ] && return $?
msg_normal "Updating pkg-index for local repository at:\n"
msg_normal " $XBPS_PACKAGESDIR\n"
${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null
fi
return 0 return 0
fi fi
@ -161,7 +170,17 @@ install_pkg()
# Autoremove packages installed as dependencies if # Autoremove packages installed as dependencies if
# XBPS_PREFER_BINPKG_DEPS is set. # XBPS_PREFER_BINPKG_DEPS is set.
# #
autoremove_pkg_dependencies $KEEP_AUTODEPS autoremove_pkg_dependencies $KEEP_AUTODEPS || return $?
# Build binary package and update local repo index if
# -B is set.
if [ -n "$BUILD_BINPKG" ]; then
xbps_make_binpkg
[ $? -ne 0 ] && return $?
msg_normal "Updating pkg-index for local repository at:\n"
msg_normal " $XBPS_PACKAGESDIR\n"
${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null
fi
return $? return $?
} }

View File

@ -436,14 +436,6 @@ install)
setup_tmpl ${_ORIGINPKG} setup_tmpl ${_ORIGINPKG}
install_pkg $pkgname || exit $? install_pkg $pkgname || exit $?
fi fi
if [ -z "$IN_CHROOT" -a -n "$BUILD_BINPKG" ]; then
setup_tmpl ${_ORIGINPKG}
xbps_make_binpkg
[ -n "${_PACKAGEDIR}" ] && XBPS_PACKAGESDIR="${_PACKAGEDIR}"
msg_normal "Updating pkg-index for local repository at:\n"
msg_normal " $XBPS_PACKAGESDIR\n"
${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null
fi
;; ;;
list) list)
$XBPS_BIN_CMD list $XBPS_BIN_CMD list