xbps-src: make -B flag build binpkgs for required pkg deps.
This commit is contained in:
parent
0b348a677c
commit
e22c565811
5 changed files with 52 additions and 43 deletions
|
@ -26,16 +26,6 @@
|
|||
|
||||
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"
|
||||
|
||||
mount_chroot_fs()
|
||||
|
@ -43,42 +33,42 @@ mount_chroot_fs()
|
|||
local cnt f blah dowrite
|
||||
|
||||
for f in ${REQFS}; do
|
||||
if [ ! -f ${XBPS_MASTERDIR}/.${f}_mount_bind_done ]; then
|
||||
if [ ! -f ${MASTERDIR}/.${f}_mount_bind_done ]; then
|
||||
unset dowrite
|
||||
echo -n "=> Mounting /${f} in chroot... "
|
||||
if [ ! -d ${XBPS_MASTERDIR}/${f} ]; then
|
||||
mkdir -p ${XBPS_MASTERDIR}/${f}
|
||||
if [ ! -d ${MASTERDIR}/${f} ]; then
|
||||
mkdir -p ${MASTERDIR}/${f}
|
||||
fi
|
||||
case ${f} in
|
||||
xbps)
|
||||
blah=${XBPS_DISTRIBUTIONDIR}
|
||||
blah=${DISTRIBUTIONDIR}
|
||||
dowrite="-w"
|
||||
;;
|
||||
host)
|
||||
blah=${XBPS_HOSTDIR}
|
||||
blah=${HOSTDIR}
|
||||
dowrite="-w"
|
||||
;;
|
||||
*) blah=/${f};;
|
||||
esac
|
||||
if [ -z "$XBPS_HOSTDIR" -a "$f" = "host" ]; then
|
||||
if [ -z "$HOSTDIR" -a "$f" = "host" ]; then
|
||||
echo "unset, ignoring."
|
||||
continue
|
||||
fi
|
||||
[ ! -d ${blah} ] && echo "failed." && continue
|
||||
@@XBPS_INSTALL_LIBEXECDIR@@/capmount \
|
||||
${dowrite} ${blah} ${XBPS_MASTERDIR}/${f} \
|
||||
${dowrite} ${blah} ${MASTERDIR}/${f} \
|
||||
2>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo 1 > ${XBPS_MASTERDIR}/.${f}_mount_bind_done
|
||||
echo 1 > ${MASTERDIR}/.${f}_mount_bind_done
|
||||
echo "done."
|
||||
else
|
||||
echo "FAILED!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
cnt=$(cat ${XBPS_MASTERDIR}/.${f}_mount_bind_done)
|
||||
cnt=$(cat ${MASTERDIR}/.${f}_mount_bind_done)
|
||||
cnt=$((${cnt} + 1))
|
||||
echo ${cnt} > ${XBPS_MASTERDIR}/.${f}_mount_bind_done
|
||||
echo ${cnt} > ${MASTERDIR}/.${f}_mount_bind_done
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
@ -88,17 +78,17 @@ umount_chroot_fs()
|
|||
local fs dir cnt
|
||||
|
||||
for fs in ${REQFS}; do
|
||||
[ ! -f ${XBPS_MASTERDIR}/.${fs}_mount_bind_done ] && continue
|
||||
cnt=$(cat ${XBPS_MASTERDIR}/.${fs}_mount_bind_done)
|
||||
[ ! -f ${MASTERDIR}/.${fs}_mount_bind_done ] && continue
|
||||
cnt=$(cat ${MASTERDIR}/.${fs}_mount_bind_done)
|
||||
if [ ${cnt} -gt 1 ]; then
|
||||
cnt=$((${cnt} - 1))
|
||||
echo ${cnt} > ${XBPS_MASTERDIR}/.${fs}_mount_bind_done
|
||||
echo ${cnt} > ${MASTERDIR}/.${fs}_mount_bind_done
|
||||
else
|
||||
echo -n "=> Unmounting ${fs} from chroot... "
|
||||
@@XBPS_INSTALL_LIBEXECDIR@@/capumount \
|
||||
${XBPS_MASTERDIR} ${fs} 2>/dev/null
|
||||
${MASTERDIR} ${fs} 2>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
rm -f ${XBPS_MASTERDIR}/.${fs}_mount_bind_done
|
||||
rm -f ${MASTERDIR}/.${fs}_mount_bind_done
|
||||
echo "done."
|
||||
else
|
||||
echo "FAILED!!!"
|
||||
|
@ -113,6 +103,11 @@ if [ $# -ne 1 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$MASTERDIR" -o -z "$DISTRIBUTIONDIR" ]; then
|
||||
echo "$0: MASTERDIR or DISTRIBUTIONDIR unset, can't continue."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "${HANDLER}" in
|
||||
mount) mount_chroot_fs;;
|
||||
umount) umount_chroot_fs;;
|
||||
|
|
|
@ -25,14 +25,16 @@
|
|||
|
||||
_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
|
||||
return $?
|
||||
}
|
||||
|
||||
_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
|
||||
return $?
|
||||
}
|
||||
|
@ -231,8 +233,7 @@ create_busybox_links()
|
|||
cd ${lbindir} || return 1
|
||||
|
||||
for f in $(${XBPS_MASTERDIR}/bin/busybox --list); do
|
||||
if [ "$f" = "tar" -o "$f" = "xz" -o \
|
||||
"$f" = "bzip2" -o "$f" = "gzip" -o "$f" = "sh" ]; then
|
||||
if [ "$f" = "tar" -o "$f" = "sh" -o "$f" = "xz" ]; then
|
||||
continue
|
||||
fi
|
||||
ln -s ../../../bin/busybox $f
|
||||
|
@ -313,12 +314,13 @@ xbps_chroot_handler()
|
|||
[ -n "$KEEP_WRKSRC" ] && arg="$arg -C"
|
||||
[ -n "$KEEP_AUTODEPS" ] && arg="$arg -K"
|
||||
[ -n "$DESTDIR_ONLY_INSTALL" ] && arg="$arg -D"
|
||||
[ -n "$BUILD_BINPKG" ] && arg="$arg -B"
|
||||
|
||||
action="$arg $action"
|
||||
env in_chroot=1 IN_CHROOT=1 LANG=C _ORIGINPKG="$pkg" \
|
||||
PATH=$PATH:/usr/local/bin \
|
||||
${chroot_cmd} $XBPS_MASTERDIR sh -c \
|
||||
"cd /xbps/srcpkgs/$pkg && xbps-src $action" || rv=$?
|
||||
"xbps-src $action $pkg" || rv=$?
|
||||
fi
|
||||
|
||||
msg_normal "Exiting from the chroot on $XBPS_MASTERDIR.\n"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#-
|
||||
# Copyright (c) 2008-2010 Juan Romero Pardines.
|
||||
# Copyright (c) 2008-2011 Juan Romero Pardines.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
@ -47,6 +47,7 @@ binpkg_cleanup()
|
|||
{
|
||||
local pkgdir="$1" binpkg="$2"
|
||||
|
||||
[ -z "$pkgdir" -o -z "$binpkg" ] && return 1
|
||||
msg_red "\nInterrupted! removing $binpkg file!\n"
|
||||
rm -f $pkgdir/$binpkg
|
||||
exit 1
|
||||
|
@ -106,7 +107,6 @@ xbps_make_binpkg_real()
|
|||
done
|
||||
|
||||
[ -n "$XBPS_COMPRESS_LEVEL" ] && clevel="-$XBPS_COMPRESS_LEVEL"
|
||||
|
||||
[ ! -d $pkgdir ] && mkdir -p $pkgdir
|
||||
|
||||
# Remove binpkg if interrupted...
|
||||
|
@ -117,12 +117,13 @@ xbps_make_binpkg_real()
|
|||
tar --exclude "var/db/xbps/metadata/*/flist" \
|
||||
-cpf - ${mfiles} ${dirs} | \
|
||||
$XBPS_COMPRESS_CMD ${clevel} -qf > $pkgdir/$binpkg
|
||||
if [ $? -eq 0 ]; then
|
||||
rval=$?
|
||||
if [ $rval -eq 0 ]; then
|
||||
msg_normal_append "done.\n"
|
||||
else
|
||||
rm -f $pkgdir/$binpkg
|
||||
msg_normal_append "failed!\n"
|
||||
fi
|
||||
|
||||
return $?
|
||||
return $rval
|
||||
}
|
||||
|
|
|
@ -123,6 +123,15 @@ install_pkg()
|
|||
remove_tmpl_wrksrc $wrksrc
|
||||
fi
|
||||
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
|
||||
fi
|
||||
|
||||
|
@ -161,7 +170,17 @@ install_pkg()
|
|||
# Autoremove packages installed as dependencies if
|
||||
# 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 $?
|
||||
}
|
||||
|
|
|
@ -436,14 +436,6 @@ install)
|
|||
setup_tmpl ${_ORIGINPKG}
|
||||
install_pkg $pkgname || exit $?
|
||||
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)
|
||||
$XBPS_BIN_CMD list
|
||||
|
|
Loading…
Reference in a new issue