|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
4de5d4 |
# manual_removeEntry.sh -- This function removes a documentation entry
|
|
|
4c79b5 |
# from your working copy documentation structure.
|
|
|
4c79b5 |
#
|
|
|
9f5f2e |
# Copyright (C) 2009-2011 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 |
|
|
|
4de5d4 |
function manual_removeEntry {
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define variables as local to avoid conflicts outside.
|
|
|
4c79b5 |
local ENTRIES=''
|
|
|
abc39e |
local ENTRIES_COUNTER=1
|
|
|
4c79b5 |
local LOCATION=''
|
|
|
4c79b5 |
|
|
|
f8fb31 |
# Check changes in the working copy.
|
|
|
f8fb31 |
cli_commitRepoChanges "$ENTRY"
|
|
|
f8fb31 |
|
|
|
4c79b5 |
# Check if the entry has been already removed.
|
|
|
4c79b5 |
if [[ ! -f $ENTRY ]];then
|
|
|
abc39e |
cli_printMessage "`eval_gettext "The entry \\\`\\\$ENTRY' doesn't exist."`" 'AsErrorLine'
|
|
|
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
|
|
|
4de5d4 |
# working copy (e.g., centos-art manual --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.
|
|
|
abc39e |
cli_printMessage "`ngettext "The following entry will be deleted" \
|
|
|
abc39e |
"The following entries will be deleted" $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.
|
|
|
abc39e |
cli_printMessage "$ENTRY" "AsDeletingLine"
|
|
|
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.
|
|
|
f8fb31 |
svn del "$ENTRY" --quiet
|
|
|
4456e8 |
|
|
|
f8fb31 |
elif [[ "$(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.
|
|
|
abc39e |
cli_printMessage "`eval_gettext "The entry \\\`\\\$ENTRY' cannot be deleted."`" 'AsErrorLine'
|
|
|
4456e8 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
4456e8 |
|
|
|
4456e8 |
fi
|
|
|
4456e8 |
|
|
|
f8fb31 |
# Remove entry on section's menu and nodes to reflect the
|
|
|
f8fb31 |
# fact that documentation entry has been removed.
|
|
|
4de5d4 |
manual_updateMenu "remove-entry"
|
|
|
4de5d4 |
manual_updateNodes
|
|
|
4456e8 |
|
|
|
f8fb31 |
# Remove entry cross references from documentation manual.
|
|
|
f8fb31 |
manual_removeCrossReferences
|
|
|
f8fb31 |
|
|
|
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
|
|
|
4de5d4 |
manual_updateChaptersMenu 'remove-entry'
|
|
|
4de5d4 |
manual_updateChaptersNodes
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Update manuals' related output files.
|
|
|
4de5d4 |
manual_updateOutputFiles
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|