Go to main content

Packaging and Delivering Software With the Image Packaging System in Oracle® Solaris 11.4

Exit Print View

Updated: November 2020

Assembling a Custom File from Fragment Files

This section shows how to use an IPS package to deliver multiple files and deliver an SMF service that assembles these multiple files into one file.

The following package manifest delivers the self-assembly service. The isvapp-self-assembly service assembles the files inc1, inc2, and inc3 in the /opt/isvapp/config.d directory into the single /opt/isvapp/isvconf file.

set name=pkg.fmri value=isvappcfg@1.0
set name=pkg.summary value="Deliver isvapp config files and assembly service"
set name=pkg.description \
    value="This example package delivers a directory with fragment configuration
 files and a service to assemble them."
set name=org.opensolaris.smf.fmri value=svc:/site/isvapp-self-assembly \
set name=variant.arch value=i386
file lib/svc/manifest/site/isvapp-self-assembly.xml \
    path=lib/svc/manifest/site/isvapp-self-assembly.xml owner=root group=sys \
    mode=0444 restart_fmri=svc:/system/manifest-import:default
file lib/svc/method/isvapp-self-assembly.sh \
    path=lib/svc/method/isvapp-self-assembly.sh owner=root group=bin \
dir  path=opt/isvapp owner=root group=bin mode=0755
dir  path=opt/isvapp/config.d owner=root group=bin mode=0755
file opt/isvapp/config.d/inc1 path=opt/isvapp/config.d/inc1 owner=root \
    group=bin mode=0644
file opt/isvapp/config.d/inc2 path=opt/isvapp/config.d/inc2 owner=root \
    group=bin mode=0644
file opt/isvapp/config.d/inc3 path=opt/isvapp/config.d/inc3 owner=root \
    group=bin mode=0644
file opt/isvapp/isvconf path=opt/isvapp/isvconf owner=root group=bin mode=0644
depend fmri=pkg:/shell/ksh93@ type=require
depend fmri=pkg:/system/core-os@11.4- type=require

If you want to allow other packages to deliver configuration files with these same names, add overlay and preserve attributes to the files. See Delivering a File That Is Also Delivered by Another Package for an example.

To reassemble the configuration file when new fragments of the configuration are installed, removed, or updated, add restart_fmri or refresh_fmri actuators to the configuration files. See Apache Web Server Configuration for an example.

The following script does the configuration assembly for the service. The comment in the exit call will be displayed by the svcs command.


# Load SMF shell support definitions
. /lib/svc/share/smf_include.sh

# If files exist in /opt/isvapp/config.d,
# and if /opt/isvapp/isvconf exists,
# merge all into /opt/isvapp/isvconf

# After this script runs, the service does not need to remain online.
smf_method_exit $SMF_EXIT_TEMP_DISABLE done "/opt/isvapp/isvconf assembled"

Use the svcbundle command to create the service manifest. In the service-name, include the category site because this is a custom service. The value of start-method is the name of the above script.

$ svcbundle -o ./isvapp-self-assembly.xml -s service-name=site/isvapp-self-assembly \
> -s start-method=/lib/svc/method/isvapp-self-assembly.sh -s start-timeout=180

The ./isvapp-self-assembly.xml manifest is shown below.

Verify that the content of the manifest is what you need. This manifest specifies the default dependency on the multi-user milestone service. You might want to change this dependency section as shown in Delivering a Service that Runs Once.

Add common_name and description information in the template data area. You can also add documentation and other template data.

<?xml version="1.0" ?>
<!DOCTYPE service_bundle
  SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
    Manifest created by svcbundle (2020-Oct-11 22:40:05-0700)
<service_bundle name="site/isvapp-self-assembly" type="manifest">
    <service name="site/isvapp-self-assembly" version="1" type="service">
            The following dependency keeps us from starting until the
            multi-user milestone is reached.
        <dependency name="multi_user_dependency" grouping="require_all"
            restart_on="none" type="service">
            <service_fmri value="svc:/milestone/multi-user"/>
        <exec_method name="start" type="method" timeout_seconds="180"
            The exec attribute below can be changed to a command that SMF
            should execute to stop the service.  Use svcbundle -s
            stop-method to set the attribute.
        <exec_method name="stop" type="method" timeout_seconds="60"
            The exec attribute below can be changed to a command that SMF
            should execute when the service is refreshed.  Use svcbundle -s
            refresh-method to set the attribute.
        <exec_method name="refresh" type="method" timeout_seconds="60"
        <property_group name="startd" type="framework">
            <propval name="duration" type="astring" value="transient"/>
        <instance name="default" enabled="true"/>
                    Replace loctext content with a short name for the
                <loctext xml:lang="C">
                    Replace loctext content with a brief description of the
                <loctext xml:lang="C">
                        The site/isvapp-self-assembly service.

Use the svccfg validate command to make sure the service manifest is valid.

After you publish and install the package, the svcs command shows that the isvapp-self-assembly service is temporarily disabled, and the log file contains the method exit comment that the file assembly is complete.

In contrast to the example shown in Delivering a Service that Runs Once, when you enable the isvapp-self-assembly service, the service start script runs again before the service is again disabled.