97c01e48ed
Currently we have all our elements and library files in a top-level directory and install them into <root>/share/diskimage-builder/[elements|lib] (where root is either / or the root of a virtualenv). The problem with this is that editable/development installs (pip -e) do *not* install data_files. Thus we have no canonical location to look for elements -- leading to the various odd things we do such as a whole bunch of guessing at the top of disk-image-create and having a special test-loader in tests/test_elements.py so we can run python unit tests on those elements that have it. data_files is really the wrong thing to use for what are essentially assets of the program. data_files install works well for things like config-files, init.d files or dropping documentation files. By moving the elements under the diskimage_builder package, we always know where they are relative to where we import from. In fact, pkg_resources has an api for this which we wrap in the new diskimage_builder/paths.py helper [1]. We use this helper to find the correct path in the couple of places we need to find the base-elements dir, and for the paths to import the library shell functions. Elements such as svc-map and pkg-map include python unit-tests, which we do not need tests/test_elements.py to special-case load any more. They just get found automatically by the normal subunit loader. I have a follow-on change (I69ca3d26fede0506a6353c077c69f735c8d84d28) to move disk-image-create to a regular python entry-point. Unfortunately, this has to move to work with setuptools. You'd think a symlink under diskimage_builder/[elements|lib] would work, but it doesn't. [1] this API handles stuff like getting files out of .zip archive modules, which we don't do. Essentially for us it's returning __file__. Change-Id: I5e3e3c97f385b1a4ff2031a161a55b231895df5b
47 lines
1.8 KiB
Bash
Executable file
47 lines
1.8 KiB
Bash
Executable file
#!/bin/bash
|
|
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
|
set -x
|
|
fi
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
# grub2 isn't available on rhel6/centos6; they are setup to use
|
|
# extlinux. skip this
|
|
# you would think we could match on $DISTRO or something else; but
|
|
# we can't because the rhel/centos elements are a bit mixed up;
|
|
# centos-minimal for example sets distro to "centos". so the best
|
|
# check is just for the original "grub-install" script
|
|
if [ -f /sbin/grub-install ]; then
|
|
exit 0
|
|
fi
|
|
|
|
# remove grub2 package. As described in
|
|
# elements/ubuntu/pre-install.d/00-remove-grub; the grub post-kernel
|
|
# install hook will barf if the block device can't be found (as
|
|
# happens in a chroot).
|
|
#
|
|
# XXX : it is not clear this is necessary for fedora/centos7 and it's
|
|
# install hooks. Investigation is required.
|
|
if rpm -q grub2; then
|
|
install-packages -e grub-pc
|
|
fi
|
|
|
|
# now configure things to re-install grub at the end. We don't want
|
|
# to rely on vm/finalise.d/51-bootloader to simply reinstall the
|
|
# package via the package-manager, because at that point (during
|
|
# finalise) the build-time yum-cache has been unmounted (hence the
|
|
# local-cache looks empty) and yum may try to repopulate the
|
|
# local-cache with all the grub2 dependencies. This is slow, and
|
|
# potentially fills up the disk.
|
|
#
|
|
# XXX : At this point, keepcache=0 *should* probably be set for
|
|
# yum/dnf. We have not standarised/documented that this will be done,
|
|
# however. This would *probably* stop dependencies being populated
|
|
# into the cache. We could investigate this, and possibly remove this
|
|
# all together if we standardise some of these behaviours.
|
|
|
|
# So we download the latest grub2 package and setup the install script
|
|
# to just install the single-package, which will be called later by
|
|
# vm/finalise.d/51-bootloader
|
|
install-packages -d /tmp/grub grub-pc
|
|
echo "rpm -i /tmp/grub/*.rpm" > /tmp/grub/install
|