|
|
08abde |
#!/bin/bash
|
|
|
08abde |
#
|
|
|
38d53d |
# prepare_doLinks.sh -- This option creates/updates the symbolic links
|
|
|
38d53d |
# information required in your workstation to connect it with the
|
|
|
38d53d |
# files inside the working copy of The CentOS Artwork Repository. When
|
|
|
38d53d |
# you provide this option, the centos-art.sh put itself into your
|
|
|
38d53d |
# system's execution path and make common brushes, patterns, palettes
|
|
|
38d53d |
# and fonts available inside applications like GIMP, so you can make
|
|
|
38d53d |
# use of them without loosing version control over them.
|
|
|
08abde |
#
|
|
|
3b0984 |
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
|
|
|
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
|
|
|
7ac5a5 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
7ac5a5 |
# your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# 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
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
08abde |
# ----------------------------------------------------------------------
|
|
|
08abde |
# $Id$
|
|
|
08abde |
# ----------------------------------------------------------------------
|
|
|
08abde |
|
|
|
1700f3 |
function prepare_doLinks {
|
|
|
08abde |
|
|
|
8e457b |
local -a LINKS_SRC
|
|
|
8e457b |
local -a LINKS_DST
|
|
|
38d53d |
local SUFFIX='centos'
|
|
|
06f172 |
local USERFILES=''
|
|
|
0b585a |
local PALETTE=''
|
|
|
0b585a |
local BRUSH=''
|
|
|
0b585a |
local PATTERN=''
|
|
|
0b585a |
local FONT=''
|
|
|
0b585a |
local FILE=''
|
|
|
8e457b |
local COUNT=0
|
|
|
08abde |
|
|
|
38d53d |
# Define user's directories where most configuration linkes will
|
|
|
38d53d |
# be created in.
|
|
|
38d53d |
local GIMP_HOME=${HOME}/.$(rpm -q gimp | cut -d. -f-2)
|
|
|
38d53d |
local INKS_HOME=${HOME}/.inkscape
|
|
|
c3ce6a |
|
|
|
c3ce6a |
# Define link relation for cli.
|
|
|
c23a8a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${HOME}/bin/$CLI_PROGRAM
|
|
|
c23a8a |
LINKS_DST[((++${#LINKS_DST[*]}))]=${CLI_BASEDIR}/${CLI_PROGRAM}.sh
|
|
|
c0ce08 |
USERFILES="${HOME}/bin/$CLI_PROGRAM"
|
|
|
8e457b |
|
|
|
c3ce6a |
# Define link relation for fonts.
|
|
|
4da581 |
for FONT in $(cli_getFilesList ${HOME}/artwork/trunk/Identity/Fonts --pattern='denmark\.ttf');do
|
|
|
0b585a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${HOME}/.fonts/$(basename $FONT)
|
|
|
0b585a |
LINKS_DST[((++${#LINKS_DST[*]}))]=$FONT
|
|
|
bc584b |
done
|
|
|
bc584b |
|
|
|
c3ce6a |
# Define link relation for common palettes.
|
|
|
4da581 |
for PALETTE in $(cli_getFilesList ${HOME}/artwork/trunk/Identity/Palettes --pattern=".+\.gpl");do
|
|
|
38d53d |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_HOME}/palettes/${SUFFIX}-$(basename $PALETTE)
|
|
|
0b585a |
LINKS_DST[((++${#LINKS_DST[*]}))]=$PALETTE
|
|
|
38d53d |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${INKS_HOME}/palettes/${SUFFIX}-$(basename $PALETTE)
|
|
|
0b585a |
LINKS_DST[((++${#LINKS_DST[*]}))]=$PALETTE
|
|
|
0b585a |
done
|
|
|
8e457b |
|
|
|
c3ce6a |
# Define link relation for common brushes.
|
|
|
4da581 |
for BRUSH in $(cli_getFilesList ${HOME}/artwork/trunk/Identity/Brushes --pattern=".+\.(gbr|gih)");do
|
|
|
38d53d |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_HOME}/brushes/${SUFFIX}-$(basename $BRUSH)
|
|
|
0b585a |
LINKS_DST[((++${#LINKS_DST[*]}))]=$BRUSH
|
|
|
0b585a |
done
|
|
|
8e457b |
|
|
|
c3ce6a |
# Define link relation for common patterns.
|
|
|
4da581 |
for PATTERN in $(cli_getFilesList ${HOME}/artwork/trunk/Identity/Patterns --pattern=".+\.png");do
|
|
|
38d53d |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_HOME}/patterns/${SUFFIX}-$(basename $PATTERN)
|
|
|
0b585a |
LINKS_DST[((++${#LINKS_DST[*]}))]=$PATTERN
|
|
|
0b585a |
done
|
|
|
8e457b |
|
|
|
38d53d |
# Define link relation for Vim text editor's configuration.
|
|
|
c0ce08 |
if [[ $EDITOR == '/usr/bin/vim' ]];then
|
|
|
c0ce08 |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${HOME}/.vimrc
|
|
|
38d53d |
LINKS_DST[((++${#LINKS_DST[*]}))]=${PREPARE_CONFIG_DIR}/vimrc
|
|
|
c0ce08 |
USERFILES="${USERFILES} ${HOME}/.vimrc"
|
|
|
c0ce08 |
fi
|
|
|
c0ce08 |
|
|
|
38d53d |
# Define which files inside the user's configuration directories
|
|
|
38d53d |
# need to be removed in order for centos-art.sh script to make a
|
|
|
38d53d |
# fresh installation of common patterns, common palettes and
|
|
|
38d53d |
# common brushes using symbolic links from the working copy to the
|
|
|
38d53d |
# user's configuration directories inside the workstation.
|
|
|
c0ce08 |
USERFILES=$(echo "$USERFILES";
|
|
|
4da581 |
cli_getFilesList ${HOME}/bin --pattern='.+\.sh';
|
|
|
4da581 |
cli_getFilesList ${HOME}/.fonts --pattern='.+\.ttf';
|
|
|
38d53d |
cli_getFilesList ${GIMP_HOME}/brushes --pattern='.+\.(gbr|gih)';
|
|
|
38d53d |
cli_getFilesList ${GIMP_HOME}/patterns --pattern='.+\.(pat|png|jpg|bmp)';
|
|
|
38d53d |
cli_getFilesList ${GIMP_HOME}/palettes --pattern='.+\.gpl';
|
|
|
38d53d |
cli_getFilesList ${INKS_HOME}/palettes --pattern='.+\.gpl';)
|
|
|
38d53d |
|
|
|
38d53d |
# Remove user-specific configuration files from user's home
|
|
|
38d53d |
# directory. Otherwise, we might end up having links insid user's
|
|
|
38d53d |
# home directory that don't exist inside the working copy.
|
|
|
06f172 |
if [[ "$USERFILES" != '' ]];then
|
|
|
c23a8a |
rm -r $USERFILES
|
|
|
06f172 |
fi
|
|
|
8e457b |
|
|
|
0b585a |
while [[ $COUNT -lt ${#LINKS_SRC[*]} ]];do
|
|
|
8e457b |
|
|
|
c23a8a |
# Print action message.
|
|
|
38d53d |
cli_printMessage "${LINKS_SRC[$COUNT]}" --as-creating-line
|
|
|
8e457b |
|
|
|
38d53d |
# Create symbolic link's parent directory if it doesn't exist.
|
|
|
0b585a |
if [[ ! -d $(dirname ${LINKS_SRC[$COUNT]}) ]];then
|
|
|
0b585a |
mkdir -p $(dirname ${LINKS_SRC[$COUNT]})
|
|
|
0b585a |
fi
|
|
|
8e457b |
|
|
|
c23a8a |
# Create symbolic link.
|
|
|
0b585a |
ln ${LINKS_DST[$COUNT]} ${LINKS_SRC[$COUNT]} --symbolic --force
|
|
|
8e457b |
|
|
|
c23a8a |
# Increment counter.
|
|
|
0b585a |
COUNT=$(($COUNT + 1))
|
|
|
8e457b |
|
|
|
8e457b |
done
|
|
|
08abde |
|
|
|
08abde |
}
|