Blame Automation/Modules/Tuneup/tuneup.sh

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