|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# help_removeEntry.sh -- This function removes a documentation entry
|
|
|
4c79b5 |
# from your working copy documentation structure.
|
|
|
4c79b5 |
#
|
|
|
7cd8e9 |
# Copyright (C) 2009, 2010 Alain Reguera Delgado
|
|
|
4c79b5 |
#
|
|
|
7cd8e9 |
# This program is free software; you can redistribute it and/or
|
|
|
7cd8e9 |
# modify it under the terms of the GNU General Public License as
|
|
|
7cd8e9 |
# published by the Free Software Foundation; either version 2 of the
|
|
|
7cd8e9 |
# License, or (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 |
|
|
|
4456e8 |
# Remove documentation entry. At this point, documentation
|
|
|
4456e8 |
# entry can be under version control or not versioned at all.
|
|
|
4456e8 |
# Here we need to decide how to remove documentation entries
|
|
|
4456e8 |
# based on whether they are under version control or not.
|
|
|
4456e8 |
if [[ "$(cli_getRepoStatus "$ENTRY")" == ' ' ]];then
|
|
|
4456e8 |
|
|
|
4456e8 |
# Documentation entry is under version control and clean
|
|
|
4456e8 |
# of changes. Only if documentation entry is clean of
|
|
|
4456e8 |
# changes we can mark it for deletion. So use subversion's
|
|
|
4456e8 |
# `del' command to do so.
|
|
|
4456e8 |
eval svn del "$ENTRY" --quiet
|
|
|
4456e8 |
|
|
|
4456e8 |
elif [[ "$(cli_getRepoStatus "$ENTRY")" == '?' ]] \
|
|
|
4456e8 |
|| [[ "$(cli_getRepoStatus "$ENTRY")" == '' ]] ;then
|
|
|
4456e8 |
|
|
|
4456e8 |
# Documentation entry is not under version control, so we
|
|
|
4456e8 |
# don't care about changes inside unversioned
|
|
|
4456e8 |
# documentation entries at all. If you say centos-art.sh
|
|
|
4456e8 |
# script to remove an unversion documentation entry it
|
|
|
4456e8 |
# will do so, using convenctional `rm' command.
|
|
|
4456e8 |
if [[ -d "$ENTRY" ]];then
|
|
|
4456e8 |
rm -r "$ENTRY"
|
|
|
4456e8 |
else
|
|
|
4456e8 |
rm "$ENTRY"
|
|
|
4456e8 |
fi
|
|
|
4456e8 |
|
|
|
4456e8 |
else
|
|
|
4456e8 |
|
|
|
4456e8 |
# Documentation entry is under version control and it does
|
|
|
4456e8 |
# have changes. We don't remove a versioned documentation
|
|
|
4456e8 |
# entry with changes. So print a message about it and stop
|
|
|
4456e8 |
# script execution.
|
|
|
4456e8 |
cli_printMessage "`gettext "The documentation entry cannot be removed."`" 'AsErrorLine'
|
|
|
4456e8 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
4456e8 |
|
|
|
4456e8 |
fi
|
|
|
4456e8 |
|
|
|
4456e8 |
# Update section's menu and nodes to reflect the fact that
|
|
|
4456e8 |
# documentation entry has been removed.
|
|
|
4c79b5 |
help_updateMenu "remove-entry"
|
|
|
4c79b5 |
help_updateNodes
|
|
|
4456e8 |
|
|
|
4456e8 |
done
|
|
|
4456e8 |
|
|
|
4456e8 |
# Update chapter's menu and nodes in the master texinfo document.
|
|
|
4456e8 |
# This is mainly applied when one of the chapters (e.g., trunk/,
|
|
|
4456e8 |
# tags/, or branches/) is removed.
|
|
|
4456e8 |
if [[ ! -d $ENTRYCHAPTER ]];then
|
|
|
4c79b5 |
help_updateChaptersMenu 'remove-entry'
|
|
|
4c79b5 |
help_updateChaptersNodes
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Update manuals' related output files.
|
|
|
4c79b5 |
help_updateOutputFiles
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|