Avoid using env(1) to set values passed to mk-vmimage.sh,
and instead pass the values as arguments to the script, making it easier to run this by hand, without 'make release'. Add usage_vm_base() and usage_vm_image() usage helpers. Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
fadf2a24fe
commit
0bc9be5e74
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/release-vmimage/; revision=272380
@ -317,20 +317,18 @@ install:
|
|||||||
|
|
||||||
vm-base:
|
vm-base:
|
||||||
.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
|
.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
|
||||||
env IMAKE=${IMAKE} WORLDDIR=${WORLDDIR} \
|
env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
|
||||||
VMBASE=${VMBASE}.img VMSIZE=${VMSIZE} \
|
${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET} \
|
||||||
DESTDIR=${.OBJDIR}/${.TARGET} \
|
${VMBASE}.img ${WORLDDIR} ${.OBJDIR}/${.TARGET} ${VMSIZE}
|
||||||
TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
|
|
||||||
${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET}
|
|
||||||
.endif
|
.endif
|
||||||
touch ${.TARGET}
|
touch ${.TARGET}
|
||||||
|
|
||||||
vm-image: vm-base
|
vm-image: vm-base
|
||||||
.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
|
.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
|
||||||
. for FORMAT in ${VMFORMATS}
|
. for FORMAT in ${VMFORMATS}
|
||||||
env FORMAT=${FORMAT} VMIMAGE=${VMBASE}.${FORMAT} VMBASE=${VMBASE}.img \
|
env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
|
||||||
TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
|
${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET} \
|
||||||
${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET}
|
${VMBASE}.img ${FORMAT} ${VMBASE}.${FORMAT}
|
||||||
. endfor
|
. endfor
|
||||||
.endif
|
.endif
|
||||||
touch ${.TARGET}
|
touch ${.TARGET}
|
||||||
|
@ -35,8 +35,25 @@
|
|||||||
PATH="/bin:/usr/bin:/sbin:/usr/sbin"
|
PATH="/bin:/usr/bin:/sbin:/usr/sbin"
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
|
usage_vm_base() {
|
||||||
|
echo -n "$(basename ${0}) vm-base <base image> <source tree>"
|
||||||
|
echo " <dest dir> <disk image size>"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
usage_vm_image() {
|
||||||
|
echo -n "$(basename ${0}) vm-image <base image> <image format>"
|
||||||
|
echo " <output image>"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "$(basename ${0}) <command> <target> [...]"
|
echo "Usage:"
|
||||||
|
echo "$(basename ${0}) [vm-base|vm-image] [...]"
|
||||||
|
echo
|
||||||
|
usage_vm_base
|
||||||
|
echo
|
||||||
|
usage_vm_image
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +73,20 @@ panic() {
|
|||||||
vm_create_baseimage() {
|
vm_create_baseimage() {
|
||||||
# Creates the UFS root filesystem for the virtual machine disk,
|
# Creates the UFS root filesystem for the virtual machine disk,
|
||||||
# written to the formatted disk image with mkimg(1).
|
# written to the formatted disk image with mkimg(1).
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# vm-base <base image> <source tree> <dest dir> <disk image size>
|
||||||
|
|
||||||
|
VMBASE="${1}"
|
||||||
|
WORLDDIR="${2}"
|
||||||
|
DESTDIR="${3}"
|
||||||
|
VMSIZE="${4}"
|
||||||
|
|
||||||
|
if [ -z "${VMBASE}" -o -z "${WORLDDIR}" -o -z "${DESTDIR}" \
|
||||||
|
-o -z "${VMSIZE}" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
mkdir -p ${DESTDIR}
|
mkdir -p ${DESTDIR}
|
||||||
truncate -s ${VMSIZE} ${VMBASE}
|
truncate -s ${VMSIZE} ${VMBASE}
|
||||||
@ -63,7 +94,7 @@ vm_create_baseimage() {
|
|||||||
newfs -j /dev/${mddev}
|
newfs -j /dev/${mddev}
|
||||||
mount /dev/${mddev} ${DESTDIR}
|
mount /dev/${mddev} ${DESTDIR}
|
||||||
cd ${WORLDDIR} && \
|
cd ${WORLDDIR} && \
|
||||||
${IMAKE} DESTDIR=${DESTDIR} \
|
make DESTDIR=${DESTDIR} \
|
||||||
installworld installkernel distribution || \
|
installworld installkernel distribution || \
|
||||||
panic 1 "\n\nCannot install the base system to ${DESTDIR}."
|
panic 1 "\n\nCannot install the base system to ${DESTDIR}."
|
||||||
chroot ${DESTDIR} /usr/bin/newaliases
|
chroot ${DESTDIR} /usr/bin/newaliases
|
||||||
@ -89,6 +120,19 @@ vm_create_baseimage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vm_create_vmdisk() {
|
vm_create_vmdisk() {
|
||||||
|
# Creates the virtual machine disk image from the raw disk image.
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# vm-image <base image> <image format> <output image>"
|
||||||
|
|
||||||
|
VMBASE="${1}"
|
||||||
|
FORMAT="${2}"
|
||||||
|
VMIMAGE="${3}"
|
||||||
|
|
||||||
|
if [ -z "${VMBASE}" -o -z "${FORMAT}" -o -z "${VMIMAGE}" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
mkimg_version=$(mkimg --version 2>/dev/null | awk '{print $2}')
|
mkimg_version=$(mkimg --version 2>/dev/null | awk '{print $2}')
|
||||||
|
|
||||||
# We need mkimg(1) '--version' output, at minimum, to be able to
|
# We need mkimg(1) '--version' output, at minimum, to be able to
|
||||||
@ -124,10 +168,7 @@ vm_create_vmdisk() {
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
cmd="${1}"
|
cmd="${1}"
|
||||||
|
shift 1
|
||||||
if [ -z "${MAKEFLAGS}" ]; then
|
|
||||||
echo "It is probably not safe to run this by hand yet..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
case ${cmd} in
|
case ${cmd} in
|
||||||
vm-base)
|
vm-base)
|
||||||
|
@ -35,8 +35,25 @@
|
|||||||
PATH="/bin:/usr/bin:/sbin:/usr/sbin"
|
PATH="/bin:/usr/bin:/sbin:/usr/sbin"
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
|
usage_vm_base() {
|
||||||
|
echo -n "$(basename ${0}) vm-base <base image> <source tree>"
|
||||||
|
echo " <dest dir> <disk image size>"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
usage_vm_image() {
|
||||||
|
echo -n "$(basename ${0}) vm-image <base image> <image format>"
|
||||||
|
echo " <output image>"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "$(basename ${0}) <command> <target> [...]"
|
echo "Usage:"
|
||||||
|
echo "$(basename ${0}) [vm-base|vm-image] [...]"
|
||||||
|
echo
|
||||||
|
usage_vm_base
|
||||||
|
echo
|
||||||
|
usage_vm_image
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +73,20 @@ panic() {
|
|||||||
vm_create_baseimage() {
|
vm_create_baseimage() {
|
||||||
# Creates the UFS root filesystem for the virtual machine disk,
|
# Creates the UFS root filesystem for the virtual machine disk,
|
||||||
# written to the formatted disk image with mkimg(1).
|
# written to the formatted disk image with mkimg(1).
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# vm-base <base image> <source tree> <dest dir> <disk image size>
|
||||||
|
|
||||||
|
VMBASE="${1}"
|
||||||
|
WORLDDIR="${2}"
|
||||||
|
DESTDIR="${3}"
|
||||||
|
VMSIZE="${4}"
|
||||||
|
|
||||||
|
if [ -z "${VMBASE}" -o -z "${WORLDDIR}" -o -z "${DESTDIR}" \
|
||||||
|
-o -z "${VMSIZE}" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
mkdir -p ${DESTDIR}
|
mkdir -p ${DESTDIR}
|
||||||
truncate -s ${VMSIZE} ${VMBASE}
|
truncate -s ${VMSIZE} ${VMBASE}
|
||||||
@ -63,7 +94,7 @@ vm_create_baseimage() {
|
|||||||
newfs -j /dev/${mddev}
|
newfs -j /dev/${mddev}
|
||||||
mount /dev/${mddev} ${DESTDIR}
|
mount /dev/${mddev} ${DESTDIR}
|
||||||
cd ${WORLDDIR} && \
|
cd ${WORLDDIR} && \
|
||||||
${IMAKE} DESTDIR=${DESTDIR} \
|
make DESTDIR=${DESTDIR} \
|
||||||
installworld installkernel distribution || \
|
installworld installkernel distribution || \
|
||||||
panic 1 "\n\nCannot install the base system to ${DESTDIR}."
|
panic 1 "\n\nCannot install the base system to ${DESTDIR}."
|
||||||
chroot ${DESTDIR} /usr/bin/newaliases
|
chroot ${DESTDIR} /usr/bin/newaliases
|
||||||
@ -89,6 +120,19 @@ vm_create_baseimage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vm_create_vmdisk() {
|
vm_create_vmdisk() {
|
||||||
|
# Creates the virtual machine disk image from the raw disk image.
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# vm-image <base image> <image format> <output image>"
|
||||||
|
|
||||||
|
VMBASE="${1}"
|
||||||
|
FORMAT="${2}"
|
||||||
|
VMIMAGE="${3}"
|
||||||
|
|
||||||
|
if [ -z "${VMBASE}" -o -z "${FORMAT}" -o -z "${VMIMAGE}" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
mkimg_version=$(mkimg --version 2>/dev/null | awk '{print $2}')
|
mkimg_version=$(mkimg --version 2>/dev/null | awk '{print $2}')
|
||||||
|
|
||||||
# We need mkimg(1) '--version' output, at minimum, to be able to
|
# We need mkimg(1) '--version' output, at minimum, to be able to
|
||||||
@ -124,10 +168,7 @@ vm_create_vmdisk() {
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
cmd="${1}"
|
cmd="${1}"
|
||||||
|
shift 1
|
||||||
if [ -z "${MAKEFLAGS}" ]; then
|
|
||||||
echo "It is probably not safe to run this by hand yet..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
case ${cmd} in
|
case ${cmd} in
|
||||||
vm-base)
|
vm-base)
|
||||||
|
Loading…
Reference in New Issue
Block a user