From fd424757a64921a60b92837a625a23b8f681130a Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 16 Mar 2017 13:58:31 +1100 Subject: [PATCH] Don't provide dib-run-parts It was an oversight during v2 development for dib to start providing dib-run-parts. The intention was for dib to use a vendored dib-run-parts directly from $_LIB and have no dependencies on dib-utils at all. By exporting dib-run-parts, we created an unintentional conflict with the dib-utils package which provides the same script. Tools that depend on dib-utils are unaffected by this (os-refresh-config). The only tool that installs diskimage-builder and then assumes dib-run-parts is available in the path is instack. I have proposed Ibfe972208df40fa092b11b5419043524c903f1b4 to modify that to use our internal version. Change-Id: I149c345d38d761a49b3a6ccc4833482f09f1cd05 --- diskimage_builder/dib_run_parts.py | 37 ------------------- .../elements/dib-run-parts/README.rst | 5 ++- diskimage_builder/lib/common-functions | 9 ++++- diskimage_builder/lib/dib-run-parts | 0 diskimage_builder/lib/img-functions | 2 + .../notes/dib-run-parts-e18cc3a6c2d66c24.yaml | 9 +++++ setup.cfg | 1 - 7 files changed, 22 insertions(+), 41 deletions(-) delete mode 100644 diskimage_builder/dib_run_parts.py mode change 100644 => 100755 diskimage_builder/lib/dib-run-parts create mode 100644 releasenotes/notes/dib-run-parts-e18cc3a6c2d66c24.yaml diff --git a/diskimage_builder/dib_run_parts.py b/diskimage_builder/dib_run_parts.py deleted file mode 100644 index 77a74e5b..00000000 --- a/diskimage_builder/dib_run_parts.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2016 Ian Wienand (iwienand@redhat.com) -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import os -import os.path -import sys - -import diskimage_builder.paths - - -# simply wrap the dib-run-parts in lib -# -# Note to would-be modifiers : the same dib-run-parts script we are -# calling in "lib" here is actually copied into the chroot's -# /usr/local/bin by the dib-run-parts element, where it is run diretly -# by disk-image-create. Ergo, if you do something clever in here, it -# won't be reflected in the dib-run-parts that actually runs in the -# chroot. It may not always be like this, but it does reduce reliance -# on Python inside the chroot image. -def main(): - environ = os.environ - - script = "%s/%s" % (diskimage_builder.paths.get_path('lib'), - os.path.basename(sys.argv[0])) - - os.execve("/bin/bash", ['bash', script] + sys.argv[1:], environ) diff --git a/diskimage_builder/elements/dib-run-parts/README.rst b/diskimage_builder/elements/dib-run-parts/README.rst index 8c2fa36c..d5e02599 100644 --- a/diskimage_builder/elements/dib-run-parts/README.rst +++ b/diskimage_builder/elements/dib-run-parts/README.rst @@ -4,4 +4,7 @@ dib-run-parts Install ``dib-run-parts`` into the chroot environment - +Currently this element copies the ``dib-run-parts`` used by +diskimage-builder outside the chroot to inside. However, note while +the interface remains the same this element may be provided in future +with a different interface. diff --git a/diskimage_builder/lib/common-functions b/diskimage_builder/lib/common-functions index b1f77058..c33d4724 100644 --- a/diskimage_builder/lib/common-functions +++ b/diskimage_builder/lib/common-functions @@ -14,6 +14,11 @@ # License for the specific language governing permissions and limitations # under the License. +# This is the "internal" verison of dib-run-parts. Note the currently +# this is copied by the dib-run-parts element into the chroot. If you +# modify this, be aware that it needs to run in both contexts. +DIB_RUN_PARTS=${_LIB}/dib-run-parts + function tmpfs_check() { local echo_message=${1:-1} [ "$DIB_NO_TMPFS" == "0" ] || return 1 @@ -223,12 +228,12 @@ function run_d() { if [ -d ${TMP_HOOKS_PATH}/$1.d ] ; then echo "Running hooks from ${TMP_HOOKS_PATH}/$1.d" if [ -n "$2" ]; then - dib-run-parts ${TMP_HOOKS_PATH}/$1.d | tee $2 + ${DIB_RUN_PARTS} ${TMP_HOOKS_PATH}/$1.d | tee $2 if [[ ${PIPESTATUS[0]} != 0 ]]; then return 1 fi else - dib-run-parts ${TMP_HOOKS_PATH}/$1.d + ${DIB_RUN_PARTS} ${TMP_HOOKS_PATH}/$1.d fi fi check_break after-$1 bash diff --git a/diskimage_builder/lib/dib-run-parts b/diskimage_builder/lib/dib-run-parts old mode 100644 new mode 100755 diff --git a/diskimage_builder/lib/img-functions b/diskimage_builder/lib/img-functions index 38f758a5..d7bee24c 100644 --- a/diskimage_builder/lib/img-functions +++ b/diskimage_builder/lib/img-functions @@ -86,6 +86,8 @@ function run_d_in_target () { check_break before-$1 run_in_target bash [ -z "$break_outside_target" ] && in_target_arg="run_in_target" || in_target_arg= trap "check_break after-error $in_target_arg ${break_cmd:-bash}" ERR + # NOTE: this is the dib-run-parts copied into the chroot by the + # dib-run-parts element. run_in_target dib-run-parts /tmp/in_target.d/$1.d trap - ERR check_break after-$1 run_in_target bash diff --git a/releasenotes/notes/dib-run-parts-e18cc3a6c2d66c24.yaml b/releasenotes/notes/dib-run-parts-e18cc3a6c2d66c24.yaml new file mode 100644 index 00000000..63a49fb5 --- /dev/null +++ b/releasenotes/notes/dib-run-parts-e18cc3a6c2d66c24.yaml @@ -0,0 +1,9 @@ +--- +deprecations: + - | + dib no longer exports ``dib-run-parts``. Adding this was an + oversight made during v2 development, since ``dib-utils`` already + provides this. The ``dib-run-parts`` used internally + (``diskimage_builder/lib/dib-run-parts``) is not intended to be + used by external tools. If you require ``dib-run-parts``, you + should install the ``dib-utils`` package. \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 6a42eb0c..2878a1f9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -55,7 +55,6 @@ console_scripts = dib-block-device = diskimage_builder.block_device:main disk-image-create = diskimage_builder.disk_image_create:main ramdisk-image-create = diskimage_builder.disk_image_create:main - dib-run-parts = diskimage_builder.dib_run_parts:main diskimage_builder.block_device.plugin = local_loop = diskimage_builder.block_device.level0.localloop:LocalLoop