|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
742c46 |
# manual_deleteEntry.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 |
|
|
|
742c46 |
function manual_deleteEntry {
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define variables as local to avoid conflicts outside.
|
|
|
4c79b5 |
local ENTRIES=''
|
|
|
4c79b5 |
local LOCATION=''
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Check if the entry has been already removed.
|
|
|
638bf8 |
cli_checkFiles $ENTRY 'f'
|
|
|
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 |
|
|
|
638bf8 |
# Redefine location to match the chapter's root directory. This
|
|
|
4c79b5 |
# applies when you try to remove the whole chapter from the
|
|
|
638bf8 |
# working copy (e.g., centos-art manual --delete=/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 |
done
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Remove duplicated lines from entries list.
|
|
|
4c79b5 |
ENTRIES=$(echo "$ENTRIES" | tr ' ' "\n" | sort -r | uniq)
|
|
|
4c79b5 |
|
|
|
638bf8 |
# Print action preamble.
|
|
|
638bf8 |
cli_printActionPreamble "$ENTRIES" 'doDelete' 'AsResponseLine'
|
|
|
638bf8 |
|
|
|
638bf8 |
# Redefine ENTRY using affected entries as reference.
|
|
|
4c79b5 |
for ENTRY in $ENTRIES;do
|
|
|
4c79b5 |
|
|
|
638bf8 |
# Verify entry inside the working copy.
|
|
|
d2b9ba |
if [[ $(cli_getRepoStatus "$ENTRY") =~ '^(\?)?$' ]];then
|
|
|
4c79b5 |
|
|
|
638bf8 |
# Print action message.
|
|
|
638bf8 |
cli_printMessage "$ENTRY" "AsDeletingLine"
|
|
|
638bf8 |
|
|
|
638bf8 |
else
|
|
|
4c79b5 |
|
|
|
638bf8 |
# Do not remove a versioned documentation entry with
|
|
|
638bf8 |
# changes inside. Print a message about it and stop script
|
|
|
638bf8 |
# execution instead.
|
|
|
125fdf |
cli_printMessage "`gettext "There are changes that need to be committed first."`" 'AsErrorLine'
|
|
|
638bf8 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
638bf8 |
|
|
|
638bf8 |
fi
|
|
|
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
|
|
|
476434 |
# based on whether they are under version control or not.
|
|
|
d2b9ba |
if [[ "$(cli_getRepoStatus "$ENTRY")" == '' ]];then
|
|
|
4456e8 |
|
|
|
638bf8 |
# Documentation entry is under version control and there
|
|
|
d2b9ba |
# is no change to be committed up to central repository.
|
|
|
d2b9ba |
# We are safe to schedule it for deletion.
|
|
|
f8fb31 |
svn del "$ENTRY" --quiet
|
|
|
4456e8 |
|
|
|
f8fb31 |
elif [[ "$(cli_getRepoStatus "$ENTRY")" == '?' ]];then
|
|
|
4456e8 |
|
|
|
4456e8 |
# Documentation entry is not under version control, so we
|
|
|
638bf8 |
# don't care about changes inside it. If you say
|
|
|
638bf8 |
# centos-art.sh script to remove an unversion
|
|
|
638bf8 |
# documentation entry it will do so, using convenctional
|
|
|
638bf8 |
# `rm' command.
|
|
|
638bf8 |
rm -r "$ENTRY"
|
|
|
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.
|
|
|
742c46 |
manual_deleteCrossReferences
|
|
|
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 |
}
|