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

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