|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# help_removeEntry.sh -- This function removes a documentation entry
|
|
|
4c79b5 |
# from your working copy documentation structure.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# Copyright (C) 2009-2010 Alain Reguera Delgado
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# This program is free software; you can redistribute it and/or modify
|
|
|
4c79b5 |
# it under the terms of the GNU General Public License as published by
|
|
|
4c79b5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
4c79b5 |
# (at your option) any later version.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# This program is distributed in the hope that it will be useful, but
|
|
|
4c79b5 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
4c79b5 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
4c79b5 |
# General Public License for more details.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# You should have received a copy of the GNU General Public License
|
|
|
4c79b5 |
# along with this program; if not, write to the Free Software
|
|
|
4c79b5 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
4c79b5 |
# USA.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function help_removeEntry {
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define variables as local to avoid conflicts outside.
|
|
|
4c79b5 |
local ENTRIES=''
|
|
|
4c79b5 |
local ENTRIES_COUNTER=0
|
|
|
4c79b5 |
local LOCATION=''
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Check if the entry has been already removed.
|
|
|
4c79b5 |
if [[ ! -f $ENTRY ]];then
|
|
|
4c79b5 |
cli_printMessage "`gettext "The following entry doesn't exist:"`"
|
|
|
4c79b5 |
cli_printMessage "$ENTRY" "AsResponseLine"
|
|
|
1f1b3c |
cli_printMessage "$(caller)" "AsToKnowMoreLine"
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define entries. Start with the one being processed currently.
|
|
|
4c79b5 |
ENTRIES=$ENTRY
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define root location to look for entries.
|
|
|
4c79b5 |
LOCATION=$(echo $ENTRY | sed -r 's!\.texi$!!')
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Re-define location to match the chapter's root directory. This
|
|
|
4c79b5 |
# applies when you try to remove the whole chapter from the
|
|
|
4c79b5 |
# working copy (e.g., centos-art help --remove=/home/centos/artwork/trunk/).
|
|
|
4c79b5 |
if [[ $ENTRY =~ "${MANUALS_FILE[7]}$" ]];then
|
|
|
4c79b5 |
LOCATION=$(dirname $ENTRY)
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
3a4c5e |
# Look for dependent entries. In this context, dependent entries
|
|
|
4c79b5 |
# are all files ending in .texi which have a directory name that
|
|
|
4c79b5 |
# matches the file name (without .texi extension) of the entry
|
|
|
4c79b5 |
# being processed currently. See LOCATION default definition
|
|
|
3a4c5e |
# above. If location directory doesn't exist it is probably
|
|
|
3a4c5e |
# because there is no dependent entries.
|
|
|
4c79b5 |
if [[ -d $LOCATION ]];then
|
|
|
4c79b5 |
for ENTRY in $(find $LOCATION -name '*.texi');do
|
|
|
4c79b5 |
ENTRIES="$ENTRIES $ENTRY $(dirname $ENTRY)"
|
|
|
4c79b5 |
ENTRIES_COUNTER=$(($ENTRIES_COUNTER + 1))
|
|
|
4c79b5 |
done
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Remove duplicated lines from entries list.
|
|
|
4c79b5 |
ENTRIES=$(echo "$ENTRIES" | tr ' ' "\n" | sort -r | uniq)
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Show a verification message before doing anything.
|
|
|
4c79b5 |
cli_printMessage "`ngettext "The following entry will be removed:" \
|
|
|
4c79b5 |
"The following entries will be removed:" \
|
|
|
4c79b5 |
$ENTRIES_COUNTER`"
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Show list of affected entries.
|
|
|
4c79b5 |
for ENTRY in $ENTRIES;do
|
|
|
4c79b5 |
cli_printMessage "$ENTRY" "AsResponseLine"
|
|
|
4c79b5 |
done
|
|
|
4c79b5 |
|
|
|
4c79b5 |
cli_printMessage "`gettext "Do you want to continue?"`" "AsYesOrNoRequestLine"
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Re-define ENTRY using affected entries as reference.
|
|
|
4c79b5 |
for ENTRY in $ENTRIES;do
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Show which entry is being removed.
|
|
|
4c79b5 |
cli_printMessage "$ENTRY" "AsRemovingLine"
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Try to remove it from working copy using subversion's
|
|
|
4c79b5 |
# del command.
|
|
|
4c79b5 |
eval svn del $ENTRY --force --quiet
|
|
|
4c79b5 |
|
|
|
4c79b5 |
done
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Update menu and nodes in order to produce output files
|
|
|
4c79b5 |
# correctly.
|
|
|
4c79b5 |
if [[ -d $ENTRYCHAPTER ]];then
|
|
|
4c79b5 |
# At this point the chapter directory was not removed but
|
|
|
4c79b5 |
# we need to update its menu and nodes to reflect the fact
|
|
|
4c79b5 |
# that some documentation entries were removed inside it.
|
|
|
4c79b5 |
help_updateMenu "remove-entry"
|
|
|
4c79b5 |
help_updateNodes
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
# At this point the chapter directory and all its sections
|
|
|
4c79b5 |
# were removed. Update the menu and nodes in the master
|
|
|
4c79b5 |
# texinfo document to reflect that fact.
|
|
|
4c79b5 |
help_updateChaptersMenu 'remove-entry'
|
|
|
4c79b5 |
help_updateChaptersNodes
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Update manuals' related output files.
|
|
|
4c79b5 |
help_updateOutputFiles
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|