Move the dpkg specific stuff to a dpkg element rather than being hardcoded.
This includes the install-packages implementation for dpkg, apt http proxy config, daemon blocking and unblocking. Change-Id: I8f159021d2b223d7003cec067de3aa605ad06974
This commit is contained in:
parent
3860af4be5
commit
7f77729ec5
14
README.md
14
README.md
@ -91,9 +91,17 @@ part of the process you need to customise:
|
||||
alternative distribution support is added, or customisations such as
|
||||
building on an existing image. If no element configures a root, the ubuntu
|
||||
element will be automatically invoked to obtain an Ubuntu image.
|
||||
Runs outside the chroot on the host environment, so should cleanup after
|
||||
itself using the root-finished.d hook.
|
||||
NB: Only one element can use this at a time.
|
||||
Runs outside the chroot on the host environment.
|
||||
|
||||
Only one element can use this at a time unless particular care is taken not
|
||||
to blindly overwrite but instead to adapt the context extracted by other
|
||||
elements.
|
||||
|
||||
* inputs: $ARCH=i386|amd64 $TARGET\_ROOT=/path/to/target/workarea
|
||||
|
||||
* cleanup.d: Perform cleanups of the root filesystem content. For instance,
|
||||
temporary settings to use the image build environment HTTP proxy are removed
|
||||
here in the dpkg element. Runs outside the chroot on the host environment.
|
||||
|
||||
* inputs: $ARCH=i386|amd64 $TARGET\_ROOT=/path/to/target/workarea
|
||||
|
||||
|
@ -109,9 +109,11 @@ mount_tmp_image ${IMAGE_BLOCK_DEVICE}
|
||||
|
||||
create_base
|
||||
run_d extra-data
|
||||
do_pre_install
|
||||
# Run pre-install scripts. These do things that prepare the chroot for package installs
|
||||
run_d_in_target pre-install
|
||||
do_extra_package_install
|
||||
do_install
|
||||
# Call install scripts to pull in the software users want.
|
||||
run_d_in_target install
|
||||
prepare_first_boot
|
||||
finalise_base
|
||||
unmount_image
|
||||
|
@ -3,6 +3,14 @@
|
||||
|
||||
set -e
|
||||
|
||||
apt-get -y update
|
||||
install-packages python-software-properties
|
||||
add-apt-repository -y ppa:tripleo/demo
|
||||
DISTRO=`lsb_release -si`
|
||||
|
||||
case $DISTRO in
|
||||
'Ubuntu'|'Debian')
|
||||
# Note: add-apt-repository would be nice for RPM platforms too - so when we
|
||||
# need something like it, create a wrapper in dpkg/bin and fedora/bin.
|
||||
apt-get -y update
|
||||
install-packages python-software-properties
|
||||
add-apt-repository -y ppa:tripleo/demo
|
||||
;;
|
||||
esac
|
||||
|
8
elements/dpkg/README.md
Normal file
8
elements/dpkg/README.md
Normal file
@ -0,0 +1,8 @@
|
||||
Provide dpkg specific image building glue.
|
||||
|
||||
The ubuntu element needs customisations at the start and end of the image build
|
||||
process that do not apply to RPM distributions, such as using the host machine
|
||||
HTTP proxy when installing packages. These customisations live here, where they
|
||||
can be used by any dpkg based element.
|
||||
|
||||
The dpkg specific version of install-packages is also kept here.
|
11
elements/dpkg/cleanup.d/40-unblock-daemons
Executable file
11
elements/dpkg/cleanup.d/40-unblock-daemons
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
[ -n "$TARGET_ROOT" ]
|
||||
|
||||
sudo mv $TARGET_ROOT/sbin/start-stop-daemon.REAL $TARGET_ROOT/sbin/start-stop-daemon
|
||||
sudo mv $TARGET_ROOT/sbin/initctl.REAL $TARGET_ROOT/sbin/initctl
|
||||
sudo mv $TARGET_ROOT/usr/sbin/invoke-rc.d.REAL $TARGET_ROOT/usr/sbin/invoke-rc.d
|
||||
|
||||
|
8
elements/dpkg/cleanup.d/50-remove-img-build-proxy
Executable file
8
elements/dpkg/cleanup.d/50-remove-img-build-proxy
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
[ -n "$TARGET_ROOT" ]
|
||||
|
||||
# Undo our proxy support
|
||||
sudo rm -f $TARGET_ROOT/etc/apt/apt.conf.d/60img-build-proxy
|
12
elements/dpkg/root.d/50-build-with-http-cache
Executable file
12
elements/dpkg/root.d/50-build-with-http-cache
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
[ -n "$TARGET_ROOT" ]
|
||||
|
||||
# If we have a network proxy, use it.
|
||||
if [ -n "$http_proxy" ] ; then
|
||||
sudo dd of=$TARGET_ROOT/etc/apt/apt.conf.d/60img-build-proxy << _EOF_
|
||||
Acquire::http::Proxy "$http_proxy";
|
||||
_EOF_
|
||||
fi
|
13
elements/dpkg/root.d/60-block-apt-translations
Executable file
13
elements/dpkg/root.d/60-block-apt-translations
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
[ -n "$TARGET_ROOT" ]
|
||||
|
||||
# Configure APT not to fetch translations files
|
||||
sudo dd of=$TARGET_ROOT/etc/apt/apt.conf.d/95no-translations <<EOF
|
||||
APT::Acquire::Languages "none";
|
||||
EOF
|
||||
|
||||
# And now make sure that we don't fall foul of Debian bug 641967
|
||||
find $TARGET_ROOT/var/lib/apt/lists/ -type f -name '*_i18n_Translation-*' -exec sudo rm -f {} \;
|
30
elements/dpkg/root.d/99-block-daemons
Executable file
30
elements/dpkg/root.d/99-block-daemons
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
[ -n "$TARGET_ROOT" ]
|
||||
|
||||
# Prevent package installs from starting daemons
|
||||
sudo mv $TARGET_ROOT/sbin/start-stop-daemon $TARGET_ROOT/sbin/start-stop-daemon.REAL
|
||||
sudo dd of=$TARGET_ROOT/sbin/start-stop-daemon <<EOF
|
||||
#!/bin/sh
|
||||
echo
|
||||
echo "Warning: Fake start-stop-daemon called, doing nothing"
|
||||
EOF
|
||||
sudo chmod 755 $TARGET_ROOT/sbin/start-stop-daemon
|
||||
|
||||
sudo mv $TARGET_ROOT/sbin/initctl $TARGET_ROOT/sbin/initctl.REAL
|
||||
sudo dd of=$TARGET_ROOT/sbin/initctl <<EOF
|
||||
#!/bin/sh
|
||||
echo "initctl (tripleo 1.0)"
|
||||
echo "Warning: Fake initctl called, doing nothing"
|
||||
EOF
|
||||
sudo chmod 755 $TARGET_ROOT/sbin/initctl
|
||||
|
||||
sudo mv $TARGET_ROOT/usr/sbin/invoke-rc.d $TARGET_ROOT/usr/sbin/invoke-rc.d.REAL
|
||||
sudo dd of=$TARGET_ROOT/usr/sbin/invoke-rc.d <<EOF
|
||||
#!/bin/sh
|
||||
echo "invoke-rc.d (tripleo 1.0)"
|
||||
echo "Warning: Fake inovke-rc.d called, doing nothing"
|
||||
EOF
|
||||
sudo chmod 755 $TARGET_ROOT/usr/sbin/invoke-rc.d
|
1
elements/ubuntu/element-deps
Normal file
1
elements/ubuntu/element-deps
Normal file
@ -0,0 +1 @@
|
||||
dpkg
|
@ -98,12 +98,6 @@ function create_base () {
|
||||
sudo mount --bind /dev $TMP_MOUNT_PATH/dev
|
||||
sudo mount -t sysfs none $TMP_MOUNT_PATH/sys
|
||||
|
||||
# If we have a network proxy, use it.
|
||||
if [ -n "$http_proxy" ] ; then
|
||||
sudo dd of=$TMP_MOUNT_PATH/etc/apt/apt.conf.d/60img-build-proxy << _EOF_
|
||||
Acquire::http::Proxy "$http_proxy";
|
||||
_EOF_
|
||||
fi
|
||||
}
|
||||
|
||||
# Helper function to run a command inside the chroot
|
||||
@ -160,8 +154,7 @@ EOF
|
||||
}
|
||||
|
||||
function finalise_base () {
|
||||
# Undo our proxy support
|
||||
sudo rm -f $TMP_MOUNT_PATH/etc/apt/apt.conf.d/60img-build-proxy
|
||||
TARGET_ROOT=$TMP_MOUNT_PATH run_d cleanup
|
||||
# Now remove the resolv.conf we created above
|
||||
sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf
|
||||
# The we need to recreate it as a link
|
||||
@ -175,62 +168,6 @@ function compress_image () {
|
||||
mv $TMP_IMAGE_PATH-new $TMP_IMAGE_PATH
|
||||
}
|
||||
|
||||
function block_apt_translations () {
|
||||
# Configure APT not to fetch translations files
|
||||
sudo dd of=$TMP_MOUNT_PATH/etc/apt/apt.conf.d/95no-translations <<EOF
|
||||
APT::Acquire::Languages "none";
|
||||
EOF
|
||||
|
||||
# And now make sure that we don't fall foul of Debian bug 641967
|
||||
find $TMP_MOUNT_PATH/var/lib/apt/lists/ -type f -name '*_i18n_Translation-*' -exec sudo rm -f {} \;
|
||||
}
|
||||
|
||||
function block_daemons () {
|
||||
# Prevent package installs from starting daemons
|
||||
sudo mv $TMP_MOUNT_PATH/sbin/start-stop-daemon $TMP_MOUNT_PATH/sbin/start-stop-daemon.REAL
|
||||
sudo dd of=$TMP_MOUNT_PATH/sbin/start-stop-daemon <<EOF
|
||||
#!/bin/sh
|
||||
echo
|
||||
echo "Warning: Fake start-stop-daemon called, doing nothing"
|
||||
EOF
|
||||
sudo chmod 755 $TMP_MOUNT_PATH/sbin/start-stop-daemon
|
||||
|
||||
sudo mv $TMP_MOUNT_PATH/sbin/initctl $TMP_MOUNT_PATH/sbin/initctl.REAL
|
||||
sudo dd of=$TMP_MOUNT_PATH/sbin/initctl <<EOF
|
||||
#!/bin/sh
|
||||
echo "initctl (tripleo 1.0)"
|
||||
echo "Warning: Fake initctl called, doing nothing"
|
||||
EOF
|
||||
sudo chmod 755 $TMP_MOUNT_PATH/sbin/initctl
|
||||
|
||||
sudo mv $TMP_MOUNT_PATH/usr/sbin/invoke-rc.d $TMP_MOUNT_PATH/usr/sbin/invoke-rc.d.REAL
|
||||
sudo dd of=$TMP_MOUNT_PATH/usr/sbin/invoke-rc.d <<EOF
|
||||
#!/bin/sh
|
||||
echo "invoke-rc.d (tripleo 1.0)"
|
||||
echo "Warning: Fake inovke-rc.d called, doing nothing"
|
||||
EOF
|
||||
sudo chmod 755 $TMP_MOUNT_PATH/usr/sbin/invoke-rc.d
|
||||
}
|
||||
|
||||
function unblock_daemons () {
|
||||
sudo mv $TMP_MOUNT_PATH/sbin/start-stop-daemon.REAL $TMP_MOUNT_PATH/sbin/start-stop-daemon
|
||||
sudo mv $TMP_MOUNT_PATH/sbin/initctl.REAL $TMP_MOUNT_PATH/sbin/initctl
|
||||
sudo mv $TMP_MOUNT_PATH/usr/sbin/invoke-rc.d.REAL $TMP_MOUNT_PATH/usr/sbin/invoke-rc.d
|
||||
}
|
||||
|
||||
function do_pre_install () {
|
||||
block_daemons
|
||||
block_apt_translations
|
||||
# Run pre-install scripts. These do things that prepare the chroot for package installs
|
||||
run_d_in_target pre-install
|
||||
}
|
||||
|
||||
function do_install () {
|
||||
# Call install scripts to pull in the software users want.
|
||||
run_d_in_target install
|
||||
unblock_daemons
|
||||
}
|
||||
|
||||
function do_extra_package_install () {
|
||||
# Install any packages that were requested with the -p command line option
|
||||
if [ "$INSTALL_PACKAGES" != "" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user