[go: up one dir, main page]

File: build-distribution

package info (click to toggle)
comixcursors 0.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 876 kB
  • sloc: sh: 588; makefile: 153; python: 128
file content (153 lines) | stat: -rwxr-xr-x 4,343 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#! /bin/bash
#
# build-distribution
# Part of ComixCursors, a desktop cursor theme.
#
# Copyright © 2010–2013 Ben Finney <ben+opendesktop@benfinney.id.au>
# Copyright © 2006–2013 Jens Luetkens <j.luetkens@limitland.de>
#
# This work is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This work is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this work. If not, see <http://www.gnu.org/licenses/>.

# This script creates all distribution packages of ComixCursors from
# the sources. Run it as root from inside the source VCS working tree.
#
# Additional requirements:
# * Git <https://git-scm.com/>
# * RPM package building tools <http://rpm.org/>

set -o errexit

bindir=bin

VERSION=$("${bindir}"/current-package-version)
export VERSION

themename_root="ComixCursors"
distdir="${PWD}/dist"

#
# start
#

printf "Packaging %s %s...\n" "$themename_root" "$VERSION"

workdir="$(mktemp -t -d)"
DESTDIR="${workdir}/dest"

#
# source package
#
printf "Creating source package...\n"

make clean
srcname="${themename_root}-sources-${VERSION}"
srcdir="${workdir}/${srcname}"
mkdir --parents "${srcdir}"
# bzr export "$srcdir"/
git clone . "${srcdir}"

mkdir --parents "$distdir"
rm -rf "${distdir:?}"/*

tarfile="${distdir}/${srcname}.tar.bz2"
tar -cjf "$tarfile" --exclude-vcs --directory "$workdir" "$srcname"/

#
# Now build the cursors for packaging.
#

printf "Installing cursor files...\n"

# Make a temporary directory for installing icons into.
icons_destdir="${DESTDIR}/usr/share/icons"

export DESTDIR

./install-all

function package_variant {
    # Package the tarball for a specific variant of the cursors.
    local variant="$1"
    local SUMMARY="$2"

    if [ -n "$variant" ] ; then
        PACKAGENAME="${themename_root}-${variant}"
    else
        PACKAGENAME="${themename_root}"
    fi

    printf "Creating cursors package %s...\n" "$PACKAGENAME"

    # Now it's important that the variants get processed in an
    # "reverse" order, so only directories matching package name get
    # moved and packaged.

    packagedir="${workdir}/${PACKAGENAME}"
    mkdir --parents "$packagedir"
    mv "${icons_destdir}/${PACKAGENAME}"* "$packagedir"/.

    tarfile="${distdir}/${PACKAGENAME}-${VERSION}.tar.bz2"
    tar -cjf "$tarfile" --directory "$packagedir" --files-from <(
        cd "$packagedir"
        ls
    )
    ln -s "${PACKAGENAME}-${VERSION}.tar.bz2" "${distdir}/${PACKAGENAME}-latest.tar.bz2"

    #
    # RPM packages
    #
    rpmdir=${RPMDIR:-"/usr/src/packages"}
    if [ -d "$rpmdir" ] ; then
        printf "Creating RPM package...\n"
        specfilename="${PACKAGENAME}.spec"
        specfile="${rpmdir}/SPECS/${specfilename}"
        rpmsourcesdir="${rpmdir}/SOURCES"
        export PACKAGENAME SUMMARY
        make "$specfilename"
        cp "$specfilename" "$specfile"
        cp "$tarfile" "${rpmsourcesdir}"/.
        (
            cd "$rpmsourcesdir"
            rpmbuild -bb "$specfile"
        )
        mv "${rpmdir}/RPMS/noarch/${PACKAGENAME}"* "$distdir"/.
    else
        printf "Directory $rpmdir not found, skipping RPM packaging.\n"
    fi

}

package_variant "LH-Opaque" "The opaque left-handed Comix Cursors"
package_variant "LH" "The left-handed Comix Cursors"
package_variant "Opaque" "The opaque Comix Cursors"
package_variant "" "The original Comix Cursors"


#
# Finally build a list of distribution files and pass that to the
# deployment index.html.
#
printf "Generating deployment index.html...\n"
templatefile="deployment/index.html.template"
indexfile="deployment/index.html"
sed "s/THEMENAME/${themename_root}/g" "${templatefile}" > "${indexfile}"
FILES=$(find -L ${distdir} -type f -printf '<p><a href="%f">%f<\\/a> (%TY-%Tm-%Td %TH:%TM, %k kB)<\\/p>\\n')
sed -i "s/VERSION/${VERSION}/" "${indexfile}"
sed -i "s/FILELIST/${FILES}/" "${indexfile}"


printf "Cleaning up temporary working area...\n"
rm -r "$workdir"

printf "Done.\n"