<?xml version='1.0'?>
<!--
//
//
// This file and its contents are supplied under the terms of the
// Common Development and Distribution License ("CDDL"), version 1.0.
// You may only use this file in accordance with the terms of version
// 1.0 of the CDDL.
//
// A full copy of the text of the CDDL should have accompanied this
// source.  A copy of the CDDL is also available via the Internet at
// http://www.illumos.org/license/CDDL.
//
//
// Copyright 2021 by Jim Klimov
//
-->
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='ccache-update-symlinks'>
  <service
    name='system/ccache-update-symlinks'
    type='service'
    version='1'>

    <create_default_instance enabled='true' />

    <single_instance />

    <!--
      Wait for all local filesystems to be mounted.
    -->
    <dependency name='filesystem-local'
        grouping='require_all'
        restart_on='none'
        type='service'>
        <service_fmri
        value='svc:/system/filesystem/local:default'/>
    </dependency>

    <exec_method type='method'
               name='start'
               exec='/lib/svc/method/ccache-update-symlinks.sh'
               timeout_seconds='60'>
    </exec_method>

    <exec_method type='method'
               name='stop'
               exec=':true'
               timeout_seconds='0'>
    </exec_method>

    <exec_method type='method'
               name='refresh'
               exec='/lib/svc/method/ccache-update-symlinks.sh'
               timeout_seconds='60'>
    </exec_method>

    <property_group name='startd' type='framework'>
        <propval name='duration' type='astring' value='transient' />
    </property_group>

    <property_group name='ccache-update-symlinks' type='application'>
        <stability value='Evolving' />
        <!-- By default the method script only adds symlinks, to avoid
             surprises for developers on their systems customized manually
             (and/or before this service was introduced). After they make
             sure all symlinks are what they intend to have and nothing
             unexpected is queued to be deleted (as can be seen in log)
             then can toggle this flag to "true" in their deployment.
             Probably customizing PATH_ADD and/or TOOLS_ADD will be
             critical for those developers for whom it really matters.
        -->
        <propval type='boolean' name='ALLOW_DELETE' value='false' />
        <!-- The PATH_ADD contents are added to the PATH set by SMF, which
             includes /usr/bin (with most of the packaged compilers) already.
             Default PATH_ADD below can help find compilers in locations
             typical for local customizations of OpenIndiana deployments.
        -->
        <propval type='astring' name='PATH_ADD' value='/usr/local/bin:/usr/gnu/bin' />
        <!-- If a developer's system has further filenames for compilers
             that ccache is compatible with, list the (version-less)
             names here. For example, "icc" listed here would match
             and symlink to ccache both "icc" and "icc-123" but neither
             "icc-style" nor "icc-cpp" nor "icc++" if such names are
             installed and in PATH (list all relevant prefixes for that
             tool chain's C and C++ compilers, and CPP preprocessor,
             separated by whitespaces).
        -->
        <propval type='astring' name='TOOLS_ADD' value='' />
    </property_group>

    <stability value='Evolving' />

    <template>
      <common_name>
        <loctext xml:lang='C'>ccache-update-symlinks - keep ccache symlinks in sync with installed compatible compilers</loctext>
      </common_name>
    </template>

  </service>
</service_bundle>