-#!/bin/bash
+#!/usr/bin/env bash
#
-# Generate the source directory for sylpheed-claws-themes package
-# from the theme tarballs in http://sylpheed-claws.net/themes.php
+# Generate the source directory for claws-mail-themes package
+# from the theme tarballs in http://www.claws-mail.org/themes.php
#
-# Copyright (c) 2006 Ricardo Mones <ricardo@mones.org>
-# Paul Mangan <claws@thewildbeast.co.uk>
+# Copyright (c) 2006-2010 Ricardo Mones <ricardo@mones.org>
+# Paul Mangan <paul@claws-mail.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-function printHelp()
-{
- echo "Syntax: ";
- echo " $0 version {--clean[-all]|--download|--autotoolize|--all}"
-}
-
-test x$1 = x && echo "Error: version number not given" && printHelp && exit 1;
+test x$1 = x && echo "Error: version number not given" && exit 1;
VERS=$1
shift;
-SITE=http://sylpheed-claws.net
-NAME=sylpheed-claws-themes
-NOTES=RELEASE_NOTES
+SITE=http://www.claws-mail.org
+NAME=claws-mail-themes
DDIR=$NAME-$VERS
PAGE=themes.php
LIST=themes.list
{
for theme in `cat ${LIST} `;
do tarf=`echo $theme | cut -f2 -d/ `;
+ test $tarf = "png" \
+ && tarf=`echo $theme | cut -f3 -d/ `;
echo -n "Downloading... ";
- wget -q -a ${WLOG} -P ${DDIR} ${SITE}/$theme
+ wget -q -a ${WLOG} -O ${DDIR}/$tarf ${SITE}/$theme
test ! -f ${DDIR}/$tarf && echo "Error: couldn't get $tarf" && exit 1;
pushd ${DDIR} > /dev/null
tarops="";
cd "..";
}
+function fixPermissions()
+{
+ find ${DDIR} -type d -exec chmod 755 '{}' +
+ find ${DDIR} -type f -exec chmod 644 '{}' +
+}
+
function createProject()
{
- touch ${DDIR}/${NAME} ${DDIR}/${NOTES}
- find ${DDIR} -type f -exec chmod -x '{}' +
+ touch ${DDIR}/${NAME}
}
function createThemeMakefileAm()
MA="/tmp/tmp.makefile.am";
cd "$1"
dir="$1";
- echo 'themedir = $(prefix)/share/sylpheed-claws/themes/'${dir} > $MA
+ echo 'themedir = $(prefix)/share/claws-mail/themes/'${dir} > $MA
echo "" >> $MA
- echo -n 'dist_theme_DATA =' >> $MA
- test -f .sylpheed_themeinfo \
- && echo " .sylpheed_themeinfo \\" >> $MA;
- count=`ls *.xpm | wc -l `;
+ echo -n 'dist_theme_DATA =' >> $MA
+ count_png=`ls -1 *.png 2> /dev/null | wc -l `
+ count_xpm=`ls -1 *.xpm 2> /dev/null | wc -l `
+ ext="xpm"
+ count=$count_xpm
+ if [ $count_png -gt $count_xpm ];
+ then ext="png";
+ count=$count_png;
+ fi
i=1;
- for px in `ls -1 *.xpm `;
+ for px in `ls -1 *.${ext} `;
do if [ $i -lt $count ];
then echo " $px \\" >> $MA;
else echo " $px" >> $MA;
i=$((1 + $i));
done;
echo "" >> $MA;
- count=`ls * | grep -v '\.xpm$' | wc -l `;
+ count=`ls * | grep -v "\.${ext}$" | wc -l `;
if [ $count -gt 0 ];
then echo -n 'EXTRA_DIST =' >> $MA;
i=1;
- for npx in `ls -1 * | grep -v '\.xpm$' `;
+ for npx in `ls -1 * | grep -v "\.${ext}$" `;
do if [ $i -lt $count ];
then echo " $npx \\" >> $MA;
else echo " $npx" >> $MA;
{
cd ${DDIR}
MA=Makefile.am
- echo "EXTRA_DIST = INSTALL "${NOTES} ${NAME} > $MA
+ if [ -f INSTALL ]
+ then echo "EXTRA_DIST = INSTALL "${NAME} > $MA
+ else echo "EXTRA_DIST = "${NAME} > $MA
+ fi
echo "" >> $MA
echo -n "SUBDIRS =" >> $MA
for dir in *;
do test -d "$dir" && echo -n " ${dir}" >> $MA;
done;
- echo "" >> $MA
- echo "" >> $MA
- echo "BZIP2_ENV =" >> $MA
- echo "" >> $MA
- echo "release: distdir" >> $MA
- echo " -chmod -R a+r \$(distdir)" >> $MA
- echo " GZIP=\$(GZIP_ENV) \$(AMTAR)\$(TAR) chozf \$(distdir).tar.gz \$(distdir)" >> $MA
- echo " BZIP2=\$(BZIP2_ENV) \$(AMTAR)\$(TAR) --bzip2 -chof \$(distdir).tar.bz2 \$(distdir)" >> $MA
- echo " -rm -rf \$(distdir)" >> $MA
- echo "" >> $MA
cd ".."
echo "Created Makefile.am"
}
;;
--autotoolize)
removeWhitespaces;
+ fixPermissions;
createProject;
createAutogenSh;
createMakefileAm;
echo "Done.";
;;
*)
- printHelp;
+ echo "Syntax: ";
+ echo " $0 vers {--clean[-all]|--download|--autotoolize|--all}"
;;
esac