|
|
08abde |
#!/bin/bash
|
|
|
08abde |
#
|
|
|
8cbdc0 |
# prepare_updateLinks.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 |
|
|
|
8cbdc0 |
function prepare_updateLinks {
|
|
|
08abde |
|
|
|
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 |
|
|
|
fd578a |
# Define user's directories. This is the place where configuration
|
|
|
fd578a |
# links are created in.
|
|
|
fd578a |
local GIMP_DIR=${HOME}/.$(rpm -q gimp | cut -d. -f-2)
|
|
|
fd578a |
local GIMP_DIR_BRUSHES=${GIMP_DIR}/brushes
|
|
|
fd578a |
local GIMP_DIR_PALETTES=${GIMP_DIR}/palettes
|
|
|
fd578a |
local GIMP_DIR_PATTERNS=${GIMP_DIR}/patterns
|
|
|
fd578a |
local INKS_DIR=${HOME}/.inkscape
|
|
|
fd578a |
local INKS_DIR_PALETTES=${INKS_DIR}/palettes
|
|
|
fd578a |
local FONT_DIR=${HOME}/.fonts
|
|
|
fd578a |
local APPS_DIR=${HOME}/bin
|
|
|
fd578a |
|
|
|
fd578a |
# Define working copy directories. This is the place where
|
|
|
fd578a |
# configuration links point to.
|
|
|
fd578a |
local WCDIR=$(cli_getRepoTLDir)/Identity
|
|
|
fd578a |
local WCDIR_BRUSHES=${WCDIR}/Brushes
|
|
|
fd578a |
local WCDIR_PALETTES=${WCDIR}/Palettes
|
|
|
fd578a |
local WCDIR_PATTERNS=${WCDIR}/Patterns
|
|
|
fd578a |
local WCDIR_FONTS=${WCDIR}/Fonts
|
|
|
49f245 |
local WCDIR_EDITOR=${CONFIGDIR}
|
|
|
c3ce6a |
|
|
|
c3ce6a |
# Define link relation for cli.
|
|
|
fd578a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${APPS_DIR}/${CLI_PROGRAM}
|
|
|
c23a8a |
LINKS_DST[((++${#LINKS_DST[*]}))]=${CLI_BASEDIR}/${CLI_PROGRAM}.sh
|
|
|
fd578a |
USERFILES="${APPS_DIR}/${CLI_PROGRAM}"
|
|
|
8e457b |
|
|
|
c3ce6a |
# Define link relation for fonts.
|
|
|
fd578a |
for FONT in $(cli_getFilesList "${WCDIR_FONTS}" --pattern='.+\.ttf');do
|
|
|
fd578a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${FONT_DIR}/$(basename $FONT)
|
|
|
fd578a |
LINKS_DST[((++${#LINKS_DST[*]}))]=${FONT}
|
|
|
bc584b |
done
|
|
|
bc584b |
|
|
|
c3ce6a |
# Define link relation for common palettes.
|
|
|
fd578a |
for PALETTE in $(cli_getFilesList "${WCDIR_PALETTES}" --pattern=".+\.gpl");do
|
|
|
fd578a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_PALETTES}/$(prepare_getLinkName ${WCDIR_PALETTES} ${PALETTE})
|
|
|
fd578a |
LINKS_DST[((++${#LINKS_DST[*]}))]=${PALETTE}
|
|
|
fd578a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${INKS_DIR_PALETTES}/$(prepare_getLinkName ${WCDIR_PALETTES} ${PALETTE})
|
|
|
fd578a |
LINKS_DST[((++${#LINKS_DST[*]}))]=${PALETTE}
|
|
|
0b585a |
done
|
|
|
8e457b |
|
|
|
c3ce6a |
# Define link relation for common brushes.
|
|
|
fd578a |
for BRUSH in $(cli_getFilesList "${WCDIR_BRUSHES}" --pattern=".+\.(gbr|gih)");do
|
|
|
fd578a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_BRUSHES}/$(prepare_getLinkName ${WCDIR_BRUSHES} ${BRUSH})
|
|
|
fd578a |
LINKS_DST[((++${#LINKS_DST[*]}))]=${BRUSH}
|
|
|
0b585a |
done
|
|
|
8e457b |
|
|
|
c3ce6a |
# Define link relation for common patterns.
|
|
|
fd578a |
for PATTERN in $(cli_getFilesList "${WCDIR_PATTERNS}" --pattern=".+\.png");do
|
|
|
fd578a |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_PATTERNS}/$(prepare_getLinkName ${WCDIR_BRUSHES} ${BRUSH})
|
|
|
fd578a |
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
|
|
|
536661 |
LINKS_DST[((++${#LINKS_DST[*]}))]=${WCDIR_EDITOR}/vim.conf
|
|
|
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";
|
|
|
fd578a |
cli_getFilesList ${APPS_DIR} --pattern='.+\.sh';
|
|
|
fd578a |
cli_getFilesList ${FONT_DIR} --pattern='.+\.ttf';
|
|
|
fd578a |
cli_getFilesList ${GIMP_DIR_BRUSHES} --pattern='.+\.(gbr|gih)';
|
|
|
fd578a |
cli_getFilesList ${GIMP_DIR_PATTERNS} --pattern='.+\.(pat|png|jpg|bmp)';
|
|
|
fd578a |
cli_getFilesList ${GIMP_DIR_PALETTES} --pattern='.+\.gpl';
|
|
|
fd578a |
cli_getFilesList ${INKS_DIR_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 |
}
|