diff options
author | jpaetzel <jpaetzel@FreeBSD.org> | 2013-03-03 23:01:46 +0000 |
---|---|---|
committer | jpaetzel <jpaetzel@FreeBSD.org> | 2013-03-03 23:01:46 +0000 |
commit | 3da475a963077e2df4022d88c2fba553595f4e9b (patch) | |
tree | 6aa4ff315eb7f8728315569dc1f65aa1699a51c6 /usr.sbin/pc-sysinstall/backend/functions-installpackages.sh | |
parent | 8bb3da133f0682d6d4de1df7fcc02836faaddb68 (diff) | |
download | FreeBSD-src-3da475a963077e2df4022d88c2fba553595f4e9b.zip FreeBSD-src-3da475a963077e2df4022d88c2fba553595f4e9b.tar.gz |
Improves and enhances using the "installPackages=" variable.
Adds "pkgExt=" variable to set if pkgs are .tbz or .txz or other.
Auto-detects if packages are PKGNG or old PKG format.
Auto-bootstrap of PKGNG for the new installed environment.
Fixes issues with installing packages from local media, such as DVD/USB.
Switch to using a space-delimiter for installPackages, since a number
of packages use a "," in their version string.
Fix pc-sysinstall to ignore install scripts, and not hang on
user interaction prompts when installing pkgs.
Add pkg2ng command as apart of pkgng bootstrap process.
Obtained from: PC-BSD
Diffstat (limited to 'usr.sbin/pc-sysinstall/backend/functions-installpackages.sh')
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions-installpackages.sh | 131 |
1 files changed, 97 insertions, 34 deletions
diff --git a/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh b/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh index 7572efb..c1a879a 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh @@ -76,50 +76,113 @@ fetch_package_dependencies() # Check for any packages specified, and begin loading them install_packages() { + echo "Checking for packages to install..." + sleep 2 + # First, lets check and see if we even have any packages to install get_value_from_cfg installPackages - if [ -n "${VAL}" ] - then - HERE=`pwd` - rc_nohalt "mkdir -p ${FSMNT}/${PKGTMPDIR}" - rc_nohalt "cd ${FSMNT}/${PKGTMPDIR}" - if [ ! -f "${CONFDIR}/INDEX" ] + # Nothing to do? + if [ -z "${VAL}" ]; then return; fi + + echo "Installing packages..." + sleep 3 + + local PKGPTH + + HERE=`pwd` + rc_halt "mkdir -p ${FSMNT}${PKGTMPDIR}" + + # Determine the directory we will install packages from + get_package_location + rc_halt "cd ${PKGDLDIR}" + + # Set the location of the INDEXFILE + INDEXFILE="${TMPDIR}/INDEX" + + if [ ! -f "${INDEXFILE}" ]; then + get_package_index + fi + + if [ ! -f "${TMPDIR}/INDEX.parsed" -a "$INSTALLMEDIUM" = "ftp" ]; then + parse_package_index + fi + + # What extension are we using for pkgs? + PKGEXT="txz" + get_value_from_cfg pkgExt + if [ -n "${VAL}" ]; then + strip_white_space ${VAL} + PKGEXT="$VAL" + fi + export PKGEXT + + # We dont want to be bothered with scripts asking questions + PACKAGE_BUILDING=yes + export PACKAGE_BUILDING + + # Lets start by cleaning up the string and getting it ready to parse + get_value_from_cfg_with_spaces installPackages + PACKAGES="${VAL}" + echo_log "Packages to install: `echo $PACKAGES | wc -w | awk '{print $1}'`" + for i in $PACKAGES + do + if ! get_package_name "${i}" then - get_package_index + echo_log "Unable to locate package ${i}" + continue fi - if [ ! -f "${CONFDIR}/INDEX.parsed" ] - then - parse_package_index + PKGNAME="${VAL}" + + # Fetch package + deps, but skip if installing from local media + if [ "${INSTALLMEDIUM}" = "ftp" ] ; then + DEPFILE="${FSMNT}/${PKGTMPDIR}/.${PKGNAME}.deps" + rc_nohalt "touch ${DEPFILE}" + determine_package_dependencies "${PKGNAME}" "${DEPFILE}" + fetch_package_dependencies "${DEPFILE}" "${FSMNT}/${PKGTMPDIR}" fi - # Lets start by cleaning up the string and getting it ready to parse - strip_white_space ${VAL} - PACKAGES=`echo ${VAL} | sed -e "s|,| |g"` - for i in $PACKAGES - do - if get_package_name "${i}" - then - PKGNAME="${VAL}" - DEPFILE="${FSMNT}/${PKGTMPDIR}/.${PKGNAME}.deps" - - rc_nohalt "touch ${DEPFILE}" - determine_package_dependencies "${PKGNAME}" "${DEPFILE}" - fetch_package_dependencies "${DEPFILE}" "${FSMNT}/${PKGTMPDIR}" - - # If the package is not already installed, install it! - if ! run_chroot_cmd "pkg_info -e ${PKGNAME}" - then - rc_nohalt "pkg_add -C ${FSMNT} ${PKGTMPDIR}/${PKGNAME}.tbz" - fi - - rc_nohalt "rm ${DEPFILE}" + # Set package location + case "${INSTALLMEDIUM}" in + usb|dvd|local) PKGPTH="${PKGTMPDIR}/All/${PKGNAME}" ;; + *) PKGPTH="${PKGTMPDIR}/${PKGNAME}" ;; + esac + + # See if we need to determine the package format we are working with + if [ -z "${PKGINFO}" ] ; then + tar tqf "${FSMNT}${PKGPTH}" '+MANIFEST' >/dev/null 2>/dev/null + if [ $? -ne 0 ] ; then + PKGADD="pkg_add -C ${FSMNT}" + PKGINFO="pkg_info" + else + PKGADD="pkg -c ${FSMNT} add" + PKGINFO="pkg info" + bootstrap_pkgng fi + fi - rc_nohalt "cd ${HERE}" - done + # If the package is not already installed, install it! + if ! run_chroot_cmd "${PKGINFO} -e ${PKGNAME}" >/dev/null 2>/dev/null + then + echo_log "Installing package: ${PKGNAME}" + rc_nohalt "${PKGADD} ${PKGPTH}" + fi + + if [ "${INSTALLMEDIUM}" = "ftp" ] ; then + rc_nohalt "rm ${DEPFILE}" + fi + + done + + echo_log "Package installation complete!" - rm -rf "${FSMNT}/${PKGTMPDIR}" + # Cleanup after ourselves + rc_halt "cd ${HERE}" + if [ "${INSTALLMEDIUM}" = "ftp" ] ; then + rc_halt "rm -rf ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null + else + rc_halt "umount ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null + rc_halt "rmdir ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null fi }; |