Use local isos fixed (#361)

* Start adding params for existing isos

* Merge parameter handling code

* initial testing seems reasonable

Note that if copying files in, "wget -c " will assume

smaller-than-remote files are parts and continue
so likely will cause hashing failures
or if no hash check then corrupt isos.

* Added usage for --help

* Usage enhanced and added to Readme

* spurios unused cruft removed

* Fixed race

adding belts and braces

* Removed debugging and cruft

* Not yet able to cache windows because windows

* Working for cached macos

with limitations
This commit is contained in:
Phil Clifford 2022-02-19 11:49:09 +00:00 committed by GitHub
parent 65b78eb8a4
commit da8d0c7899
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 48 additions and 23 deletions

View File

@ -537,23 +537,34 @@ function check_hash() {
}
function copy_local(){
if [ -n "${ISODIR}" ]; then
# use supplied filename or default to original distro ISO name
if [ -z ${LOCALISO} ]; then
LOCALISO=${FILE}
fi
LOCALFILE=$(find ${ISODIR} -type f -name "${LOCALISO}" -print -quit )
#echo got local file "${LOCALFILE}"
if [ -f "${DIR}/${FILE}" ]; then
echo "ERROR! File Exists - not copying over local file"
echo "Move it out of the way to replace it with a local file"
exit 1
else
cp -pv "${LOCALFILE}" ${DIR}/${FILE}
# if ! ; then echo ERROR! Failed to copy ${LOCALFILE}" to ${DIR}/${FILE}"
fi
#exit 0 # while testing
fi
case $OS in
windows)
echo "${OS} not (yet?) supported for local isos" ;;
macos)
# echo "${OS} not (yet?) supported for local isos" ;;
if [ -n "${ISODIR}" ]; then
for macfile in RecoveryImage.dmg RecoveryImage.chunklist
do
find "${ISODIR}" -type f -name "${macfile}" -exec cp -pv \{\} "$DIR"/ \;
done
fi;;
*)
if [ -n "${ISODIR}" ]; then
# use supplied filename or default to original distro ISO name
if [ -z "${LOCALISO}" ]; then
LOCALISO=${FILE}
fi
LOCALFILE=$(find "${ISODIR}" -type f -name "${LOCALISO}" -print -quit )
if [ -f "${DIR}/${FILE}" ]; then
echo "ERROR! File Exists - not copying over local file"
echo "Move it out of the way to replace it with a local file"
exit 1
else
cp -pv "${LOCALFILE}" "${DIR}"/"${FILE}"
# if ! ; then echo ERROR! Failed to copy ${LOCALFILE}" to ${DIR}/${FILE}"
fi
fi
esac
}
function web_get() {
@ -572,7 +583,14 @@ function web_get() {
echo "ERROR! Unable to create directory ${DIR}"
exit 1
fi
if [ -n "${LOCALISO}" ] || [ -n "${ISODIR}" ] ; then
copy_local
# you only get one shot
LOCALISO=""
ISODIR=""
fi
if command -v aria2c > /dev/null; then
if ! aria2c -x16 --continue=true --summary-interval=0 --download-result=hide --console-log-level=error "${URL}" -o "${DIR}/${FILE}"; then
@ -613,7 +631,12 @@ function zsync_get() {
exit 1
fi
if [ -n "${LOCALISO}" ] || [ -n "${ISODIR}" ] ; then
copy_local
# you only get one shot
LOCALISO=""
ISODIR=""
fi
if ! zsync "${URL}.zsync" -i "${DIR}/${OUT}" -o "${DIR}/${OUT}" 2>/dev/null; then
echo "ERROR! Failed to download ${URL}.zsync"
@ -634,6 +657,7 @@ function start_vm_info() {
echo "To start your ${OS} ${RELEASE} virtual machine run:"
echo " quickemu --vm ${OS}-${RELEASE}.conf"
echo
exit 0
}
function make_vm_config() {
@ -684,7 +708,7 @@ EOF
echo "fixed_iso=\"${VM_PATH}/${ISO_FILE}\"" >> "${OS}-${RELEASE}.conf"
fi
if [ "${OS}" == "alma" ] && [ ${ISOTYPE} == "dvd" ]; then
if [ "${OS}" == "alma" ] && [ "${ISOTYPE}" == "dvd" ]; then
echo "disk_size=\"32G\"" >> "${OS}-${RELEASE}.conf"
fi
@ -1941,10 +1965,10 @@ languages_windows
# handle parameters
# Take command line arguments
#if [ $# -lt 1 ]; then
# usage
# exit 0
#else
if [ $# -lt 1 ]; then
usage
exit 0
fi
while [ $# -gt 0 ]; do
case "${1}" in
-isodir|--isodir)
@ -1967,10 +1991,11 @@ languages_windows
quickemu_version=$( "${whereIam}"/quickemu --version)
echo "Quickemu Version: ${quickemu_version}"
exit 0;;
test*)
-t|--t|-test|--test)
echo "you are just testing
ISODIR: ${ISODIR}
LOCALISO: ${LOCALISO}"
ls -lh "${ISODIR}/${LOCALISO}"
exit 0;;
*)