Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of debootstrap #2602

Merged
merged 4 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion build-tests/arm/ubuntu/test-image-rpi/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
<package name="rpi-eeprom"/>
<package name="libraspberrypi-bin"/>
<!-- system packages -->
<package name="gawk"/>
<package name="libpam-runtime"/>
<package name="bash-completion"/>
<package name="git"/>
<package name="sudo"/>
Expand Down Expand Up @@ -79,5 +81,9 @@
<package name="fdisk"/>
<package name="language-pack-en"/>
</packages>
<packages type="bootstrap"/>
<packages type="bootstrap">
<package name="apt-utils"/>
<package name="debconf"/>
<package name="mawk"/>
</packages>
</image>
1 change: 1 addition & 0 deletions build-tests/x86/debian/test-image-live-disk/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<source path="obs://Debian:12/standard"/>
</repository>
<packages type="image">
<package name="libpam-runtime"/>
<package name="grub-theme-starfield"/>
<package name="plymouth-themes"/>
<package name="vim"/>
Expand Down
19 changes: 2 additions & 17 deletions build-tests/x86/debian/test-image-live-disk/config.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
#!/bin/bash
#================
# FILE : config.sh
#----------------
# PROJECT : OpenSuSE KIWI Image System
# COPYRIGHT : (c) 2006 SUSE LINUX Products GmbH. All rights reserved
# :
# AUTHOR : Marcus Schaefer <[email protected]>
# :
# BELONGS TO : Operating System images
# :
# DESCRIPTION : configuration script for Debian based
# : operating systems
# :
# :
# STATUS : BETA
#----------------
set -ex

#======================================
# Functions...
#--------------------------------------
test -f /.kconfig && . /.kconfig
test -f /.profile && . /.profile

#======================================
# Greeting...
Expand Down
15 changes: 10 additions & 5 deletions build-tests/x86/ubuntu/test-image-docker/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<source path="obs://Ubuntu:23.04/standard"/>
</repository>
<packages type="image">
<package name="libpam-runtime"/>
<package name="gawk"/>
<package name="util-linux"/>
<package name="systemd"/>
<package name="init"/>
<package name="gnupg"/>
<package name="iproute2"/>
<package name="iptables"/>
Expand All @@ -43,11 +48,11 @@
<package name="dbus"/>
<package name="xz-utils"/>
<package name="usrmerge"/>
<!--
mawk is included so OBS adds it as a build dependency,
however this is installed by debootstrap
-->
<package name="language-pack-en"/>
</packages>
<packages type="bootstrap">
<package name="apt-utils"/>
<package name="debconf"/>
<package name="mawk"/>
</packages>
<packages type="bootstrap"/>
</image>
17 changes: 10 additions & 7 deletions build-tests/x86/ubuntu/test-image-live-disk/appliance.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,21 @@
<source path="obs://Ubuntu:23.04/standard"/>
</repository>
<packages type="image">
<package name="libpam-runtime"/>
<package name="gawk"/>
<package name="apt-utils"/>
<package name="debconf"/>
<package name="mawk"/>
<package name="dialog"/>
<package name="util-linux"/>
<package name="grub2-themes-ubuntu-mate"/>
<package name="plymouth-theme-sabily"/>
<package name="plymouth"/>
<package name="grub-pc-bin"/>
<package name="grub-efi-amd64" arch="x86_64"/>
<package name="grub-efi-arm64" arch="aarch64"/>
<package name="grub-common"/>
<package name="grub2-common"/>
<package name="grub-efi-amd64-bin"/>
<package name="grub-pc-bin" arch="x86_64"/>
<package name="linux-generic"/>
<package name="systemd"/>
<package name="dracut"/>
Expand All @@ -84,11 +92,6 @@
<package name="xz-utils"/>
<package name="usrmerge"/>
<package name="language-pack-en"/>
<!--
mawk is included so OBS adds it as a build dependency,
however this is installed by debootstrap
-->
<package name="mawk"/>
</packages>
<packages type="image" profiles="Virtual">
<package name="shim"/>
Expand Down
51 changes: 2 additions & 49 deletions build-tests/x86/ubuntu/test-image-live-disk/config.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
set -ex

#======================================
# Functions...
#--------------------------------------
Expand All @@ -9,56 +11,7 @@ test -f /.kconfig && . /.kconfig
#--------------------------------------
echo "Configure image: [${kiwi_iname}]..."

# On Debian based distributions the kiwi built in way
# to setup locale, keyboard and timezone via systemd tools
# does not work because not(yet) provided by the distribution.
# Thus the following manual steps to make the values provided
# in the image description effective needs to be done.
#
#=======================================
# Setup system locale
#---------------------------------------
echo "LANG=${kiwi_language}" > /etc/locale.conf

#=======================================
# Setup system keymap
#---------------------------------------
echo "KEYMAP=${kiwi_keytable}" > /etc/vconsole.conf
echo "FONT=eurlatgr.psfu" >> /etc/vconsole.conf
echo "FONT_MAP=" >> /etc/vconsole.conf
echo "FONT_UNIMAP=" >> /etc/vconsole.conf

#=======================================
# Setup system timezone
#---------------------------------------
[ -f /etc/localtime ] && rm /etc/localtime
ln -s /usr/share/zoneinfo/${kiwi_timezone} /etc/localtime

#=======================================
# Setup HW clock to UTC
#---------------------------------------
echo "0.0 0 0.0" > /etc/adjtime
echo "0" >> /etc/adjtime
echo "UTC" >> /etc/adjtime

#======================================
# Disable systemd NTP timesync
#--------------------------------------
baseRemoveService systemd-timesyncd

#======================================
# Enable firstboot resolv.conf setting
#--------------------------------------
baseInsertService symlink-resolvconf

#======================================
# Setup default target, multi-user
#--------------------------------------
baseSetRunlevel 3

#======================================
# Clear apt-get data
#--------------------------------------
apt-get clean
rm -r /var/lib/apt/*
rm -r /var/cache/apt/*
5 changes: 2 additions & 3 deletions doc/source/image_description/elements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,7 @@ bootstrap_package="package_name":
in :file:`/var/lib/bootstrap/PACKAGE_NAME.ARCH.tar.xz`.
The tarball will be unpacked and used as the bootstrap
rootfs to begin with. This allows for an alternative bootstrap
method preventing the use of `debootstrap`. For further details
see :ref:`debootstrap_alternative`.
method. For further details see :ref:`debianbootstrap_alternative`.

compressed="true|false":
Specifies whether the image output file should be
Expand Down Expand Up @@ -1259,7 +1258,7 @@ components="name"

distribution="name"
Used for Debian (apt) based repositories only. Specifies the
distribution name to be used on call of `debootstrap`
distribution name used in the repository data structure.

imageonly="true|false"
Specifies whether or not this repository should be configured in
Expand Down
2 changes: 1 addition & 1 deletion doc/source/working_with_images.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ Working with Images
working_with_images/build_with_profiles
working_with_images/build_in_buildservice
working_with_images/use_suse_media
working_with_images/build_without_debootstrap
working_with_images/build_without_debianbootstrap
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
.. _debootstrap_alternative:
.. _debianbootstrap_alternative:

Circumvent debootstrap
======================
Circumvent Debian Bootstrap
===========================

.. sidebar:: Abstract

This page provides information how to build Debian based
images with `apt` but without using `debootstrap` to bootstrap
the image root tree

When building Debian based images {kiwi} uses two tools to
create the image root tree. First it calls `debootstrap` to
initialize a minimal root tree and next it chroot's into that
tree to complete the installation via `apt`. The reason why it
is done that way is because `apt` does not(yet) support to
install packages into an empty root directory like it is done
with all other packagemanager interfaces implemented in {kiwi}.

The use of `debootstrap` comes along with some prerequisites
and limitations:

* It can only use one repository to bootstrap from
* It can only use an official archive repo
* It has its own dependency resolver different from apt

If one ore more of this properties turns into an issue, {kiwi}
allows for an alternative process which is based on a prebuilt
bootstrap-root archive provided as a package.
images without an extra bootstrap process.

When building Debian based images {kiwi} uses `apt` in the
bootstrap and the system phase to create the image root tree.
However, `apt` does not support a native way to bootstrap
an empty root tree. Therefore the bootstrap phase uses
apt only to resolve the given bootstrap packages and to
download these packages from the given repositories.
The list of packages is then manually extracted into the
new root tree which is not exactly the same as if `apt`
would have installed them natively. For the purpose of
creating an initial tree to begin with, this procedure
is acceptable though.

If, for some reasons, this bootstrap procedure is not
applicable, {kiwi} allows for an alternative process which is
based on a prebuilt bootstrap-root archive provided as a package.

To make use of a `bootstrap_package`, the name of that package
needs to be referenced in the {kiwi} description as follows:
Expand Down Expand Up @@ -54,10 +50,10 @@ How to Create a bootstrap_package
---------------------------------

Changing the setup in {kiwi} to use a `bootstrap_package` rather
then letting `debootstrap` do the job comes with the task to create
that package providing the bootstrap root tree. There are more than
one way to do this. The following procedure is just one example and
requires some background knowledge about the Open Build Service
then using {kiwi}'s debian bootstrap method to do the job, comes with
the task to create that package providing the bootstrap root tree. There
are more than one way to do this. The following procedure is just one
example and requires some background knowledge about the Open Build Service
`OBS <https://build.opensuse.org>`__ and its {kiwi} integration.

1. Create an OBS project and repository setup that matches your image target
Expand Down Expand Up @@ -89,13 +85,28 @@ requires some background knowledge about the Open Build Service
</repository>

<packages type="image">
<!-- packages included so OBS adds it as a build dependency, however this is installed by debootstrap -->
<package name="gawk"/>
<package name="apt-utils"/>
<package name="debconf"/>
<package name="mawk"/>
<package name="libpam-runtime"/>
<package name="util-linux"/>
<package name="systemd"/>
<package name="init"/>
<package name="gnupg"/>
<package name="iproute2"/>
<package name="iptables"/>
<package name="iputils-ping"/>
<package name="ifupdown"/>
<package name="isc-dhcp-client"/>
<package name="netbase"/>
<package name="dbus"/>
<package name="xz-utils"/>
<package name="usrmerge"/>
<package name="language-pack-en"/>
</packages>

<packages type="bootstrap">
<!-- bootstrap done via debootstrap -->
</packages>
<packages type="bootstrap"/>
</image>

.. code:: bash
Expand Down
6 changes: 3 additions & 3 deletions kiwi/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ class KiwiDataStructureError(KiwiError):
"""


class KiwiDebootstrapError(KiwiError):
class KiwiDebianBootstrapError(KiwiError):
"""
Exception raised if not enough user data to call debootstrap
were provided or the debootstrap has failed.
Exception raised if the bootstrap installation for Debian
based systems has failed
"""


Expand Down
Loading
Loading