Blame Automation/Modules/Help/Texinfo/texinfo_updateChapterNodes.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# texinfo_updateChapterNodes.sh -- This function updates nodes of
Alain Reguera Delgado 8f60cb
# chapters based on menu of chapters.
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 texinfo_updateChapterNodes {
Alain Reguera Delgado 8f60cb
    
Alain Reguera Delgado 8f60cb
    # Print action name.
Alain Reguera Delgado 8f60cb
    cli_printMessage "${MANUAL_BASEFILE}-nodes.${MANUAL_EXTENSION}" --as-creating-line
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Build chapter nodes using entries from chapter menu as
Alain Reguera Delgado 8f60cb
    # reference. Don't include `Licenses' or `Index' chapters here.
Alain Reguera Delgado 8f60cb
    # These chapters are part of our manual's main definition file and
Alain Reguera Delgado 8f60cb
    # shouldn't be handled as regular chapters.
Alain Reguera Delgado 8f60cb
    local CHAPTERNODES=$(cat ${MANUAL_BASEFILE}-menu.${MANUAL_EXTENSION} \
Alain Reguera Delgado 8f60cb
        | egrep -v '^@(end )?menu$' | egrep -v '^\* (Licenses|Index)::$'\
Alain Reguera Delgado 8f60cb
        | sed -r 's!^\* !!' | sed -r 's!::[[:print:]]*$!!g' \
Alain Reguera Delgado 8f60cb
        | sed -r 's! !_!g')
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Build list of inclusions from chapter nodes. 
Alain Reguera Delgado 8f60cb
    local FILENODE=$(\
Alain Reguera Delgado 8f60cb
        for CHAPTERNODE in ${CHAPTERNODES};do
Alain Reguera Delgado 8f60cb
            INCL=$(echo ${CHAPTERNODE} \
Alain Reguera Delgado 8f60cb
                | sed -r "s!(${CHAPTERNODE})!\1.${MANUAL_EXTENSION}!")
Alain Reguera Delgado 8f60cb
            # Output inclusion line using texinfo format.
Alain Reguera Delgado 8f60cb
            echo "@include $INCL"
Alain Reguera Delgado 8f60cb
        done)
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Dump organized nodes of chapters into file.
Alain Reguera Delgado 8f60cb
    echo "$FILENODE" > ${MANUAL_BASEFILE}-nodes.${MANUAL_EXTENSION}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}