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/pc-sysinstall/backend/functions-packages.sh | |
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/pc-sysinstall/backend/functions-packages.sh')
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions-packages.sh | 130 |
1 files changed, 112 insertions, 18 deletions
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 +}; |