make.themes.project 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. #!/bin/bash
  2. #
  3. # Generate the source directory for sylpheed-claws-themes package
  4. # from the theme tarballs in http://sylpheed-claws.net/themes.php
  5. #
  6. # Copyright (c) 2006 Ricardo Mones <ricardo@mones.org>
  7. # Paul Mangan <claws@thewildbeast.co.uk>
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 2 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program; if not, write to the Free Software
  21. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  22. #
  23. function printHelp()
  24. {
  25. echo "Syntax: ";
  26. echo " $0 version {--clean[-all]|--download|--autotoolize|--all}"
  27. }
  28. test x$1 = x && echo "Error: version number not given" && printHelp && exit 1;
  29. VERS=$1
  30. shift;
  31. SITE=http://sylpheed-claws.net
  32. NAME=sylpheed-claws-themes
  33. NOTES=RELEASE_NOTES
  34. DDIR=$NAME-$VERS
  35. PAGE=themes.php
  36. LIST=themes.list
  37. WLOG=themes.wget.log
  38. function getListFromPage()
  39. {
  40. test -f ${PAGE} && rm -f ${PAGE};
  41. wget -q -a ${WLOG} ${SITE}/${PAGE}
  42. test ! -f ${PAGE} && echo "Error: couldn't get ${PAGE}." && exit 1;
  43. grep 'download.php?file=' ${PAGE} \
  44. | cut -f2 -d\" \
  45. > ${LIST}
  46. }
  47. function makeRoomForThemes()
  48. {
  49. test -d ${DDIR} \
  50. && rm -rf ${DDIR} \
  51. && echo "Removing previous destination";
  52. mkdir ${DDIR};
  53. }
  54. function downloadThemes()
  55. {
  56. for theme in `cat ${LIST} `;
  57. do tarf=`echo $theme | cut -f2 -d/ `;
  58. echo -n "Downloading... ";
  59. wget -q -a ${WLOG} -P ${DDIR} ${SITE}/$theme
  60. test ! -f ${DDIR}/$tarf && echo "Error: couldn't get $tarf" && exit 1;
  61. pushd ${DDIR} > /dev/null
  62. tarops="";
  63. test ${tarf} = ${tarf/.tar.bz2/} && tarops="xzf" || tarops="xjf";
  64. echo -n "unpacking... " \
  65. && tar $tarops $tarf \
  66. && echo -n "deleting tarball... " \
  67. && rm -f $tarf \
  68. && echo "Ok ($tarf)";
  69. popd > /dev/null
  70. done;
  71. }
  72. function removeWhitespaces()
  73. {
  74. cd ${DDIR};
  75. for dir in *;
  76. do test -d "$dir" \
  77. && test ! "${dir}" = "${dir/ /_}" \
  78. && mv "${dir}" "${dir// /_}";
  79. done;
  80. cd "..";
  81. }
  82. function createProject()
  83. {
  84. touch ${DDIR}/${NAME} ${DDIR}/${NOTES}
  85. find ${DDIR} -type f -exec chmod -x '{}' +
  86. }
  87. function createThemeMakefileAm()
  88. {
  89. echo "Making $1";
  90. MA="/tmp/tmp.makefile.am";
  91. cd "$1"
  92. dir="$1";
  93. echo 'themedir = $(prefix)/share/sylpheed-claws/themes/'${dir} > $MA
  94. echo "" >> $MA
  95. echo -n 'dist_theme_DATA =' >> $MA
  96. test -f .sylpheed_themeinfo \
  97. && echo " .sylpheed_themeinfo \\" >> $MA;
  98. count=`ls *.xpm | wc -l `;
  99. i=1;
  100. for px in `ls -1 *.xpm `;
  101. do if [ $i -lt $count ];
  102. then echo " $px \\" >> $MA;
  103. else echo " $px" >> $MA;
  104. fi;
  105. i=$((1 + $i));
  106. done;
  107. echo "" >> $MA;
  108. count=`ls * | grep -v '\.xpm$' | wc -l `;
  109. if [ $count -gt 0 ];
  110. then echo -n 'EXTRA_DIST =' >> $MA;
  111. i=1;
  112. for npx in `ls -1 * | grep -v '\.xpm$' `;
  113. do if [ $i -lt $count ];
  114. then echo " $npx \\" >> $MA;
  115. else echo " $npx" >> $MA;
  116. fi;
  117. i=$((1 + $i));
  118. done;
  119. echo "" >> $MA;
  120. fi;
  121. mv $MA Makefile.am
  122. cd ".."
  123. }
  124. function createAutogenSh()
  125. {
  126. cat<<EOA > ${DDIR}/autogen.sh
  127. #!/bin/sh
  128. aclocal \
  129. && automake --add-missing --foreign --copy \
  130. && autoconf \
  131. && ./configure --enable-maintainer-mode $@
  132. EOA
  133. chmod +x ${DDIR}/autogen.sh
  134. echo "Created autogen.sh"
  135. }
  136. function createMakefileAm()
  137. {
  138. cd ${DDIR}
  139. MA=Makefile.am
  140. echo "AUTOMAKE_OPTIONS = dist-bzip2" > $MA
  141. echo "" >> $MA
  142. echo "EXTRA_DIST = INSTALL "${NOTES} ${NAME} >> $MA
  143. echo "" >> $MA
  144. echo -n "SUBDIRS =" >> $MA
  145. for dir in *;
  146. do test -d "$dir" && echo -n " ${dir}" >> $MA;
  147. done;
  148. echo "" >> $MA
  149. cd ".."
  150. echo "Created Makefile.am"
  151. }
  152. function createConfigureAc()
  153. {
  154. cd ${DDIR}
  155. CA=configure.ac
  156. echo 'AC_PREREQ(2.59d)' > $CA
  157. echo 'AC_INIT('${NAME}')' >> $CA
  158. echo 'AM_INIT_AUTOMAKE('${NAME}', '${VERS}')' >> $CA
  159. cat >> $CA <<EOC
  160. AM_MAINTAINER_MODE
  161. dnl Checks for programs.
  162. AC_PROG_INSTALL
  163. AC_OUTPUT([
  164. Makefile
  165. EOC
  166. # the list of Makefiles
  167. for dir in *;
  168. do test -d "$dir" \
  169. && echo "${dir}/Makefile" >> $CA \
  170. && createThemeMakefileAm "$dir";
  171. done;
  172. echo "])" >> $CA
  173. cd "..";
  174. echo "Created $CA";
  175. }
  176. function cleanMine()
  177. {
  178. find ${DDIR} -name Makefile.am -delete
  179. rm -f \
  180. ${DDIR}/autogen.sh \
  181. ${DDIR}/configure.ac \
  182. ${DDIR}/${NAME}
  183. }
  184. function cleanGenerated()
  185. {
  186. find ${DDIR} -name Makefile.in -delete
  187. find ${DDIR} -name Makefile -delete
  188. rm -rf ${DDIR}/autom4te.cache
  189. rm -f \
  190. ${DDIR}/aclocal.m4 \
  191. ${DDIR}/install-sh \
  192. ${DDIR}/missing \
  193. ${DDIR}/config.status \
  194. ${DDIR}/configure \
  195. ${DDIR}/config.log
  196. }
  197. case "$1" in
  198. --clean)
  199. cleanMine;
  200. echo "Cleaned.";
  201. ;;
  202. --clean-all)
  203. cleanMine;
  204. cleanGenerated;
  205. echo "Cleaned all.";
  206. ;;
  207. --download)
  208. getListFromPage;
  209. makeRoomForThemes;
  210. downloadThemes;
  211. echo "Downloaded.";
  212. ;;
  213. --autotoolize)
  214. removeWhitespaces;
  215. createProject;
  216. createAutogenSh;
  217. createMakefileAm;
  218. createConfigureAc;
  219. echo "Autotoolized.";
  220. ;;
  221. --all)
  222. $0 $VERS --download
  223. $0 $VERS --autotoolize
  224. echo "Done.";
  225. ;;
  226. *)
  227. printHelp;
  228. ;;
  229. esac