Blame Scripts/Bash/Functions/Help/Texinfo/texinfo_copyEntrySection.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# texinfo_copyEntrySection.sh -- This function standardizes section
878a2b
# duplication inside manuals written in texinfo format.
878a2b
#
878a2b
# Copyright (C) 2009, 2010, 2011 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
878a2b
function texinfo_copyEntrySection {
878a2b
878a2b
    # Define absolute path to section source and target locations
878a2b
    # based on non-option arguments passed to `centos-art.sh' script.
878a2b
    if [[ ${MANUAL_SECT[((${MANUAL_DOCENTRY_ID} + 1))]} != '' ]];then
878a2b
878a2b
        # When the section name is specified in first and second
878a2b
        # non-option arguments, source and target are set as specified
878a2b
        # in first and second non-option arguments respectively.
878a2b
        MANUAL_ENTRY_SRC=$(texinfo_getEntry ${MANUAL_SECT[${MANUAL_DOCENTRY_ID}]})
878a2b
        MANUAL_ENTRY_DST=$(texinfo_getEntry ${MANUAL_SECT[((${MANUAL_DOCENTRY_ID} + 1))]})
878a2b
878a2b
    elif [[ ${MANUAL_SECT[((${MANUAL_DOCENTRY_ID} + 1))]} == '' ]] \
878a2b
        && [[ ${MANUAL_CHAP[((${MANUAL_DOCENTRY_ID} + 1))]} != '' ]];then
878a2b
878a2b
        # When the section name is specified only in the first
878a2b
        # non-option argument and the chapter name has been provided
878a2b
        # in the second non-option argument, use the section name
878a2b
        # passed in first argument to build the section name that will
878a2b
        # be used as target.
878a2b
        MANUAL_ENTRY_SRC=$(texinfo_getEntry ${MANUAL_SECT[${MANUAL_DOCENTRY_ID}]})
878a2b
        MANUAL_ENTRY_DST=$(echo $MANUAL_ENTRY_SRC \
878a2b
            | sed -r "s!${MANUAL_CHAP[${MANUAL_DOCENTRY_ID}]}!${MANUAL_CHAP[((${MANUAL_DOCENTRY_ID} + 1))]}!")
878a2b
878a2b
    else
878a2b
        cli_printMessage "`gettext "The location provided as target isn't valid."`" --as-error-line
878a2b
    fi
878a2b
878a2b
    # Print separator line along with action message.
878a2b
    cli_printMessage '-' --as-separator-line
878a2b
    cli_printMessage "${MANUAL_ENTRY_DST}" --as-creating-line
878a2b
878a2b
    # Verify entry source and target locations.
878a2b
    texinfo_checkEntrySrcDst "${MANUAL_ENTRY_SRC}" "${MANUAL_ENTRY_DST}"
878a2b
878a2b
    # Copy section entry from source to target using subversion.
878a2b
    svn cp "${MANUAL_ENTRY_SRC}" "${MANUAL_ENTRY_DST}" --quiet
878a2b
878a2b
    # Redefine chapter name using chapter name passed to
878a2b
    # `centos-art.sh' script as second non-option argument.
878a2b
    local MANUAL_CHAPTER_NAME=${MANUAL_CHAP[((${MANUAL_DOCENTRY_ID} + 1))]}
878a2b
878a2b
    # Redefine chapter directory to use the chapter provided to
878a2b
    # `centos-art.sh' script as second non-option argument. This is
878a2b
    # required in order to update the `chapter-menu.texinfo' file
878a2b
    # inside the target chapter where section entry was copied to, not
878a2b
    # the source chapter where the section entry was taken from.  This
878a2b
    # is particulary useful section entries are copied from one
878a2b
    # chapter into another different.
878a2b
    local MANUAL_CHAPTER_DIR=$(dirname ${MANUAL_ENTRY_DST})
878a2b
878a2b
    # At this point, all copying actions and chapter related
878a2b
    # redefinitions have took place. It is time, then, to update the
878a2b
    # document structure using the information collected so far.
878a2b
    texinfo_updateStructureSection "${MANUAL_ENTRY_DST}"
878a2b
878a2b
}