Remove dib-block-device console entrypoint

This is never called externally to dib, so doesn't need to be an
entrypoint.  Call it from within dib using the running python
executable and from the lib/ directory; this means we do not need to
have the virtualenv activated to run disk-image-create.

Change-Id: Ie9b551824792864402b0c63ccc350dc5c92dcc3f
This commit is contained in:
Ian Wienand 2020-11-09 16:43:19 +11:00
parent 6f73e123d0
commit 8a12243517
4 changed files with 25 additions and 17 deletions

View File

@ -0,0 +1,7 @@
import sys
from diskimage_builder.block_device.cmd import main
if __name__ == "__main__":
sys.exit(main())

View File

@ -41,6 +41,8 @@ diskimage_builder.paths.show_path("elements")')
source $_LIB/die source $_LIB/die
DIB_BLOCK_DEVICE="${DIB_PYTHON_EXEC} ${_LIB}/dib-block-device.py"
IS_RAMDISK=0 IS_RAMDISK=0
if [ "$SCRIPTNAME" == "ramdisk-image-create" ]; then if [ "$SCRIPTNAME" == "ramdisk-image-create" ]; then
IS_RAMDISK=1 IS_RAMDISK=1
@ -330,19 +332,19 @@ mount-base: ${TMP_BUILD_DIR}/mnt
build-dir: ${TMP_BUILD_DIR} build-dir: ${TMP_BUILD_DIR}
EOF EOF
dib-block-device init ${DIB_BLOCK_DEVICE} init
# Need to get the real root label because it can be overwritten # Need to get the real root label because it can be overwritten
# by the BLOCK_DEVICE_CONFIG. # by the BLOCK_DEVICE_CONFIG.
DIB_ROOT_LABEL=$(dib-block-device getval root-label) DIB_ROOT_LABEL=$(${DIB_BLOCK_DEVICE} getval root-label)
export DIB_ROOT_LABEL export DIB_ROOT_LABEL
# Need to get the real fs type for the root filesystem # Need to get the real fs type for the root filesystem
DIB_ROOT_FSTYPE=$(dib-block-device getval root-fstype) DIB_ROOT_FSTYPE=$(${DIB_BLOCK_DEVICE} getval root-fstype)
export DIB_ROOT_FSTYPE export DIB_ROOT_FSTYPE
# retrieve mount points so we can reuse in elements # retrieve mount points so we can reuse in elements
DIB_MOUNTPOINTS=$(dib-block-device getval mount-points) DIB_MOUNTPOINTS=$(${DIB_BLOCK_DEVICE} getval mount-points)
export DIB_MOUNTPOINTS export DIB_MOUNTPOINTS
create_base create_base
@ -501,33 +503,33 @@ if [ -z ${IMAGE_BLOCK_DEVICE} ] ; then
fi fi
# After changeing the parameters, there is the need to # After changeing the parameters, there is the need to
# re-run dib-block-device init because some value might # re-run ${DIB_BLOCK_DEVICE} init because some value might
# change based on the new set parameters. # change based on the new set parameters.
dib-block-device init ${DIB_BLOCK_DEVICE} init
# values to dib-block-device: using the YAML config and # values to ${DIB_BLOCK_DEVICE}: using the YAML config and
dib-block-device create ${DIB_BLOCK_DEVICE} create
# This is the device (/dev/loopX). It's where to install the # This is the device (/dev/loopX). It's where to install the
# bootloader. # bootloader.
IMAGE_BLOCK_DEVICE=$(dib-block-device getval image-block-device) IMAGE_BLOCK_DEVICE=$(${DIB_BLOCK_DEVICE} getval image-block-device)
export IMAGE_BLOCK_DEVICE export IMAGE_BLOCK_DEVICE
# Similar to above, but all mounted devices. This is handy for # Similar to above, but all mounted devices. This is handy for
# some bootloaders that have multi-partition layouts and want to # some bootloaders that have multi-partition layouts and want to
# copy things to different places other than just # copy things to different places other than just
# IMAGE_BLOCK_DEVICE. "eval" this into an array as needed # IMAGE_BLOCK_DEVICE. "eval" this into an array as needed
IMAGE_BLOCK_DEVICES=$(dib-block-device getval image-block-devices) IMAGE_BLOCK_DEVICES=$(${DIB_BLOCK_DEVICE} getval image-block-devices)
export IMAGE_BLOCK_DEVICES export IMAGE_BLOCK_DEVICES
# Write the fstab # Write the fstab
dib-block-device writefstab ${DIB_BLOCK_DEVICE} writefstab
fi fi
# XXX: needed? # XXX: needed?
LOOPDEV=${IMAGE_BLOCK_DEVICE} LOOPDEV=${IMAGE_BLOCK_DEVICE}
# At this point, dib-block-device has created the raw image file # At this point, ${DIB_BLOCK_DEVICE} has created the raw image file
# (IMAGE_BLOCK_DEVICE) and mounted all the partitions under # (IMAGE_BLOCK_DEVICE) and mounted all the partitions under
# $TMP_BUILD_DIR/mnt for us. We can now copy into the final image. # $TMP_BUILD_DIR/mnt for us. We can now copy into the final image.
@ -582,12 +584,12 @@ done
export EXTRA_UNMOUNT="" export EXTRA_UNMOUNT=""
unmount_image unmount_image
TMP_IMAGE_PATH=$(dib-block-device getval image-path) TMP_IMAGE_PATH=$(${DIB_BLOCK_DEVICE} getval image-path)
export TMP_IMAGE_PATH export TMP_IMAGE_PATH
# remove all mounts # remove all mounts
dib-block-device umount ${DIB_BLOCK_DEVICE} umount
dib-block-device cleanup ${DIB_BLOCK_DEVICE} cleanup
cleanup_build_dir cleanup_build_dir

View File

@ -40,7 +40,7 @@ function trap_cleanup() {
function cleanup () { function cleanup () {
unmount_image unmount_image
dib-block-device umount ${DIB_PYTHON_EXEC} ${_LIB}/dib-block-device.py umount
cleanup_build_dir cleanup_build_dir
cleanup_image_dir cleanup_image_dir
} }

View File

@ -32,7 +32,6 @@ data_files =
[entry_points] [entry_points]
console_scripts = console_scripts =
dib-block-device = diskimage_builder.block_device.cmd:main
disk-image-create = diskimage_builder.disk_image_create:main disk-image-create = diskimage_builder.disk_image_create:main
ramdisk-image-create = diskimage_builder.disk_image_create:main ramdisk-image-create = diskimage_builder.disk_image_create:main