Fix a bug extracting files from dist scheme

Obtained from:	PC-BSD
This commit is contained in:
Josh Paetzel 2013-03-03 09:47:47 +00:00
parent 4514d6fa18
commit b771592d97
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=247705
4 changed files with 131 additions and 25 deletions

View File

@ -29,23 +29,60 @@
. ${BACKEND}/functions-mountoptical.sh
# Performs the extraction of data to disk from FreeBSD dist files
start_extract_dist()
{
if [ -z "$1" ] ; then exit_err "Called dist extraction with no directory set!"; fi
if [ -z "$INSFILE" ]; then exit_err "Called extraction with no install file set!"; fi
local DDIR="$1"
# Check if we are doing an upgrade, and if so use our exclude list
if [ "${INSTALLMODE}" = "upgrade" ]; then
TAROPTS="-X ${PROGDIR}/conf/exclude-from-upgrade"
else
TAROPTS=""
fi
# Loop though and extract dist files
for di in $INSFILE
do
# Check the MANIFEST see if we have an archive size / count
if [ -e "${DDIR}/MANIFEST" ]; then
count=`grep "^${di}.txz" ${DDIR}/MANIFEST | awk '{print $3}'`
if [ ! -z "$count" ] ; then
echo "INSTALLCOUNT: $count"
fi
fi
echo_log "pc-sysinstall: Starting Extraction (${di})"
tar -xpv -C ${FSMNT} -f ${DDIR}/${di}.txz ${TAROPTS} >&1 2>&1
if [ $? -ne 0 ]; then
exit_err "ERROR: Failed extracting the dist file: $di"
fi
done
# Check if this was a FTP download and clean it up now
if [ "${INSTALLMEDIUM}" = "ftp" ]; then
echo_log "Cleaning up downloaded archives"
rm -rf ${DDIR}
fi
echo_log "pc-sysinstall: Extraction Finished"
}
# Performs the extraction of data to disk from a uzip or tar archive
start_extract_uzip_tar()
{
if [ -z "$INSFILE" ]
then
if [ -z "$INSFILE" ]; then
exit_err "ERROR: Called extraction with no install file set!"
fi
# Check if we have a .count file, and echo it out for a front-end to use in progress bars
if [ -e "${INSFILE}.count" ]
then
if [ -e "${INSFILE}.count" ]; then
echo "INSTALLCOUNT: `cat ${INSFILE}.count`"
fi
# Check if we are doing an upgrade, and if so use our exclude list
if [ "${INSTALLMODE}" = "upgrade" ]
then
if [ "${INSTALLMODE}" = "upgrade" ]; then
TAROPTS="-X ${PROGDIR}/conf/exclude-from-upgrade"
else
TAROPTS=""
@ -87,9 +124,8 @@ start_extract_uzip_tar()
mdconfig -d -u ${MDDEVICE}
;;
tar)
tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1
if [ $? -ne 0 ]
then
tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1
if [ $? -ne 0 ]; then
exit_err "ERROR: Failed extracting the tar image"
fi
;;
@ -176,6 +212,38 @@ start_extract_split()
echo_log "pc-sysinstall: Extraction Finished"
};
# Function which will attempt to fetch the dist file(s) before we start
fetch_dist_file()
{
get_value_from_cfg ftpPath
if [ -z "$VAL" ]
then
exit_err "ERROR: Install medium was set to ftp, but no ftpPath was provided!"
fi
FTPPATH="${VAL}"
# Check if we have a /usr partition to save the download
if [ -d "${FSMNT}/usr" ]
then
DLDIR="${FSMNT}/usr/.fetch.$$"
else
DLDIR="${FSMNT}/.fetch.$$"
fi
mkdir -p ${DLDIR}
# Do the fetch of the dist archive(s) now
for di in $INSFILE
do
fetch_file "${FTPPATH}/${di}.txz" "${DLDIR}/${di}.txz" "1"
done
# Check to see if there is a MANIFEST file for this install
fetch_file "${FTPPATH}/MANIFEST" "${DLDIR}/MANIFEST" "0"
export DLDIR
};
# Function which will attempt to fetch the install file before we start
# the install
fetch_install_file()
@ -390,6 +458,13 @@ init_extraction()
case $PACKAGETYPE in
uzip) INSFILE="${FBSD_UZIP_FILE}" ;;
tar) INSFILE="${FBSD_TAR_FILE}" ;;
dist)
get_value_from_cfg_with_spaces distFiles
if [ -z "$VAL" ] ; then
exit_err "No dist files specified!"
fi
INSFILE="${VAL}"
;;
split)
INSDIR="${FBSD_BRANCH_DIR}"
@ -401,6 +476,13 @@ init_extraction()
case $PACKAGETYPE in
uzip) INSFILE="${UZIP_FILE}" ;;
tar) INSFILE="${TAR_FILE}" ;;
dist)
get_value_from_cfg_with_spaces distFiles
if [ -z "$VAL" ] ; then
exit_err "No dist files specified!"
fi
INSFILE="${VAL}"
;;
esac
fi
export INSFILE
@ -417,22 +499,32 @@ init_extraction()
start_extract_split
else
INSFILE="${CDMNT}/${INSFILE}" ; export INSFILE
start_extract_uzip_tar
if [ "$PACKAGETYPE" = "dist" ] ; then
start_extract_dist "${CDMNT}/usr/freebsd-dist"
else
INSFILE="${CDMNT}/${INSFILE}" ; export INSFILE
start_extract_uzip_tar
fi
fi
;;
ftp)
if [ "$PACKAGETYPE" = "split" ]
then
fetch_split_files
case $PACKAGETYPE in
split)
fetch_split_files
INSDIR="${INSFILE}" ; export INSDIR
start_extract_split
else
fetch_install_file
start_extract_uzip_tar
fi
INSDIR="${INSFILE}" ; export INSDIR
start_extract_split
;;
dist)
fetch_dist_file
start_extract_dist "$DLDIR"
;;
*)
fetch_install_file
start_extract_uzip_tar
;;
esac
;;
sftp) ;;
@ -446,8 +538,13 @@ init_extraction()
exit_err "Install medium was set to local, but no localPath was provided!"
fi
LOCALPATH=$VAL
INSFILE="${LOCALPATH}/${INSFILE}" ; export INSFILE
start_extract_uzip_tar
if [ "$PACKAGETYPE" = "dist" ] ; then
INSFILE="${INSFILE}" ; export INSFILE
start_extract_dist "$LOCALPATH"
else
INSFILE="${LOCALPATH}/${INSFILE}" ; export INSFILE
start_extract_uzip_tar
fi
;;
*) exit_err "ERROR: Unknown install medium" ;;
esac

View File

@ -45,7 +45,7 @@ get_value_from_cfg_with_spaces()
{
if [ -n "${1}" ]
then
export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2-`
export VAL="`grep ^${1}= ${CFGF} | head -n 1 | cut -d '=' -f 2-`"
else
exit_err "Error: Did we forgot to supply a setting to grab?"
fi

View File

@ -69,7 +69,7 @@ file_sanity_check "installMode installType installMedium packageType"
check_value installMode "fresh upgrade extract"
check_value installType "PCBSD FreeBSD"
check_value installMedium "dvd usb ftp rsync image local"
check_value packageType "uzip tar rsync split"
check_value packageType "uzip tar rsync split dist"
if_check_value_exists mirrorbal "load prefer round-robin split"
# We passed all sanity checks! Yay, lets start the install

View File

@ -243,11 +243,16 @@ Set installMedium= to the source type we will be using for this install.
Available Types:
dvd - Search for and mount the DVD which contains the install archive
local - Pull files directly from a local directory
usb - Search for and mount the USB drive which contains the install archive
ftp - The install archive will be fetched from a FTP / HTTP server before install
rsync - Pull the system data from a ssh + rsync server, specified with variables below
image - Install system from an image
# localPath=/usr/freebsd-dist
Location of the directory we will be pulling installation files from
# installType=(PCBSD, FreeBSD)
Set the type of system we are installing, PCBSD or FreeBSD
@ -256,10 +261,14 @@ Set the type of system we are installing, PCBSD or FreeBSD
The installer archive, if not using the defaults specified in conf/pc-sysinstall.conf
# packageType=(tar, uzip, split)
# packageType=(tar, uzip, split, dist)
The archive type we are extracting from when using dvd, usb or ftp
# distFiles=base src kernel
List of dist files to install when packageType=dist
# ftpPath=ftp://ftp.pcbsd.org/pub/8.0/netinstall
Location of the installer archive when using a installMedium=ftp