diff --git a/Scripts/Bash/Functions/Commons/cli_checkRepoDirSource.sh b/Scripts/Bash/Functions/Commons/cli_checkRepoDirSource.sh index cb107d8..d48dbc6 100755 --- a/Scripts/Bash/Functions/Commons/cli_checkRepoDirSource.sh +++ b/Scripts/Bash/Functions/Commons/cli_checkRepoDirSource.sh @@ -42,6 +42,16 @@ function cli_checkRepoDirSource { local LOCATION=${1} + # Remove any dot from arguments passed to centos-art.sh script. + # This way it is possible to use a single dot to reflect the + # current location from which centos-art.sh was executed. Notice + # that using a dot as argument is optional (e.g.: when you pass no + # argument to centos-art command-line, the current location is + # used as default location). However, it might be useful to use a + # dot as argument when you want to include the current location in + # a list of arguments to process. + LOCATION=$(echo "$LOCATION" | sed -r "s,^\.$,$(pwd),g") + # Remove the working directory absolute path from location to # avoid path duplications here. LOCATION=$(echo "$LOCATION" | sed "s,${TCAR_WORKDIR}/,,g") diff --git a/Scripts/Bash/Functions/Commons/cli_getConfigLines.sh b/Scripts/Bash/Functions/Commons/cli_getConfigLines.sh index 21f1574..a1ab8ea 100755 --- a/Scripts/Bash/Functions/Commons/cli_getConfigLines.sh +++ b/Scripts/Bash/Functions/Commons/cli_getConfigLines.sh @@ -50,7 +50,7 @@ function cli_getConfigLines { # well-formed paths. Be sure configuration variable name starts # just at the beginning of the line. if [[ ! $CONFIG_OPTION =~ '^[[:alnum:]_./-]+$' ]];then - CONFIG_OPTION='[[:alnum:]_./-]+=' + CONFIG_OPTION='[[:alnum:]_./-]+[[:space:]]*=' fi # Retrieve configuration lines from configuration file. diff --git a/Scripts/Bash/Functions/Commons/cli_parseArgumentsReDef.sh b/Scripts/Bash/Functions/Commons/cli_parseArgumentsReDef.sh index 3c69293..9292473 100755 --- a/Scripts/Bash/Functions/Commons/cli_parseArgumentsReDef.sh +++ b/Scripts/Bash/Functions/Commons/cli_parseArgumentsReDef.sh @@ -34,7 +34,7 @@ function cli_parseArgumentsReDef { # Fill up arguments global variable with current positional # parameter information. To avoid interpretation problems, use # single quotes to enclose each argument (ARG) from command-line - # idividually. + # individually. for ARG in "$@"; do # Remove any single quote from arguments passed to @@ -42,16 +42,17 @@ function cli_parseArgumentsReDef { # option values so white space can be passed through them. ARG=$(echo "$ARG" | tr -d "'") - # Concatenate arguments and encolose them to let getopt to + # Concatenate arguments and enclose them to let getopt to # process them when they have spaces inside. ARGUMENTS="$ARGUMENTS '$ARG'" done # Verify non-option arguments passed to command-line. If there - # isn't any, redefine the ARGUMENTS variable to use the current - # location the centos-art.sh script was called from. - if [[ $ARGUMENTS == '' ]];then + # isn't any or dot is provided, redefine the ARGUMENTS variable to + # use the current location the centos-art.sh script was called + # from. + if [[ -z $ARGUMENTS ]];then ARGUMENTS=${PWD} fi diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo.sh index 0cd2abe..fe04c04 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo.sh @@ -78,7 +78,7 @@ function texinfo { # and define documentation entry based on chapter's main # definition file. - MANUAL_ENTRY="${MANUAL_BASEDIR_L10N}/${MANUAL_CHAPTER_NAME}/chapter.${MANUAL_EXTENSION}" + MANUAL_ENTRY="${MANUAL_BASEDIR_L10N}/${MANUAL_CHAPTER_NAME}.${MANUAL_EXTENSION}" elif [[ $MANUAL_CHAPTER_NAME != '' ]] && [[ $MANUAL_SECTION_NAME != '' ]];then diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_checkEntrySrcDst.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_checkEntrySrcDst.sh index 2ad58a6..76ea460 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_checkEntrySrcDst.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_checkEntrySrcDst.sh @@ -46,7 +46,7 @@ function texinfo_checkEntrySrcDst { # Verify source location to be sure it is under version control # and there isn't pending change to be committed first. cli_checkFiles ${MANUAL_ENTRY_SRC} --is-versioned - if [[ $(cli_runFnEnvironment vcs --get-status ${MANUAL_ENTRY_SRC}) != '' ]];then + if [[ $(cli_runFnEnvironment vcs --status ${MANUAL_ENTRY_SRC}) != '' ]];then cli_printMessage "`gettext "The source location has pending changes."`" --as-error-line fi diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_createChapter.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_createChapter.sh index 55a12dc..fbfff77 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_createChapter.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_createChapter.sh @@ -34,7 +34,7 @@ function texinfo_createChapter { return else cli_printMessage "`gettext "The following documentation chapter doesn't exist:"`" --as-stdout-line - cli_printMessage "${MANUAL_CHAPTER_DIR}" --as-response-line + cli_printMessage "${MANUAL_CHAPTER_DIR}.${MANUAL_EXTENSION}" --as-response-line cli_printMessage "`gettext "Do you want to create it now?"`" --as-yesornorequest-line fi @@ -55,12 +55,12 @@ function texinfo_createChapter { # Define list of template files used to build the chapter main # definition files. local FILE='' - local FILES=$(cli_getFilesList "${MANUAL_TEMPLATE_L10N}/Chapters" \ + local FILES=$(cli_getFilesList "${MANUAL_TEMPLATE_L10N}" \ --maxdepth='1' \ - --pattern="^.+/chapter(-menu|-nodes)?\.${MANUAL_EXTENSION}$") + --pattern="^.+/Chapters(-menu|-nodes)?\.${MANUAL_EXTENSION}$") - # Create chapter directory using subversion. This is the place - # where all chapter-specific files will be stored in. + # Create chapter directory using version control. This is the + # place where all chapter-specific files will be stored in. if [[ ! -d ${MANUAL_CHAPTER_DIR} ]];then cli_printMessage "${MANUAL_CHAPTER_DIR}" --as-creating-line cli_runFnEnvironment vcs --quiet --mkdir ${MANUAL_CHAPTER_DIR} @@ -70,21 +70,25 @@ function texinfo_createChapter { for FILE in $FILES;do # Verify texinfo templates used as based to build the chapter - # structure. Be sure they are inside the working copy of - # The CentOS Artwork Repository (-w) and under version control + # structure. Be sure they are inside the working copy of The + # CentOS Artwork Repository (-w) and under version control # (-n), too. - cli_checkFiles ${FILE} --is-versioned + cli_checkFiles ${FILE} + + # Redefine the chapter file using the correct name. + local MANUAL_CHAPTER_FILE=${MANUAL_CHAPTER_DIR}$(basename ${FILE} \ + | sed -r 's,Chapters,,') # Print action name. - cli_printMessage "${MANUAL_CHAPTER_DIR}/$(basename ${FILE})" --as-creating-line + cli_printMessage "${MANUAL_CHAPTER_FILE}" --as-creating-line # Copy template files into the chapter directory. - cli_runFnEnvironment vcs --quiet --copy ${FILE} ${MANUAL_CHAPTER_DIR} + cli_runFnEnvironment vcs --quiet --copy ${FILE} ${MANUAL_CHAPTER_FILE} done # Before expanding chapter information, be sure the slash (/) - # character be scaped. Otherwise, if the slashes aren't scape, + # character be escaped. Otherwise, if the slashes aren't scape, # they will be interpreted as sed's separator and might provoke # sed to complain. MANUAL_CHAPTER_NODE=$(echo "$MANUAL_CHAPTER_NODE" | sed -r 's/\//\\\//g') @@ -98,7 +102,7 @@ function texinfo_createChapter { -e "s/=CHAPTER_TITLE=/${MANUAL_CHAPTER_TITLE}/" \ -e "s/=CHAPTER_CIND=/${MANUAL_CHAPTER_CIND}/" \ -e "s/=CHAPTER_NAME=/${MANUAL_CHAPTER_NAME}/" \ - ${MANUAL_CHAPTER_DIR}/chapter.${MANUAL_EXTENSION} + ${MANUAL_CHAPTER_DIR}.${MANUAL_EXTENSION} # Remove content from `chapter-nodes.texinfo' file to start with a # clean node structure. This file is also used to create new @@ -106,7 +110,7 @@ function texinfo_createChapter { # now (when the chapter structure is created), just an empty copy # of the file. The node structure of chapter is created # automatically based on action value. - echo "" > ${MANUAL_CHAPTER_DIR}/chapter-nodes.${MANUAL_EXTENSION} + echo "" > ${MANUAL_CHAPTER_DIR}-nodes.${MANUAL_EXTENSION} # Update chapter information inside the manual's texinfo # structure. diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_createStructure.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_createStructure.sh index 2c7e017..cee18db 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_createStructure.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_createStructure.sh @@ -34,7 +34,7 @@ function texinfo_createStructure { return else cli_printMessage "`eval_gettext "The following documentation manual doesn't exist:"`" --as-stdout-line - cli_printMessage "${MANUAL_BASEFILE}.texinfo" --as-response-line + cli_printMessage "${MANUAL_BASEFILE}.${MANUAL_EXTENSION}" --as-response-line cli_printMessage "`gettext "Do you want to create it now?"`" --as-yesornorequest-line fi diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_createStructureChapters.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_createStructureChapters.sh index 8ed7a7d..14a7de8 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_createStructureChapters.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_createStructureChapters.sh @@ -36,7 +36,7 @@ function texinfo_createStructureChapters { # from its default template directory. local FILE='' local FILES=$(cli_getFilesList ${MANUAL_TEMPLATE_L10N} \ - --pattern="^.+/chapter(-menu|-nodes)?\.${MANUAL_EXTENSION}$" --mindepth='2' \ + --pattern="^.+/Chapters(-menu|-nodes)?\.${MANUAL_EXTENSION}$" --mindepth='1' \ | egrep -v '/(Chapters|Licenses)/') # Loop through chapter structures and create them inside the @@ -68,10 +68,6 @@ function texinfo_createStructureChapters { # isn't a need to duplicate this information. In fact it is # important not to have it duplicated so we can centralize such # information for all documentation manuals. - if [[ -d ${MANUAL_CHAPTER_DIR}/Licenses ]];then - rm -r ${MANUAL_CHAPTER_DIR}/Licenses - else - ln -s ${TCAR_WORKDIR}/Documentation/Models/Texinfo/Default/${CLI_LANG_LL}/Licenses ${MANUAL_CHAPTER_DIR}/Licenses - fi + texinfo_updateLicenseLink } diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteCrossReferences.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteCrossReferences.sh index 0a8fc5e..8617734 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteCrossReferences.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteCrossReferences.sh @@ -51,10 +51,10 @@ function texinfo_deleteCrossReferences { # Define replacement string for missing entries. It is convenient # to keep missing entries in documentation for documentation team - # to know. Removing the missing cross reference may intorudce - # confussion. Imagine that! you are spending lots of hours in an - # article and suddenly one of your cross refereces disappears with - # no visible reason, with the next working copy update you + # to know. Removing the missing cross reference may introduce + # confusion. Imagine that you are spending lots of hours in an + # article and suddenly one of your cross references disappears + # with no visible reason, with the next working copy update you # perform. That's frustrating. Instead, when centos-art.sh script # finds a missing cross reference it removes the link and remark # the issue for you to act on it. @@ -75,7 +75,7 @@ function texinfo_deleteCrossReferences { # use the `a' letter to name the label we use, followed by N # command to add a newline to the pattern space, the s command to # make the pattern replacement using the `g' flag to make it - # global and finaly the command `b' to branch label named `a'. + # global and finally the command `b' to branch label named `a'. sed -r -i ":a;N;s!${PATTERN[0]}!${REPLACE[0]}!g;ba" ${MANUAL_ENTRIES} # Update menu-related cross references. Menu-related cross diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntry.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntry.sh index 8177479..3d6fac3 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntry.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntry.sh @@ -25,9 +25,6 @@ function texinfo_deleteEntry { - # Print separator line. - cli_printMessage '-' --as-separator-line - # Remove manual, chapter or section based on documentation entry # provided as non-option argument to `centos-art.sh' script. if [[ ${MANUAL_SECT[$MANUAL_DOCENTRY_ID]} != '' ]];then diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntryChapter.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntryChapter.sh index be3d398..c712a31 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntryChapter.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntryChapter.sh @@ -25,12 +25,12 @@ function texinfo_deleteEntryChapter { - # Print action message. - cli_printMessage "$MANUAL_CHAPTER_DIR" --as-deleting-line - # Verify existence of documentation entry before deleting it. # We cannot delete an entry which doesn't exist. - cli_checkFiles "$MANUAL_CHAPTER_DIR" -d + cli_checkFiles "${MANUAL_CHAPTER_DIR}" -d + cli_checkFiles "${MANUAL_CHAPTER_DIR}-menu.${MANUAL_EXTENSION}" -f + cli_checkFiles "${MANUAL_CHAPTER_DIR}-nodes.${MANUAL_EXTENSION}" -f + cli_checkFiles "${MANUAL_CHAPTER_DIR}.${MANUAL_EXTENSION}" -f # Define list of chapters that shouldn't be removed. local SPECIAL_CHAPTERS='/(Licenses|Index)$' @@ -46,12 +46,14 @@ function texinfo_deleteEntryChapter { # that point to section entries inside the chapter that will be # deleted. Take care don't include the chapter definition files. local MANUAL_ENTRIES=$(cli_getFilesList $MANUAL_CHAPTER_DIR \ - --pattern="^.+\.${MANUAL_EXTENSION}$" \ - | egrep -v "(${MANUAL_NAME}|chapter)-(menu|nodes|index)") + --pattern="^/.+\.${MANUAL_EXTENSION}$") - # Remove chapter directory using subversion to register the - # change. - cli_runFnEnvironment vcs --quiet --delete ${MANUAL_CHAPTER_DIR} + # Remove chapter directory and related files using version control + # to register the change. + cli_runFnEnvironment vcs --delete ${MANUAL_CHAPTER_DIR} + cli_runFnEnvironment vcs --delete ${MANUAL_CHAPTER_DIR}-menu.${MANUAL_EXTENSION} + cli_runFnEnvironment vcs --delete ${MANUAL_CHAPTER_DIR}-nodes.${MANUAL_EXTENSION} + cli_runFnEnvironment vcs --delete ${MANUAL_CHAPTER_DIR}.${MANUAL_EXTENSION} # Update chapter menu and nodes inside manual structure. texinfo_updateChapterMenu --delete-entry diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh index cf08b28..6028966 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh @@ -25,9 +25,6 @@ function texinfo_deleteEntryManual { - # Print action message. - cli_printMessage "$MANUAL_ENTRY" --as-deleting-line - # Verify existence of documentation entry before deleting it. We # cannot delete an entry which doesn't exist. cli_checkFiles "$MANUAL_ENTRY" -f @@ -48,8 +45,8 @@ function texinfo_deleteEntryManual { cli_runFnEnvironment vcs --delete ${MANUAL_BASEDIR} # Redefine absolute paths to changed directory. This is - # required in order for `subversion_commitRepoChanges' to be - # aware that we are deleting MANUAL_BASEDIR, not + # required in order for `(git|subversion)_commitRepoChanges' + # to be aware that we are deleting MANUAL_BASEDIR, not # MANUAL_BASEDIR_L10N. MANUAL_CHANGED_DIRS="${MANUAL_BASEDIR}" diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntrySection.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntrySection.sh index 211e018..bc71600 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntrySection.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntrySection.sh @@ -25,6 +25,10 @@ function texinfo_deleteEntrySection { + # Verify documentation entry existence. We cannot remove a + # documentation entry which doesn't exist. + cli_checkFiles ${MANUAL_ENTRY} -f + # Remove documentation entry using subversion to register the # change. cli_runFnEnvironment vcs --delete "${MANUAL_ENTRY}" diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_editEntry.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_editEntry.sh index 555aded..a377d66 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_editEntry.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_editEntry.sh @@ -32,7 +32,7 @@ function texinfo_editEntry { # manuals, all documentation entries are stored directly under # its chapter directory. There is no more levels deep so it is # possible to perform a direct chapter verification here. - if [[ ! -a $(dirname $MANUAL_ENTRY)/chapter.${MANUAL_EXTENSION} ]];then + if [[ ! -a $(dirname $MANUAL_ENTRY).${MANUAL_EXTENSION} ]];then texinfo_createChapter fi @@ -45,7 +45,7 @@ function texinfo_editEntry { cli_printMessage "$MANUAL_ENTRY" --as-updating-line # Update section menu, nodes and cross references based on - # changes in order for manual structure to remain cosistent. + # changes in order for manual structure to remain consistent. texinfo_updateStructureSection "$MANUAL_ENTRY" # Use default text editor to write changes on documentation entry. diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_makeSeeAlso.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_makeSeeAlso.sh index 9b7fb29..ac5ced4 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_makeSeeAlso.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_makeSeeAlso.sh @@ -73,7 +73,7 @@ function texinfo_makeSeeAlso { TMARKS=$(echo "$TMARKS" | sed -r 's/ /\\040/g') # Define pattern used to build list of child sections. A child - # section shares the same path information of its parent with out + # section shares the same path information of its parent without # file extension. For example, if you have the `identity', # `identity-images' and `identity-images-themes' section entries, # `identity-images' is a child entry of `identity' likewise @@ -84,7 +84,7 @@ function texinfo_makeSeeAlso { # menu nodes. Reverse the output here to produce the correct value # based on menu nodes definition set further. CHILD_ENTRIES=$(cli_getFilesList $(dirname ${MANUAL_ENTRY}) \ - --pattern="^.+/${ENTRY_PATTERN}-[[:alnum:]]+\.${MANUAL_EXTENSION}$" | sort -r | uniq ) + --pattern="^${ENTRY_PATTERN}-[[:alnum:]]+\.${MANUAL_EXTENSION}$" | sort -r | uniq ) # Loop through translation marker definition lines. for TMARK in $TMARKS;do @@ -105,7 +105,7 @@ function texinfo_makeSeeAlso { # Define list properties (type included). LIST_PROP=$(echo "$TMARK" | sed -r -e 's/\\040/ /g' -e "s/${TMARK_PATTERN}/\1/") - # Define `SeeAlso' transltaion marker regular expression + # Define `SeeAlso' translation marker regular expression # pattern that matches the translation marker definition. # Notice that we cannot use TMARK_PATTERN here because it # includes a selection list of all possible translation diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_restoreCrossReferences.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_restoreCrossReferences.sh index 2d15cbe..29b0794 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_restoreCrossReferences.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_restoreCrossReferences.sh @@ -61,7 +61,7 @@ function texinfo_restoreCrossReferences { # Define list of entries to process. local MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR_L10N} \ --pattern="^.+\.${MANUAL_EXTENSION}$") - + # Update node-related cross references. The node-related cross # reference definition, long ones specially, could require more # than one line to be set. By default, GNU sed does not matches @@ -71,7 +71,7 @@ function texinfo_restoreCrossReferences { # use the `a' letter to name the label we use, followed by N # command to add a newline to the pattern space, the s command to # make the pattern replacement using the `g' flag to make it - # global and finaly the command `b' to branch label named `a'. + # global and finally the command `b' to branch label named `a'. sed -r -i ":a;N;s!${PATTERN[0]}!${REPLACE[0]}!g;ba" ${MANUAL_ENTRIES} # Update menu-related cross references. Menu-related cross diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateChapterMenu.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateChapterMenu.sh index 5696b11..42f1371 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateChapterMenu.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateChapterMenu.sh @@ -71,7 +71,7 @@ function texinfo_updateChapterMenu { # Organize menu of chapters alphabetically and verify that no # duplicated line be included on the list. Notice that organizing - # menu this way supresses the idea of putting the last chapter + # menu this way suppresses the idea of putting the last chapter # created at the end of the list. #MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sort | uniq) diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateChapterNodes.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateChapterNodes.sh index 0a63f59..cc7724b 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateChapterNodes.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateChapterNodes.sh @@ -30,7 +30,7 @@ function texinfo_updateChapterNodes { # Build chapter nodes using entries from chapter menu as # reference. Don't include `Licenses' or `Index' chapters here. - # These chapters are part of our manual's main defintion file and + # These chapters are part of our manual's main definition file and # shouldn't be handled as regular chapters. local CHAPTERNODES=$(cat ${MANUAL_BASEFILE}-menu.${MANUAL_EXTENSION} \ | egrep -v '^@(end )?menu$' | egrep -v '^\* (Licenses|Index)::$'\ @@ -41,7 +41,7 @@ function texinfo_updateChapterNodes { local FILENODE=$(\ for CHAPTERNODE in ${CHAPTERNODES};do INCL=$(echo ${CHAPTERNODE} \ - | sed -r "s!(${CHAPTERNODE})!\1/chapter\.${MANUAL_EXTENSION}!") + | sed -r "s!(${CHAPTERNODE})!\1.${MANUAL_EXTENSION}!") # Output inclusion line using texinfo format. echo "@include $INCL" done) diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateLicenseLink.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateLicenseLink.sh new file mode 100755 index 0000000..8b617a9 --- /dev/null +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateLicenseLink.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# texinfo_updateLicenseLink.sh -- This function updates the link +# information related to License directory used by Texinfo +# documentation manuals. There isn't a need to duplicate the License +# information in each documentation manual. In fact it is important +# not to have it duplicated so we can centralize such information for +# all documentation manuals. +# +# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function texinfo_updateLicenseLink { + + # Define directory where license templates are stored in. + local DIR=${TCAR_WORKDIR}/Documentation/Models/Texinfo/Default/${CLI_LANG_LC} + + # Define files related to license templates. + local FILES=$(find ${DIR} -name 'Licenses*') + + for FILE in $FILES;do + + # Remove path from license templates. + FILE=$(basename ${FILE}) + + # Remove license files from manual's specific models. + if [[ -e ${MANUAL_BASEDIR_L10N}/${FILE} ]];then + rm -r ${MANUAL_BASEDIR_L10N}/${FILE} + fi + + # Create link from manual's default models to manual's + # specific models. + ln -s ${DIR}/${FILE} ${MANUAL_BASEDIR_L10N}/${FILE} + + done + +} diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateOutputFilePdf.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateOutputFilePdf.sh index 1fa6217..ea2bc1b 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateOutputFilePdf.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateOutputFilePdf.sh @@ -25,6 +25,12 @@ function texinfo_updateOutputFilePdf { + # Verify texi2pdf package existence. If this package isn't + # installed in the system, stop script execution with an error + # message. texi2pdf isn't a package by itself but a program of + # texinfo-tex package. So check the correct package. + cli_checkFiles texinfo-tex --is-installed + # Output action message. cli_printMessage "${MANUAL_OUTPUT_BASEFILE}.pdf" --as-creating-line diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateOutputFileXhtml.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateOutputFileXhtml.sh index f9db873..8eba2cc 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateOutputFileXhtml.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateOutputFileXhtml.sh @@ -25,6 +25,11 @@ function texinfo_updateOutputFileXhtml { + # Verify texi2html package existence. If this package isn't + # installed in the system, stop script execution with an error + # message. + cli_checkFiles texi2html --is-installed + # Output action message. cli_printMessage "${MANUAL_OUTPUT_BASEFILE}.xhtml.tar.bz2" --as-creating-line diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateOutputFiles.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateOutputFiles.sh index cb8f43e..24c62ad 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateOutputFiles.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateOutputFiles.sh @@ -32,7 +32,7 @@ function texinfo_updateOutputFiles { return fi - # Create output directory if it doesn't exist. + # Verify output directory. if [[ ! -d $(dirname $MANUAL_OUTPUT_BASEFILE) ]];then mkdir -p $(dirname $MANUAL_OUTPUT_BASEFILE) fi @@ -42,12 +42,20 @@ function texinfo_updateOutputFiles { # paths incorrectly. pushd ${MANUAL_BASEDIR_L10N} > /dev/null + # Verify existence of link to Licenses information. + texinfo_updateLicenseLink + + # Keep the order in which these actions are performed. Begin with + # actions that use the makeinfo file to realize the export. Later, + # continue with action that need other tools to realize the export + # (e.g., texi2html to produce XHTML and texi2pdf to produce PDF + # outputs). texinfo_updateOutputFileInfo - texinfo_updateOutputFileXhtml texinfo_updateOutputFileXml texinfo_updateOutputFileDocbook - texinfo_updateOutputFilePdf texinfo_updateOutputFilePlaintext + texinfo_updateOutputFileXhtml + texinfo_updateOutputFilePdf # Remove the working copy root directory from directory stack. popd > /dev/null diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateSectionMenu.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateSectionMenu.sh index e8f2bec..ed44a57 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateSectionMenu.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateSectionMenu.sh @@ -55,9 +55,9 @@ function texinfo_updateSectionMenu { # reference. local MENULINE="* ${MENUNODE}::" - # Retrive list of menu entries from chapter menu and exclude + # Retrieve list of menu entries from chapter menu and exclude # `@menu', `@end menu' and empty lines from output. - local MENU=$(cat $(dirname ${MANUAL_ENTRY})/chapter-menu.${MANUAL_EXTENSION} \ + local MENU=$(cat ${MENUFILE} \ | egrep -v '^[[:space:]]*$' | egrep -v '^@(end )?menu') # Re-defined chapter menu entries based on action provided to this @@ -108,6 +108,6 @@ function texinfo_updateSectionMenu { # Dump chapter menu entries back into chapter's menu definition # file. - echo "$MENU" > $(dirname ${MANUAL_ENTRY})/chapter-menu.${MANUAL_EXTENSION} + echo "$MENU" > ${MENUFILE} } diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateSectionNodes.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateSectionNodes.sh index 4b60bdc..67932ea 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateSectionNodes.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateSectionNodes.sh @@ -26,9 +26,12 @@ function texinfo_updateSectionNodes { + # Define node file. + local NODEFILE=$(echo $MENUFILE | sed -r "s,-menu,-nodes,") + # Build list of chapter nodes using entries from chapter menu as # reference. - local NODES=$(cat $(dirname ${MANUAL_ENTRY})/chapter-menu.${MANUAL_EXTENSION} \ + local NODES=$(cat ${MENUFILE} \ | sed -r 's!^\* !!' | sed -r 's!:{1,2}.*$!!g' \ | egrep -v '^@(end )?menu$' | sed -r 's! !:!g') @@ -40,29 +43,29 @@ function texinfo_updateSectionNodes { local SECT=$(texinfo_getEntryTitle "$NODE") local CIND=$(texinfo_getEntryIndex "$NODE") + # Initialize absolute path to final texinfo template. + local TEMPLATE='' + # Create texinfo section file using templates, only if the # section file doesn't exist and hasn't been marked for # deletion. Otherwise, when the files have been marked for # deletion, they will be created again from texinfo template # to working copy and that might create confusion. if [[ ! -f ${MANUAL_BASEDIR_L10N}/$INCL ]] \ - && [[ $(cli_runFnEnvironment vcs --get-status ${MANUAL_BASEDIR_L10N}/$INCL) != 'D' ]];then + && [[ $(cli_runFnEnvironment vcs --status ${MANUAL_BASEDIR_L10N}/$INCL) != 'D' ]];then - # Retrive configuration lines from configuration file. Be - # sure no line begining with `#' or space remain in the + # Retrieve configuration lines from configuration file. Be + # sure no line beginning with `#' or space remain in the # line. Otherwise, it would be difficult to loop through # configuration lines. local CONFLINE='' - local CONFLINES=$(cli_getConfigLines "${MANUAL_CONFIG_FILE}" "templates") + local CONFLINES=$(cli_getConfigLines "${MANUAL_CONFIG_FILE}" "templates" "*") # Initialize both left hand side and right hand side # configuration values. local CONFLHS='' local CONFRHS='' - # Initialize absolute path to final texinfo template. - local TEMPLATE='' - # Define what section template to apply using # documentation entry absolute path and values provided by # configuration line. Be sure to break the loop in the @@ -87,11 +90,11 @@ function texinfo_updateSectionNodes { # Verify existence of texinfo template file. If no # template is found, stop script execution with an error # message. We cannot continue without it. - cli_checkFiles -e $TEMPLATE + cli_checkFiles -e ${TEMPLATE} # Create documentation entry using texinfo template as # reference. - cli_runFnEnvironment vcs --copy ${TEMPLATE} ${MANUAL_BASEDIR_L10N}/$INCL + cli_runFnEnvironment vcs --copy --quiet ${TEMPLATE} ${MANUAL_BASEDIR_L10N}/$INCL fi @@ -111,10 +114,10 @@ function texinfo_updateSectionNodes { -e '0,/^@cindex/c@cindex =CIND=' \ "${MANUAL_BASEDIR_L10N}/$INCL" - # Before expading node, section and concept index, be sure + # Before expanding node, section and concept index, be sure # that all slash characters (`/') be escaped. Otherwise, they # might be interpreted as separators and that isn't - # desireable in anyway. + # desirable in anyway. NODE=$(echo "$NODE" | sed -r 's/\//\\\//g') SECT=$(echo "$SECT" | sed -r 's/\//\\\//g') CIND=$(echo "$CIND" | sed -r 's/\//\\\//g') @@ -127,16 +130,16 @@ function texinfo_updateSectionNodes { -e "s/=CIND=/${CIND}/g" \ "${MANUAL_BASEDIR_L10N}/$INCL" - # Verify existence of chapter-nodes template file. If no - # chapter-nodes template is found, stop script execution with + # Verify existence of Chapter-nodes template file. If no + # Chapter-nodes template is found, stop script execution with # an error message. We cannot continue without it. - cli_checkFiles -e ${MANUAL_TEMPLATE_L10N}/Chapters/chapter-nodes.${MANUAL_EXTENSION} + cli_checkFiles -e ${MANUAL_TEMPLATE_L10N}/Chapters-nodes.${MANUAL_EXTENSION} # Expand chapter node inclusion definition. - cat ${MANUAL_TEMPLATE_L10N}/Chapters/chapter-nodes.${MANUAL_EXTENSION} \ + cat ${MANUAL_TEMPLATE_L10N}/Chapters-nodes.${MANUAL_EXTENSION} \ | sed -r "s!=INCL=!${INCL}!g" # Dump chapter node definition into manual structure. - done > $(dirname ${MANUAL_ENTRY})/chapter-nodes.${MANUAL_EXTENSION} + done > ${NODEFILE} } diff --git a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateStructureSection.sh b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateStructureSection.sh index 82b0869..e87b3c8 100755 --- a/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateStructureSection.sh +++ b/Scripts/Bash/Functions/Help/Texinfo/texinfo_updateStructureSection.sh @@ -1,8 +1,9 @@ #!/bin/bash # # texinfo_updateStructureSection.sh -- This function looks for all -# section entry files inside manual's base directory and updates menu, -# nodes and cross references definitions for them all, one at a time. +# section entries (i.e., files holding section definitions) inside the +# manual's base directory and updates menu, nodes and cross references +# definitions for them all, one at a time. # # Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project # @@ -28,19 +29,12 @@ function texinfo_updateStructureSection { local PATTERN="${1}" - # Define regular expression pattern used to build the list of - # section entries that will be processed. - if [[ $PATTERN == '' ]];then - PATTERN="${MANUAL_ENTRY}" - fi - - # Verify the pattern value considering both the chapter and - # section names. This is required when no chapter or section name - # is provided to `centos-art.sh' script, as non-option argument in - # the command-line (e.g., `centos-art help --update-structure'). + # Define regular expression pattern used to build list of section + # entries when pattern points to manual's file name or it is not + # provided at all. if [[ $PATTERN =~ "${MANUAL_NAME}\.${MANUAL_EXTENSION}$" ]] \ - || [[ $PATTERN =~ "chapter\.${MANUAL_EXTENSION}$" ]];then - PATTERN="^$(dirname ${MANUAL_ENTRY})/.+\.${MANUAL_EXTENSION}$" + || [[ $PATTERN == '' ]]; then + PATTERN="/.+\.${MANUAL_EXTENSION}$" fi local MANUAL_ENTRY='' @@ -56,28 +50,28 @@ function texinfo_updateStructureSection { # Remove menu and node definitions for sections inside # manual, in order to reflect the changes. - ACTIONNAM_SECMENU='updateSectionMenu --delete-entry' + ACTIONNAM_SECMENU='texinfo_updateSectionMenu --delete-entry' # Remove cross reference definitions inside manual # structure. - ACTIONNAM_CROSREF='deleteCrossReferences' + ACTIONNAM_CROSREF='texinfo_deleteCrossReferences' ;; --update | * ) # Update menu and node definitions for sections inside # manual, in order to reflect the changes. - ACTIONNAM_SECMENU='updateSectionMenu --add-entry' + ACTIONNAM_SECMENU='texinfo_updateSectionMenu --add-entry' - # Resotre cross reference definitions inside manual + # Restore cross reference definitions inside manual # structure. If a documentation entry has been removed by # mistake and that mistake is later fixed by adding the # removed documentation entry back into the manual # structure, it is necessary to rebuild the missing cross # reference information inside the manual structure in - # order to reactivate the removed cross refereces, as + # order to reactivate the removed cross references, as # well. - ACTIONNAM_CROSREF='restoreCrossReferences' + ACTIONNAM_CROSREF='texinfo_restoreCrossReferences' ;; esac @@ -95,13 +89,12 @@ function texinfo_updateStructureSection { # definitions (i.e., all those section definition file that match # the pattern you specified). MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR_L10N} \ - --pattern="${PATTERN}" \ - | egrep -v "/(${MANUAL_NAME}|chapter)-(menu|nodes|index)") + --pattern="${PATTERN}" --mindepth="2" --maxdepth="2") # Verify list of target entries. Assuming is is empty, define # list of target documentation entries using pattern as reference # instead. When we delete a section entry from the working copy, - # using find to retrive its path isn't possible because the + # using find to retrieve its path isn't possible because the # section definition file is removed before executing find and by # consequence no match is found. This issue provokes no section # entry to be removed from menu, nodes and cross references. In @@ -127,13 +120,20 @@ function texinfo_updateStructureSection { # nodes and related cross-references). for MANUAL_ENTRY in ${MANUAL_ENTRIES};do + # Define menu file based on manual entry. We use the menu file + # as reference to build the nodes files and update the menu + # file itself based on available section files. + local MENUFILE=$(dirname ${MANUAL_ENTRY} \ + | sed -r 's,/$,,')-menu.${MANUAL_EXTENSION} + # Don't print action name here. Instead, make it integral part # of documentation entry creation process. + #cli_printMessage "${MANUAL_ENTRY}" --as-stdout-line - texinfo_${ACTIONNAM_SECMENU} + ${ACTIONNAM_SECMENU} texinfo_updateSectionNodes texinfo_makeSeeAlso "${MANUAL_ENTRY}" - texinfo_${ACTIONNAM_CROSREF} "${MANUAL_ENTRY}" + ${ACTIONNAM_CROSREF} "${MANUAL_ENTRY}" done diff --git a/Scripts/Bash/Functions/Help/help.sh b/Scripts/Bash/Functions/Help/help.sh index e51c2c7..3f62e0c 100755 --- a/Scripts/Bash/Functions/Help/help.sh +++ b/Scripts/Bash/Functions/Help/help.sh @@ -138,7 +138,7 @@ function help { # extra slash be present in the value (e.g., when the part # name isn't provided). MANUAL_CHAPTER_DIR="$(echo ${MANUAL_PART_DIR}/${MANUAL_CHAPTER_NAME} \ - | sed -r 's!/{2,}!/!g' )" + | sed -r 's!/{2,}!/!g' | sed -r 's!/$!!' )" # Define section name. MANUAL_SECTION_NAME=${MANUAL_SECT[${MANUAL_DOCENTRY_ID}]} diff --git a/Scripts/Bash/Functions/Prepare/Config/bash_profile.conf b/Scripts/Bash/Functions/Prepare/Config/bash_profile.conf old mode 100644 new mode 100755 diff --git a/Scripts/Bash/Functions/Prepare/prepare_updateEnvironment.sh b/Scripts/Bash/Functions/Prepare/prepare_updateEnvironment.sh index c5c5bc6..1648b46 100755 --- a/Scripts/Bash/Functions/Prepare/prepare_updateEnvironment.sh +++ b/Scripts/Bash/Functions/Prepare/prepare_updateEnvironment.sh @@ -46,7 +46,7 @@ function prepare_updateEnvironment { if [[ $TCAR_WORKDIR =~ "^${HOME}/bin" ]];then cli_printMessage "`eval_gettext "The repository working directory cannot be $HOME/bin"`" --as-error-line else - local TCAR_WORKDIR=$(dirname "$0" | sed "s,${TCAR_BASHSCRIPTS},,") + local TCAR_WORKDIR=$(dirname "$0" | sed "s,/${TCAR_BASHSCRIPTS},,") fi # Determine which is the brand information that will be used as diff --git a/Scripts/Bash/Functions/Tuneup/Sh/Config/topcomment.sed b/Scripts/Bash/Functions/Tuneup/Sh/Config/topcomment.sed old mode 100644 new mode 100755 diff --git a/Scripts/Bash/Functions/Tuneup/Svg/Config/metadata.sed b/Scripts/Bash/Functions/Tuneup/Svg/Config/metadata.sed old mode 100644 new mode 100755 diff --git a/Scripts/Bash/Functions/Tuneup/Xhtml/Config/toc.awk b/Scripts/Bash/Functions/Tuneup/Xhtml/Config/toc.awk old mode 100644 new mode 100755 diff --git a/Scripts/Bash/Functions/Vcs/Git/git.sh b/Scripts/Bash/Functions/Vcs/Git/git.sh index 2eb22ed..103fc13 100755 --- a/Scripts/Bash/Functions/Vcs/Git/git.sh +++ b/Scripts/Bash/Functions/Vcs/Git/git.sh @@ -25,10 +25,6 @@ function git { - local ACTIONNAM='' - local ACTIONNAMS='' - local ACTIONVAL='' - # Redefine positional parameters using ARGUMENTS. At this point, # option arguments have been removed from ARGUMENTS variable and # only non-option arguments remain in it. diff --git a/Scripts/Bash/Functions/Vcs/Git/git_commitRepoChanges.sh b/Scripts/Bash/Functions/Vcs/Git/git_commitRepoChanges.sh new file mode 100755 index 0000000..bc483e8 --- /dev/null +++ b/Scripts/Bash/Functions/Vcs/Git/git_commitRepoChanges.sh @@ -0,0 +1,153 @@ +#!/bin/bash +# +# git_commitRepoChanges.sh -- This function commits all the changes +# found in files under version control. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function git_commitRepoChanges { + + local -a FILES + local -a INFO + local -a FILESNUM + local COUNT=0 + local STATUSOUT='' + local PREDICATE='' + local CHNGTOTAL=0 + local LOCATION=$(cli_checkRepoDirSource "$1") + + # Verify source location absolute path. It should point to + # existent files or directories. They don't need to be under + # version control. + cli_checkFiles ${LOCATION} -e + + # Print action message. + cli_printMessage "`gettext "Checking changes in the working copy"`" --as-banner-line + + # Build list of files that have received changes in its version + # status. Be sure to keep output files off from this list. + # Remember, output files are not version inside the working copy, + # so they are not considered for evaluation here. But take care, + # sometimes output files are in the same format of source files, + # so we need to differentiate them using their locations. + STATUSOUT="$(${COMMAND} status --porcelain ${LOCATION})" + + # Process location based on its path information. Both + # by-extension and by-location exclusions are no longer needed + # here. They are already set in the `.git/info/exclude' file. + + # Define path to files considered recent modifications from + # working copy up to local repository. + FILES[0]=$(echo "$STATUSOUT" | egrep "^.M" | sed -r "s,^.+${TCAR_WORKDIR}/,,") + FILES[1]=$(echo "$STATUSOUT" | egrep "^.\?" | sed -r "s,^.+${TCAR_WORKDIR}/,,") + FILES[2]=$(echo "$STATUSOUT" | egrep "^.D" | sed -r "s,^.+${TCAR_WORKDIR}/,,") + FILES[3]=$(echo "$STATUSOUT" | egrep "^.A" | sed -r "s,^.+${TCAR_WORKDIR}/,,") + + # Define description of files considered recent modifications from + # working copy up to local repository. + INFO[0]="`gettext "Modified"`" + INFO[1]="`gettext "Unversioned"`" + INFO[2]="`gettext "Deleted"`" + INFO[3]="`gettext "Added"`" + + while [[ $COUNT -ne ${#FILES[*]} ]];do + + # Define total number of files. Avoid counting empty line. + if [[ "${FILES[$COUNT]}" == '' ]];then + FILESNUM[$COUNT]=0 + else + FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l) + fi + + # Calculate total amount of changes. + CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]})) + + # Build report predicate. Use report predicate to show any + # information specific to the number of files found. For + # example, you can use this section to show warning messages, + # notes, and so on. By default we use the word `file' or + # `files' at ngettext's consideration followed by change + # direction. + PREDICATE[$COUNT]=`ngettext "file in the working copy" \ + "files in the working copy" $((${FILESNUM[$COUNT]} + 1))` + + # Output report line. + cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}" --as-stdout-line + + # Increase counter. + COUNT=$(($COUNT + 1)) + + done + + # When files have changed in the target location, show which these + # files are and request user to see such changes and then, for + # committing them up to the local repository. + if [[ ${FILESNUM[0]} -gt 0 ]];then + + # Print action message. + cli_printMessage "`gettext "Do you want to see changes now?"`" --as-yesornorequest-line + + # Show differences. + ${COMMAND} diff ${LOCATION} | less + + # Print action message. + cli_printMessage "`gettext "Do you want to commit changes now?"`" --as-yesornorequest-line + + # Add changes for next commit. + ${COMMAND} add ${LOCATION} + + # Commit changes up to local repository. + ${COMMAND} commit ${LOCATION} + + fi + + # When there are unversioned files in the target location, show + # which these files are and request user to add such files into + # the working copy. + if [[ ${FILESNUM[1]} -gt 0 ]];then + + # Print action message. + cli_printMessage '-' --as-separator-line + cli_printMessage "`gettext "Do you want to add unversioned files now?"`" --as-yesornorequest-line + + # Add unversioned files to be considered in the next commit. + for FILE in ${FILES[1]};do + ${COMMAND} add "${TCAR_WORKDIR}/$FILE" + done + + # Print action message. + cli_printMessage "`gettext "Do you want to commit changes now?"`" --as-yesornorequest-line + + # Commit changes up to local repository. + ${COMMAND} commit ${LOCATION} + + fi + + # When there are added files in the target location, show which + # these files are and request user to commit them up to local + # repository. + if [[ ${FILESNUM[3]} -gt 0 ]];then + cli_printMessage '-' --as-separator-line + cli_printMessage "`gettext "Do you want to commit changes now?"`" --as-yesornorequest-line + ${COMMAND} commit ${LOCATION} + fi + +} diff --git a/Scripts/Bash/Functions/Vcs/Git/git_copyRepoFile.sh b/Scripts/Bash/Functions/Vcs/Git/git_copyRepoFile.sh new file mode 100755 index 0000000..e09209d --- /dev/null +++ b/Scripts/Bash/Functions/Vcs/Git/git_copyRepoFile.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# +# git_copyRepoFile.sh -- This function standardizes the way files +# (including directories) are duplicated inside the working copy. This +# function is an interface for git's `copy' command. +# +# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function git_copyRepoFile { + + local SOURCE=$(cli_checkRepoDirSource ${1}) + local TARGET=$(cli_checkRepoDirSource ${2}) + + # Verify source location absolute path. It should point to + # existent files or directories. They don't need to be under + # version control. + cli_checkFiles ${LOCATION} -e + + # Print action reference. + if [[ -f ${SOURCE} ]];then + cli_printMessage "${TARGET}/$(basename ${SOURCE})" --as-creating-line + else + cli_printMessage "${TARGET}" --as-creating-line + fi + + # Copy source location to its target using version control. I + # didn't find a copy command for Git. If you know a better way to + # track a copy action through Git, set it here. + /bin/cp ${SOURCE} ${TARGET} + if [[ $? -eq 0 ]];then + ${COMMAND} add ${TARGET} + fi + +} diff --git a/Scripts/Bash/Functions/Vcs/Git/git_deleteRepoFile.sh b/Scripts/Bash/Functions/Vcs/Git/git_deleteRepoFile.sh new file mode 100755 index 0000000..2c249a1 --- /dev/null +++ b/Scripts/Bash/Functions/Vcs/Git/git_deleteRepoFile.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# git_deleteRepoFile.sh -- This function standardizes the way +# centos-art.sh script deletes files and directories inside the +# working copy. +# +# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function git_deleteRepoFile { + + local TARGET=$(cli_checkRepoDirSource ${1}) + + # Print action reference. + cli_printMessage "${TARGET}" --as-deleting-line + + # Reset target to its default status before remove it from the + # work copy. + if [[ $(cli_runFnEnvironment vcs --status ${TARGET}) =~ '^(A|M|R)$' ]];then + ${COMMAND} reset HEAD ${TARGET} --quiet + fi + + # Remove target based on whether it is under version control or + # not. + if [[ $(cli_runFnEnvironment vcs --status ${TARGET}) == '?' ]];then + # Target isn't under version control. + if [[ -d ${TARGET} ]];then + rm -r ${TARGET} + else + rm ${TARGET} + fi + else + # Target is under version control. + if [[ -d ${TARGET} ]];then + ${COMMAND} rm ${TARGET} -r --force --quiet + else + ${COMMAND} rm ${TARGET} --force --quiet + fi + fi + +} diff --git a/Scripts/Bash/Functions/Vcs/Git/git_getRepoStatus.sh b/Scripts/Bash/Functions/Vcs/Git/git_getRepoStatus.sh new file mode 100755 index 0000000..032535c --- /dev/null +++ b/Scripts/Bash/Functions/Vcs/Git/git_getRepoStatus.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# +# git_getRepoStatus.sh -- This function requests the working copy +# using the status command and returns the first character in the +# output line, as described in git help status, for the LOCATION +# specified. Use this function to perform verifications based a +# repository LOCATION status. +# +# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function git_getRepoStatus { + + local LOCATION=$(cli_checkRepoDirSource "$1") + + # Verify source location absolute path. It should point either to + # existent files or directories both under version control inside + # the working copy. Otherwise, if it doesn't point to an existent + # file under version control, finish the script execution with an + # error message. + cli_checkFiles ${LOCATION} -e + + # Define regular expression pattern to retrieve the work tree + # status. This is the second character of the first column + # returned by `git status --porcelain' command. + local PATTERN='^(.)(.)[[:space:]]+.+$' + + # Output the work tree status. + ${COMMAND} status "$LOCATION" --porcelain \ + | sed -r "s/${PATTERN}/\2/" + +} diff --git a/Scripts/Bash/Functions/Vcs/Git/git_isVersioned.sh b/Scripts/Bash/Functions/Vcs/Git/git_isVersioned.sh new file mode 100755 index 0000000..0b8c814 --- /dev/null +++ b/Scripts/Bash/Functions/Vcs/Git/git_isVersioned.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# git_isVersioned.sh -- This function determines whether a location is +# under version control or not. When the location is under version +# control, this function returns `0'. When the location isn't under +# version control, this function returns `1'. +# +# Copyright (C) 2009-2013 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function git_isVersioned { + + # Define the location absolute path we want to determine whether + # it is under version control or not. Only the first non-option + # argument passed to centos-art.sh command-line will be used. + local LOCATION=$(cli_checkRepoDirSource "${1}") + + # Use Git to determine whether the location is under version + # control or not. + local OUTPUT=$(${COMMAND} status --porcelain ${LOCATION} \ + | egrep "\?\? ${LOCATION}") + + # If there are unversioned files inside location, stop the script + # execution with an error message. All files must be under version + # control except those set in the `.git/info/exclude/' file. + if [[ ! -z ${OUTPUT} ]];then + cli_printMessage "${LOCATION} `gettext " contains untracked files."`" --as-error-line + fi + +} diff --git a/Scripts/Bash/Functions/Vcs/Git/git_mkRepoDirectory.sh b/Scripts/Bash/Functions/Vcs/Git/git_mkRepoDirectory.sh new file mode 100755 index 0000000..62f0d05 --- /dev/null +++ b/Scripts/Bash/Functions/Vcs/Git/git_mkRepoDirectory.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# git_mkRepoDirectory.sh -- This function standardizes the way +# centos-art.sh script creates directories inside the working copy. +# +# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function git_mkRepoDirectory { + + local TARGET=$(cli_checkRepoDirSource ${1}) + + # Print action reference. + cli_printMessage "${TARGET}" --as-creating-line + + # Copy source location to its target using version control. + /bin/mkdir ${TARGET} + ${COMMAND} add ${TARGET} + +} diff --git a/Scripts/Bash/Functions/Vcs/Subversion/subversion_commitRepoChanges.sh b/Scripts/Bash/Functions/Vcs/Subversion/subversion_commitRepoChanges.sh index c565ec0..0e6693c 100755 --- a/Scripts/Bash/Functions/Vcs/Subversion/subversion_commitRepoChanges.sh +++ b/Scripts/Bash/Functions/Vcs/Subversion/subversion_commitRepoChanges.sh @@ -113,7 +113,7 @@ function subversion_commitRepoChanges { # When files have changed in the target location, show which these # files are and request user to see such changes and then, for - # commtting them up to the central repository. + # committing them up to the central repository. if [[ ${FILESNUM[0]} -gt 0 ]];then cli_printMessage "`gettext "Do you want to see changes now?"`" --as-yesornorequest-line diff --git a/Scripts/Bash/Functions/Vcs/Subversion/subversion_getOptions.sh b/Scripts/Bash/Functions/Vcs/Subversion/subversion_getOptions.sh deleted file mode 100755 index d2149f8..0000000 --- a/Scripts/Bash/Functions/Vcs/Subversion/subversion_getOptions.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -# -# subversion_getOptions.sh -- This function interprets option -# parameters passed to `svn' functionality and calls actions -# accordingly. -# -# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function subversion_getOptions { - - # Define short options we want to support. - local ARGSS="h,q" - - # Define long options we want to support. - local ARGSL="help,quiet,synchronize,update,commit,is-versioned,get-status,mkdir,copy,delete" - - # Redefine ARGUMENTS using getopt(1) command parser. - cli_parseArguments - - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" - - # Look for options passed through command-line. - while true; do - - case "$1" in - - -h | --help ) - cli_runFnEnvironment help --read --format="texinfo" "tcar-fs::scripts:bash-functions-vcs-subversion" - shift 1 - exit - ;; - - -q | --quiet ) - FLAG_QUIET="true" - shift 1 - ;; - - --synchronize ) - ACTIONNAMS="${ACTIONNAMS} subversion_syncRepoChanges" - shift 1 - ;; - - --commit ) - ACTIONNAMS="${ACTIONNAMS} subversion_commitRepoChanges" - shift 1 - ;; - - --update ) - ACTIONNAMS="${ACTIONNAMS} subversion_updateRepoChanges" - shift 1 - ;; - - --is-versioned ) - ACTIONNAMS="${ACTIONNAMS} subversion_isVersioned" - shift 1 - ;; - - --get-status ) - ACTIONNAMS="${ACTIONNAMS} subversion_getRepoStatus" - shift 1 - ;; - - --copy ) - ACTIONNAMS="${ACTIONNAMS} subversion_copyRepoFile" - shift 1 - ;; - - --mkdir ) - ACTIONNAMS="${ACTIONNAMS} subversion_mkRepoDirectory" - shift 1 - ;; - - --delete ) - ACTIONNAMS="${ACTIONNAMS} subversion_deleteRepoFile" - shift 1 - ;; - - -- ) - # Remove the `--' argument from the list of arguments - # in order for processing non-option arguments - # correctly. At this point all option arguments have - # been processed already but the `--' argument still - # remains to mark ending of option arguments and - # beginning of non-option arguments. The `--' argument - # needs to be removed here in order to avoid - # centos-art.sh script to process it as a path inside - # the repository, which obviously is not. - shift 1 - break - ;; - esac - done - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" - -} diff --git a/Scripts/Bash/Functions/Vcs/Subversion/subversion_syncRepoChanges.sh b/Scripts/Bash/Functions/Vcs/Subversion/subversion_syncRepoChanges.sh index 6520c2a..a13971b 100755 --- a/Scripts/Bash/Functions/Vcs/Subversion/subversion_syncRepoChanges.sh +++ b/Scripts/Bash/Functions/Vcs/Subversion/subversion_syncRepoChanges.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# subversion_syncRepoChanges.sh -- This function syncnizes both +# subversion_syncRepoChanges.sh -- This function synchronizes both # central repository and working copy directory structures by # performing a subversion update command first and a subversion commit # command later. diff --git a/Scripts/Bash/Functions/Vcs/vcs_getOptions.sh b/Scripts/Bash/Functions/Vcs/vcs_getOptions.sh index 5b95914..df97fd9 100755 --- a/Scripts/Bash/Functions/Vcs/vcs_getOptions.sh +++ b/Scripts/Bash/Functions/Vcs/vcs_getOptions.sh @@ -1,8 +1,9 @@ #!/bin/bash # # vcs_getOptions.sh -- This function interprets option parameters -# passed to `vcs' functionality and calls actions accordingly. It -# serves as interface to Subversion and Git sub-functionalities. +# passed to `vcs' functionality and calls actions accordingly. This +# function serves as interface to Subversion and Git +# sub-functionalities. # # Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project # @@ -30,7 +31,7 @@ function vcs_getOptions { local ARGSS="h,q" # Define long options we want to support. - local ARGSL="help,quiet,synchronize,update,commit,is-versioned,get-status,mkdir,copy,delete" + local ARGSL="help,quiet,synchronize,update,commit,is-versioned,status,mkdir,copy,delete" # Redefine ARGUMENTS using getopt(1) command parser. cli_parseArguments @@ -74,7 +75,7 @@ function vcs_getOptions { shift 1 ;; - --get-status ) + --status ) ACTIONNAMS="${ACTIONNAMS} ${PACKAGE}_getRepoStatus" shift 1 ;; diff --git a/Scripts/Bash/centos-art.conf b/Scripts/Bash/centos-art.conf old mode 100644 new mode 100755 index 1e89b02..cc03d89 --- a/Scripts/Bash/centos-art.conf +++ b/Scripts/Bash/centos-art.conf @@ -4,6 +4,8 @@ # Repository. # +[repository] + [identity] [documentation] @@ -13,5 +15,6 @@ [locales] [version_control] + package = "git" -enabled = "1" +enabled = "0" diff --git a/Scripts/Bash/centos-art.sh b/Scripts/Bash/centos-art.sh index bc0fa2e..3717622 100755 --- a/Scripts/Bash/centos-art.sh +++ b/Scripts/Bash/centos-art.sh @@ -44,15 +44,22 @@ if [[ ! $TCAR_WORKDIR ]] || [[ $TCAR_WORKDIR == '' ]] ;then if [[ $0 =~ "^${HOME}/bin" ]];then echo "To run centos-art correctly, you need to prepare your workstation first." exit 1 - else - - # Initialize absolute path to the working copy. - TCAR_WORKDIR=$(dirname $0 | sed "s,/${TCAR_BASHSCRIPTS},,") - fi fi +# Initialize absolute path to the working copy. Take care that, in +# some cases, you might execute centos-art.sh script from a path +# different to that set in TCAR_WORKDIR variable inside your +# ~/.bash_profile (e.g., you are changing your working copy from one +# location to another). In these cases, the last path must be used as +# reference whenever it doesn't point to user's bin directory. This is +# another reason to provide the centos-art.sh absolute path when you +# execute the prepare function. +if [[ ! $TCAR_WORKDIR =~ "^$(dirname $0)" ]] \ + && [[ ! $(dirname $0) =~ "^${HOME}/bin" ]];then + TCAR_WORKDIR=$(dirname $0 | sed "s,/${TCAR_BASHSCRIPTS},,") +fi # Redefine the working copy absolute path considering the (Subversion) # previous directory structures used in the repository. if [[ -d ${TCAR_WORKDIR}/trunk ]];then @@ -60,7 +67,7 @@ if [[ -d ${TCAR_WORKDIR}/trunk ]];then fi # Initialize repository brand information. -if [[ ! $TCAR_BRAND ]] || [[ $TCAR_BRAND == "" ]] ;then +if [[ ! $TCAR_BRAND ]] || [[ $TCAR_BRAND == "" ]];then TCAR_BRAND='centos' fi