Blame Identity/Themes/Motifs/Mettle/Promo/Media/render.sh

4c79b5
#!/bin/bash
4c79b5
#
4c79b5
# Render script.
4c79b5
#
4c79b5
4c79b5
# Define export id
4c79b5
ID='CENTOSARTWORK'
4c79b5
4c79b5
# Make first argument required
4c79b5
if [ ! "$1" ]; then
4c79b5
    echo ' Syntax Error!. See the README file for more information.';
4c79b5
    exit;
4c79b5
fi
4c79b5
 
4c79b5
SVG=svg
4c79b5
TXT=../../../../../../trunk/Translations/Promo/Media
4c79b5
4c79b5
# Define absolute path for the background file. Relative path is not
4c79b5
# allowed. Inkscape needs an absolute path as reference to the
4c79b5
# background image. That is the absolute path we build here.
4c79b5
MYPATH=`pwd`
4c79b5
BGFILE=../../../../../../trunk/Themes/Mettle/Wallpapers/img
4c79b5
cd $BGFILE
4c79b5
BGFILE=`pwd`/wallpaper-fog.png
4c79b5
cd $MYPATH
4c79b5
4c79b5
# Define file name filter
4c79b5
if [ "$3" ];then
4c79b5
    TXTDIRS=`ls $TXT/$FILE | egrep "$3"`
4c79b5
else
4c79b5
    TXTDIRS=`ls $TXT/$FILE`
4c79b5
fi
4c79b5
4c79b5
# Look for versions 
4c79b5
for VERSION in `echo "$1"`; do
4c79b5
4c79b5
    # Define major version
4c79b5
    MAJORV=`echo $VERSION | sed -e 's/\.[0-9]//'`
4c79b5
4c79b5
    # Define Image directory
4c79b5
    IMG=img/$VERSION
4c79b5
    if [ ! -d $IMG ];then
4c79b5
        mkdir $IMG
4c79b5
    fi
4c79b5
4c79b5
    # Look for architectures
4c79b5
    for ARCH in `echo "$2"`;do
4c79b5
4c79b5
        # Look for translations
4c79b5
        for FILE in $TXTDIRS; do
4c79b5
    
4c79b5
            # Define translation file names
4c79b5
            TRANSLATION=$TXT/$FILE
4c79b5
    
4c79b5
            # Define svg template file name
4c79b5
            TEMPLATE=`echo $FILE | sed -r 's!\.sed$!.svg!'`
4c79b5
    
4c79b5
            # Define png image file name
4c79b5
            IMAGE=$IMG/`echo $FILE | sed -r "s/\.sed$/-$ARCH.png/"`
4c79b5
        
4c79b5
            # Define svg template instance. Specify which svg template
4c79b5
            # will be used for a specific translation file and creates
4c79b5
            # a copy of it in the current directory for further
4c79b5
            # translations.
4c79b5
            case $TEMPLATE in
4c79b5
        
4c79b5
        	    # CD Labels
4c79b5
                label.svg		)
4c79b5
                    cat $SVG/label.svg > $TEMPLATE
4c79b5
                ;;
4c79b5
        
4c79b5
        	    # CD Sleeves
4c79b5
    	        sleeve-cd.svg	)
4c79b5
                    cat $SVG/sleeve-cd.svg > $TEMPLATE
4c79b5
	            ;;
4c79b5
4c79b5
                # DVD Sleeves
4c79b5
	            sleeve-dvd.svg	)
4c79b5
    	            cat $SVG/sleeve-dvd.svg > $TEMPLATE
4c79b5
                ;;
4c79b5
4c79b5
            esac
4c79b5
4c79b5
            # Translation. Makes replacements over the recently
4c79b5
            # created template instance.
4c79b5
        	sed -i -e "s!=BGFILE=!$BGFILE!" \
4c79b5
                   -e "s!=ARCH=!$ARCH!" \
4c79b5
                   -f $TRANSLATION \
4c79b5
                   -e "s!=MAJORV=!$MAJORV!" \
4c79b5
                   -e "s!=VERSION=!$VERSION!" $TEMPLATE
4c79b5
4c79b5
            # Rendering.
4c79b5
            inkscape $TEMPLATE --export-id=$ID --export-png=$IMAGE; 
4c79b5
4c79b5
            # Remove temporal file
4c79b5
            rm $TEMPLATE
4c79b5
4c79b5
        done
4c79b5
    done
4c79b5
done