build_packages.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #! /bin/bash
  2. version=`cat fbreader/VERSION`
  3. tmpdir=fbreader-$version
  4. if [ "$1" == "-non-GPL" ]; then
  5. distdir=distributions-nonGPL
  6. pkgdir=packages-nonGPL
  7. prepare_nonGPL=true
  8. shift;
  9. else
  10. distdir=distributions
  11. pkgdir=packages
  12. prepare_nonGPL=false
  13. fi
  14. if [ $# -lt 1 ]; then
  15. echo "usage:"
  16. echo " $0 [-non-GPL] <architecture>"
  17. echo "or"
  18. echo " $0 [-non-GPL] all"
  19. echo "or"
  20. echo " $0 [-non-GPL] supported"
  21. echo ""
  22. echo "available architectures are:"
  23. for pkgtype in $distdir/*; do
  24. for archtype in $pkgtype/*; do
  25. echo " `basename $archtype`-`basename $pkgtype`";
  26. done;
  27. done;
  28. exit 1;
  29. fi
  30. create_tmpdir() {
  31. mkdir $tmpdir
  32. cp -r Makefile build_packages.sh zlibrary fbreader makefiles README.build CHANGES* distributions distributions-nonGPL ChangeLog $tmpdir
  33. rm -rf `find $tmpdir -name ".svn"`
  34. make -C $tmpdir distclean 1> /dev/null 2>&1
  35. if [ "$prepare_nonGPL" == "true" ]; then
  36. pushd $tmpdir > /dev/null;
  37. echo -en "Removing Arabic localization... ";
  38. rm -rf fbreader/data/resources/ar.xml zlibrary/core/data/resources/ar.xml fbreader/data/help/MiniHelp.*.ar.fb2;
  39. echo OK;
  40. echo -en "Removing Finnish localization... ";
  41. rm -rf fbreader/data/resources/fi.xml zlibrary/core/data/resources/fi.xml fbreader/data/help/MiniHelp.*.fi.fb2;
  42. echo OK;
  43. echo -en "Removing Swedish localization... ";
  44. rm -rf fbreader/data/resources/sv.xml zlibrary/core/data/resources/sv.xml fbreader/data/help/MiniHelp.*.sv.fb2;
  45. echo OK;
  46. echo -en "Removing German localization... ";
  47. rm -rf fbreader/data/resources/de.xml zlibrary/core/data/resources/de.xml fbreader/data/help/MiniHelp.*.de.fb2;
  48. echo OK;
  49. echo -en "Removing Czech hyphenation patterns... ";
  50. zip -dq zlibrary/text/data/hyphenationPatterns.zip cs.pattern;
  51. echo OK;
  52. echo -en "Removing Indonesian hyphenation patterns... ";
  53. zip -dq zlibrary/text/data/hyphenationPatterns.zip id.pattern;
  54. echo OK;
  55. echo -en "Removing Qt-based interface... ";
  56. rm -rf zlibrary/ui/src/opie zlibrary/ui/src/qtopia zlibrary/ui/src/qt zlibrary/ui/src/qt4
  57. echo OK;
  58. popd > /dev/null;
  59. fi;
  60. }
  61. remove_tmpdir() {
  62. rm -rf $tmpdir
  63. }
  64. build_package() {
  65. make_package="make -f makefiles/packaging.mk -C $tmpdir DIST_DIR=$distdir"
  66. case "$2" in
  67. debian)
  68. case "$1" in
  69. maemo)
  70. /scratchbox/login sb-conf se SDK_ARM
  71. /scratchbox/login -d `pwd` $make_package ARCHITECTURE=$1 $2
  72. ;;
  73. maemo2|maemo3)
  74. /scratchbox/login sb-conf se SDK_ARMEL
  75. /scratchbox/login -d `pwd` $make_package ARCHITECTURE=$1 $2
  76. ;;
  77. maemo4)
  78. /scratchbox/login sb-conf se CHINOOK_ARMEL
  79. /scratchbox/login -d `pwd` $make_package ARCHITECTURE=$1 $2
  80. ;;
  81. maemo5)
  82. /scratchbox/login sb-conf se FREMANTLE_ARMEL
  83. /scratchbox/login -d `pwd` $make_package ARCHITECTURE=$1 $2
  84. ;;
  85. *)
  86. $make_package ARCHITECTURE=$1 $2
  87. ;;
  88. esac;
  89. mkdir -p $pkgdir/$1
  90. mv -f $tmpdir/*.deb $tmpdir/*.dsc $tmpdir/*.changes $tmpdir/*.tar.gz $pkgdir/$1
  91. ;;
  92. ipk|debipk)
  93. $make_package ARCHITECTURE=$1 $2
  94. mkdir -p $pkgdir/$1
  95. mv -f $tmpdir/*.ipk $pkgdir/$1
  96. ;;
  97. motopkg)
  98. $make_package ARCHITECTURE=$1 $2
  99. mkdir -p $pkgdir/$1
  100. mv -f $tmpdir/*.pkg $pkgdir/$1
  101. ;;
  102. tarball)
  103. $make_package ARCHITECTURE=$1 $2
  104. mkdir -p $pkgdir/$1
  105. mv -f $tmpdir/*.tgz $pkgdir/$1
  106. ;;
  107. nsi)
  108. $make_package ARCHITECTURE=$1 $2
  109. mkdir -p $pkgdir/$1
  110. mv -f $tmpdir/*.exe $pkgdir/$1
  111. ;;
  112. *)
  113. echo no rule is defined for package type ''$2'';
  114. ;;
  115. esac;
  116. }
  117. if [ $1 == all ]; then
  118. create_tmpdir
  119. for pkgtype in $distdir/*; do
  120. for archtype in $pkgtype/*; do
  121. build_package `basename $archtype` `basename $pkgtype`;
  122. done;
  123. done;
  124. remove_tmpdir
  125. elif [ $1 == supported ]; then
  126. create_tmpdir
  127. build_package desktop debian
  128. build_package win32 nsi
  129. build_package source tarball
  130. remove_tmpdir
  131. else
  132. while [ $# -gt 0 ] ; do
  133. archtype=`echo $1 | cut -d "-" -f 1`;
  134. pkgtype=`echo $1 | cut -d "-" -f 2`;
  135. extra=`echo $1 | cut -d "-" -f 3`;
  136. if [ "$pkgtype" != "" -a "$extra" == "" -a -d $distdir/$pkgtype/$archtype ]; then
  137. create_tmpdir
  138. build_package $archtype $pkgtype
  139. remove_tmpdir
  140. else
  141. echo "unknown architecture: $1"
  142. fi;
  143. shift;
  144. done;
  145. fi;