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

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# texinfo_copyEntryChapter.sh -- This function standardizes chapter
Alain Reguera Delgado 8f60cb
# duplication inside manuals written in texinfo format.
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_copyEntryChapter {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Redefine documentation entry source's location.
Alain Reguera Delgado 8f60cb
    MANUAL_ENTRY_SRC=${MANUAL_BASEDIR_L10N}/${MANUAL_CHAP[${MANUAL_DOCENTRY_ID}]}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Redefine documentation entry target's location.
Alain Reguera Delgado 8f60cb
    MANUAL_ENTRY_DST=${MANUAL_BASEDIR_L10N}/${MANUAL_CHAP[((${MANUAL_DOCENTRY_ID} + 1))]}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Verify entry source and target locations.
Alain Reguera Delgado 8f60cb
    texinfo_checkEntrySrcDst "${MANUAL_ENTRY_SRC}" "${MANUAL_ENTRY_DST}"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # When we are copying chapters, document structure actualization
Alain Reguera Delgado 8f60cb
    # needs to be performed against the target chapter not the source
Alain Reguera Delgado 8f60cb
    # one used to create the duplication.  To achieve this goal,
Alain Reguera Delgado 8f60cb
    # define both chapter's directory and chapter's name at this
Alain Reguera Delgado 8f60cb
    # point.
Alain Reguera Delgado 8f60cb
    local MANUAL_CHAPTER_DIR=$MANUAL_ENTRY_DST
Alain Reguera Delgado 8f60cb
    local MANUAL_CHAPTER_NAME=${MANUAL_CHAP[((${MANUAL_DOCENTRY_ID} + 1))]}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # When we are copying chapters, the chapter itself cannot be
Alain Reguera Delgado 8f60cb
    # copied as we regularly do with sections. Instead, the target
Alain Reguera Delgado 8f60cb
    # chapter must be created as a new chapter and then sections from
Alain Reguera Delgado 8f60cb
    # source chapter must be copied one by one to the recently created
Alain Reguera Delgado 8f60cb
    # chapter. At this point then, is when menu, nodes and cross
Alain Reguera Delgado 8f60cb
    # references for the new chapter are updated.
Alain Reguera Delgado 8f60cb
    texinfo_createChapter
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Create list of sections from source chapter that need to be
Alain Reguera Delgado 8f60cb
    # copied to target chapter. Don't include chapter's main
Alain Reguera Delgado 8f60cb
    # definition files.
Alain Reguera Delgado 8f60cb
    local MANUAL_ENTRIES=$(cli_getFilesList $MANUAL_ENTRY_SRC \
Alain Reguera Delgado 8f60cb
        --pattern="^.+\.${MANUAL_EXTENSION}$" | egrep -v '/chapter')
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    for MANUAL_ENTRY in $MANUAL_ENTRIES;do
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Copy sections from source chapter to target chapter.
Alain Reguera Delgado 8f60cb
        cli_runFnEnvironment vcs --copy $MANUAL_ENTRY $MANUAL_ENTRY_DST
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Update section menu, nodes and cross reference definitions
Alain Reguera Delgado 8f60cb
        # to all sections inside the documentation manual.
Alain Reguera Delgado 8f60cb
        texinfo_updateStructureSection "${MANUAL_ENTRY_DST}/$(basename ${MANUAL_ENTRY})"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    done
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Update chapter menu and node definitions inside the manual
Alain Reguera Delgado 8f60cb
    # structure.
Alain Reguera Delgado 8f60cb
    texinfo_updateChapterMenu
Alain Reguera Delgado 8f60cb
    texinfo_updateChapterNodes
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}