-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmakeDEB.sh
executable file
·215 lines (177 loc) · 5.6 KB
/
makeDEB.sh
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/bin/sh
#
# This script will produce a deb for DMDirc.
#
# DMDirc - Open Source IRC Client
# Copyright (c) 2006-2017 DMDirc Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
showHelp() {
echo "This will generate a DMDirc debian package."
echo "The following command line arguments are known:"
echo "---------------------"
echo "-h, --help Help information"
echo "-j, --jar <jar> What jar to use for the package (requires --version)"
echo "-v, --version <version> What version is this package."
echo "-u, --unsigned Don't sign the output"
echo "-p, --packagename <name> Name for output (rather than DMDirc-<version>"
echo "-e, --extra <extra> Extra tagging on output file."
echo " --runtests If building from source, also run tests and javadoc"
echo "---------------------"
exit 0;
}
JAR=""
VERSION=""
SIGNED="true"
TESTSANDJAVADOC="0"
finalTag=""
PACKAGENAME=""
while test -n "$1"; do
case "$1" in
--jar|-j)
shift
JAR=${1}
;;
--version|-v)
shift
VERSION=${1}
;;
--unsigned|-u)
SIGNED="false"
;;
--runtests)
TESTSANDJAVADOC="1"
;;
--help|-h)
showHelp;
;;
--packagename|-p)
shift
PACKAGENAME="${1}"
;;
--extra|-e)
shift
finalTag="${1}"
;;
esac
shift
done
if [ "${JAR}" != "" -a "${VERSION}" = "" ]; then
echo "When providing a jar, you must also provide a version."
echo ""
echo "Providing neither will make a fresh checkout of the current source and"
echo "build that. (Used to produce debian-uploadable packages)"
exit 1;
fi;
# Debian package revision
DEBIANREVISION=1
# Debian package epoch
DEBIANEPOCH=0
# Find out where we are
BASEDIR=$(cd "${0%/*}" 2>/dev/null; echo $PWD)
cd ${BASEDIR}
# "debian" directory
DEBDIR=${BASEDIR}/deb
# Where will we be building DMDirc today?
BUILDDIR=`mktemp -d "--tmpdir=${BASEDIR}"`
echo "Building in: '${BUILDDIR}'"
# Options to pass to DPKG.
DPKGOPTS=""
# If we are not given a jar to use, then we produce a full-source build.
# This will produce files ready for upload to debian.
if [ "${JAR}" = "" -o ! -e "${JAR}" ]; then
# Clone a copy of the repo to the temp dir
git clone git://dmdirc.com/client "${BUILDDIR}"
# Change into the temp dir
cd "${BUILDDIR}"
# Init the submodules
git submodule init
git submodule update
# What version of the client is this?
VERSION=`git describe --tags --always`
else
cp "${JAR}" "${BUILDDIR}/DMDirc.jar"
# Change into the temp dir
cd "${BUILDDIR}"
# Modify the version.config for debian-ness
jar -xf DMDirc.jar com/dmdirc/version.config
cat <<EOF >>com/dmdirc/version.config
version:
noupdates=true
EOF
# Update the version in the jar
jar uf DMDirc.jar com/dmdirc/version.config;
rm -Rf com
# Create a simple build.xml that will satisfy dpkg-buildpackage
cat <<EOF >build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="DMDirc" default="default" basedir=".">
<description>Builds a pre-built DMDirc!</description>
<target description="Clean project." name="clean">
<delete dir="dist" />
</target>
<target description="Do Nothing" name="with.disabled.updater" />
<target description="Build project." name="default" depends="jar" />
<target description="Build project." name="jar">
<copy file="DMDirc.jar" tofile="dist/DMDirc.jar" overwrite="true" />
</target>
</project>
EOF
DPKGOPTS=" -A"
fi;
# Copy in the debian rules
mkdir -p "${BUILDDIR}/debian"
cp -Rfv "${DEBDIR}/"* .
cp -Rfv ../res/logo.svg icon.svg
# Include function for creating Debain Versions
. "${DEBDIR}/debianVersion.sh";
# Create a Debain Version from the DMDirc version.
DEBIANVERSION=$(debianVersion "${VERSION}" "${DEBIANREVISION}" "${DEBIANEPOCH}")
# What time is this build happening?
BUILDTIME=`date -R`
# Change the changelog to be a default one.
cat <<EOF >debian/changelog
dmdirc (${DEBIANVERSION}) unstable; urgency=low
* Debian Package for DMDirc ${VERSION}, for changes see: http://git.dmdirc.com/
* This changelog will be better in future, honest!
-- DMDirc Developers <[email protected]> ${BUILDTIME}
EOF
# And build
if [ "${SIGNED}" != "true" ]; then
DPKGOPTS=" -uc -us"
fi;
dpkg-buildpackage ${DPKGOPTS}
# Move the resulting files to the output directory.
cd "${BASEDIR}"
mkdir -p "output/debian"
mv "dmdirc_${DEBIANVERSION}"*.* "output/debian"
# Copy the files we actually care about into the output directory
SRC=`ls -1 "output/debian/dmdirc_${DEBIANVERSION}"*".deb"`
if [ "${PACKAGENAME}" = "" ]; then
DEST="DMDirc-${VERSION}"
else
DEST="${PACKAGENAME}"
fi
if [ "${finalTag}" != "" ]; then
DEST="${DEST}-${finalTag}"
fi;
DEST="${DEST}.deb"
cp -v "${SRC}" "output/${DEST}"
# Clean Up
rm -Rf "${BUILDDIR}"