diff options
author | imp <imp@FreeBSD.org> | 2010-08-19 06:01:25 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2010-08-19 06:01:25 +0000 |
commit | bc2b00ae354e3bf5e5d2bd85ca560e795b337a4f (patch) | |
tree | 4e215640a4befc7ecd6afd497df17fffe1dbc76c /usr.sbin | |
parent | 23d9b9fddd80cb970290ccdde4452d75102c2ce0 (diff) | |
download | FreeBSD-src-bc2b00ae354e3bf5e5d2bd85ca560e795b337a4f.zip FreeBSD-src-bc2b00ae354e3bf5e5d2bd85ca560e795b337a4f.tar.gz |
Updates to pc-sysinstall that allow FTP installation of FreeBSD.
PR: 148661
Submitted by: John Hixson
Diffstat (limited to 'usr.sbin')
4 files changed, 224 insertions, 39 deletions
diff --git a/usr.sbin/pc-sysinstall/backend-query/list-packages.sh b/usr.sbin/pc-sysinstall/backend-query/list-packages.sh index 02d3e9a..b5d93f5 100755 --- a/usr.sbin/pc-sysinstall/backend-query/list-packages.sh +++ b/usr.sbin/pc-sysinstall/backend-query/list-packages.sh @@ -56,14 +56,26 @@ then NARGS=$((NARGS+1)) fi -echo "Available Packages:" if [ "${NARGS}" -eq "0" ] then show_packages elif [ "${NARGS}" -eq "1" ] then - show_packages_by_category "${PACKAGE_CATEGORY}" + + if [ "${PACKAGE_CATEGORY}" = "@INDEX@" ] + then + if [ -f "${PKGDIR}/INDEX" ] + then + echo "${PKGDIR}/INDEX" + exit 0 + else + exit 1 + fi + + else + show_packages_by_category "${PACKAGE_CATEGORY}" + fi elif [ "${NARGS}" -eq "2" ] then diff --git a/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh b/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh index e4fccce..de86711 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh @@ -203,6 +203,69 @@ fetch_install_file() }; +# Function which will download freebsd install files +fetch_split_files() +{ + 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}" + + # Check if we have a /usr partition to save the download + if [ -d "${FSMNT}/usr" ] + then + OUTFILE="${FSMNT}/usr/.fetch-${INSFILE}" + else + OUTFILE="${FSMNT}/.fetch-${INSFILE}" + fi + + NETRC="${OUTFILE}/.netrc" + cat<<EOF>"${NETRC}" +machine ${FTPHOST} +login anonymous +password anonymous +macdef INSTALL +bin +prompt +EOF + + DIRS="base catpages dict doc games info manpages proflibs kernels src" + if [ "${FBSD_ARCH}" = "amd64" ] + then + DIRS="${DIRS} lib32" + fi + + for d in ${DIRS} + do + cat<<EOF>>"${NETRC}" +cd ${FTPDIR}/${d} +lcd ${OUTFILE}/${d} +mreget * +EOF + done + + cat<<EOF>>"${NETRC}" +bye + + +EOF + + # Fetch the files via ftp + echo "$ INSTALL" | ftp -N "${NETRC}" "${FTPHOST}" + + # Done fetching, now reset the INSFILE to our downloaded archived + INSFILE="${OUTFILE}" ; export INSFILE +} + # Function which does the rsync download from the server specifed in cfg start_rsync_copy() { @@ -304,8 +367,17 @@ init_extraction() start_extract_uzip_tar fi ;; - ftp) fetch_install_file - start_extract_uzip_tar + ftp) + if [ "$PACKAGETYPE" = "split" ] + then + fetch_split_files + + INSDIR="${INSFILE}" ; export INSDIR + start_extract_split + else + fetch_install_file + start_extract_uzip_tar + fi ;; rsync) start_rsync_copy ;; diff --git a/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh b/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh index 8d5f408..e967011 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh @@ -45,7 +45,7 @@ determine_package_dependencies() for d in ${DEPS} do - get_all_package_dependencies "${d}" "${DEPFILE}" + determine_package_dependencies "${d}" "${DEPFILE}" done fi }; @@ -55,9 +55,11 @@ fetch_package_dependencies() { local DEPFILE local DEPS + local SAVEDIR DEPFILE="${1}" DEPS=`cat "${DEPFILE}"` + SAVEDIR="${2}" for d in ${DEPS} do @@ -67,7 +69,7 @@ fetch_package_dependencies() get_package_category "${SNAME}" CATEGORY="${VAL}" - fetch_package "${CATEGORY}" "${d}" + fetch_package "${CATEGORY}" "${d}" "${SAVEDIR}" done }; @@ -78,10 +80,19 @@ install_packages() get_value_from_cfg installPackages if [ ! -z "${VAL}" ] then - mkdir -p "${PKGTMPDIR}" - HERE=`pwd` - cd "${PKGTMPDIR}" + rc_nohalt "mkdir -p ${FSMNT}/${PKGTMPDIR}" + rc_nohalt "cd ${FSMNT}/${PKGTMPDIR}" + + if [ ! -f "${CONFDIR}/INDEX" ] + then + get_package_index + fi + + if [ ! -f "${CONFDIR}/INDEX.parsed" ] + then + parse_package_index + fi # Lets start by cleaning up the string and getting it ready to parse strip_white_space ${VAL} @@ -91,28 +102,24 @@ install_packages() if get_package_name "${i}" then PKGNAME="${VAL}" - DEPFILE="${PKGTMPDIR}/.${PKGNAME}.deps" + DEPFILE="${FSMNT}/${PKGTMPDIR}/.${PKGNAME}.deps" - touch "${DEPFILE}" + rc_nohalt "touch ${DEPFILE}" determine_package_dependencies "${PKGNAME}" "${DEPFILE}" - fetch_package_dependencies "${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 - echo_log "Adding package ${PKGNAME}" - pkg_add -C "${FSMNT}" "${PKGNAME}.tbz" >/dev/null 2>&1 - if [ "$?" -eq "0" ] - then - echo_log "${PKGNAME} successfully installed!" - fi + rc_nohalt "pkg_add -C ${FSMNT} ${PKGTMPDIR}/${PKGNAME}.tbz" fi - rm "${DEPFILE}" + rc_nohalt "rm ${DEPFILE}" fi + + rc_nohalt "cd ${HERE}" done - #rm -rf "${PKGTMPDIR}" - cd "${HERE}" + #rm -rf "${FSMNT}/${PKGTMPDIR}" fi }; diff --git a/usr.sbin/pc-sysinstall/backend/functions-packages.sh b/usr.sbin/pc-sysinstall/backend/functions-packages.sh index a522718..1ec24be 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-packages.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-packages.sh @@ -32,31 +32,80 @@ . ${BACKEND}/functions-ftp.sh -get_package_index() +get_package_index_by_ftp() { + local INDEX_FILE + local FTP_SERVER + + FTP_SERVER="${1}" INDEX_FILE="INDEX" USE_BZIP2=0 - get_ftp_mirror - FTP_SERVER="${VAL}" - - FTP_DIR="ftp://${FTP_SERVER}/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}/packages" - if [ -f "/usr/bin/bzip2" ] then INDEX_FILE="${INDEX_FILE}.bz2" USE_BZIP2=1 fi - fetch_file "${FTP_DIR}/${INDEX_FILE}" "${PKGDIR}/${INDEX_FILE}" "1" + INDEX_PATH="${CONFDIR}/${INDEX_FILE}" + 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() +{ + local INDEX_FILE + + INDEX_FILE="${CDMNT}/packages/INDEX" + fetch_file "${INDEX_FILE}" "${CONFDIR}/" "0" +}; - HERE=`pwd` - cd "${PKGDIR}" - if [ -f "${INDEX_FILE}" ] && [ "${USE_BZIP2}" -eq "1" ] +get_package_index() +{ + RES=0 + + if [ -z "${INSTALLMODE}" ] then - bzip2 -d "${INDEX_FILE}" + 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 + 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}" + + case "${INSTALLMEDIUM}" in + usb|dvd) get_package_index_by_fs + ;; + ftp) get_package_index_by_ftp "${FTPPATH}" + ;; + *) RES=1 + ;; + esac + fi - cd "${HERE}" + + return ${RES} }; parse_package_index() @@ -117,6 +166,8 @@ show_package_file() { PKGFILE="${1}" + echo "Available Packages:" + exec 3<&0 exec 0<"${PKGFILE}" @@ -252,19 +303,62 @@ get_package_category() return ${RES} }; -fetch_package() +fetch_package_by_ftp() { CATEGORY="${1}" PACKAGE="${2}" + SAVEDIR="${3}" - get_ftp_mirror - FTP_SERVER="${VAL}" + 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}.tbz" - if [ ! -f "${PKGTMPDIR}/${PACKAGE}" ] + FTP_SERVER="ftp://${FTPHOST}${FTPDIR}" + + if [ ! -f "${SAVEDIR}/${PACKAGE}" ] then PKGPATH="${CATEGORY}/${PACKAGE}" - FTP_PATH="ftp://${FTP_SERVER}/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}/packages/${PKGPATH}" - fetch_file "${FTP_PATH}" "${PKGTMPDIR}/" "0" + FTP_PATH="${FTP_HOST}/packages/${PKGPATH}" + fetch_file "${FTP_PATH}" "${SAVEDIR}/" "0" + fi +}; + +fetch_package_by_fs() +{ + CATEGORY="${1}" + PACKAGE="${2}" + SAVEDIR="${3}" + + PACKAGE="${PACKAGE}.tbz" + if [ ! -f "${SAVEDIR}/${PACKAGE}" ] + then + fetch_file "${CDMNT}/packages/${CATEGORY}/${PACKAGE}" "${SAVEDIR}/" "0" fi }; + +fetch_package() +{ + CATEGORY="${1}" + PACKAGE="${2}" + SAVEDIR="${3}" + + case "${INSTALLMEDIUM}" in + usb|dvd) + fetch_package_by_fs "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" + ;; + ftp) + fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" + ;; + esac +}; |