Blame Automation/centos-art.sh-mods/Render/Docbook/docbook_setExpansionSystemEntities.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# docbook_setExpansionSystemEntities.sh -- This function expands system
Alain Reguera Delgado 8f60cb
# entities required by DocBook projects stored under
Alain Reguera Delgado 8f60cb
# `Documentation/Manuals' directory.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# Copyright (C) 2009-2013 The CentOS Project
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado 8f60cb
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado 8f60cb
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado 8f60cb
# your option) any later version.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado 8f60cb
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado 8f60cb
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado 8f60cb
# General Public License for more details.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado 8f60cb
# along with this program; if not, write to the Free Software
Alain Reguera Delgado 8f60cb
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
# $Id$
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
function docbook_setExpansionSystemEntities {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to instance where all operations will take
Alain Reguera Delgado 8f60cb
    # place in.
Alain Reguera Delgado 8f60cb
    local INSTANCE=$1
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to both common and specific system
Alain Reguera Delgado 8f60cb
    # entities.
Alain Reguera Delgado 8f60cb
    local ENTITIES_PATHS="$(cli_getFilesList ${TCAR_WORKDIR}/Documentation/Models/Docbook/Default/Book $(dirname ${TEMPLATE}) \
Alain Reguera Delgado 8f60cb
        --pattern='^.*/[[:alpha:]-]+\.ent$' --maxdepth=1 --mindepth=1 --type='f')"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Build definition of both common and specific system entities.
Alain Reguera Delgado 8f60cb
    local ENTITIES="$(\
Alain Reguera Delgado 8f60cb
        for ENTITY_PATH in $ENTITIES_PATHS;do
Alain Reguera Delgado 8f60cb
            local ENTITY_NAME=$(basename ${ENTITY_PATH})
Alain Reguera Delgado 8f60cb
            echo '\n\t\n'
Alain Reguera Delgado 8f60cb
            echo '\t%'${ENTITY_NAME}';'
Alain Reguera Delgado 8f60cb
        done)"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define both xml and docbook public definition.
Alain Reguera Delgado 8f60cb
    local PREAMBLE=""
Alain Reguera Delgado 8f60cb
    PREAMBLE="${PREAMBLE}\n
Alain Reguera Delgado 8f60cb
    PREAMBLE="${PREAMBLE}\n\t\"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd\" ["
Alain Reguera Delgado 8f60cb
    PREAMBLE="${PREAMBLE}\n${ENTITIES}"
Alain Reguera Delgado 8f60cb
    PREAMBLE="${PREAMBLE}\n\t]>"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Remove both xml and docbook preamble from instance and insert
Alain Reguera Delgado 8f60cb
    # it again with definitions of required common and specific system
Alain Reguera Delgado 8f60cb
    # entities.
Alain Reguera Delgado 8f60cb
    sed -r -i "1,2c$(echo $PREAMBLE)" ${INSTANCE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}