Blob Blame History Raw
#!/bin/bash
#
# texinfo_createStructureChapters.sh -- This function initiates the
# chapter documentation structure of a manual, using the current
# language and template files as reference.
#
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# ----------------------------------------------------------------------
# $Id$
# ----------------------------------------------------------------------

function texinfo_createStructureChapters {

    local MANUAL_CHAPTER_DIR=''

    # Define list of chapter templates files used to build the
    # documentation manual. Do not include the `Chapters' and
    # `Licenses' directory here. The Chapters directory is used to
    # build chapters based on value of `--chapter' option passed
    # through the command-line. The `Licenses' directory is linked
    # from its default template directory.
    local FILE=''
    local FILES=$(cli_getFilesList ${MANUAL_TEMPLATE_L10N} \
        --pattern="^.+/Chapters(-menu|-nodes)?\.${MANUAL_EXTENSION}$" --mindepth='1' \
        | egrep -v '/(Chapters|Licenses)/')

    # Loop through chapter structures and create them inside the
    # manual.
    for FILE in $FILES;do

        # Redefine manual's chapter directory based on template files.
        MANUAL_CHAPTER_DIR=${MANUAL_BASEDIR_L10N}/$(basename $(dirname ${FILE}))

        # Verify texinfo templates used as based to build the chapter.
        # Be sure they are inside the working copy of CentOS Artwork
        # Repository and under version control, too.
        cli_checkFiles ${FILE} --is-versioned

        # Print action name.
        cli_printMessage "${MANUAL_CHAPTER_DIR}/$(basename ${FILE})" --as-creating-line

        # Verify chapter's directory. If it doesn't exist, create it.
        if [[ ! -d ${MANUAL_CHAPTER_DIR} ]];then
            cli_runFnEnvironment vcs --quiet --mkdir ${MANUAL_CHAPTER_DIR}
        fi

        # Copy template files into chapter's directory.
        cli_runFnEnvironment vcs --quiet --copy ${FILE} ${MANUAL_CHAPTER_DIR}

    done

    # Create link to `Licenses' default template directory. There
    # isn't a need to duplicate this information. In fact it is
    # important not to have it duplicated so we can centralize such
    # information for all documentation manuals.
    texinfo_updateLicenseLink

}