|
Alain Reguera Delgado |
8f60cb |
#!/bin/bash
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# texinfo_updateChapterMenu.sh -- This function updates chapter menu.
|
|
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_updateChapterMenu {
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
local ACTION=$1
|
|
Alain Reguera Delgado |
8f60cb |
local MENUCHAPTERS=''
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Print action name.
|
|
Alain Reguera Delgado |
8f60cb |
cli_printMessage "${MANUAL_BASEFILE}-menu.${MANUAL_EXTENSION}" --as-creating-line
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Build menu of chapters. The Index node is not included as other
|
|
Alain Reguera Delgado |
8f60cb |
# nodes are. The Index node is defined inside the master texinfo
|
|
Alain Reguera Delgado |
8f60cb |
# file (repository.texinfo) as an included file. To create the final
|
|
Alain Reguera Delgado |
8f60cb |
# .info file correctly, the Index line in the menu should remain,
|
|
Alain Reguera Delgado |
8f60cb |
# even no other node exist.
|
|
Alain Reguera Delgado |
8f60cb |
if [[ -f ${MANUAL_BASEFILE}-menu.${MANUAL_EXTENSION} ]];then
|
|
Alain Reguera Delgado |
8f60cb |
MENUCHAPTERS=$(cat ${MANUAL_BASEFILE}-menu.${MANUAL_EXTENSION} \
|
|
Alain Reguera Delgado |
8f60cb |
| egrep -v "^@(end )?menu$" \
|
|
Alain Reguera Delgado |
8f60cb |
| egrep -v '^\* (Licenses|Index)::$')
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Re-defined menu of chapters based on action.
|
|
Alain Reguera Delgado |
8f60cb |
case $ACTION in
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
--delete-entry )
|
|
Alain Reguera Delgado |
8f60cb |
# Remove chapter from menu.
|
|
Alain Reguera Delgado |
8f60cb |
MENUCHAPTERS=$(echo "${MENUCHAPTERS}" \
|
|
Alain Reguera Delgado |
8f60cb |
| egrep -v '^\* '"${MANUAL_CHAPTER_NAME}"'::[[:print:]]*$')
|
|
Alain Reguera Delgado |
8f60cb |
;;
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
--add-entry | * )
|
|
Alain Reguera Delgado |
8f60cb |
# Update chapter menu using texinfo format. Be sure the
|
|
Alain Reguera Delgado |
8f60cb |
# chapter node itself is not included here, that would
|
|
Alain Reguera Delgado |
8f60cb |
# duplicate it inside the menu definition file which end
|
|
Alain Reguera Delgado |
8f60cb |
# up being a definition error. Take care the way you quote
|
|
Alain Reguera Delgado |
8f60cb |
# egrep's pattern, prevent to end up using the syntax
|
|
Alain Reguera Delgado |
8f60cb |
# `$"..."' which has security risks.
|
|
Alain Reguera Delgado |
8f60cb |
MENUCHAPTERS="$(echo "${MENUCHAPTERS}" \
|
|
Alain Reguera Delgado |
8f60cb |
| egrep -v '\* '"${MANUAL_CHAPTER_NAME}"'::[[:print:]]*$')
|
|
Alain Reguera Delgado |
8f60cb |
* ${MANUAL_CHAPTER_NAME}::"
|
|
Alain Reguera Delgado |
8f60cb |
;;
|
|
Alain Reguera Delgado |
8f60cb |
esac
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Remove opening spaces/tabs and empty line from the menu of
|
|
Alain Reguera Delgado |
8f60cb |
# chapters. Empty lines may occur the first time the menu of
|
|
Alain Reguera Delgado |
8f60cb |
# chapters is created.
|
|
Alain Reguera Delgado |
8f60cb |
MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sed -r 's!^[[:space:]]+!!' \
|
|
Alain Reguera Delgado |
8f60cb |
| egrep -v '^[[:space:]]*$')
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Organize menu of chapters alphabetically and verify that no
|
|
Alain Reguera Delgado |
8f60cb |
# duplicated line be included on the list. Notice that organizing
|
|
Alain Reguera Delgado |
8f60cb |
# menu this way suppresses the idea of putting the last chapter
|
|
Alain Reguera Delgado |
8f60cb |
# created at the end of the list.
|
|
Alain Reguera Delgado |
8f60cb |
#MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sort | uniq)
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Give format to final menu output.
|
|
Alain Reguera Delgado |
8f60cb |
MENUCHAPTERS="@menu
|
|
Alain Reguera Delgado |
8f60cb |
${MENUCHAPTERS}
|
|
Alain Reguera Delgado |
8f60cb |
* Licenses::
|
|
Alain Reguera Delgado |
8f60cb |
* Index::
|
|
Alain Reguera Delgado |
8f60cb |
@end menu"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Remove opening space/tabs from menu's final definition.
|
|
Alain Reguera Delgado |
8f60cb |
MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sed -r 's!^[[:space:]]+!!' \
|
|
Alain Reguera Delgado |
8f60cb |
| egrep -v '^[[:space:]]*$')
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Dump organized menu of chapters into file.
|
|
Alain Reguera Delgado |
8f60cb |
echo "${MENUCHAPTERS}" > ${MANUAL_BASEFILE}-menu.${MANUAL_EXTENSION}
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
}
|