|
Alain Reguera Delgado |
8f60cb |
#!/bin/bash
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# texinfo_updateSectionNodes.sh -- This function updates section's
|
|
Alain Reguera Delgado |
8f60cb |
# nodes definition files using section's menu definition file both
|
|
Alain Reguera Delgado |
8f60cb |
# inside the same chapter.
|
|
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_updateSectionNodes {
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Define node file.
|
|
Alain Reguera Delgado |
8f60cb |
local NODEFILE=$(echo $MENUFILE | sed -r "s,-menu,-nodes,")
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Build list of chapter nodes using entries from chapter menu as
|
|
Alain Reguera Delgado |
8f60cb |
# reference.
|
|
Alain Reguera Delgado |
8f60cb |
local NODES=$(cat ${MENUFILE} \
|
|
Alain Reguera Delgado |
8f60cb |
| sed -r 's!^\* !!' | sed -r 's!:{1,2}.*$!!g' \
|
|
Alain Reguera Delgado |
8f60cb |
| egrep -v '^@(end )?menu$' | sed -r 's! !:!g')
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Build chapter nodes based on chapter menu.
|
|
Alain Reguera Delgado |
8f60cb |
for NODE in $NODES;do
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
local NODE=$(echo "${NODE}" | sed -r 's!:! !g')
|
|
Alain Reguera Delgado |
8f60cb |
local INCL=$(echo "${NODE}" | sed -r -e 's! !/!' -e 's! !-!g' -e's!/(.+)!/\L\1!').${MANUAL_EXTENSION}
|
|
Alain Reguera Delgado |
8f60cb |
local SECT=$(texinfo_getEntryTitle "$NODE")
|
|
Alain Reguera Delgado |
8f60cb |
local CIND=$(texinfo_getEntryIndex "$NODE")
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Initialize absolute path to final texinfo template.
|
|
Alain Reguera Delgado |
8f60cb |
local TEMPLATE=''
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Create texinfo section file using templates, only if the
|
|
Alain Reguera Delgado |
8f60cb |
# section file doesn't exist and hasn't been marked for
|
|
Alain Reguera Delgado |
8f60cb |
# deletion. Otherwise, when the files have been marked for
|
|
Alain Reguera Delgado |
8f60cb |
# deletion, they will be created again from texinfo template
|
|
Alain Reguera Delgado |
8f60cb |
# to working copy and that might create confusion.
|
|
Alain Reguera Delgado |
8f60cb |
if [[ ! -f ${MANUAL_BASEDIR_L10N}/$INCL ]] \
|
|
Alain Reguera Delgado |
8f60cb |
&& [[ $(cli_runFnEnvironment vcs --status ${MANUAL_BASEDIR_L10N}/$INCL) != 'D' ]];then
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Retrieve configuration lines from configuration file. Be
|
|
Alain Reguera Delgado |
8f60cb |
# sure no line beginning with `#' or space remain in the
|
|
Alain Reguera Delgado |
8f60cb |
# line. Otherwise, it would be difficult to loop through
|
|
Alain Reguera Delgado |
8f60cb |
# configuration lines.
|
|
Alain Reguera Delgado |
8f60cb |
local CONFLINE=''
|
|
Alain Reguera Delgado |
8f60cb |
local CONFLINES=$(cli_getConfigLines "${MANUAL_CONFIG_FILE}" "templates" "*")
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Initialize both left hand side and right hand side
|
|
Alain Reguera Delgado |
8f60cb |
# configuration values.
|
|
Alain Reguera Delgado |
8f60cb |
local CONFLHS=''
|
|
Alain Reguera Delgado |
8f60cb |
local CONFRHS=''
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Define what section template to apply using
|
|
Alain Reguera Delgado |
8f60cb |
# documentation entry absolute path and values provided by
|
|
Alain Reguera Delgado |
8f60cb |
# configuration line. Be sure to break the loop in the
|
|
Alain Reguera Delgado |
8f60cb |
# first match.
|
|
Alain Reguera Delgado |
8f60cb |
for CONFLINE in $CONFLINES;do
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
CONFLHS=$(echo $CONFLINE \
|
|
Alain Reguera Delgado |
8f60cb |
| gawk 'BEGIN{FS="="}; { print $1 }' \
|
|
Alain Reguera Delgado |
8f60cb |
| sed -r 's![[:space:]]*!!g')
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
CONFRHS=$(echo $CONFLINE \
|
|
Alain Reguera Delgado |
8f60cb |
| gawk 'BEGIN{FS="="}; { print $2 }' \
|
|
Alain Reguera Delgado |
8f60cb |
| sed -r -e 's![[:space:]]*!!g' -e 's!^"(.+)"$!\1!')
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
if [[ ${MANUAL_BASEDIR_L10N}/${INCL} =~ $CONFRHS ]];then
|
|
Alain Reguera Delgado |
8f60cb |
TEMPLATE="${MANUAL_TEMPLATE_L10N}/${CONFLHS}"
|
|
Alain Reguera Delgado |
8f60cb |
break
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
done
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Verify existence of texinfo template file. If no
|
|
Alain Reguera Delgado |
8f60cb |
# template is found, stop script execution with an error
|
|
Alain Reguera Delgado |
8f60cb |
# message. We cannot continue without it.
|
|
Alain Reguera Delgado |
8f60cb |
cli_checkFiles -e ${TEMPLATE}
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Create documentation entry using texinfo template as
|
|
Alain Reguera Delgado |
8f60cb |
# reference.
|
|
Alain Reguera Delgado |
8f60cb |
cli_runFnEnvironment vcs --copy --quiet ${TEMPLATE} ${MANUAL_BASEDIR_L10N}/$INCL
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Expand common translation markers in documentation entry.
|
|
Alain Reguera Delgado |
8f60cb |
cli_expandTMarkers "${MANUAL_BASEDIR_L10N}/$INCL"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Replace node, section and concept index definitions already
|
|
Alain Reguera Delgado |
8f60cb |
# defined with node, section and concept index translation
|
|
Alain Reguera Delgado |
8f60cb |
# markers. Otherwise, incorrect sectioning may happen. Take
|
|
Alain Reguera Delgado |
8f60cb |
# care with index definitions, more than one index definition
|
|
Alain Reguera Delgado |
8f60cb |
# might be found in the section file but only the first
|
|
Alain Reguera Delgado |
8f60cb |
# concept index entry (i.e., `cindex') will be updated, the
|
|
Alain Reguera Delgado |
8f60cb |
# rest will remain as they are.
|
|
Alain Reguera Delgado |
8f60cb |
sed -i -r \
|
|
Alain Reguera Delgado |
8f60cb |
-e '/^@node/c@node =NODE=' \
|
|
Alain Reguera Delgado |
8f60cb |
-e '/^@section/c@section =SECT=' \
|
|
Alain Reguera Delgado |
8f60cb |
-e '0,/^@cindex/c@cindex =CIND=' \
|
|
Alain Reguera Delgado |
8f60cb |
"${MANUAL_BASEDIR_L10N}/$INCL"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Before expanding node, section and concept index, be sure
|
|
Alain Reguera Delgado |
8f60cb |
# that all slash characters (`/') be escaped. Otherwise, they
|
|
Alain Reguera Delgado |
8f60cb |
# might be interpreted as separators and that isn't
|
|
Alain Reguera Delgado |
8f60cb |
# desirable in anyway.
|
|
Alain Reguera Delgado |
8f60cb |
NODE=$(echo "$NODE" | sed -r 's/\//\\\//g')
|
|
Alain Reguera Delgado |
8f60cb |
SECT=$(echo "$SECT" | sed -r 's/\//\\\//g')
|
|
Alain Reguera Delgado |
8f60cb |
CIND=$(echo "$CIND" | sed -r 's/\//\\\//g')
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Expand node, section and concept index translation
|
|
Alain Reguera Delgado |
8f60cb |
# markers in documentation entry.
|
|
Alain Reguera Delgado |
8f60cb |
sed -i -r \
|
|
Alain Reguera Delgado |
8f60cb |
-e "s/=NODE=/${NODE}/g" \
|
|
Alain Reguera Delgado |
8f60cb |
-e "s/=SECT=/${SECT}/g" \
|
|
Alain Reguera Delgado |
8f60cb |
-e "s/=CIND=/${CIND}/g" \
|
|
Alain Reguera Delgado |
8f60cb |
"${MANUAL_BASEDIR_L10N}/$INCL"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Verify existence of Chapter-nodes template file. If no
|
|
Alain Reguera Delgado |
8f60cb |
# Chapter-nodes template is found, stop script execution with
|
|
Alain Reguera Delgado |
8f60cb |
# an error message. We cannot continue without it.
|
|
Alain Reguera Delgado |
8f60cb |
cli_checkFiles -e ${MANUAL_TEMPLATE_L10N}/Chapters-nodes.${MANUAL_EXTENSION}
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Expand chapter node inclusion definition.
|
|
Alain Reguera Delgado |
8f60cb |
cat ${MANUAL_TEMPLATE_L10N}/Chapters-nodes.${MANUAL_EXTENSION} \
|
|
Alain Reguera Delgado |
8f60cb |
| sed -r "s!=INCL=!${INCL}!g"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Dump chapter node definition into manual structure.
|
|
Alain Reguera Delgado |
8f60cb |
done > ${NODEFILE}
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
}
|