|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# prepare_updateLinks.sh -- This option creates/updates the symbolic links
|
|
|
878a2b |
# information required in your workstation to connect it with the
|
|
|
878a2b |
# files inside the working copy of The CentOS Artwork Repository. When
|
|
|
878a2b |
# you provide this option, the centos-art.sh put itself into your
|
|
|
878a2b |
# system's execution path and make common brushes, patterns, palettes
|
|
|
878a2b |
# and fonts available inside applications like GIMP, so you can make
|
|
|
878a2b |
# use of them without loosing version control over them.
|
|
|
878a2b |
#
|
|
|
03486a |
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is free software; you can redistribute it and/or modify
|
|
|
878a2b |
# it under the terms of the GNU General Public License as published by
|
|
|
878a2b |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
878a2b |
# your option) any later version.
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is distributed in the hope that it will be useful, but
|
|
|
878a2b |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
878a2b |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
878a2b |
# General Public License for more details.
|
|
|
878a2b |
#
|
|
|
878a2b |
# You should have received a copy of the GNU General Public License
|
|
|
878a2b |
# along with this program; if not, write to the Free Software
|
|
|
878a2b |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
878a2b |
#
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
# $Id$
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
|
|
|
878a2b |
function prepare_updateLinks {
|
|
|
878a2b |
|
|
|
878a2b |
local -a LINKS_SRC
|
|
|
878a2b |
local -a LINKS_DST
|
|
|
878a2b |
local USERFILES=''
|
|
|
878a2b |
local PALETTE=''
|
|
|
878a2b |
local BRUSH=''
|
|
|
878a2b |
local PATTERN=''
|
|
|
878a2b |
local FONT=''
|
|
|
878a2b |
local FILE=''
|
|
|
878a2b |
local COUNT=0
|
|
|
878a2b |
|
|
|
d4d4d3 |
# Define user's directories. Here is where configuration links are
|
|
|
d4d4d3 |
# created in the local workstation.
|
|
|
878a2b |
local GIMP_DIR=${HOME}/.$(rpm -q gimp | cut -d. -f-2)
|
|
|
878a2b |
local GIMP_DIR_BRUSHES=${GIMP_DIR}/brushes
|
|
|
878a2b |
local GIMP_DIR_PALETTES=${GIMP_DIR}/palettes
|
|
|
878a2b |
local GIMP_DIR_PATTERNS=${GIMP_DIR}/patterns
|
|
|
878a2b |
local INKS_DIR=${HOME}/.inkscape
|
|
|
878a2b |
local INKS_DIR_PALETTES=${INKS_DIR}/palettes
|
|
|
878a2b |
local FONT_DIR=${HOME}/.fonts
|
|
|
878a2b |
local APPS_DIR=${HOME}/bin
|
|
|
878a2b |
|
|
|
d4d4d3 |
# Define the working copy directory structure. Here is where user
|
|
|
d4d4d3 |
# specific configuration links in the workstation will point to.
|
|
|
878a2b |
local WCDIR=$(cli_getRepoTLDir)/Identity
|
|
|
878a2b |
local WCDIR_BRUSHES=${WCDIR}/Brushes
|
|
|
878a2b |
local WCDIR_PALETTES=${WCDIR}/Palettes
|
|
|
878a2b |
local WCDIR_PATTERNS=${WCDIR}/Patterns
|
|
|
878a2b |
local WCDIR_FONTS=${WCDIR}/Fonts
|
|
|
878a2b |
local WCDIR_EDITOR=${PREPARE_CONFIG_DIR}
|
|
|
878a2b |
|
|
|
d4d4d3 |
# Verify required working copy directory structure. If these
|
|
|
d4d4d3 |
# directories don't exist, there isn't a target location where
|
|
|
d4d4d3 |
# configuration links can point to. To prevent such an issue
|
|
|
d4d4d3 |
# output an error message and stop the script execution after it.
|
|
|
d4d4d3 |
if [[ ! -d $WCDIR ]];then
|
|
|
d4d4d3 |
cli_printMessage "`eval_gettext "The directory \\\"\\\$WCDIR\\\" doesn't exist."`"
|
|
|
d4d4d3 |
cli_printMessage "`gettext "Do you want to download a working copy for it now?"`" --as-yesornorequest-line
|
|
|
d4d4d3 |
svn -N co $(cli_printUrl --projects-artwork)trunk/Identity $WCDIR
|
|
|
d4d4d3 |
|
|
|
d4d4d3 |
fi
|
|
|
d4d4d3 |
for DIR in $(echo "Brushes Palettes Patterns Fonts");do
|
|
|
d4d4d3 |
if [[ ! -d ${WCDIR}/${DIR} ]];then
|
|
|
d4d4d3 |
cli_printMessage "`eval_gettext "The directory \\\"\\\$WCDIR/\\\$DIR\\\" doesn't exist."`"
|
|
|
d4d4d3 |
cli_printMessage "`gettext "Do you want to download a working copy for it now?"`" --as-yesornorequest-line
|
|
|
d4d4d3 |
svn co $(cli_printUrl --projects-artwork)trunk/Identity/${DIR} ${WCDIR}/${DIR}
|
|
|
d4d4d3 |
fi
|
|
|
d4d4d3 |
done
|
|
|
d4d4d3 |
|
|
|
878a2b |
# Define link relation for cli.
|
|
|
4aaae3 |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${APPS_DIR}/${CLI_NAME}
|
|
|
4aaae3 |
LINKS_DST[((++${#LINKS_DST[*]}))]=${CLI_BASEDIR}/${CLI_NAME}.sh
|
|
|
4aaae3 |
USERFILES="${APPS_DIR}/${CLI_NAME}"
|
|
|
878a2b |
|
|
|
878a2b |
# Define link relation for fonts.
|
|
|
878a2b |
for FONT in $(cli_getFilesList "${WCDIR_FONTS}" --pattern='.+\.ttf');do
|
|
|
878a2b |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${FONT_DIR}/$(basename $FONT)
|
|
|
878a2b |
LINKS_DST[((++${#LINKS_DST[*]}))]=${FONT}
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
# Define link relation for common palettes.
|
|
|
878a2b |
for PALETTE in $(cli_getFilesList "${WCDIR_PALETTES}" --pattern=".+\.gpl");do
|
|
|
878a2b |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_PALETTES}/$(prepare_getLinkName ${WCDIR_PALETTES} ${PALETTE})
|
|
|
878a2b |
LINKS_DST[((++${#LINKS_DST[*]}))]=${PALETTE}
|
|
|
878a2b |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${INKS_DIR_PALETTES}/$(prepare_getLinkName ${WCDIR_PALETTES} ${PALETTE})
|
|
|
878a2b |
LINKS_DST[((++${#LINKS_DST[*]}))]=${PALETTE}
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
# Define link relation for common brushes.
|
|
|
878a2b |
for BRUSH in $(cli_getFilesList "${WCDIR_BRUSHES}" --pattern=".+\.(gbr|gih)");do
|
|
|
878a2b |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_BRUSHES}/$(prepare_getLinkName ${WCDIR_BRUSHES} ${BRUSH})
|
|
|
878a2b |
LINKS_DST[((++${#LINKS_DST[*]}))]=${BRUSH}
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
# Define link relation for common patterns.
|
|
|
878a2b |
for PATTERN in $(cli_getFilesList "${WCDIR_PATTERNS}" --pattern=".+\.png");do
|
|
|
878a2b |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_PATTERNS}/$(prepare_getLinkName ${WCDIR_BRUSHES} ${BRUSH})
|
|
|
878a2b |
LINKS_DST[((++${#LINKS_DST[*]}))]=${PATTERN}
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
# Define link relation for Vim text editor's configuration.
|
|
|
878a2b |
if [[ $EDITOR == '/usr/bin/vim' ]];then
|
|
|
878a2b |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${HOME}/.vimrc
|
|
|
878a2b |
LINKS_DST[((++${#LINKS_DST[*]}))]=${WCDIR_EDITOR}/vim.conf
|
|
|
878a2b |
USERFILES="${USERFILES} ${HOME}/.vimrc"
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
# Define which files inside the user's configuration directories
|
|
|
878a2b |
# need to be removed in order for centos-art.sh script to make a
|
|
|
878a2b |
# fresh installation of common patterns, common palettes and
|
|
|
878a2b |
# common brushes using symbolic links from the working copy to the
|
|
|
878a2b |
# user's configuration directories inside the workstation.
|
|
|
878a2b |
USERFILES=$(echo "$USERFILES";
|
|
|
878a2b |
cli_getFilesList ${APPS_DIR} --pattern='.+\.sh';
|
|
|
878a2b |
cli_getFilesList ${FONT_DIR} --pattern='.+\.ttf';
|
|
|
878a2b |
cli_getFilesList ${GIMP_DIR_BRUSHES} --pattern='.+\.(gbr|gih)';
|
|
|
878a2b |
cli_getFilesList ${GIMP_DIR_PATTERNS} --pattern='.+\.(pat|png|jpg|bmp)';
|
|
|
878a2b |
cli_getFilesList ${GIMP_DIR_PALETTES} --pattern='.+\.gpl';
|
|
|
878a2b |
cli_getFilesList ${INKS_DIR_PALETTES} --pattern='.+\.gpl';)
|
|
|
878a2b |
|
|
|
878a2b |
# Remove user-specific configuration files from user's home
|
|
|
878a2b |
# directory. Otherwise, we might end up having links insid user's
|
|
|
878a2b |
# home directory that don't exist inside the working copy.
|
|
|
878a2b |
if [[ "$USERFILES" != '' ]];then
|
|
|
878a2b |
rm -r $USERFILES
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
while [[ $COUNT -lt ${#LINKS_SRC[*]} ]];do
|
|
|
878a2b |
|
|
|
878a2b |
# Print action message.
|
|
|
878a2b |
cli_printMessage "${LINKS_SRC[$COUNT]}" --as-creating-line
|
|
|
878a2b |
|
|
|
878a2b |
# Create symbolic link's parent directory if it doesn't exist.
|
|
|
878a2b |
if [[ ! -d $(dirname ${LINKS_SRC[$COUNT]}) ]];then
|
|
|
878a2b |
mkdir -p $(dirname ${LINKS_SRC[$COUNT]})
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
# Create symbolic link.
|
|
|
878a2b |
ln ${LINKS_DST[$COUNT]} ${LINKS_SRC[$COUNT]} --symbolic --force
|
|
|
878a2b |
|
|
|
878a2b |
# Increment counter.
|
|
|
878a2b |
COUNT=$(($COUNT + 1))
|
|
|
878a2b |
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
}
|