8.4 Building Images with scr

After you have installed ImageBuilder and the image templates, copied the image source files to a distribution directory, and defined the image source location files, you can start building Point of Services images.

The process required to build an image with scr is as follows:

  1. Clone the Image Description Tree.

  2. Add software packages or add-on options to an image.

  3. Configure the image.

  4. Build the image.

These steps are explained in the following sections.

8.4.1 Cloning the Image Description Tree

scr builds images using a specific file system directory structure known as the Image Description Tree. The Image Description Tree provides the structure, scripts, configuration files, and other components required to build images for Point of Service systems.

You can use the default Image Description Trees provided with Novell Linux Point of Service to generate the DiskNetBoot, CDBoot, Minimal, Browser, Java, and Desktop images. However, to maintain a standardized source tree and simplify the upgrade process, it is recommended that you maintain the default Image Description Trees provided with Novell Linux Point of Service as master copies. To build your own images, you can clone the default Image Description Trees, then modify the cloned tree.

NOTE:To view a list of available Image Description Trees, execute the scr --list command.

The basic syntax to clone an Image Description Tree is as follows:

scr --create image_name-version --image image_name-version

For example, the following command clones the Minimal-2.0.21 Image Description Tree to create a new Image Description Tree named myImage-1.1.1:

scr --create myImage-1.1.1 --image minimal-2.0.21

IMPORTANT:You cannot use the word “boot” in any image name other than the cdboot and disknetboot images.

The new Image Description Tree is located at /opt/SLES/POS/system/myImage-1.1.1. You can then modify the cloned Image Description Tree as required to create your new image. For a description of the individual Image Description Tree components, see Section 8.2.1, Image Description Tree and Section B.0, Novell Linux Point of Service Files and Directory Structure.

8.4.2 Adding Software Packages or Add-on Options to an Image

Extending an image is the process used to add software packages or add-on options to an image. You can extend images with software packages included within the Novell Linux Point of Service CD set as well as packages that are not included within the Novell Linux Point of Service CD set. You can also extend images with unpackaged software.

To extend client images with software packages that are included within the Novell Linux Point of Service CD set such as the client image add-on options, you simply add the package to the list of packages marked for installation. For example, to extend the Minimal image to provide the Samba 3 client, it is only necessary to add the package to the list of packages marked for installation. This can be done in two ways:

  • Add the package to the setup file, which can be found in the Image Description Tree. After this, adapt the size parameter of configuration file, which can be found in the description tree. For information on this procedure, see Adding a Package to the Setup File.
  • Create a custom setup file using the same syntax as the setup file and add the package to it. The size parameter can also be part of this file. Specify the file as an argument of the scr --extend option. For information on this procedure, see Adding a Package to a Custom File.

To extend client images with software packages not included within the Novell Linux Point of Service CD set, you must add those packages to directory ImageBuilder uses to build the image, list the package in the setup file, and adapt the size parameter of configuration file. For information on this procedure, see Extending Images with Non-Standard Packages

To extend client images with unpackaged software, you must prepare the Image Description Tree, install the unpackaged software within the image, then build the image. For information on this procedure, see Extending an Image with Unpackaged Software.

Adding a Package to the Setup File

The following instructions illustrate how to add the vim package file to the myImage-1.1.1 setup file:

  1. Create a copy of the standard Minimal Image Description Tree:

    scr --create myImage-1.1.1 --image minimal-2.0.21
    
  2. Add the following line to /opt/SLES/POS/system/myImage-1.1.1/setup:

    vim : x : x
    
  3. Adapt the size parameter of the /opt/SLES/POS/system/myImage-1.1.1/config file.

    size:42M
    

    IMPORTANT:You must modify the size parameter in the image config file to reflect the new image size because the scr ImageBuilder tool requires accurate image size information to generate the image.

  4. You can then build the new image.

    For information on this procedure, see Section 8.4.4, Building the Image.

Adding a Package to a Custom File

The following instructions illustrate how to add the vim package to a file with the same syntax as the setup file:

  1. Create a copy of the standard Minimal Image Description Tree:

    scr --create myImage-1.1.1 --image minimal-2.0.21
    
  2. Create the /tmp/setup.with.vim file and add the following lines:

    size:42M
    vim : x : x
    

    The specification of packages in this file requires the single packages to exist at /opt/SLES/POS/pac. If your package resides elsewhere, specify the path at the end of the line, for example, vim : x : x : /tmp/editors.

  3. You can then build the new image.

    For information on this procedure, see Section 8.4.4, Building the Image.

Extending Images with Non-Standard Packages

The following instructions illustrate how to add an alternate vim package (that is, a vim package not included with Novell Linux Point of Service CD set) to myImage-1.1.1:

  1. Create a copy of the standard Minimal image:

    scr --create myImage-1.1.1 --image minimal-2.0.21
    
  2. Copy the vim package to the global package directory, /opt/SLES/POS/pac.

    cp vim-other.rpm /opt/SLES/POS/pac
    
  3. Add the following line to /opt/SLES/POS/system/myImage-1.1.1/setup.user:

    vim-other : x : x
    

    The example uses the package name vim-nstandard.rpm. If you use package names with version numbers, for example, vim-other-1.3-471.i586.rpm, you must add the following line in setup.user:

    vim-other : x : 1.3-471.
    
  4. Adapt the size parameter of the /opt/SLES/POS/system/myImage-1.1.1/config file.

    size:42M
    

    IMPORTANT:You must modify the size parameter in the image config file to reflect the new image size because the scr ImageBuilder tool requires accurate image size information to generate the image.

  5. You can then build the new image.

    For information on this procedure, see Section 8.4.4, Building the Image.

Extending an Image with Unpackaged Software

The following instructions illustrate how to add software not packaged into an RPM package to myImage-1.1.1:

  1. Create a copy of the standard Minimal image:

    scr --create myImage-1.1.1 --image minimal-2.0.21
    
  2. Prepare the image:

    scr --prepare --image myImage-1.1.1
    
  3. After the image is prepared, find the root system of the image below the directory root-myImage-1.1.1.

  4. Copy the non-RPM software to a directory within the image. For example:

    cp software root-myImage-1.1.1/tmp
    
  5. Change to the image system with the command:

    chroot root-myImage-1.1.1 bash
    
  6. Perform all the steps needed to install the software.

  7. Exit the image system with the exit command.

  8. Adapt the size parameter of the /opt/SLES/POS/system/myImage-1.1.1/config file.

    size:42M
    

    IMPORTANT:You must modify the size parameter in the image config file to reflect the new image size because the scr ImageBuilder tool requires accurate image size information to generate the image.

  9. You can then build the new image.

    For information on this procedure, see Section 8.4.4, Building the Image.

8.4.3 Configuring the Image

Configuring an image means adapting it for a specific hardware environment. This includes activating and deactivating services, setting up special POStinstall scripts, adding standard configuration files and setting the time zone.

The following sections review these image configuration options.

Setting the Time Zone

Time zones are set in the config file.

timezone:relative_path_to_time_zone

All time zone definitions are located in the /usr/share/zoneinfo directory. To specify which time zone you want to use in the image, enter the relative path to a specific time zone definition. For example, timezone:US/Mountain. The ImageBuilder uses this information to extract the corresponding time zone from the timezone package. The time zone value is then stored as /etc/localtime in the image.

For more information on the config file, see Section 8.2.1, Image Description Tree.

Including Fixed Configuration Files

A fixed configuration is a configuration file that provides information for a service that is hardware independent. Fixed configuration files are stored in the Image Description Tree under the files-user subdirectory.

The following instructions illustrate how to add the fixed configuration file, /etc/sysconfig/hotplug, to the Image Description Tree, /opt/SLES/POS/system/myImage-1.1.1/:

  1. Go to the /opt/SLES/POS/system/image_name-version/files-user directory:

    cd /opt/SLES/POS/system/myImage-1.1.1/files-user
    
  2. Within the files-user directory, create a directory structure that parallels the original system location of the configuration file:

    mkdir -p etc/sysconfig
    
  3. Copy the configuration file to the appropriate directory within the files-user tree.

    In this case, simply copy the hotplug file to the /opt/SLES/POS/system/image_name-version/files-user/etc/sysconfig/ directory:

    cp /etc/sysconfig/hotplug etc/sysconfig
    

The file tree within files-user is completely copied to the image when it is generated. For more information on the files-user directory, see Section 8.2.1, Image Description Tree

Using Data Images to Manage External Configuration Files

A data-only image is an ext2 image file that contains only a copy of the Image Description Tree starting at the given directory. This kind of image cannot be used as operating system or boot image. However, it can be used to add external configuration files to a Point of Service terminal.

If a disk-based system is booting and the IMAGE parameter in the config.MAC_address file includes an additional data image that will be downloaded to a /dev/ramx device, the data contents are automatically included into the system. If a data image is downloaded into a partition on the disk, the data is available at the mount point referring to the contents of the PART variable.

The advantage of using data images to add external configuration files to a Point of Service terminal is that the data image is controlled in the same way as the client image. This means you can manage the configuration files independent of the client image.

IMPORTANT:To implement this functionality, you must manually modify the config.MAC_address file for each Point of Service terminal that you want to load the data image. However, when you run posAdmin --updateconfig or posldap2crconfig.pl --dumpall to refresh the config.MAC_address files on the Branch Server, these modifications are overwritten. Therefore, to maintain the functionality, you must manually reconfigure the config.MAC_address files each time you regenerate the files.

For more information on the posldap2crconfig.pl command, see Section A.3.5, posldap2crconfig.pl.

For more information on the posAdmin --updateconfig command, see Section 6.9, Updating config.MAC_address and Hardware Configuration Files.

The following instructions illustrate how to manage external configuration files with a data image:

  1. Create a temporary directory that contains the data.

    mkdir /tmp/mydata
    
  2. Create the directory structure according to the original system location of the configuration file below this data directory and apply your configurations.

    mkdir -p /tmp/mydata/etc/X11
    vi /tmp/mydata/etc/X11/XF86Config
    
  3. Create a data image.

    xscr --create-data-image /tmp/mydata \
        --image mydata-2.0.21 --destdir /tmp/myDataDirectory
    

    This call creates the data image, mydata-2.0.21, and the referring MD5 sum in /tmp/myDataDirectory/.

  4. Copy the image to the /opt/SLES/POS/rsync/image/ directory on the Administration Server.

    IMPORTANT:The data image must be copied to the /opt/SLES/POS/rsync/image directory on the Administration Server before the Branch Server can distribute it to Point of Service terminals.

  5. To activate the data image, add the data image to the IMAGE parameter in the config.MAC_Address file.

    The IMAGE entry might appear as follows:

    IMAGE=/dev/hda2;minimal;1.1.8;192.168.100.1;1024,
          /dev/ram2;mydata;2.0.21;192.168.100.1;1024
    

    IMPORTANT:To ensure the contents of the data image are copied to the system, the image must be downloaded to a /dev/ramx device.

With the data image listed as an IMAGE entry in the config.MAC_address file, the data image contents are copied to the Point of Service terminal after the data image has been downloaded to /dev/ram2.

To update the data image on the Point of Service terminal, you must perform the following:

  1. Generate a new version of the data image.

  2. Copy the new data image version to the /opt/SLES/POS/rsync/image/ directory on the Administration Server.

  3. Run possyncimages.pl to download the image to the Branch Server.

  4. Modify the IMAGE entry in the config.MAC_Address file to reflect the data image's new version number.

Enabling DMA on Point of Service Terminal CD Drives

Setting up a Direct Memory Access (DMA) channel for the CD drive on your Point of Service terminals speeds up the process of booting and loading an image from CD. The CDBoot image template provided with Novell Linux Point of Service includes the RPM package (hdparm) required to enable DMA so that the DMA channel is configured when the terminal boots from CD. However, if you would like DMA to be enabled beyond the initial install, you must add the DMA feature to the client image.

To add DMA functionality to a client image:

  1. Include the hdparm package in the image’s opt/SLES/POS/system/image_name-version/setup file as follows:

    hdparm : RPM_Option : Package_Version
    

    NOTE:The CDBoot Image Specification Document includes the hdparm RPM package by default.

  2. Add the CD device (usually /dev/hdc) to the DEVICES_FORCE_IDE_DMA flag in the /etc/sysconfig/ide file. For example:

    DEVICES_FORCE_IDE_DMA="/dev/hdc:on"
    
  3. Provide a way for the /etc/sysconfig/ide file to be deployed on the Point of Service terminal.

    This can be accomplished in one of two ways:

  4. Build the image.

    For more information on this procedure, see Section 8.4.4, Building the Image.

Activating and Deactivating System Services

System services are activated or deactivated in the config.system file by using the insserv command to set or remove links.

To activate a service, add the following call to the config.system file:

sbin/insserv /etc/init.d/service

To deactivate a service, add the following call to the config.system file:

sbin/insserv -r /etc/init.d/service

For more information on the config.system file, see Section 8.2.1, Image Description Tree.

Writing Post-Install Scripts

A Post-install script is always bound to a package from the setup file and is usually used to remove items from the package that are not needed for the image. This type of script must have the same name as the corresponding package and is stored in the script directory of the Image Description Tree (opt/SLES/POS/system/image_name-version/script/). The script itself is called within the image environment, which means it is not possible to damage the host system with your script even if you are using absolute paths.

A Post-install script uses the following format:

#!/bin/sh
echo -n "Image [image_name_version]..."
test -f /.profile \&\& . /.profile

... script code

echo done

image_name-version is the name of the image to which this script belongs.

For more information on the script directory, see Section 8.2.1, Image Description Tree.

8.4.4 Building the Image

To get a list of available Image Description Trees, execute the following command:

scr --list

The output appears as follows:

28-Jul 17:52:52 <1> : Image: browser         Version: 2.0.21
28-Jul 17:52:52 <1> : Image: minimal         Version: 2.0.21
28-Jul 17:52:52 <1> : Image: disknetboot     Version: 2.0.21
28-Jul 17:52:52 <1> : Image: java            Version: 2.0.21
28-Jul 17:52:52 <1> : Image: cdboot          Version: 2.0.21
28-Jul 17:52:52 <1> : Image: desktop         Version: 2.0.21

NOTE:The --list option does not validate the Image Description Tree. You can build an image from the listed description trees only if they are complete.

To generate an image from one of the available Image Description Trees, execute the scr command with the --prepare and --build options. For example, the following scr command creates the standard Minimal image with the version 2.0.21 in the working directory myImages and verifies the RPM packages:

    scr --prepare --image minimal-2.0.21 
        --build --destdir myImages --verify

The following command illustrates how to enable support for the serial console using the --feature option for the Minimal image:

    scr --prepare --image minimal-2.0.21 
        --build --destdir compiled --feature serial_console

IMPORTANT:scr only maintains five builds of a single image in the same directory. When you generate the sixth build of an image, scr deletes the oldest image version. (xscr determines the oldest image version by the image date.) If you want to maintain more than five versions of a single image, you must maintain them in separate directories.