Request 197 was acted upon.
_________________________________________________________________________

         URL: https://rt.openpkg.org/id/197
      Ticket: [OpenPKG #197]
     Subject: fsl template
  Requestors: 
       Queue: openpkg
       Owner: thl
      Status: open
 Transaction: Correspondence added by thl
        Time: Mon Jul 14 15:31:29 2003
________________________________________________________________________

How to integrate the "fake syslog library" (fsl) into an existing
OpenPKG package named FIXME.

    o in the .spec file

      - between "Release" and the list of sources, place the fsl
        %option. We default to "yes".  Align the "yes" with other
        options, if there are any. The "with_fsl" should always be the
        first option.

      - add rc.FIXME and fsl.FIXME to the list of sources.  It is very
        likely that rc.FIXME already exists. The order must be rc before
        fsl.

      - make sure that "PreReq" requires at least OpenPKG version
        20030415, as it introduced the %{l_fsl...} macros.

      - immediately after "PreReq" and before other "if ... with..."
        constructs or, if none exist, before "AutoReq", place the "if
        ... with_fsl ..." construct for conditional "(Build)PreReq".

      - %build section, try if LDFLAGS and LIBS can be used to inject
        %{l_fsl_ldflags} and %{l_fsl_libs} as shown in the template
        %right after CFLAGS. If this doesn't work, i.e. because
        %configure desperatly searches for a library with empty name
        %when build with "with_fsl no", try to wrap the LDFLAGS/LIBS
        %section with a "if ... with_fsl ..." construct, too.

      - %install section, make sure the "shtool mkdir" exists, creates a
        .../var/FIXME directory and is placed immediately after the
        initial "rm".

      - %install section, make sure the rc.FIXME file is installed and
        the @@ variables are substituted, see "install run-command
        script".

      - %install section, make sure the fsl.FIXME file is installed and
        the @@ variables are substituted, see "install OSSP fsl
        configuration".

      - %install section, make sure the fsl directory is listed as "%not
        %dir" and the fsl.FIXME receives a "%config" tag.

    o in the rc.FIXME file

      - make sure a %config section exists which creates at least the
        _enable and _log_ variables.

      - make sure a %daily section exists which does log file rotation,
        see "rotate logfile". The job must be run as @[EMAIL PROTECTED]

    o create a fsl.FIXME file

      - and make sure the proper regex is used for "ident". This
        requires source code examination (sometimes patching) and often
        run-time testing.

      - the epilog of the log file rotation is fully package dependent.
        It is valid to run a "rc FIXME restart" (using no path to rc).
        An alternative is to use the "jitter=1" option in the l2 file
        channel, which was introduced with fsl-1.2.0 (note the fsl
        "(Build)PreReq" in the .spec)

      - the use of "append=1" in the l2 file channel is deprecated, as
        "replace=0" was introduced with fsl-1.2.0 and became the default
        (note the fsl "(Build)PreReq" in the .spec)

##
##  FIXME.spec -- OpenPKG RPM Specification
...
Release:      ...

#   package options
%option       with_fsl  yes

#   list of sources
...
Source...:      rc.FIXME
Source...:      fsl.FIXME
...
PreReq:       OpenPKG, openpkg >= 20030415 ...
%if "%{with_fsl}" == "yes"
BuildPreReq:  fsl >= 1.2.0
PreReq:       fsl >= 1.2.0
%endif
AutoReq:      no ...


%build
    ...
    CFLAGS=... \
    LDFLAGS="%{l_fsl_ldflags}" \
    LIBS="%{l_fsl_libs}" \
    ./configure \
    ...

%install
    rm -rf $RPM_BUILD_ROOT
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/var/FIXME \
        ...

    #   install run-command script
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
    %{l_shtool} install -c -m 755 \
        -e 's;@l_prefix@;%{l_prefix};g' \
        -e 's;@l_susr@;%{l_susr};g' \
        -e 's;@l_rusr@;%{l_rusr};g' \
        -e 's;@l_rgrp@;%{l_rgrp};g' \
        %{SOURCE rc.FIXME} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/

    #   install OSSP fsl configuration
    %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
    %{l_shtool} install -c -m 644 \
        -e 's;@l_prefix@;%{l_prefix};g' \
        %{SOURCE fsl.FIXME} \
        $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%not %dir %{l_prefix}/etc/fsl' \
        '%config %{l_prefix}/etc/fsl/fsl.FIXME' \

[EMAIL PROTECTED]@/lib/openpkg/bash @l_prefix@/etc/rc
##
##  rc.FIXME -- Run-Commands
##

%config
    FIXME_enable="yes"
    ...
    FIXME_log_prolog="true"
    FIXME_log_epilog="true"
    FIXME_log_numfiles="10"
    FIXME_log_minsize="1M"
    FIXME_log_complevel="9"
    ...

%daily -u @l_susr@
    opServiceEnabled FIXME || exit 0

    #   rotate logfile
    shtool rotate -f \
        -n${FIXME_log_numfiles} -s${FIXME_log_minsize} -d \
        -z${FIXME_log_complevel} [EMAIL PROTECTED]@ [EMAIL PROTECTED]@ -m644 \
        -P "${FIXME_log_prolog}" \
        -E "${FIXME_log_epilog} && rc FIXME restart" \
        @l_prefix@/var/FIXME/FIXME.log

##
##  fsl.FIXME -- OSSP fsl configuration
##

ident (FIXME.*)/.+ q{
    prefix(
        prefix="%b %d %H:%M:%S %N <%L> $1[%P]: "
    )
    -> {
        debug: file(
            path="@l_prefix@/var/FIXME/FIXME.log",
            perm=0644
        )
    }
};

--
[EMAIL PROTECTED]
Development Team, Operations Northern Europe, Cable & Wireless

Reply via email to