|
Alain Reguera Delgado |
379a73 |
#!/bin/bash
|
|
Alain Reguera Delgado |
379a73 |
######################################################################
|
|
Alain Reguera Delgado |
379a73 |
#
|
|
Alain Reguera Delgado |
379a73 |
# tuneup.sh -- This module standardizes source code file
|
|
Alain Reguera Delgado |
379a73 |
# maintainance inside the repository.
|
|
Alain Reguera Delgado |
379a73 |
#
|
|
Alain Reguera Delgado |
379a73 |
# Written by:
|
|
Alain Reguera Delgado |
379a73 |
# * Alain Reguera Delgado <al@centos.org.cu>, 2009-2013
|
|
Alain Reguera Delgado |
379a73 |
#
|
|
Alain Reguera Delgado |
379a73 |
# Copyright (C) 2009-2013 The CentOS Artwork SIG
|
|
Alain Reguera Delgado |
379a73 |
#
|
|
Alain Reguera Delgado |
379a73 |
# This program is free software; you can redistribute it and/or modify
|
|
Alain Reguera Delgado |
379a73 |
# it under the terms of the GNU General Public License as published by
|
|
Alain Reguera Delgado |
379a73 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
Alain Reguera Delgado |
379a73 |
# your option) any later version.
|
|
Alain Reguera Delgado |
379a73 |
#
|
|
Alain Reguera Delgado |
379a73 |
# This program is distributed in the hope that it will be useful, but
|
|
Alain Reguera Delgado |
379a73 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
379a73 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
379a73 |
# General Public License for more details.
|
|
Alain Reguera Delgado |
379a73 |
#
|
|
Alain Reguera Delgado |
379a73 |
# You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
379a73 |
# along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
379a73 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
379a73 |
#
|
|
Alain Reguera Delgado |
379a73 |
######################################################################
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
function tuneup {
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
# Define file extensions tuneup module will look for processing.
|
|
Alain Reguera Delgado |
379a73 |
local FILE_EXTENSION_REGEX='\.(svgz|svg|shtml|xhtml|html|sh)$'
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
tuneup_getOptions
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
for ARGUMENT in ${TCAR_MODULE_ARGUMENT};do
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
# Sanitate non-option arguments to be sure they match the
|
|
Alain Reguera Delgado |
379a73 |
# directory conventions established by centos-art.sh script
|
|
Alain Reguera Delgado |
379a73 |
# against source directory locations in the working copy.
|
|
Alain Reguera Delgado |
379a73 |
local ARGUMENT=$(tcar_checkRepoDirSource ${ARGUMENT})
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
# Build list of files to process.
|
|
Alain Reguera Delgado |
379a73 |
if [[ -f ${ARGUMENT} ]];then
|
|
Alain Reguera Delgado |
379a73 |
local FILES=${ARGUMENT}
|
|
Alain Reguera Delgado |
379a73 |
elif [[ -d ${ARGUMENT} ]];then
|
|
Alain Reguera Delgado |
379a73 |
local FILES=$(tcar_getFilesList ${ARGUMENT} \
|
|
Alain Reguera Delgado |
379a73 |
--pattern=".+${FILE_EXTENSION_REGEX}" \
|
|
Alain Reguera Delgado |
379a73 |
--type='f' | egrep ${TCAR_FLAG_FILTER})
|
|
Alain Reguera Delgado |
379a73 |
else
|
|
Alain Reguera Delgado |
379a73 |
tcar_printMessage "`gettext "The argument provided isn't valid."`" --as-error-line
|
|
Alain Reguera Delgado |
379a73 |
fi
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
# Process list of files.
|
|
Alain Reguera Delgado |
379a73 |
for FILE in ${FILES};do
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
# Print action message.
|
|
Alain Reguera Delgado |
379a73 |
tcar_printMessage "${FILE}" --as-tuningup-line
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
# Retrieve module name to apply based on file extension .
|
|
Alain Reguera Delgado |
379a73 |
local FILE_EXTENSION=$(echo ${FILE} \
|
|
Alain Reguera Delgado |
379a73 |
| sed -r "s/.+${FILE_EXTENSION_REGEX}/\1/")
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
# Set module aliases.
|
|
Alain Reguera Delgado |
379a73 |
if [[ ${FILE_EXTENSION} =~ '(shtml|html|htm)' ]];then
|
|
Alain Reguera Delgado |
379a73 |
FILE_EXTENSION='xhtml'
|
|
Alain Reguera Delgado |
379a73 |
fi
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
# Initiate module's environment for processing file.
|
|
Alain Reguera Delgado |
379a73 |
tcar_setModuleEnvironment -m "${FILE_EXTENSION}" -t "child" "${FILE}"
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
done
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
done
|
|
Alain Reguera Delgado |
379a73 |
|
|
Alain Reguera Delgado |
379a73 |
}
|