build-distribution 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #! /bin/bash
  2. #
  3. # build-distribution
  4. # Part of ComixCursors, a desktop cursor theme.
  5. #
  6. # Copyright © 2010–2013 Ben Finney <ben+opendesktop@benfinney.id.au>
  7. # Copyright © 2006–2013 Jens Luetkens <j.luetkens@limitland.de>
  8. #
  9. # This work is free software: you can redistribute it and/or modify it
  10. # under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, either version 3 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This work is distributed in the hope that it will be useful, but
  15. # WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. # General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this work. If not, see <http://www.gnu.org/licenses/>.
  21. # This script creates all distribution packages of ComixCursors from
  22. # the sources. Run it as root from inside the source VCS working tree.
  23. #
  24. # Additional requirements:
  25. # * Bazaar VCS program <http://bazaar.canonical.com/>
  26. # * RPM package building tools <http://rpm.org/>
  27. set -o errexit
  28. bindir=bin
  29. VERSION=$("${bindir}"/current-package-version)
  30. export VERSION
  31. themename_root="ComixCursors"
  32. distdir="${PWD}/dist"
  33. #
  34. # start
  35. #
  36. printf "Packaging %s %s...\n" "$themename_root" $VERSION
  37. workdir="$(mktemp -t -d)"
  38. #
  39. # source package
  40. #
  41. printf "Creating source package...\n"
  42. make clean
  43. srcname="${themename_root}-sources-${VERSION}"
  44. srcdir="${workdir}/${srcname}"
  45. mkdir --parents "${srcdir}"
  46. # bzr export "$srcdir"/
  47. mkdir --parents "$distdir"
  48. rm -rf "$distdir"/*
  49. tarfile="${distdir}/${srcname}.tar.bz2"
  50. tar -cjf "$tarfile" --exclude-vcs --directory "$workdir" "$srcname"/
  51. #
  52. # Now build the cursors for packaging.
  53. #
  54. printf "Installing cursor files...\n"
  55. # Make a temporary directory for installing icons into.
  56. ICONSDIR="${workdir}/icons"
  57. export ICONSDIR
  58. mkdir --parents "${ICONSDIR}"
  59. ./install-all
  60. function package_variant {
  61. # Package the tarball for a specific variant of the cursors.
  62. local variant="$1"
  63. local SUMMARY="$2"
  64. if [ -n "$variant" ] ; then
  65. PACKAGENAME="${themename_root}-${variant}"
  66. else
  67. PACKAGENAME="${themename_root}"
  68. fi
  69. printf "Creating cursors package %s...\n" "$PACKAGENAME"
  70. # Now it's important that the variants get processed in an
  71. # "reverse" order, so only directories matching package name get
  72. # moved and packaged.
  73. packagedir="${workdir}/${PACKAGENAME}"
  74. mkdir --parents "$packagedir"
  75. mv "${ICONSDIR}/${PACKAGENAME}"* "$packagedir"/.
  76. tarfile="${distdir}/${PACKAGENAME}-${VERSION}.tar.bz2"
  77. tar -cjf "$tarfile" --directory "$packagedir" --files-from <(
  78. cd "$packagedir"
  79. ls
  80. )
  81. #
  82. # RPM packages
  83. #
  84. rpmdir="/usr/src/packages"
  85. if [ -d "$rpmdir" ] ; then
  86. printf "Creating RPM package...\n"
  87. specfilename="${PACKAGENAME}.spec"
  88. specfile="${rpmdir}/SPECS/${specfilename}"
  89. rpmsourcesdir="${rpmdir}/SOURCES"
  90. export PACKAGENAME SUMMARY
  91. make "$specfilename"
  92. cp "$specfilename" "$specfile"
  93. cp "$tarfile" "${rpmsourcesdir}"/.
  94. (
  95. cd "$rpmsourcesdir"
  96. rpmbuild -bb "$specfile"
  97. )
  98. mv "${rpmdir}/RPMS/noarch/${PACKAGENAME}"* "$distdir"/.
  99. else
  100. printf "Directory $rpmdir not found, skipping RPM packaging.\n"
  101. fi
  102. }
  103. package_variant "LH-Opaque" "The opaque left-handed Comix Cursors"
  104. package_variant "LH" "The left-handed Comix Cursors"
  105. package_variant "Opaque" "The opaque Comix Cursors"
  106. package_variant "" "The original Comix Cursors"
  107. printf "Cleaning up temporary working area...\n"
  108. rm -r "$workdir"
  109. printf "Done.\n"