|
|
08abde |
#!/bin/bash
|
|
|
08abde |
#
|
|
|
0b585a |
# prepare_doLinks.sh -- This function installs the symbolic links your
|
|
|
0b585a |
# workstation needs to have in order for centos-art command to run
|
|
|
0b585a |
# correctly.
|
|
|
08abde |
#
|
|
|
9f5f2e |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
fa95b1 |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
fa95b1 |
# (at your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
08abde |
# This program is distributed in the hope that it will be useful, but
|
|
|
08abde |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
08abde |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
08abde |
# General Public License for more details.
|
|
|
08abde |
#
|
|
|
08abde |
# You should have received a copy of the GNU General Public License
|
|
|
08abde |
# along with this program; if not, write to the Free Software
|
|
|
08abde |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
08abde |
# USA.
|
|
|
08abde |
# ----------------------------------------------------------------------
|
|
|
08abde |
# $Id$
|
|
|
08abde |
# ----------------------------------------------------------------------
|
|
|
08abde |
|
|
|
1700f3 |
function prepare_doLinks {
|
|
|
08abde |
|
|
|
8e457b |
# Verify `--links' option.
|
|
|
8e457b |
if [[ $FLAG_LINKS == 'false' ]];then
|
|
|
8e457b |
return
|
|
|
8e457b |
fi
|
|
|
8e457b |
|
|
|
8e457b |
# Print line separator.
|
|
|
8e457b |
cli_printMessage '-' 'AsSeparatorLine'
|
|
|
8e457b |
|
|
|
0b585a |
# Print action message.
|
|
|
0b585a |
cli_printMessage "`gettext "Checking symbolic links"`" 'AsResponseLine'
|
|
|
0b585a |
|
|
|
0b585a |
# Print line separator.
|
|
|
0b585a |
cli_printMessage '-' 'AsSeparatorLine'
|
|
|
0b585a |
|
|
|
8e457b |
local -a LINKS_SRC
|
|
|
8e457b |
local -a LINKS_DST
|
|
|
06f172 |
local USERFILES=''
|
|
|
0b585a |
local PALETTE=''
|
|
|
0b585a |
local BRUSH=''
|
|
|
0b585a |
local PATTERN=''
|
|
|
0b585a |
local FONT=''
|
|
|
0b585a |
local FILE=''
|
|
|
8e457b |
local COUNT=0
|
|
|
08abde |
|
|
|
06f172 |
# Initialize file prefix. Since we are taking the same file names
|
|
|
06f172 |
# from different theme directory and putting them into the same
|
|
|
06f172 |
# directory structure it is required to identify them some way in
|
|
|
06f172 |
# that common directory structure. For this we use the theme path
|
|
|
06f172 |
# identifier.
|
|
|
06f172 |
local PREFIX=''
|
|
|
06f172 |
|
|
|
0b585a |
# Define user-specific directory for Gimp.
|
|
|
0b585a |
local GIMP_USER_DIR=${HOME}/.$(rpm -q gimp | cut -d. -f-2)
|
|
|
8e457b |
|
|
|
0b585a |
# Define user-specific directory for Inkscape.
|
|
|
0b585a |
local INKS_USER_DIR=${HOME}/.inkscape
|
|
|
0b585a |
|
|
|
0b585a |
# Define both source and target location for centos-art command.
|
|
|
0b585a |
LINKS_SRC[0]=${HOME}/bin/$CLI_PROGRAM
|
|
|
a34b3a |
LINKS_DST[0]=${CLI_BASEDIR}/${CLI_PROGRAM}.sh
|
|
|
8e457b |
|
|
|
0b585a |
# Define both source and target location for fonts.
|
|
|
0b585a |
local FONTS=$(cli_getFilesList "${HOME}/artwork/trunk/Identity/Fonts" 'denmark\.ttf')
|
|
|
0b585a |
for FONT in $FONTS;do
|
|
|
0b585a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${HOME}/.fonts/$(basename $FONT)
|
|
|
0b585a |
LINKS_DST[((++${#LINKS_DST[*]}))]=$FONT
|
|
|
bc584b |
done
|
|
|
bc584b |
|
|
|
0b585a |
# Define both source and target location for Gimp and Inkscape
|
|
|
0b585a |
# palettes.
|
|
|
a34b3a |
local PALETTES=$(cli_getFilesList \
|
|
|
481307 |
"${HOME}/artwork/trunk/Identity/Themes/Motifs/*/*/Palettes
|
|
|
a34b3a |
${HOME}/artwork/trunk/Identity/Palettes" ".+\.gpl")
|
|
|
0b585a |
for PALETTE in $PALETTES;do
|
|
|
a34b3a |
if [[ "$PALETTE" =~ "$(cli_getPathComponent '--theme-pattern')" ]];then
|
|
|
a34b3a |
NAME="$(cli_getRepoName "$(cli_getPathComponent "$PALETTE" '--theme-name')" 'f')-"
|
|
|
a34b3a |
VERS="$(cli_getPathComponent "$PALETTE" '--theme-release')-"
|
|
|
a34b3a |
else
|
|
|
a34b3a |
NAME=''
|
|
|
a34b3a |
VERS=''
|
|
|
06f172 |
fi
|
|
|
a34b3a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_USER_DIR}/palettes/${NAME}${VERS}$(basename $PALETTE)
|
|
|
0b585a |
LINKS_DST[((++${#LINKS_DST[*]}))]=$PALETTE
|
|
|
a34b3a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${INKS_USER_DIR}/palettes/${NAME}${VERS}$(basename $PALETTE)
|
|
|
0b585a |
LINKS_DST[((++${#LINKS_DST[*]}))]=$PALETTE
|
|
|
0b585a |
done
|
|
|
8e457b |
|
|
|
0b585a |
# Define both source and target location for Gimp brushes.
|
|
|
0b585a |
local BRUSHES=$(cli_getFilesList \
|
|
|
481307 |
"${HOME}/artwork/trunk/Identity/Themes/Motifs/*/*/Brushes
|
|
|
a34b3a |
${HOME}/artwork/trunk/Identity/Brushes" ".+\.(gbr|gih)")
|
|
|
0b585a |
for BRUSH in $BRUSHES;do
|
|
|
a34b3a |
if [[ "$BRUSH" =~ "$(cli_getPathComponent '--theme-pattern')" ]];then
|
|
|
a34b3a |
NAME="$(cli_getRepoName "$(cli_getPathComponent "$BRUSH" '--theme-name')" 'f')-"
|
|
|
a34b3a |
VERS="$(cli_getPathComponent "$BRUSH" '--theme-release')-"
|
|
|
a34b3a |
else
|
|
|
a34b3a |
NAME=''
|
|
|
a34b3a |
VERS=''
|
|
|
a34b3a |
fi
|
|
|
a34b3a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_USER_DIR}/brushes/${NAME}${VERS}$(basename $BRUSH)
|
|
|
0b585a |
LINKS_DST[((++${#LINKS_DST[*]}))]=$BRUSH
|
|
|
0b585a |
done
|
|
|
8e457b |
|
|
|
0b585a |
# Define both source and target location for Gimp patterns.
|
|
|
0b585a |
local PATTERNS=$(cli_getFilesList \
|
|
|
481307 |
"${HOME}/artwork/trunk/Identity/Themes/Motifs/*/*/Patterns
|
|
|
a34b3a |
${HOME}/artwork/trunk/Identity/Patterns" ".+\.png")
|
|
|
0b585a |
for PATTERN in $PATTERNS;do
|
|
|
a34b3a |
if [[ "$PATTERN" =~ "$(cli_getPathComponent '--theme-pattern')" ]];then
|
|
|
a34b3a |
NAME="$(cli_getRepoName "$(cli_getPathComponent "$PATTERN" '--theme-name')" 'f')-"
|
|
|
a34b3a |
VERS="$(cli_getPathComponent "$PATTERN" '--theme-release')-"
|
|
|
a34b3a |
else
|
|
|
a34b3a |
NAME=''
|
|
|
a34b3a |
VERS=''
|
|
|
a34b3a |
fi
|
|
|
a34b3a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_USER_DIR}/patterns/${NAME}${VERS}$(basename $PATTERN)
|
|
|
0b585a |
LINKS_DST[((++${#LINKS_DST[*]}))]=$PATTERN
|
|
|
0b585a |
done
|
|
|
8e457b |
|
|
|
06f172 |
# Define files inside user-specific directories that need to be
|
|
|
06f172 |
# removed in order to make a fresh installation of patterns,
|
|
|
06f172 |
# palettes and brushes using symbolic links from the repository.
|
|
|
06f172 |
USERFILES=$(cli_getFilesList "${HOME}/.fonts" '.+\.ttf';
|
|
|
06f172 |
cli_getFilesList "${HOME}/bin" '.+\.sh';
|
|
|
06f172 |
cli_getFilesList "${GIMP_USER_DIR}/palettes" '.+\.gpl';
|
|
|
06f172 |
cli_getFilesList "${GIMP_USER_DIR}/brushes" '.+\.(gbr|gih)';
|
|
|
06f172 |
cli_getFilesList "${GIMP_USER_DIR}/patterns" '.+\.png';
|
|
|
06f172 |
cli_getFilesList "${INKS_USER_DIR}/palettes" '.+\.gpl')
|
|
|
06f172 |
|
|
|
06f172 |
# Remove installed files inside user-specific directories.
|
|
|
06f172 |
if [[ "$USERFILES" != '' ]];then
|
|
|
06f172 |
cli_printActionPreamble "${USERFILES[*]}" 'doDelete' 'AsResponseLine'
|
|
|
06f172 |
for FILE in ${USERFILES[@]};do
|
|
|
06f172 |
cli_printMessage "${FILE}" 'AsDeletingLine'
|
|
|
06f172 |
rm -r $FILE
|
|
|
06f172 |
done
|
|
|
06f172 |
fi
|
|
|
8e457b |
|
|
|
0b585a |
# Create symbolic links. In case the the symbolic link parent
|
|
|
0b585a |
# directory isn't created, it will be created in order to make
|
|
|
06f172 |
# the link creation possible.
|
|
|
06f172 |
cli_printActionPreamble "${LINKS_SRC[*]}" 'doCreate' 'AsResponseLine'
|
|
|
0b585a |
while [[ $COUNT -lt ${#LINKS_SRC[*]} ]];do
|
|
|
8e457b |
|
|
|
0b585a |
if [[ -f ${LINKS_SRC[$COUNT]} ]];then
|
|
|
0b585a |
cli_printMessage "${LINKS_SRC[$COUNT]}" 'AsUpdatingLine'
|
|
|
0b585a |
else
|
|
|
0b585a |
cli_printMessage "${LINKS_SRC[$COUNT]}" 'AsCreatingLine'
|
|
|
8e457b |
fi
|
|
|
8e457b |
|
|
|
0b585a |
if [[ ! -d $(dirname ${LINKS_SRC[$COUNT]}) ]];then
|
|
|
0b585a |
mkdir -p $(dirname ${LINKS_SRC[$COUNT]})
|
|
|
0b585a |
fi
|
|
|
8e457b |
|
|
|
0b585a |
ln ${LINKS_DST[$COUNT]} ${LINKS_SRC[$COUNT]} --symbolic --force
|
|
|
8e457b |
|
|
|
0b585a |
COUNT=$(($COUNT + 1))
|
|
|
8e457b |
|
|
|
8e457b |
done
|
|
|
08abde |
|
|
|
08abde |
}
|