Skip to content

Commit

Permalink
Modifications to speed up jail creation time
Browse files Browse the repository at this point in the history
- Use on image distfiles and packages if they exist

- Cache distfiles and packages if they get downloaded on a per
release/architecture basis

- Use overall progress based on total number of files installed
  • Loading branch information
John Hixson committed Jun 20, 2013
1 parent 1346f8e commit 96e87d9
Show file tree
Hide file tree
Showing 2 changed files with 253 additions and 172 deletions.
64 changes: 30 additions & 34 deletions src/pcbsd/warden/scripts/backend/createtemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@ PROGDIR="/usr/local/share/warden"
### Download the template files
download_template_files() {

local i
local percent
local total
local pmax
local ddir

total=`echo ${DFILES}|wc|awk '{ print $2 }'`

if [ "${TPLUGJAIL}" = "YES" ] ; then
pmax=10
elif [ "${VANILLA}" = "YES" ] ; then
pmax=100
else
pmax=30
fi

# Create the download directory
if [ -d "${JDIR}/.download" ] ; then rm -rf ${JDIR}/.download; fi
mkdir ${JDIR}/.download
Expand Down Expand Up @@ -66,7 +50,6 @@ download_template_files() {
return
fi

i=0
for f in $DFILES
do
warden_print get_freebsd_file "${FBSDARCH}/${FBSDVER}/${f}" "${JDIR}/.download/$f"
Expand All @@ -82,11 +65,7 @@ download_template_files() {
mv "${JDIR}/.download/${f}" "${DISTFILESDIR}/${f}"
sha256 -q "${DISTFILESDIR}/${f}" > "${DISTFILESDIR}/${f}.sha256"
fi

: $(( i += 1 ))

percent=`echo "scale=2;(${i}/${total})*${pmax}"|bc|cut -f1 -d.`
warden_print "===== ${percent}% ====="
show_progress
done
fi
}
Expand Down Expand Up @@ -281,33 +260,31 @@ fi

# Set the template directory
TDIR="${JDIR}/.warden-template-$TNICK"
FDIR="${JDIR}/.warden-files-cache"
export TDIR FDIR
export TDIR

DISTFILES="distfiles/${FBSDVER}/${FBSDARCH}"
PACKAGES="packages/${FBSDVER}/${FBSDARCH}"

DISTFILESDIR="${FDIR}/${DISTFILES}"
PACKAGESDIR="${FDIR}/${PACKAGES}"
DISTFILESDIR="${CACHEDIR}/${DISTFILES}"
PACKAGESDIR="${CACHEDIR}/${PACKAGES}"
export DISTFILESDIR PACKAGESDIR


if [ ! -d "${FDIR}" ]
if [ ! -d "${CACHEDIR}" ]
then
mkdir -p "${DISTFILESDIR}"
mkdir -p "${PACKAGESDIR}"
fi

if [ -d "/var/db/warden/${DISTFILES}" ] ; then
diff -urN /var/db/warden/${DISTFILES}/ "${DISTFILESDIR}/" >/dev/null 2>&1
if [ -d "${PROGDIR}/${DISTFILES}" ] ; then
diff -urN ${PROGDIR}/${DISTFILES}/ "${DISTFILESDIR}/" >/dev/null 2>&1
if [ "$?" != "0" ] ; then
cp /var/db/warden/${DISTFILES}/* "${DISTFILESDIR}/"
cp ${PROGDIR}/${DISTFILES}/* "${DISTFILESDIR}/"
fi
fi
if [ -d "/var/db/warden/${PACKAGES}" ] ; then
diff -urN /var/db/warden/${PACKAGES}/ "${PACKAGESDIR}/" >/dev/null 2>&1
if [ -d "${PROGDIR}/${PACKAGES}" ] ; then
diff -urN ${PROGDIR}/${PACKAGES}/ "${PACKAGESDIR}/" >/dev/null 2>&1
if [ "$?" != "0" ] ; then
cp /var/db/warden/${PACKAGES}/* "${PACKAGESDIR}/"
cp ${PROGDIR}/${PACKAGES}/* "${PACKAGESDIR}/"
fi
fi

Expand All @@ -330,6 +307,25 @@ if [ "$FBSDARCH" = "amd64" ] ; then
DFILES="$DFILES lib32.txz"
fi

TOTAL_INSTALL_FILES=$(echo $DFILES|wc|awk '{ print $2 }')

if [ "${VANILLA}" != "NO" ] ; then
n="$(wc -l ${PROGDIR}/pcbsd-utils-packages|awk '{ print $1 }')"
: $(( TOTAL_INSTALL_FILES += n ))
fi

if [ "${TPLUGJAIL}" = "YES" ] ; then
n="$(wc -l ${PROGDIR}/pluginjail-packages|awk '{ print $1 }')"
: $(( TOTAL_INSTALL_FILES += n ))
fi

# pkg.txz and repo.txz
if [ "${VANILLA}" != "NO" -o "${TPLUGJAIL}" = "YES" ] ; then
: $(( TOTAL_INSTALL_FILES += 2 ))
fi

export TOTAL_INSTALL_FILES

# Check if we are on REAL old versions of FreeBSD
if [ -n "$FBSDVER" ] ; then
mV=`echo $FBSDVER | cut -d '.' -f 1`
Expand Down
Loading

0 comments on commit 96e87d9

Please sign in to comment.