Blame Automation/centos-art.sh-mods/Help/Texinfo/texinfo_deleteEntryChapter.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# texinfo_deleteEntryChapter.sh -- This function standardizes chapter
Alain Reguera Delgado 8f60cb
# deletion inside the manual structure.
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_deleteEntryChapter {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Verify existence of documentation entry before deleting it.
Alain Reguera Delgado 8f60cb
    # We cannot delete an entry which doesn't exist.
Alain Reguera Delgado 8f60cb
    cli_checkFiles "${MANUAL_CHAPTER_DIR}" -d
Alain Reguera Delgado 8f60cb
    cli_checkFiles "${MANUAL_CHAPTER_DIR}-menu.${MANUAL_EXTENSION}" -f
Alain Reguera Delgado 8f60cb
    cli_checkFiles "${MANUAL_CHAPTER_DIR}-nodes.${MANUAL_EXTENSION}" -f
Alain Reguera Delgado 8f60cb
    cli_checkFiles "${MANUAL_CHAPTER_DIR}.${MANUAL_EXTENSION}" -f
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define list of chapters that shouldn't be removed.
Alain Reguera Delgado 8f60cb
    local SPECIAL_CHAPTERS='/(Licenses|Index)$'
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Verify list of chapters that shouldn't be removed against the
Alain Reguera Delgado 8f60cb
    # current chapter directory being removed.
Alain Reguera Delgado 8f60cb
    if [[ $MANUAL_CHAPTER_DIR =~ $SPECIAL_CHAPTERS ]];then
Alain Reguera Delgado 8f60cb
        cli_printMessage "`gettext "The chapter specified cannot be removed."`" --as-error-line
Alain Reguera Delgado 8f60cb
    fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Build list of section entries inside the chapter. This is
Alain Reguera Delgado 8f60cb
    # required to delete cross references from other section entries
Alain Reguera Delgado 8f60cb
    # that point to section entries inside the chapter that will be
Alain Reguera Delgado 8f60cb
    # deleted. Take care don't include the chapter definition files.
Alain Reguera Delgado 8f60cb
    local MANUAL_ENTRIES=$(cli_getFilesList $MANUAL_CHAPTER_DIR \
Alain Reguera Delgado 8f60cb
        --pattern="^/.+\.${MANUAL_EXTENSION}$")
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Remove chapter directory and related files using version control
Alain Reguera Delgado 8f60cb
    # to register the change.
Alain Reguera Delgado 8f60cb
    cli_runFnEnvironment vcs --delete ${MANUAL_CHAPTER_DIR}
Alain Reguera Delgado 8f60cb
    cli_runFnEnvironment vcs --delete ${MANUAL_CHAPTER_DIR}-menu.${MANUAL_EXTENSION}
Alain Reguera Delgado 8f60cb
    cli_runFnEnvironment vcs --delete ${MANUAL_CHAPTER_DIR}-nodes.${MANUAL_EXTENSION}
Alain Reguera Delgado 8f60cb
    cli_runFnEnvironment vcs --delete ${MANUAL_CHAPTER_DIR}.${MANUAL_EXTENSION}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Update chapter menu and nodes inside manual structure.
Alain Reguera Delgado 8f60cb
    texinfo_updateChapterMenu --delete-entry
Alain Reguera Delgado 8f60cb
    texinfo_updateChapterNodes
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Loop through section entries retrieved from chapter, before
Alain Reguera Delgado 8f60cb
    # deleting it, in order to remove cross references pointing to
Alain Reguera Delgado 8f60cb
    # those section entries. Since the chapter and all its sections
Alain Reguera Delgado 8f60cb
    # have been removed, cross references pointing them will point to
Alain Reguera Delgado 8f60cb
    # non-existent section entries. This way, all cross references
Alain Reguera Delgado 8f60cb
    # pointing to non-existent section entries will be transformed in
Alain Reguera Delgado 8f60cb
    # order for documenters to advertise the section entry state.
Alain Reguera Delgado 8f60cb
    for MANUAL_ENTRY in $MANUAL_ENTRIES;do
Alain Reguera Delgado 8f60cb
        texinfo_deleteCrossReferences ${MANUAL_ENTRY}
Alain Reguera Delgado 8f60cb
    done
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}