diff options
Diffstat (limited to 'usr.sbin/pc-sysinstall')
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend-query/disk-list.sh | 9 | ||||
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh | 13 | ||||
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions-disk.sh | 1 | ||||
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions-extractimage.sh | 143 | ||||
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions-installpackages.sh | 131 | ||||
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh | 8 | ||||
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions-newfs.sh | 44 | ||||
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions-packages.sh | 137 | ||||
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions-parse.sh | 2 | ||||
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/functions.sh | 6 | ||||
-rwxr-xr-x | usr.sbin/pc-sysinstall/backend/parseconfig.sh | 2 | ||||
-rw-r--r-- | usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf | 8 | ||||
-rw-r--r-- | usr.sbin/pc-sysinstall/examples/README | 11 |
13 files changed, 385 insertions, 130 deletions
diff --git a/usr.sbin/pc-sysinstall/backend-query/disk-list.sh b/usr.sbin/pc-sysinstall/backend-query/disk-list.sh index d390cbb..2616ef9 100755 --- a/usr.sbin/pc-sysinstall/backend-query/disk-list.sh +++ b/usr.sbin/pc-sysinstall/backend-query/disk-list.sh @@ -82,15 +82,10 @@ do esac fi - # Try and find some identification information with camcontrol or atacontrol + # Try and find some identification information with camcontrol NEWLINE=$(camcontrol identify $DEV 2>/dev/null | sed -ne 's/^device model *//p') if [ -z "$NEWLINE" ]; then - # Now try atacontrol - NEWLINE=$(atacontrol list 2>/dev/null | sed -n "s|^.*$DEV <\(.*\)>.*|\1|p") - - if [ -z "$NEWLINE" ]; then - NEWLINE=" <Unknown Device>" - fi + NEWLINE=" <Unknown Device>" fi if [ -n "${FLAGS_MD}" ] && echo "${DEV}" | grep -E '^md[0-9]+' >/dev/null 2>/dev/null diff --git a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh index 0eedfad..37353d7 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh @@ -62,7 +62,18 @@ get_fs_line_xvars() echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null if [ $? -eq 0 ] ; then ZTYPE=`echo $ZFSVARS | cut -f1 -d:` - ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"` + tmpVars=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"` + ZFSVARS="" + # make sure we have a '/dev' in front of the extra devices + for i in $tmpVars + do + echo $i | grep -q '/dev/' + if [ $? -ne 0 ] ; then + ZFSVARS="$ZFSVARS /dev/${i}" + else + ZFSVARS="$ZFSVARS $i" + fi + done fi # Return the ZFS options diff --git a/usr.sbin/pc-sysinstall/backend/functions-disk.sh b/usr.sbin/pc-sysinstall/backend/functions-disk.sh index b1b815d..eac10d9 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-disk.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-disk.sh @@ -33,6 +33,7 @@ is_disk() for _dsk in `sysctl -n kern.disks` do [ "$_dsk" = "${1}" ] && return 0 + [ "/dev/$_dsk" = "${1}" ] && return 0 done return 1 diff --git a/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh b/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh index 5d32466..fd6556d 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh @@ -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 - - INSDIR="${INSFILE}" ; export INSDIR - start_extract_split - else - fetch_install_file - start_extract_uzip_tar - fi + case $PACKAGETYPE in + split) + fetch_split_files + + 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 diff --git a/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh b/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh index 7572efb..c1a879a 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh @@ -76,50 +76,113 @@ fetch_package_dependencies() # Check for any packages specified, and begin loading them install_packages() { + echo "Checking for packages to install..." + sleep 2 + # First, lets check and see if we even have any packages to install get_value_from_cfg installPackages - if [ -n "${VAL}" ] - then - HERE=`pwd` - rc_nohalt "mkdir -p ${FSMNT}/${PKGTMPDIR}" - rc_nohalt "cd ${FSMNT}/${PKGTMPDIR}" - if [ ! -f "${CONFDIR}/INDEX" ] + # Nothing to do? + if [ -z "${VAL}" ]; then return; fi + + echo "Installing packages..." + sleep 3 + + local PKGPTH + + HERE=`pwd` + rc_halt "mkdir -p ${FSMNT}${PKGTMPDIR}" + + # Determine the directory we will install packages from + get_package_location + rc_halt "cd ${PKGDLDIR}" + + # Set the location of the INDEXFILE + INDEXFILE="${TMPDIR}/INDEX" + + if [ ! -f "${INDEXFILE}" ]; then + get_package_index + fi + + if [ ! -f "${TMPDIR}/INDEX.parsed" -a "$INSTALLMEDIUM" = "ftp" ]; then + parse_package_index + fi + + # What extension are we using for pkgs? + PKGEXT="txz" + get_value_from_cfg pkgExt + if [ -n "${VAL}" ]; then + strip_white_space ${VAL} + PKGEXT="$VAL" + fi + export PKGEXT + + # We dont want to be bothered with scripts asking questions + PACKAGE_BUILDING=yes + export PACKAGE_BUILDING + + # Lets start by cleaning up the string and getting it ready to parse + get_value_from_cfg_with_spaces installPackages + PACKAGES="${VAL}" + echo_log "Packages to install: `echo $PACKAGES | wc -w | awk '{print $1}'`" + for i in $PACKAGES + do + if ! get_package_name "${i}" then - get_package_index + echo_log "Unable to locate package ${i}" + continue fi - if [ ! -f "${CONFDIR}/INDEX.parsed" ] - then - parse_package_index + PKGNAME="${VAL}" + + # Fetch package + deps, but skip if installing from local media + if [ "${INSTALLMEDIUM}" = "ftp" ] ; then + DEPFILE="${FSMNT}/${PKGTMPDIR}/.${PKGNAME}.deps" + rc_nohalt "touch ${DEPFILE}" + determine_package_dependencies "${PKGNAME}" "${DEPFILE}" + fetch_package_dependencies "${DEPFILE}" "${FSMNT}/${PKGTMPDIR}" fi - # Lets start by cleaning up the string and getting it ready to parse - strip_white_space ${VAL} - PACKAGES=`echo ${VAL} | sed -e "s|,| |g"` - for i in $PACKAGES - do - if get_package_name "${i}" - then - PKGNAME="${VAL}" - DEPFILE="${FSMNT}/${PKGTMPDIR}/.${PKGNAME}.deps" - - rc_nohalt "touch ${DEPFILE}" - determine_package_dependencies "${PKGNAME}" "${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 - rc_nohalt "pkg_add -C ${FSMNT} ${PKGTMPDIR}/${PKGNAME}.tbz" - fi - - rc_nohalt "rm ${DEPFILE}" + # Set package location + case "${INSTALLMEDIUM}" in + usb|dvd|local) PKGPTH="${PKGTMPDIR}/All/${PKGNAME}" ;; + *) PKGPTH="${PKGTMPDIR}/${PKGNAME}" ;; + esac + + # See if we need to determine the package format we are working with + if [ -z "${PKGINFO}" ] ; then + tar tqf "${FSMNT}${PKGPTH}" '+MANIFEST' >/dev/null 2>/dev/null + if [ $? -ne 0 ] ; then + PKGADD="pkg_add -C ${FSMNT}" + PKGINFO="pkg_info" + else + PKGADD="pkg -c ${FSMNT} add" + PKGINFO="pkg info" + bootstrap_pkgng fi + fi - rc_nohalt "cd ${HERE}" - done + # If the package is not already installed, install it! + if ! run_chroot_cmd "${PKGINFO} -e ${PKGNAME}" >/dev/null 2>/dev/null + then + echo_log "Installing package: ${PKGNAME}" + rc_nohalt "${PKGADD} ${PKGPTH}" + fi + + if [ "${INSTALLMEDIUM}" = "ftp" ] ; then + rc_nohalt "rm ${DEPFILE}" + fi + + done + + echo_log "Package installation complete!" - rm -rf "${FSMNT}/${PKGTMPDIR}" + # Cleanup after ourselves + rc_halt "cd ${HERE}" + if [ "${INSTALLMEDIUM}" = "ftp" ] ; then + rc_halt "rm -rf ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null + else + rc_halt "umount ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null + rc_halt "rmdir ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null fi }; diff --git a/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh b/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh index c90c058..e9eb148 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh @@ -149,12 +149,12 @@ mount_all_filesystems() for PART in `ls ${PARTDIR}` do PARTDEV=`echo $PART | sed 's|-|/|g'` - if [ ! -e "${PARTDEV}" ] + PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" + if [ ! -e "${PARTDEV}" -a "${PARTFS}" != "ZFS" ] then exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?" fi - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`" @@ -186,12 +186,12 @@ mount_all_filesystems() for PART in `ls ${PARTDIR}` do PARTDEV=`echo $PART | sed 's|-|/|g'` - if [ ! -e "${PARTDEV}" ] + PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" + if [ ! -e "${PARTDEV}" -a "${PARTFS}" != "ZFS" ] then exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?" fi - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`" diff --git a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh index 2ab4a83..f8664f0 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh @@ -60,18 +60,56 @@ setup_zfs_filesystem() fi done - # Check if we have some custom zpool arguments and use them if so if [ ! -z "${ZPOOLOPTS}" ] ; then - rc_halt "zpool create -m none -f ${ZPOOLNAME} ${ZPOOLOPTS}" + # Sort through devices and run gnop on them + local gnopDev="" + local newOpts="" + for i in $ZPOOLOPTS + do + echo "$i" | grep -q '/dev/' + if [ $? -eq 0 ] ; then + rc_halt "gnop create -S 4096 ${i}" + gnopDev="$gnopDev $i" + newOpts="$newOpts ${i}.nop" + else + newOpts="$newOpts $i" + fi + done + + echo_log "Creating zpool ${ZPOOLNAME} with $newOpts" + rc_halt "zpool create -m none -f ${ZPOOLNAME} ${newOpts}" + + # Export the pool + rc_halt "zpool export ${ZPOOLNAME}" + + # Destroy the gnop devices + for i in $gnopDev + do + rc_halt "gnop destroy ${i}.nop" + done + + # And lastly re-import the pool + rc_halt "zpool import ${ZPOOLNAME}" else + # Lets do our pseudo-4k drive + rc_halt "gnop create -S 4096 ${PART}${EXT}" + # No zpool options, create pool on single device - rc_halt "zpool create -m none -f ${ZPOOLNAME} ${PART}${EXT}" + echo_log "Creating zpool ${ZPOOLNAME} on ${PART}${EXT}" + rc_halt "zpool create -m none -f ${ZPOOLNAME} ${PART}${EXT}.nop" + + # Finish up the gnop 4k trickery + rc_halt "zpool export ${ZPOOLNAME}" + rc_halt "gnop destroy ${PART}${EXT}.nop" + rc_halt "zpool import ${ZPOOLNAME}" fi # Disable atime for this zfs partition, speed increase rc_nohalt "zfs set atime=off ${ZPOOLNAME}" + + }; # Runs newfs on all the partiions which we've setup with bsdlabel diff --git a/usr.sbin/pc-sysinstall/backend/functions-packages.sh b/usr.sbin/pc-sysinstall/backend/functions-packages.sh index c426778..ee41928 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-packages.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-packages.sh @@ -45,9 +45,11 @@ get_package_index_by_ftp() then INDEX_FILE="${INDEX_FILE}.bz2" USE_BZIP2=1 + INDEX_PATH="${INDEXFILE}.bz2" + else + INDEX_PATH="${INDEXFILE}" fi - INDEX_PATH="${CONFDIR}/${INDEX_FILE}" fetch_file "${FTP_SERVER}/${INDEX_FILE}" "${INDEX_PATH}" "1" if [ -f "${INDEX_PATH}" ] && [ "${USE_BZIP2}" -eq "1" ] then @@ -57,17 +59,18 @@ get_package_index_by_ftp() get_package_index_by_fs() { - local INDEX_FILE - - INDEX_FILE="${CDMNT}/packages/INDEX" - fetch_file "${INDEX_FILE}" "${CONFDIR}/" "0" + if [ "$INSTALLMEDIUM" = "local" ] ; then + INDEXFILE="${LOCALPATH}/packages/INDEX" + else + INDEXFILE="${CDMNT}/packages/INDEX" + fi }; get_package_index_size() { - if [ -f "${CONFDIR}/INDEX" ] + if [ -f "${INDEXFILE}" ] then - SIZE=`ls -l ${CONFDIR}/INDEX | awk '{ print $5 }'` + SIZE=`ls -l ${INDEXFILE} | awk '{ print $5 }'` else get_ftp_mirror FTPHOST="${VAL}" @@ -94,28 +97,24 @@ get_package_index() 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}" ;; - sftp) ;; - *) RES=1 ;; + usb|dvd|local) get_package_index_by_fs ;; + ftp) 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}" + get_package_index_by_ftp "${FTPPATH}" ;; + sftp) ;; + *) RES=1 ;; esac fi @@ -125,10 +124,11 @@ get_package_index() parse_package_index() { + echo_log "Building package dep list.. Please wait.." INDEX_FILE="${PKGDIR}/INDEX" exec 3<&0 - exec 0<"${INDEX_FILE}" + exec 0<"${INDEXFILE}" while read -r line do @@ -257,20 +257,38 @@ get_package_name() { PACKAGE="${1}" RES=0 + local PKGPTH - INDEX_FILE="${PKGDIR}/INDEX.deps" - REGEX="^${PACKAGE}|" + # If we are on a local medium, we can parse the Latest/ directory + if [ "${INSTALLMEDIUM}" != "ftp" ] ; then + case "${INSTALLMEDIUM}" in + usb|dvd) PKGPTH="${CDMNT}/packages" ;; + *) PKGPTH="${LOCALPATH}/packages" ;; + esac + + # Check the /Latest dir for generic names, then look for specific version in All/ + if [ -e "${PKGPTH}/Latest/${PACKAGE}.${PKGEXT}" ] ; then + NAME=`ls -al ${PKGPTH}/Latest/${PACKAGE}.${PKGEXT} 2>/dev/null | cut -d '>' -f 2 | rev | cut -f1 -d'/' | rev | tr -s ' '` + else + NAME=`ls -al ${PKGPTH}/All/${PACKAGE}.${PKGEXT} 2>/dev/null | cut -d '>' -f 2 | rev | cut -f1 -d'/' | rev | tr -s ' '` + fi + export VAL="${NAME}" + else + # Doing remote fetch, we we will look up, but some generic names like + # "perl" wont work, since we don't know the default version + INDEX_FILE="${PKGDIR}/INDEX.deps" + REGEX="^${PACKAGE}|" - LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null` - NAME=`echo "${LINE}"|cut -f2 -d'|'` + LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null` + NAME=`echo "${LINE}"|cut -f2 -d'|'` - export VAL="${NAME}" + export VAL="${NAME}" + fi if [ -z "${VAL}" ] then RES=1 fi - return ${RES} }; @@ -334,7 +352,7 @@ fetch_package_by_ftp() fi FTPDIR="${VAL}" - PACKAGE="${PACKAGE}.tbz" + PACKAGE="${PACKAGE}.${PKGEXT}" FTP_SERVER="ftp://${FTPHOST}${FTPDIR}" if [ ! -f "${SAVEDIR}/${PACKAGE}" ] @@ -345,28 +363,49 @@ fetch_package_by_ftp() 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}" + # Fetch package, but skip if installing from local media case "${INSTALLMEDIUM}" in - usb|dvd) fetch_package_by_fs "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;; + usb|dvd|local) return ;; ftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;; sftp) ;; esac }; + +bootstrap_pkgng() +{ + # Check if we need to boot-strap pkgng + if run_chroot_cmd "which pkg-static" >/dev/null 2>/dev/null + then + return + fi + local PKGPTH + + # Ok, lets boot-strap this sucker + echo_log "Bootstraping pkgng.." + fetch_package "Latest" "pkg" "${PKGDLDIR}" + + # Figure out real location of "pkg" package + case "${INSTALLMEDIUM}" in + usb|dvd|local) PKGPTH="${PKGTMPDIR}/Latest/pkg.${PKGEXT}" ;; + *) PKGPTH="${PKGTMPDIR}/pkg.${PKGEXT}" ;; + esac + rc_halt "pkg -c ${FSMNT} add ${PKGPTH}" ; run_chroot_cmd "pkg2ng" +} + +get_package_location() +{ + case "${INSTALLMEDIUM}" in + usb|dvd) rc_halt "mount_nullfs ${CDMNT}/packages ${FSMNT}${PKGTMPDIR}" + PKGDLDIR="${FSMNT}${PKGTMPDIR}/All" ;; + local) rc_halt "mount_nullfs ${LOCALPATH}/packages ${FSMNT}${PKGTMPDIR}" + PKGDLDIR="${FSMNT}${PKGTMPDIR}/All" ;; + *) PKGDLDIR="${FSMNT}${PKGTMPDIR}" ;; + esac + export PKGDLDIR +} diff --git a/usr.sbin/pc-sysinstall/backend/functions-parse.sh b/usr.sbin/pc-sysinstall/backend/functions-parse.sh index ed0a3e6..fb7cdd2 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-parse.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-parse.sh @@ -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 diff --git a/usr.sbin/pc-sysinstall/backend/functions.sh b/usr.sbin/pc-sysinstall/backend/functions.sh index 33d0005..a2d039b 100755 --- a/usr.sbin/pc-sysinstall/backend/functions.sh +++ b/usr.sbin/pc-sysinstall/backend/functions.sh @@ -277,7 +277,11 @@ get_zpool_name() while : do NEWNAME="${BASENAME}${NUM}" - zpool import | grep -qw "${NEWNAME}" || break + zpool list | grep -qw "${NEWNAME}" + local chk1=$? + zpool import | grep -qw "${NEWNAME}" + local chk2=$? + if [ $chk1 -eq 1 -a $chk2 -eq 1 ] ; then break ; fi NUM=$((NUM+1)) done diff --git a/usr.sbin/pc-sysinstall/backend/parseconfig.sh b/usr.sbin/pc-sysinstall/backend/parseconfig.sh index c852cea..f3d89fc 100755 --- a/usr.sbin/pc-sysinstall/backend/parseconfig.sh +++ b/usr.sbin/pc-sysinstall/backend/parseconfig.sh @@ -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 diff --git a/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf b/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf index 5d682dc..9c01e31 100644 --- a/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf +++ b/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf @@ -5,11 +5,9 @@ TMPDIR="/tmp/.pc-sysinstall" export TMPDIR -if [ ! -d "${TMPDIR}" ] -then - mkdir -p ${TMPDIR} - chmod 777 ${TMPDIR} -fi +# Create a fresh TMPDIR +if [ -d "${TMPDIR}" -a "$TMPDIR" != '/' ]; then rm -rf ${TMPDIR}; fi +mkdir -p ${TMPDIR} # Set our temp directory for storing partition information PARTDIR="${TMPDIR}/part-info" diff --git a/usr.sbin/pc-sysinstall/examples/README b/usr.sbin/pc-sysinstall/examples/README index cc269a2..1e8d32d 100644 --- a/usr.sbin/pc-sysinstall/examples/README +++ b/usr.sbin/pc-sysinstall/examples/README @@ -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 |