diff --git a/Scripts/Functions/Prepare/prepare.sh b/Scripts/Functions/Prepare/prepare.sh index 76965f0..78dca0c 100755 --- a/Scripts/Functions/Prepare/prepare.sh +++ b/Scripts/Functions/Prepare/prepare.sh @@ -25,21 +25,15 @@ function prepare { - # Define packages flag. The package flag (--packages) controls - # whether package verification is performed or not. By default no - # package verification is done. - local FLAG_PACKAGES='false' + # Initialize action name variable. Here is where we store the + # name of the actions that will be executed based on the options + # passed in the command-line. + local ACTIONNAM='' + local ACTIONNAMS='' - # Define links flag. The link flag (--links) controls whether - # links verifications are performed or not. By default no link - # verification is done. - local FLAG_LINKS='false' - - # Define environment flag. The environment flag (--environment) - # controles whether verification of environment variables are - # performed or not. By default no verification of environment - # variables is done. - local FLAG_ENVIRONMENT='false' + # Define absolute path to directory holding prepare's + # configuration files. + PREPARE_CONFIG_DIR=${FUNCDIR}/${FUNCDIRNAM}/Config # Interpret arguments and options passed through command-line. prepare_getOptions @@ -61,10 +55,9 @@ function prepare { # arguments here since we are doing fixed verifications only in # predifined paths. - # Verify flags and execute actions accordingly. Start with - # packages, links and then environment. - prepare_doPackages - prepare_doLinks - prepare_doEnvironment + # Execute action names. + for ACTIONNAM in $ACTIONNAMS;do + ${ACTIONNAM} + done } diff --git a/Scripts/Functions/Prepare/prepare_doEnvironment.sh b/Scripts/Functions/Prepare/prepare_doEnvironment.sh index ddd1f63..fdc4244 100755 --- a/Scripts/Functions/Prepare/prepare_doEnvironment.sh +++ b/Scripts/Functions/Prepare/prepare_doEnvironment.sh @@ -25,14 +25,6 @@ function prepare_doEnvironment { - # Verify `--packages' option. - if [[ $FLAG_ENVIRONMENT == 'false' ]];then - return - fi - - # Print action message. - cli_printMessage "`gettext "Checking environment variables"`" --as-banner-line - local -a VARS local -a INFO local COUNT=0 diff --git a/Scripts/Functions/Prepare/prepare_doLinks.sh b/Scripts/Functions/Prepare/prepare_doLinks.sh index 1ccb606..66d10cc 100755 --- a/Scripts/Functions/Prepare/prepare_doLinks.sh +++ b/Scripts/Functions/Prepare/prepare_doLinks.sh @@ -1,10 +1,12 @@ #!/bin/bash # -# prepare_doLinks.sh -- This function creates the base configuration -# of symbolic links your workstation needs to have installed in order -# for you to use the `centos-art' command and some auxiliar components -# (e.g., palettes, brushes, patterns, fonts, etc.) that may result -# useful for you when designing graphical compositions. +# prepare_doLinks.sh -- This option creates/updates the symbolic links +# information required in your workstation to connect it with the +# files inside the working copy of The CentOS Artwork Repository. When +# you provide this option, the centos-art.sh put itself into your +# system's execution path and make common brushes, patterns, palettes +# and fonts available inside applications like GIMP, so you can make +# use of them without loosing version control over them. # # Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG # @@ -28,14 +30,9 @@ function prepare_doLinks { - # Verify `--links' option. - if [[ $FLAG_LINKS == 'false' ]];then - return - fi - local -a LINKS_SRC local -a LINKS_DST - local SUFFIX='' + local SUFFIX='centos' local USERFILES='' local PALETTE='' local BRUSH='' @@ -44,9 +41,10 @@ function prepare_doLinks { local FILE='' local COUNT=0 - # Define user-specific directories. - local GIMP_USERDIR=${HOME}/.$(rpm -q gimp | cut -d. -f-2) - local INKS_USERDIR=${HOME}/.inkscape + # Define user's directories where most configuration linkes will + # be created in. + local GIMP_HOME=${HOME}/.$(rpm -q gimp | cut -d. -f-2) + local INKS_HOME=${HOME}/.inkscape # Define link relation for cli. LINKS_SRC[((++${#LINKS_SRC[*]}))]=${HOME}/bin/$CLI_PROGRAM @@ -61,66 +59,57 @@ function prepare_doLinks { # Define link relation for common palettes. for PALETTE in $(cli_getFilesList ${HOME}/artwork/trunk/Identity/Palettes --pattern=".+\.gpl");do - SUFFIX="${GIMP_USERDIR}/palettes/$(prepare_doLinksSuffixes $PALETTE)" - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${SUFFIX}${NAME}${VERS}$(basename $PALETTE) + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_HOME}/palettes/${SUFFIX}-$(basename $PALETTE) LINKS_DST[((++${#LINKS_DST[*]}))]=$PALETTE - SUFFIX="${INKS_USERDIR}/palettes/$(prepare_doLinksSuffixes $PALETTE)" - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${SUFFIX}${NAME}${VERS}$(basename $PALETTE) + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${INKS_HOME}/palettes/${SUFFIX}-$(basename $PALETTE) LINKS_DST[((++${#LINKS_DST[*]}))]=$PALETTE done # Define link relation for common brushes. for BRUSH in $(cli_getFilesList ${HOME}/artwork/trunk/Identity/Brushes --pattern=".+\.(gbr|gih)");do - SUFFIX="${GIMP_USERDIR}/brushes/$(prepare_doLinksSuffixes $BRUSH)" - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${SUFFIX}${NAME}${VERS}$(basename $BRUSH) + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_HOME}/brushes/${SUFFIX}-$(basename $BRUSH) LINKS_DST[((++${#LINKS_DST[*]}))]=$BRUSH done # Define link relation for common patterns. for PATTERN in $(cli_getFilesList ${HOME}/artwork/trunk/Identity/Patterns --pattern=".+\.png");do - SUFFIX="${GIMP_USERDIR}/patterns/$(prepare_doLinksSuffixes $PATTERN)" - LINKS_SRC[((++${#LINKS_SRC[*]}))]=${SUFFIX}${NAME}${VERS}$(basename $PATTERN) + LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_HOME}/patterns/${SUFFIX}-$(basename $PATTERN) LINKS_DST[((++${#LINKS_DST[*]}))]=$PATTERN done - # Define link relation for Vim text editor. + # Define link relation for Vim text editor's configuration. if [[ $EDITOR == '/usr/bin/vim' ]];then LINKS_SRC[((++${#LINKS_SRC[*]}))]=${HOME}/.vimrc - LINKS_DST[((++${#LINKS_DST[*]}))]=${FUNCCONFIG}/vimrc + LINKS_DST[((++${#LINKS_DST[*]}))]=${PREPARE_CONFIG_DIR}/vimrc USERFILES="${USERFILES} ${HOME}/.vimrc" fi - # Define which files inside user-specific directories need to be - # removed in order for centos-art to make a fresh installation of - # common patterns, common palettes and common brushes using - # symbolic links from the repository. + # Define which files inside the user's configuration directories + # need to be removed in order for centos-art.sh script to make a + # fresh installation of common patterns, common palettes and + # common brushes using symbolic links from the working copy to the + # user's configuration directories inside the workstation. USERFILES=$(echo "$USERFILES"; cli_getFilesList ${HOME}/bin --pattern='.+\.sh'; cli_getFilesList ${HOME}/.fonts --pattern='.+\.ttf'; - cli_getFilesList ${GIMP_USERDIR}/brushes --pattern='.+\.(gbr|gih)'; - cli_getFilesList ${GIMP_USERDIR}/patterns --pattern='.+\.(pat|png|jpg|bmp)'; - cli_getFilesList ${GIMP_USERDIR}/palettes --pattern='.+\.gpl'; - cli_getFilesList ${INKS_USERDIR}/palettes --pattern='.+\.gpl';) - - # Remove files installed inside user-specific directories. + cli_getFilesList ${GIMP_HOME}/brushes --pattern='.+\.(gbr|gih)'; + cli_getFilesList ${GIMP_HOME}/patterns --pattern='.+\.(pat|png|jpg|bmp)'; + cli_getFilesList ${GIMP_HOME}/palettes --pattern='.+\.gpl'; + cli_getFilesList ${INKS_HOME}/palettes --pattern='.+\.gpl';) + + # Remove user-specific configuration files from user's home + # directory. Otherwise, we might end up having links insid user's + # home directory that don't exist inside the working copy. if [[ "$USERFILES" != '' ]];then - cli_printActionPreamble $USERFILES --to-delete rm -r $USERFILES fi - # Print preamble message for symbolic link creation. - cli_printActionPreamble ${LINKS_SRC[*]} --to-create - while [[ $COUNT -lt ${#LINKS_SRC[*]} ]];do # Print action message. - if [[ -a ${LINKS_SRC[$COUNT]} ]];then - cli_printMessage "${LINKS_SRC[$COUNT]}" --as-updating-line - else - cli_printMessage "${LINKS_SRC[$COUNT]}" --as-creating-line - fi + cli_printMessage "${LINKS_SRC[$COUNT]}" --as-creating-line - # Create symbolic link parent directory if it doesn't exist. + # Create symbolic link's parent directory if it doesn't exist. if [[ ! -d $(dirname ${LINKS_SRC[$COUNT]}) ]];then mkdir -p $(dirname ${LINKS_SRC[$COUNT]}) fi diff --git a/Scripts/Functions/Prepare/prepare_doLinksSuffixes.sh b/Scripts/Functions/Prepare/prepare_doLinksSuffixes.sh deleted file mode 100755 index c8628a4..0000000 --- a/Scripts/Functions/Prepare/prepare_doLinksSuffixes.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# -# prepare_doLinksSuffixes.sh -- This function uses the first argument -# passed as reference to build the link suffix required by -# prepare_doLinks function. -# -# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG -# -# 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 prepare_doLinksSuffixes { - - local FILE="$1" - local SUFFIX='centos-' - - if [[ "$FILE" =~ "$(cli_getPathComponent --motif-pattern)" ]];then - SUFFIX="${SUFFIX}$(cli_getRepoName $(cli_getPathComponent $FILE --motif-name) -f)-" - SUFFIX="${SUFFIX}$(cli_getPathComponent $FILE --motif-release)-" - fi - - echo "${SUFFIX}" - -} diff --git a/Scripts/Functions/Prepare/prepare_doPackages.sh b/Scripts/Functions/Prepare/prepare_doPackages.sh index 5bbacbb..2820a6e 100644 --- a/Scripts/Functions/Prepare/prepare_doPackages.sh +++ b/Scripts/Functions/Prepare/prepare_doPackages.sh @@ -28,11 +28,6 @@ function prepare_doPackages { - # Verify `--packages' option. - if [[ $FLAG_PACKAGES == 'false' ]];then - return - fi - local PACKAGE='' local PACKAGES='' local PACKAGES_THIRDS='' diff --git a/Scripts/Functions/Prepare/prepare_getOptions.sh b/Scripts/Functions/Prepare/prepare_getOptions.sh index 67764bd..bab80b5 100755 --- a/Scripts/Functions/Prepare/prepare_getOptions.sh +++ b/Scripts/Functions/Prepare/prepare_getOptions.sh @@ -29,7 +29,7 @@ function prepare_getOptions { local ARGSS="" # Define long options we want to support. - local ARGSL="quiet,answer-yes,packages,links,environment" + local ARGSL="quiet,answer-yes,packages,links,images,manuals,environment" # Parse arguments using getopt(1) command parser. cli_parseArguments @@ -38,6 +38,15 @@ function prepare_getOptions { # parser. eval set -- "$ARGUMENTS" + # Define default behaviour when no option is provided. + if [[ "$@" =~ '^--$' ]];then + ${FUNCNAM}_doPackages + ${FUNCNAM}_doLinks + ${FUNCNAM}_doImages + ${FUNCNAM}_doManuals + return + fi + # Look for options passed through command-line. while true; do case "$1" in @@ -54,17 +63,27 @@ function prepare_getOptions { ;; --packages ) - FLAG_PACKAGES="true" + ACTIONNAMS="${ACTIONNAMS} ${FUNCNAM}_doPackages" shift 1 ;; --links ) - FLAG_LINKS="true" + ACTIONNAMS="${ACTIONNAMS} ${FUNCNAM}_doLinks" + shift 1 + ;; + + --images ) + ACTIONNAMS="${ACTIONNAMS} ${FUNCNAM}_doImages" + shift 1 + ;; + + --manuals ) + ACTIONNAMS="${ACTIONNAMS} ${FUNCNAM}_doManuals" shift 1 ;; --environment ) - FLAG_ENVIRONMENT="true" + ACTIONNAMS="${ACTIONNAMS} ${FUNCNAM}_doEnvironment" shift 1 ;;