Merge Debian packaging for release “0.9-1”.
[debian_comixcursors.git] / build-distribution
blobfb6ca1592938a821e6277d4c64a022ffd7491699
1 #! /bin/bash
3 # build-distribution
4 # Part of ComixCursors, a desktop cursor theme.
6 # Copyright © 2010–2013 Ben Finney <ben+opendesktop@benfinney.id.au>
7 # Copyright © 2006–2013 Jens Luetkens <j.luetkens@limitland.de>
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.
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.
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/>.
22 # This script creates all distribution packages of ComixCursors from
23 # the sources. Run it as root from inside the source VCS working tree.
25 # Additional requirements:
26 # * Bazaar VCS program <http://bazaar.canonical.com/>
27 # * RPM package building tools <http://rpm.org/>
29 set -o errexit
31 bindir=bin
33 VERSION=$("${bindir}"/current-package-version)
34 export VERSION
36 themename_root="ComixCursors"
37 distdir="${PWD}/dist"
40 # start
43 printf "Packaging %s %s...\n" "$themename_root" $VERSION
45 workdir="$(mktemp -t -d)"
48 # source package
50 printf "Creating source package...\n"
52 make clean
53 srcname="${themename_root}-sources-${VERSION}"
54 srcdir="${workdir}/${srcname}"
55 mkdir --parents "${srcdir}"
56 # bzr export "$srcdir"/
58 mkdir --parents "$distdir"
59 rm -rf "$distdir"/*
61 tarfile="${distdir}/${srcname}.tar.bz2"
62 tar -cjf "$tarfile" --exclude-vcs --directory "$workdir" "$srcname"/
65 # Now build the cursors for packaging.
68 printf "Installing cursor files...\n"
70 # Make a temporary directory for installing icons into.
71 ICONSDIR="${workdir}/icons"
72 export ICONSDIR
73 mkdir --parents "${ICONSDIR}"
75 ./install-all
77 function package_variant {
78 # Package the tarball for a specific variant of the cursors.
79 local variant="$1"
80 local SUMMARY="$2"
82 if [ -n "$variant" ] ; then
83 PACKAGENAME="${themename_root}-${variant}"
84 else
85 PACKAGENAME="${themename_root}"
88 printf "Creating cursors package %s...\n" "$PACKAGENAME"
90 # Now it's important that the variants get processed in an
91 # "reverse" order, so only directories matching package name get
92 # moved and packaged.
94 packagedir="${workdir}/${PACKAGENAME}"
95 mkdir --parents "$packagedir"
96 mv "${ICONSDIR}/${PACKAGENAME}"* "$packagedir"/.
98 tarfile="${distdir}/${PACKAGENAME}-${VERSION}.tar.bz2"
99 tar -cjf "$tarfile" --directory "$packagedir" --files-from <(
100 cd "$packagedir"
105 # RPM packages
107 rpmdir="/usr/src/packages"
108 if [ -d "$rpmdir" ] ; then
109 printf "Creating RPM package...\n"
110 specfilename="${PACKAGENAME}.spec"
111 specfile="${rpmdir}/SPECS/${specfilename}"
112 rpmsourcesdir="${rpmdir}/SOURCES"
113 export PACKAGENAME SUMMARY
114 make "$specfilename"
115 cp "$specfilename" "$specfile"
116 cp "$tarfile" "${rpmsourcesdir}"/.
118 cd "$rpmsourcesdir"
119 rpmbuild -bb "$specfile"
121 mv "${rpmdir}/RPMS/noarch/${PACKAGENAME}"* "$distdir"/.
122 else
123 printf "Directory $rpmdir not found, skipping RPM packaging.\n"
127 package_variant "LH-Opaque" "The opaque left-handed Comix Cursors"
128 package_variant "LH" "The left-handed Comix Cursors"
129 package_variant "Opaque" "The opaque Comix Cursors"
130 package_variant "" "The original Comix Cursors"
132 printf "Cleaning up temporary working area...\n"
133 rm -r "$workdir"
135 printf "Done.\n"