Debian Codegraph @

build-distribution

raw ◀ ▶
1 Debian patch touch this file
1 #! /bin/bash
2 #
3 # build-distribution
4 # Part of ComixCursors, a desktop cursor theme.
5 #
6 # Copyright © 2010–2013 Ben Finney <[email protected]>
7 # Copyright © 2006–2013 Jens Luetkens <[email protected]>
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
22 # This script creates all distribution packages of ComixCursors from
23 # the sources. Run it as root from inside the source VCS working tree.
24 #
25 # Additional requirements:
26 # * Git <https://git-scm.com/>
27 # * RPM package building tools <http://rpm.org/>
28
29 set -o errexit
30
31 bindir=bin
32
33 VERSION=$("${bindir}"/current-package-version)
34 export VERSION
35
36 themename_root="ComixCursors"
37 distdir="${PWD}/dist"
38
39 #
40 # start
41 #
42
43 printf "Packaging %s %s...\n" "$themename_root" "$VERSION"
44
45 workdir="$(mktemp -t -d)"
•46 DESTDIR="${workdir}/dest"
47
48 #
49 # source package
50 #
51 printf "Creating source package...\n"
52
53 make clean
54 srcname="${themename_root}-sources-${VERSION}"
55 srcdir="${workdir}/${srcname}"
56 mkdir --parents "${srcdir}"
57 # bzr export "$srcdir"/
58 git clone . "${srcdir}"
59
60 mkdir --parents "$distdir"
61 rm -rf "${distdir:?}"/*
62
63 tarfile="${distdir}/${srcname}.tar.bz2"
64 tar -cjf "$tarfile" --exclude-vcs --directory "$workdir" "$srcname"/
65
66 #
67 # Now build the cursors for packaging.
68 #
69
70 printf "Installing cursor files...\n"
71
72 # Make a temporary directory for installing icons into.
•73 icons_destdir="${DESTDIR}/usr/share/icons"
74
75 export DESTDIR
76
77 ./install-all
78
79 function package_variant {
80 # Package the tarball for a specific variant of the cursors.
81 local variant="$1"
82 local SUMMARY="$2"
83
84 if [ -n "$variant" ] ; then
85 PACKAGENAME="${themename_root}-${variant}"
86 else
87 PACKAGENAME="${themename_root}"
88 fi
89
90 printf "Creating cursors package %s...\n" "$PACKAGENAME"
91
92 # Now it's important that the variants get processed in an
93 # "reverse" order, so only directories matching package name get
94 # moved and packaged.
95
96 packagedir="${workdir}/${PACKAGENAME}"
97 mkdir --parents "$packagedir"
•98 mv "${icons_destdir}/${PACKAGENAME}"* "$packagedir"/.
99
100 tarfile="${distdir}/${PACKAGENAME}-${VERSION}.tar.bz2"
101 tar -cjf "$tarfile" --directory "$packagedir" --files-from <(
102 cd "$packagedir"
103 ls
104 )
105 ln -s "${PACKAGENAME}-${VERSION}.tar.bz2" "${distdir}/${PACKAGENAME}-latest.tar.bz2"
106
107 #
108 # RPM packages
109 #
110 rpmdir=${RPMDIR:-"/usr/src/packages"}
111 if [ -d "$rpmdir" ] ; then
112 printf "Creating RPM package...\n"
113 specfilename="${PACKAGENAME}.spec"
114 specfile="${rpmdir}/SPECS/${specfilename}"
115 rpmsourcesdir="${rpmdir}/SOURCES"
116 export PACKAGENAME SUMMARY
117 make "$specfilename"
118 cp "$specfilename" "$specfile"
119 cp "$tarfile" "${rpmsourcesdir}"/.
120 (
121 cd "$rpmsourcesdir"
122 rpmbuild -bb "$specfile"
123 )
124 mv "${rpmdir}/RPMS/noarch/${PACKAGENAME}"* "$distdir"/.
125 else
126 printf "Directory $rpmdir not found, skipping RPM packaging.\n"
127 fi
128
129 }
130
131 package_variant "LH-Opaque" "The opaque left-handed Comix Cursors"
132 package_variant "LH" "The left-handed Comix Cursors"
133 package_variant "Opaque" "The opaque Comix Cursors"
134 package_variant "" "The original Comix Cursors"
135
136
137 #
138 # Finally build a list of distribution files and pass that to the
139 # deployment index.html.
140 #
141 printf "Generating deployment index.html...\n"
142 templatefile="deployment/index.html.template"
143 indexfile="deployment/index.html"
144 sed "s/THEMENAME/${themename_root}/g" "${templatefile}" > "${indexfile}"
145 FILES=$(find -L ${distdir} -type f -printf '<p><a href="%f">%f<\\/a> (%TY-%Tm-%Td %TH:%TM, %k kB)<\\/p>\\n')
146 sed -i "s/VERSION/${VERSION}/" "${indexfile}"
147 sed -i "s/FILELIST/${FILES}/" "${indexfile}"
148
149
150 printf "Cleaning up temporary working area...\n"
151 rm -r "$workdir"
152
153 printf "Done.\n"