|
|
0a3f74 |
#!/bin/bash
|
|
|
0a3f74 |
#
|
|
|
2a08b7 |
# svg_doMetadata.sh -- This function updates metadata values inside
|
|
|
2a08b7 |
# scalable vector graphic (SVG) files using default values from The
|
|
|
2a08b7 |
# CentOS Project.
|
|
|
0a3f74 |
#
|
|
|
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
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# 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
|
|
|
0a3f74 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
0a3f74 |
# General Public License for more details.
|
|
|
0a3f74 |
#
|
|
|
0a3f74 |
# You should have received a copy of the GNU General Public License
|
|
|
0a3f74 |
# along with this program; if not, write to the Free Software
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
0a3f74 |
# ----------------------------------------------------------------------
|
|
|
0a3f74 |
# $Id$
|
|
|
0a3f74 |
# ----------------------------------------------------------------------
|
|
|
0a3f74 |
|
|
|
2a08b7 |
function svg_doMetadata {
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Define template file name.
|
|
|
371be2 |
local TEMPLATE="${TUNEUP_BACKEND_CONFIG}/$(cli_getRepoName ${TUNEUP_BACKEND} -f)_metadata.sed"
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Check template file existence.
|
|
|
371be2 |
cli_checkFiles $TEMPLATE
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Build title from file path.
|
|
|
2a08b7 |
local TITLE=$(basename "$FILE")
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Build url from file path.
|
|
|
2a08b7 |
local URL=$(echo $FILE | sed 's!/home/centos!https://projects.centos.org/svn!')
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Build keywords from file path. Do not include filename, it is
|
|
|
0a3f74 |
# already on title.
|
|
|
2a08b7 |
local KEY=''
|
|
|
2a08b7 |
local KEYS=$(dirname "$FILE" | cut -d/ -f6- | tr '/' '\n')
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Build keywords using SVG standard format. Note that this
|
|
|
0a3f74 |
# information is inserted inside template file. The template file
|
|
|
0a3f74 |
# is a replacement set of sed commands so we need to escape the
|
|
|
0a3f74 |
# new line of each line using one backslash (\). As we are doing
|
|
|
0a3f74 |
# this inside bash, it is required to escape the backslash with
|
|
|
0a3f74 |
# another backslash so one of them passes literally to template
|
|
|
0a3f74 |
# file.
|
|
|
0a3f74 |
KEYS=$(\
|
|
|
0a3f74 |
for KEY in $KEYS;do
|
|
|
0a3f74 |
echo " <rdf:li>$KEY</rdf:li>\\"
|
|
|
0a3f74 |
done)
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Redefine template instance file name.
|
|
|
371be2 |
local INSTANCE=$(cli_getTemporalFile $TEMPLATE)
|
|
|
0a3f74 |
|
|
|
2a08b7 |
# Create instance.
|
|
|
371be2 |
cp $TEMPLATE $INSTANCE
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Check template instance. We cannot continue if the template
|
|
|
0a3f74 |
# instance couldn't be created.
|
|
|
654911 |
cli_checkFiles $INSTANCE
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Expand translation markers inside template instance.
|
|
|
0a3f74 |
sed -r -i \
|
|
|
2a08b7 |
-e "s!=TITLE=!$TITLE!" \
|
|
|
0a3f74 |
-e "s!=URL=!$URL!" \
|
|
|
0a3f74 |
-e "s!=DATE=!$(date "+%Y-%m-%d")!" $INSTANCE
|
|
|
0a3f74 |
sed -i -r "/=KEYWORDS=/c\\${KEYS}" $INSTANCE
|
|
|
0a3f74 |
sed -i -r 's/>$/>\\/g' $INSTANCE
|
|
|
63de38 |
cli_replaceTMarkers $INSTANCE
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Update scalable vector graphic using template instance.
|
|
|
0a3f74 |
sed -i -f $INSTANCE $FILE
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Remove template instance.
|
|
|
0a3f74 |
if [[ -f $INSTANCE ]];then
|
|
|
0a3f74 |
rm $INSTANCE
|
|
|
0a3f74 |
fi
|
|
|
0a3f74 |
|
|
|
0a3f74 |
# Sanitate scalable vector graphic.
|
|
|
0a3f74 |
sed -i -r '/^[[:space:]]*$/d' $FILE
|
|
|
0a3f74 |
|
|
|
0a3f74 |
}
|