Live manual

Live Systems

<< previous toc next >>

Live Systems Manual

Customizing contents

9. Customizing contents

This chapter discusses fine-tuning customization of the live system contents beyond merely choosing which packages to include. Includes allow you to add or replace arbitrary files in your live system image, hooks allow you to execute arbitrary commands at different stages of the build and at boot time, and preseeding allows you to configure packages when they are installed by supplying answers to debconf questions.

9.1 Includes

While ideally a live system would include files entirely provided by unmodified packages, it is sometimes convenient to provide or modify some content by means of files. Using includes, it is possible to add (or replace) arbitrary files in your live system image. live-build provides two mechanisms for using them:

Please see Terms for more information about the distinction between the "Live" and "binary" images.

9.1.1 Live/chroot local includes

Chroot local includes can be used to add or replace files in the chroot/Live filesystem so that they may be used in the Live system. A typical use is to populate the skeleton user directory (/etc/skel) used by the Live system to create the live user's home directory. Another is to supply configuration files that can be simply added or replaced in the image without processing; see Chroot local hooks if processing is needed.

To include files, simply add them to your config/includes.chroot directory. This directory corresponds to the root directory / of the live system. For example, to add a file /var/www/index.html in the live system, use:

$ mkdir -p config/includes.chroot/var/www
$ cp /path/to/my/index.html config/includes.chroot/var/www

Your configuration will then have the following layout:

-- config
    [...]
     |-- includes.chroot
     |   `-- var
     |       `-- www
     |           `-- index.html
    [...]

Chroot local includes are installed after package installation so that files installed by packages are overwritten.

9.1.2 Binary local includes

To include material such as documentation or videos on the medium filesystem so that it is accessible immediately upon insertion of the medium without booting the Live system, you can use binary local includes. This works in a similar fashion to chroot local includes. For example, suppose the files ~/video_demo.* are demo videos of the live system described by and linked to by an HTML index page. Simply copy the material to config/includes.binary/ as follows:

$ cp ~/video_demo.* config/includes.binary/

These files will now appear in the root directory of the live medium.

9.2 Hooks

Hooks allow commands to be run in the chroot and binary stages of the build in order to customize the image. Depending on whether you are building a live image or a regular system image you have to place your hooks in config/hooks/live or config/hooks/normal respectively. These are frequently referred to as local hooks because they are executed inside the build environment.

There are also boot-time hooks that allow you to run commands once the image has already been built, during the boot process.

9.2.1 Chroot local hooks

To run commands in the chroot stage, create a hook script with a .hook.chroot suffix containing the commands either in the config/hooks/live or config/hooks/normal directories. The hook will run in the chroot after the rest of your chroot configuration has been applied, so remember to ensure your configuration includes all packages and files your hook needs in order to run. See the example chroot hook scripts for various common chroot customization tasks provided in /usr/share/doc/live-build/examples/hooks which you can copy or symlink to use them in your own configuration.

9.2.2 Binary local hooks

To run commands in the binary stage, create a hook script with a .hook.binary suffix containing the commands either in the config/hooks/live or config/hooks/normal directories. The hook will run after all other binary commands are run, but before binary_checksums, the very last binary command. The commands in your hook do not run in the chroot, so take care not to modify any files outside of the build tree, or you may damage your build system! See the example binary hook scripts for various common binary customization tasks provided in /usr/share/doc/live-build/examples/hooks which you can copy or symlink to use them in your own configuration.

9.2.3 Boot-time hooks

To execute commands at boot time, you can supply live-config hooks as explained in the "Customization" section of its man page. Examine live-config's own hooks provided in /lib/live/config/, noting the sequence numbers. Then provide your own hook prefixed with an appropriate sequence number, either as a chroot local include in config/includes.chroot/lib/live/config/, or as a custom package as discussed in Installing modified or third-party packages.

9.3 Preseeding Debconf questions

Files in the config/preseed/ directory suffixed with .cfg followed by the stage (.chroot or .binary) are considered to be debconf preseed files and are installed by live-build using debconf-set-selections during the corresponding stage.

For more information about debconf, please see debconf(7) in the debconf package.


<< previous toc next >>