Blame Scripts/Bash/Functions/Tuneup/tuneup.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# tuneup.sh -- This function standardizes maintainance tasks for files
878a2b
# inside the repository. Maintainance tasks are applied to files using
878a2b
# file extension as reference.
878a2b
#
e6bbbf
# Copyright (C) 2009-2013 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
878a2b
function tuneup {
878a2b
878a2b
    local ACTIONNAM=''
878a2b
    local ACTIONVAL=''
878a2b
24ece8
    # Initialize name of rendition format as an empty value. The name
24ece8
    # of rendition format is determined automatically based on
878a2b
    # template file extension, later, when files are processed.
24ece8
    local TUNEUP_FORMAT=''
878a2b
24ece8
    # Initialize absolute path to format's base directory, the place
24ece8
    # where format-specific directories are stored in.
878a2b
    local TUNEUP_BASEDIR="${CLI_FUNCDIR}/${CLI_FUNCDIRNAM}"
878a2b
878a2b
    # Initialize list of supported file extensions. This is, the file
3b9515
    # extensions we want to perform maintenance tasks for.
878a2b
    local TUNEUP_EXTENSIONS='svg xhtml sh'
878a2b
878a2b
    # Interpret arguments and options passed through command-line.
878a2b
    tuneup_getOptions
878a2b
878a2b
    # Redefine positional parameters using ARGUMENTS. At this point,
878a2b
    # option arguments have been removed from ARGUMENTS variable and
878a2b
    # only non-option arguments remain in it. 
878a2b
    eval set -- "$ARGUMENTS"
878a2b
878a2b
    # Define action name. No matter what option be passed to
878a2b
    # centos-art, there is only one action to perform (i.e., build the
878a2b
    # list of files and interpretation of file extensions for further
878a2b
    # processing).
878a2b
    ACTIONNAM="tuneup_doBaseActions"
878a2b
878a2b
    # Define action value. We use non-option arguments to define the
878a2b
    # action value (ACTIONVAL) variable.
878a2b
    for ACTIONVAL in "$@";do
878a2b
        
7540da
        # Sanitate non-option arguments to be sure they match the
e04c1c
        # directory conventions established by centos-art.sh script
7540da
        # against source directory locations in the working copy.
402c20
        ACTIONVAL=$(cli_checkRepoDirSource ${ACTIONVAL})
878a2b
e04c1c
        # Verify source location absolute path. It should point to
e04c1c
        # existent directories under version control inside the
e04c1c
        # working copy.  Otherwise, if it doesn't point to an existent
e04c1c
        # file under version control, finish the script execution with
e04c1c
        # an error message.
e04c1c
        cli_checkFiles ${ACTIONVAL} -d --is-versioned
e04c1c
e04c1c
        # Synchronize changes between repository and working copy. At
878a2b
        # this point, changes in the repository are merged in the
878a2b
        # working copy and changes in the working copy committed up to
878a2b
        # repository.
402c20
        cli_synchronizeRepoChanges "${ACTIONVAL}"
878a2b
878a2b
        # Execute action name.
7540da
        ${ACTIONNAM}
878a2b
6ab51a
        # Synchronize changes between repository and working copy. At
878a2b
        # this point, changes in the repository are merged in the
878a2b
        # working copy and changes in the working copy committed up to
878a2b
        # repository.
402c20
        cli_synchronizeRepoChanges "${ACTIONVAL}"
878a2b
878a2b
    done
878a2b
878a2b
}