|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# texinfo_updateStructureSection.sh -- This function looks for all
|
|
|
878a2b |
# section entry files inside manual's base directory and updates menu,
|
|
|
878a2b |
# nodes and cross references definitions for them all, one at a time.
|
|
|
878a2b |
#
|
|
|
03486a |
# Copyright (C) 2009, 2010, 2011, 2012 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_updateStructureSection {
|
|
|
878a2b |
|
|
|
878a2b |
local PATTERN=''
|
|
|
878a2b |
local MANUAL_ENTRIES=''
|
|
|
878a2b |
local ACTIONNAM_SECMENU=''
|
|
|
878a2b |
local ACTIONNAM_CROSREF=''
|
|
|
878a2b |
|
|
|
878a2b |
# Define regular expression pattern used to build the list of
|
|
|
878a2b |
# section entries that will be processed.
|
|
|
878a2b |
if [[ "$1" != '' ]];then
|
|
|
878a2b |
PATTERN="$1"
|
|
|
878a2b |
else
|
|
|
878a2b |
PATTERN="${MANUAL_ENTRY}"
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
# Verify the pattern value considering both the chapter and
|
|
|
878a2b |
# section names. This is required when no chapter or section name
|
|
|
878a2b |
# is provided to `centos-art.sh' script, as non-option argument in
|
|
|
878a2b |
# the command-line (e.g., `centos-art help --update-structure').
|
|
|
878a2b |
if [[ $PATTERN =~ "${MANUAL_NAME}\.${MANUAL_EXTENSION}$" ]] \
|
|
|
878a2b |
|| [[ $PATTERN =~ "chapter\.${MANUAL_EXTENSION}$" ]];then
|
|
|
878a2b |
PATTERN="$(dirname ${MANUAL_ENTRY})/.+\.${MANUAL_EXTENSION}"
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
# Define action to perform on menu, nodes and cross references
|
|
|
878a2b |
# definitions.
|
|
|
878a2b |
case "$2" in
|
|
|
878a2b |
|
|
|
878a2b |
--delete )
|
|
|
878a2b |
|
|
|
878a2b |
# Remove menu and node definitions for sections inside
|
|
|
878a2b |
# manual, in order to reflect the changes.
|
|
|
878a2b |
ACTIONNAM_SECMENU='updateSectionMenu --delete-entry'
|
|
|
878a2b |
|
|
|
878a2b |
# Remove cross reference definitions inside manual
|
|
|
878a2b |
# structure.
|
|
|
878a2b |
ACTIONNAM_CROSREF='deleteCrossReferences'
|
|
|
878a2b |
;;
|
|
|
878a2b |
|
|
|
878a2b |
--update | * )
|
|
|
878a2b |
|
|
|
878a2b |
# Update menu and node definitions for sections inside
|
|
|
878a2b |
# manual, in order to reflect the changes.
|
|
|
878a2b |
ACTIONNAM_SECMENU='updateSectionMenu --add-entry'
|
|
|
878a2b |
|
|
|
878a2b |
# Resotre cross reference definitions inside manual
|
|
|
878a2b |
# structure. If a documentation entry has been removed by
|
|
|
878a2b |
# mistake and that mistake is later fixed by adding the
|
|
|
878a2b |
# removed documentation entry back into the manual
|
|
|
878a2b |
# structure, it is necessary to rebuild the missing cross
|
|
|
878a2b |
# reference information inside the manual structure in
|
|
|
878a2b |
# order to reactivate the removed cross refereces, as
|
|
|
878a2b |
# well.
|
|
|
878a2b |
ACTIONNAM_CROSREF='restoreCrossReferences'
|
|
|
878a2b |
;;
|
|
|
878a2b |
|
|
|
878a2b |
esac
|
|
|
878a2b |
|
|
|
878a2b |
# Define list of target entries using find's regular expression
|
|
|
878a2b |
# pattern as reference. Notice that, when we update section
|
|
|
878a2b |
# definition files, the files already exist in the working copy so
|
|
|
878a2b |
# the pattern can be its absolute path without any problem. If the
|
|
|
878a2b |
# pattern is built correctly, it will match the location and so be
|
|
|
878a2b |
# returned to build the list of entries to process. Notice also
|
|
|
878a2b |
# that, when updating, it is possible to use a regular expression
|
|
|
878a2b |
# to match more than one location and build the list of entries
|
|
|
878a2b |
# based on such matching. In this last configuration, let you to
|
|
|
878a2b |
# update menu, nodes and cross references to many section
|
|
|
878a2b |
# definitions (i.e., all those section definition file that match
|
|
|
878a2b |
# the pattern you specified).
|
|
|
878a2b |
MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR_L10N} \
|
|
|
878a2b |
--pattern="${PATTERN}" | egrep -v "/(${MANUAL_NAME}|chapter)")
|
|
|
878a2b |
|
|
|
878a2b |
# Verify list of target entries. Assuming is is empty, define
|
|
|
878a2b |
# list of target documentation entries using pattern as reference
|
|
|
878a2b |
# instead. When we delete a section entry from the working copy,
|
|
|
878a2b |
# using find to retrive its path isn't possible because the
|
|
|
878a2b |
# section definition file is removed before executing find and by
|
|
|
878a2b |
# consequence no match is found. This issue provokes no section
|
|
|
878a2b |
# entry to be removed from menu, nodes and cross references. In
|
|
|
878a2b |
# order to solve this, use the pattern value as list of target
|
|
|
878a2b |
# entries. Notice that, in this case, the pattern value must be
|
|
|
878a2b |
# the absolute path to that documentation entry which doesn't
|
|
|
878a2b |
# exist and we want to update menu, nodes and cross references
|
|
|
878a2b |
# information for.
|
|
|
228c64 |
if [[ $MANUAL_ENTRIES == '' ]] && [[ $PATTERN =~ '^/[[:alnum:]./_-]+$' ]];then
|
|
|
878a2b |
MANUAL_ENTRIES=${PATTERN}
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
c15d00 |
# Verify list of target entries. Assuming it is still empty, there
|
|
|
c15d00 |
# is nothing else to do here but printing an error message
|
|
|
878a2b |
# describing the fact that no section entry was found to process.
|
|
|
878a2b |
if [[ $MANUAL_ENTRIES == '' ]];then
|
|
|
878a2b |
cli_printMessage "`gettext "No section entry found to process."`" --as-error-line
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
# Loop through target documentation entries in order to update the
|
|
|
878a2b |
# documentation structure (e.g., it is not enough with copying
|
|
|
878a2b |
# documentation entry files, it is also needed to update menu,
|
|
|
878a2b |
# nodes and related cross-references).
|
|
|
878a2b |
for MANUAL_ENTRY in ${MANUAL_ENTRIES};do
|
|
|
c15d00 |
|
|
|
c15d00 |
# Don't print action message here. Instead, use the related
|
|
|
c15d00 |
# action functionality for doing so. Otherwise, if we print it
|
|
|
c15d00 |
# here, delete actions will display a creating line for the
|
|
|
c15d00 |
# documentation entry already deleted which is rather awkward.
|
|
|
c15d00 |
|
|
|
878a2b |
texinfo_${ACTIONNAM_SECMENU}
|
|
|
878a2b |
texinfo_updateSectionNodes
|
|
|
878a2b |
texinfo_makeSeeAlso "${MANUAL_ENTRY}"
|
|
|
878a2b |
texinfo_${ACTIONNAM_CROSREF} "${MANUAL_ENTRY}"
|
|
|
c15d00 |
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
}
|