Update cust_pkgng with a simpler, more robust version. We don't need
to loop for pkg, which simplifies things.
This commit is contained in:
parent
b58948f222
commit
5499ecc966
@ -916,6 +916,17 @@ cust_install_files ( ) (
|
||||
|
||||
cust_pkgng ( ) (
|
||||
|
||||
local PKG_CONF="${NANO_WORLDDIR}/usr/local/etc/pkg.conf"
|
||||
local PKGCMD="env ASSUME_ALWAYS_YES=YES PKG_DBDIR=${NANO_PKG_META_BASE}/pkg SIGNATURE_TYPE=none /usr/sbin/pkg"
|
||||
|
||||
# Ensure pkg.conf points pkg to where the package meta data lives.
|
||||
touch ${PKG_CONF}
|
||||
if grep -Eiq '^PKG_DBDIR:.*' ${PKG_CONF}; then
|
||||
sed -i -e "\|^PKG_DBDIR:.*|Is||PKG_DBDIR: "\"${NANO_PKG_META_BASE}/pkg\""|" ${PKG_CONF}
|
||||
else
|
||||
echo "PKG_DBDIR: \"${NANO_PKG_META_BASE}/pkg\"" >> ${PKG_CONF}
|
||||
fi
|
||||
|
||||
# If the package directory doesn't exist, we're done.
|
||||
if [ ! -d ${NANO_PACKAGE_DIR} ]; then
|
||||
echo "DONE 0 packages"
|
||||
@ -930,52 +941,28 @@ cust_pkgng ( ) (
|
||||
echo "FAILED: need a pkg/ package for bootstrapping"
|
||||
exit 2
|
||||
fi
|
||||
NANO_PACKAGE_LIST="${_NANO_PKG_PACKAGE} ${NANO_PACKAGE_LIST}"
|
||||
|
||||
# Copy packages into chroot
|
||||
mkdir -p ${NANO_WORLDDIR}/Pkg
|
||||
(
|
||||
cd "${NANO_PACKAGE_DIR}"
|
||||
find ${NANO_PACKAGE_LIST} -print |
|
||||
cpio -Ldumpv ${NANO_WORLDDIR}/Pkg
|
||||
)
|
||||
# Mount packages into chroot
|
||||
mkdir -p ${NANO_WORLDDIR}/_.p
|
||||
mount -t nullfs -o noatime -o ro ${NANO_PACKAGE_DIR} ${NANO_WORLDDIR}/_.p
|
||||
|
||||
#Bootstrap pkg
|
||||
CR env ASSUME_ALWAYS_YES=YES SIGNATURE_TYPE=none /usr/sbin/pkg add /Pkg/${_NANO_PKG_PACKAGE}
|
||||
CR pkg -N >/dev/null 2>&1
|
||||
if [ "$?" -ne "0" ]; then
|
||||
echo "FAILED: pkg bootstrapping faied"
|
||||
exit 2
|
||||
fi
|
||||
rm -f ${NANO_WORLDDIR}/Pkg/pkg-*
|
||||
trap "umount ${NANO_WORLDDIR}/_.p ; rm -rf ${NANO_WORLDDIR}/_.p" 1 2 15
|
||||
|
||||
# Count & report how many we have to install
|
||||
todo=`ls ${NANO_WORLDDIR}/Pkg | /usr/bin/wc -l`
|
||||
todo=$(expr $todo + 1) # add one for pkg since it is installed already
|
||||
# Install packages
|
||||
todo="$(echo "${NANO_PACKAGE_LIST}" | awk '{ print NF }')"
|
||||
echo "=== TODO: $todo"
|
||||
ls ${NANO_WORLDDIR}/Pkg
|
||||
echo "${NANO_PACKAGE_LIST}"
|
||||
echo "==="
|
||||
while true
|
||||
do
|
||||
# Record how many we have now
|
||||
have=$(CR env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg info | /usr/bin/wc -l)
|
||||
|
||||
# Attempt to install more packages
|
||||
CR0 'ls 'Pkg/*txz' | xargs env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg add'
|
||||
|
||||
# See what that got us
|
||||
now=$(CR env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg info | /usr/bin/wc -l)
|
||||
echo "=== NOW $now"
|
||||
CR env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg info
|
||||
echo "==="
|
||||
if [ $now -eq $todo ] ; then
|
||||
echo "DONE $now packages"
|
||||
break
|
||||
elif [ $now -eq $have ] ; then
|
||||
echo "FAILED: Nothing happened on this pass"
|
||||
exit 2
|
||||
fi
|
||||
for _PKG in ${NANO_PACKAGE_LIST}; do
|
||||
CR "${PKGCMD} add /_.p/${_PKG}"
|
||||
done
|
||||
rm -rf ${NANO_WORLDDIR}/Pkg
|
||||
|
||||
CR0 "${PKGCMD} info"
|
||||
|
||||
trap - 1 2 15 EXIT
|
||||
umount ${NANO_WORLDDIR}/_.p
|
||||
rm -rf ${NANO_WORLDDIR}/_.p
|
||||
)
|
||||
|
||||
#######################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user