Updates to pc-sysinstall that allow FTP installation of FreeBSD.
PR: 148661 Submitted by: John Hixson
This commit is contained in:
parent
a5a3ab24a4
commit
742736b923
@ -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
|
||||
|
@ -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
|
||||
;;
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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"
|
||||
|
||||
HERE=`pwd`
|
||||
cd "${PKGDIR}"
|
||||
if [ -f "${INDEX_FILE}" ] && [ "${USE_BZIP2}" -eq "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_FILE}"
|
||||
bzip2 -d "${INDEX_PATH}"
|
||||
fi
|
||||
cd "${HERE}"
|
||||
};
|
||||
|
||||
get_package_index_by_fs()
|
||||
{
|
||||
local INDEX_FILE
|
||||
|
||||
INDEX_FILE="${CDMNT}/packages/INDEX"
|
||||
fetch_file "${INDEX_FILE}" "${CONFDIR}/" "0"
|
||||
};
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
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_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}.tbz"
|
||||
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_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}"
|
||||
|
||||
get_ftp_mirror
|
||||
FTP_SERVER="${VAL}"
|
||||
|
||||
PACKAGE="${PACKAGE}.tbz"
|
||||
if [ ! -f "${PKGTMPDIR}/${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"
|
||||
fi
|
||||
case "${INSTALLMEDIUM}" in
|
||||
usb|dvd)
|
||||
fetch_package_by_fs "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}"
|
||||
;;
|
||||
ftp)
|
||||
fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}"
|
||||
;;
|
||||
esac
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user