Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Start the updating of pc-sysinstall for better PKGNG support

Now when we install, we expect the local media to have either a full repo,
with the various packagesite.txz dists.txz and repo.txz files.
  • Loading branch information...
commit 6653818aec85bf397f56eb4a3082a5c72ea84366 1 parent ecb2411
Kris Moore kmoore134 authored
117 src-sh/pc-sysinstall/backend/functions-installpackages.sh
View
@@ -30,49 +30,6 @@
. ${BACKEND}/functions.sh
. ${BACKEND}/functions-parse.sh
-# Recursively determine all dependencies for this package
-determine_package_dependencies()
-{
- local PKGNAME="${1}"
- local DEPFILE="${2}"
-
- grep -q "${PKGNAME}" "${DEPFILE}"
- if [ $? -ne 0 ]
- then
- echo "${PKGNAME}" >> "${DEPFILE}"
- get_package_dependencies "${PKGNAME}" "1"
-
- local DEPS="${VAL}"
- for d in ${DEPS}
- do
- determine_package_dependencies "${d}" "${DEPFILE}"
- done
- fi
-};
-
-# Fetch packages dependencies from a file
-fetch_package_dependencies()
-{
- local DEPFILE
- local DEPS
- local SAVEDIR
-
- DEPFILE="${1}"
- DEPS=`cat "${DEPFILE}"`
- SAVEDIR="${2}"
-
- for d in ${DEPS}
- do
- get_package_short_name "${d}"
- SNAME="${VAL}"
-
- get_package_category "${SNAME}"
- CATEGORY="${VAL}"
-
- fetch_package "${CATEGORY}" "${d}" "${SAVEDIR}"
- done
-};
-
# Check for any packages specified, and begin loading them
install_packages()
{
@@ -97,94 +54,42 @@ install_packages()
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
+ # Install PKGNG into the chroot
+ bootstrap_pkgng
+
# 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
- echo_log "Unable to locate package ${i}"
- continue
- fi
-
- 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
-
- # Set package location
- case "${INSTALLMEDIUM}" in
- usb|dvd|local) PKGPTH="${PKGTMPDIR}/All/${PKGNAME}" ;;
- *) PKGPTH="${PKGTMPDIR}/${PKGNAME}" ;;
- esac
+ PKGNAME="${i}"
# 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
+ PKGADD="pkg -C /mnt/pkg.conf install -y ${PKGNAME}"
+ PKGINFO="pkg info"
# 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}"
- ${PKGADD} ${PKGPTH} | tee -a ${LOGOUT}
+ run_chroot_cmd "$PKGADD" | tee -a ${LOGOUT}
+ run_chroot_cmd "rm -rf /usr/local/tmp/All"
fi
-
- if [ "${INSTALLMEDIUM}" = "ftp" ] ; then
- rc_nohalt "rm ${DEPFILE}"
- fi
-
done
echo_log "Package installation complete!"
# Cleanup after ourselves
echo_log "Cleaning up: ${FSMNT}${PKGTMPDIR}"
- sleep 10
+ sleep 1
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
+ if [ "${INSTALLMEDIUM}" != "ftp" ] ; then
+ rc_halt "umount ${FSMNT}/mnt" >/dev/null 2>/dev/null
rc_halt "rmdir ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null
fi
};
361 src-sh/pc-sysinstall/backend/functions-packages.sh
View
@@ -31,352 +31,6 @@
. ${BACKEND}/functions-parse.sh
. ${BACKEND}/functions-ftp.sh
-
-get_package_index_by_ftp()
-{
- local INDEX_FILE
- local FTP_SERVER
-
- FTP_SERVER="${1}"
- INDEX_FILE="INDEX"
- USE_BZIP2=0
-
- if [ -f "/usr/bin/bzip2" ]
- then
- INDEX_FILE="${INDEX_FILE}.bz2"
- USE_BZIP2=1
- INDEX_PATH="${INDEXFILE}.bz2"
- else
- INDEX_PATH="${INDEXFILE}"
- fi
-
- fetch_file "${FTP_SERVER}/${INDEX_FILE}" "${INDEX_PATH}" "1"
- if [ -f "${INDEX_PATH}" ] && [ "${USE_BZIP2}" -eq "1" ]
- then
- bzip2 -d "${INDEX_PATH}"
- fi
-};
-
-get_package_index_by_fs()
-{
- if [ "$INSTALLMEDIUM" = "local" ] ; then
- INDEXFILE="${LOCALPATH}/packages/INDEX"
- else
- INDEXFILE="${CDMNT}/packages/INDEX"
- fi
-};
-
-get_package_index_size()
-{
- if [ -f "${INDEXFILE}" ]
- then
- SIZE=`ls -l ${INDEXFILE} | awk '{ print $5 }'`
- else
- get_ftp_mirror
- FTPHOST="${VAL}"
-
- FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}"
- FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages"
-
- fetch -s "${FTPPATH}/INDEX.bz2"
- fi
-};
-
-get_package_index()
-{
- RES=0
-
- if [ -z "${INSTALLMODE}" ]
- then
- get_ftp_mirror
- FTPHOST="${VAL}"
-
- FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}"
- FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages"
-
- get_package_index_by_ftp "${FTPPATH}"
-
- else
-
- case "${INSTALLMEDIUM}" in
- usb|dvd|local) get_package_index_by_fs ;;
- ftp) get_value_from_cfg ftpHost
- if [ -z "$VAL" ]; then
- exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
- fi
- FTPHOST="${VAL}"
-
- get_value_from_cfg ftpDir
- if [ -z "$VAL" ]; then
- exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
- fi
- FTPDIR="${VAL}"
- FTPPATH="ftp://${FTPHOST}${FTPDIR}"
- get_package_index_by_ftp "${FTPPATH}" ;;
- sftp) ;;
- *) RES=1 ;;
- esac
-
- fi
-
- return ${RES}
-};
-
-parse_package_index()
-{
- echo_log "Building package dep list.. Please wait.."
- INDEX_FILE="${PKGDIR}/INDEX"
-
- exec 3<&0
- exec 0<"${INDEXFILE}"
-
- while read -r line
- do
- PKGNAME=""
- CATEGORY=""
- PACKAGE=""
- DESC=""
- DEPS=""
- i=0
-
- SAVE_IFS="${IFS}"
- IFS="|"
-
- for part in ${line}
- do
- if [ ${i} -eq 0 ]
- then
- PKGNAME="${part}"
-
- elif [ ${i} -eq 1 ]
- then
- PACKAGE=`basename "${part}"`
-
- elif [ ${i} -eq 3 ]
- then
- DESC="${part}"
-
- elif [ ${i} -eq 6 ]
- then
- CATEGORY=`echo "${part}" | cut -f1 -d' '`
-
- elif [ ${i} -eq 8 ]
- then
- DEPS="${part}"
- fi
-
- i=$((i+1))
- done
-
- echo "${CATEGORY}|${PACKAGE}|${DESC}" >> "${INDEX_FILE}.parsed"
- echo "${PACKAGE}|${PKGNAME}|${DEPS}" >> "${INDEX_FILE}.deps"
-
- IFS="${SAVE_IFS}"
- done
-
- exec 0<&3
-};
-
-show_package_file()
-{
- PKGFILE="${1}"
-
- echo "Available Packages:"
-
- exec 3<&0
- exec 0<"${PKGFILE}"
-
- while read -r line
- do
- CATEGORY=`echo "${line}" | cut -f1 -d'|'`
- PACKAGE=`echo "${line}" | cut -f2 -d'|'`
- DESC=`echo "${line}" | cut -f3 -d'|'`
-
- echo "${CATEGORY}/${PACKAGE}:${DESC}"
- done
-
- exec 0<&3
-};
-
-show_packages_by_category()
-{
- CATEGORY="${1}"
- INDEX_FILE="${PKGDIR}/INDEX.parsed"
- TMPFILE="/tmp/.pkg.cat"
-
- grep "^${CATEGORY}|" "${INDEX_FILE}" > "${TMPFILE}"
- show_package_file "${TMPFILE}"
- rm "${TMPFILE}"
-};
-
-show_package_by_name()
-{
- CATEGORY="${1}"
- PACKAGE="${2}"
- INDEX_FILE="${PKGDIR}/INDEX.parsed"
- TMPFILE="/tmp/.pkg.cat.pak"
-
- grep "^${CATEGORY}|${PACKAGE}" "${INDEX_FILE}" > "${TMPFILE}"
- show_package_file "${TMPFILE}"
- rm "${TMPFILE}"
-};
-
-show_packages()
-{
- show_package_file "${PKGDIR}/INDEX.parsed"
-};
-
-get_package_dependencies()
-{
- PACKAGE="${1}"
- LONG="${2:-0}"
- RES=0
-
- INDEX_FILE="${PKGDIR}/INDEX.deps"
- REGEX="^${PACKAGE}|"
-
- if [ ${LONG} -ne 0 ]
- then
- REGEX="^.*|${PACKAGE}|"
- fi
-
- LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
- DEPS=`echo "${LINE}"|cut -f3 -d'|'`
-
- export VAL="${DEPS}"
-
- if [ -z "${VAL}" ]
- then
- RES=1
- fi
-
- return ${RES}
-};
-
-get_package_name()
-{
- PACKAGE="${1}"
- RES=0
- local PKGPTH
-
- # If we are on a local medium, we can parse the Latest/ directory
- if [ "${INSTALLMEDIUM}" != "ftp" ] ; then
- case "${INSTALLMEDIUM}" in
- usb|dvd) PKGPTH="${CDMNT}/packages" ;;
- *) PKGPTH="${LOCALPATH}/packages" ;;
- esac
-
- # Check the /Latest dir for generic names, then look for specific version in All/
- if [ -e "${PKGPTH}/Latest/${PACKAGE}.${PKGEXT}" ] ; then
- NAME=`ls -al ${PKGPTH}/Latest/${PACKAGE}.${PKGEXT} 2>/dev/null | cut -d '>' -f 2 | rev | cut -f1 -d'/' | rev | tr -s ' '`
- else
- NAME=`ls -al ${PKGPTH}/All/${PACKAGE}.${PKGEXT} 2>/dev/null | cut -d '>' -f 2 | rev | cut -f1 -d'/' | rev | tr -s ' '`
- fi
- export VAL="${NAME}"
- else
- # Doing remote fetch, we we will look up, but some generic names like
- # "perl" wont work, since we don't know the default version
- INDEX_FILE="${PKGDIR}/INDEX.deps"
- REGEX="^${PACKAGE}|"
-
- LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
- NAME=`echo "${LINE}"|cut -f2 -d'|'`
-
- export VAL="${NAME}"
- fi
-
- if [ -z "${VAL}" ]
- then
- RES=1
- fi
- return ${RES}
-};
-
-get_package_short_name()
-{
- PACKAGE="${1}"
- RES=0
-
- INDEX_FILE="${PKGDIR}/INDEX.deps"
- REGEX="^.*|${PACKAGE}|"
-
- LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
- NAME=`echo "${LINE}"|cut -f1 -d'|'`
-
- export VAL="${NAME}"
-
- if [ -z "${VAL}" ]
- then
- RES=1
- fi
-
- return ${RES}
-};
-
-get_package_category()
-{
- PACKAGE="${1}"
- INDEX_FILE="${PKGDIR}/INDEX.parsed"
- RES=0
-
- LINE=`grep "|${PACKAGE}|" "${INDEX_FILE}" 2>/dev/null`
- NAME=`echo "${LINE}"|cut -f1 -d'|'`
-
- export VAL="${NAME}"
-
- if [ -z "${VAL}" ]
- then
- RES=1
- fi
-
- return ${RES}
-};
-
-fetch_package_by_ftp()
-{
- CATEGORY="${1}"
- PACKAGE="${2}"
- SAVEDIR="${3}"
-
- get_value_from_cfg ftpHost
- if [ -z "$VAL" ]
- then
- exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
- fi
- FTPHOST="${VAL}"
-
- get_value_from_cfg ftpDir
- if [ -z "$VAL" ]
- then
- exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
- fi
- FTPDIR="${VAL}"
-
- PACKAGE="${PACKAGE}.${PKGEXT}"
- FTP_SERVER="ftp://${FTPHOST}${FTPDIR}"
-
- if [ ! -f "${SAVEDIR}/${PACKAGE}" ]
- then
- PKGPATH="${CATEGORY}/${PACKAGE}"
- FTP_PATH="${FTP_HOST}/packages/${PKGPATH}"
- fetch_file "${FTP_PATH}" "${SAVEDIR}/" "0"
- fi
-};
-
-fetch_package()
-{
- CATEGORY="${1}"
- PACKAGE="${2}"
- SAVEDIR="${3}"
-
- # Fetch package, but skip if installing from local media
- case "${INSTALLMEDIUM}" in
- usb|dvd|local) return ;;
- ftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
- sftp) ;;
- esac
-};
-
bootstrap_pkgng()
{
# Check if we need to boot-strap pkgng
@@ -388,12 +42,13 @@ bootstrap_pkgng()
# Ok, lets boot-strap this sucker
echo_log "Bootstraping pkgng.."
- fetch_package "Latest" "pkg" "${PKGDLDIR}"
# Figure out real location of "pkg" package
case "${INSTALLMEDIUM}" in
- usb|dvd|local) PKGPTH="${PKGTMPDIR}/Latest/pkg.${PKGEXT}" ;;
- *) PKGPTH="${PKGTMPDIR}/pkg.${PKGEXT}" ;;
+ usb|dvd|local) rc_halt "cd ${LOCALPATH}/packages"
+ PKGPTH="/mnt/`ls All/pkg-[0-9]*.txz`"
+ ;;
+ *) PKGPTH="pkg" ;;
esac
rc_halt "pkg -c ${FSMNT} add ${PKGPTH}"
}
@@ -401,10 +56,10 @@ bootstrap_pkgng()
get_package_location()
{
case "${INSTALLMEDIUM}" in
- usb|dvd) rc_halt "mount_nullfs ${CDMNT}/packages ${FSMNT}${PKGTMPDIR}"
- PKGDLDIR="${FSMNT}${PKGTMPDIR}/All" ;;
- local) rc_halt "mount_nullfs ${LOCALPATH}/packages ${FSMNT}${PKGTMPDIR}"
- PKGDLDIR="${FSMNT}${PKGTMPDIR}/All" ;;
+ usb|dvd) rc_halt "mount_nullfs ${CDMNT}/packages ${FSMNT}/mnt"
+ PKGDLDIR="${FSMNT}/mnt" ;;
+ local) rc_halt "mount_nullfs ${LOCALPATH}/packages ${FSMNT}/mnt"
+ PKGDLDIR="${FSMNT}/mnt" ;;
*) PKGDLDIR="${FSMNT}${PKGTMPDIR}" ;;
esac
export PKGDLDIR
89 src-sh/pc-sysinstall/backend/functions-unmount.sh
View
@@ -171,55 +171,52 @@ unmount_all_filesystems_failure()
{
cd /
- # if we did a fresh install, start unmounting
- if [ "${INSTALLMODE}" = "fresh" ]
- then
+ # Start by unmounting any ZFS partitions
+ zfs_cleanup_unmount
+
+ # Lets read our partition list, and unmount each
+ ##################################################################
+ for PART in `ls ${PARTDIR}`
+ do
+ PARTDEV=`echo $PART | sed 's|-|/|g'`
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
+ PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d '#' -f 4`"
- # Lets read our partition list, and unmount each
- ##################################################################
- if [ -d "${PARTDIR}" ]
+ if [ "${PARTENC}" = "ON" ]
then
- for PART in `ls ${PARTDIR}`
- do
- PARTDEV=`echo $PART | sed 's|-|/|g'`
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
-
- if [ "${PARTFS}" = "SWAP" ]
- then
- if [ "${PARTENC}" = "ON" ]
- then
- swapoff ${PARTDEV}.eli >/dev/null 2>/dev/null
- else
- swapoff ${PARTDEV} >/dev/null 2>/dev/null
- fi
- fi
+ EXT=".eli"
+ else
+ EXT=""
+ fi
- # Check if we've found "/" again, don't need to mount it twice
- if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
- then
- umount -f ${PARTDEV} >/dev/null 2>/dev/null
- umount -f ${FSMNT}${PARTMNT} >/dev/null 2>/dev/null
- fi
- done
-
- # Last lets the /mnt partition
- #########################################################
- umount -f ${FSMNT} >/dev/null 2>/dev/null
-
- fi
- else
- # We are doing a upgrade, try unmounting any of these filesystems
- chroot ${FSMNT} /sbin/umount -a >/dev/null 2>/dev/null
- umount -f ${FSMNT}/usr >/dev/null 2>/dev/null
- umount -f ${FSMNT}/dev >/dev/null 2>/dev/null
- umount -f ${FSMNT} >/dev/null 2>/dev/null
- sh ${TMPDIR}/.upgrade-unmount >/dev/null 2>/dev/null
- fi
-
- # Unmount our CDMNT
- umount ${CDMNT} >/dev/null 2>/dev/null
+ if [ "${PARTFS}" = "SWAP" ]
+ then
+ rc_nohalt "swapoff ${PARTDEV}${EXT}"
+ fi
+
+ # Check if we've found "/", and unmount that last
+ if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
+ then
+ echo_log "Unmounting: ${PARTDEV}${EXT}"
+ rc_halt "umount -f ${PARTDEV}${EXT}"
+ fi
+ done
+
+ # Last lets the /mnt partition
+ #########################################################
+ echo_log "Unmounting: ${FSMNT}"
+ rc_nohalt "umount -f ${FSMNT}"
+
+ # Check if we need to unmount a media
+ case $INSTALLMEDIUM in
+ dvd|usb) echo_log "Unmounting DVD/USB media: ${CDMNT}"
+ sleep 5
+ rc_nohalt "umount -f ${CDMNT}" >/dev/null 2>/dev/null
+ ;;
+ *) ;;
+ esac
};
Please sign in to comment.
Something went wrong with that request. Please try again.