-
Notifications
You must be signed in to change notification settings - Fork 55
/
generate-deb.sh
executable file
·453 lines (360 loc) · 13.9 KB
/
generate-deb.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
#!/bin/sh
# you will need dh-make, dpkg-dev, fakeroot, cdbs
set -e
# clean old package build
rm -rf nautilus-dropbox{-,_}*
# Copy to a tempdir since package generation pollutes the directory.
SRCDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
TMPDIR=$(mktemp -d)
trap "rm -rf $TMPDIR" EXIT
cp -R $SRCDIR/* $TMPDIR/
cd $TMPDIR
# get version
CURVER=$(mawk '/^AC_INIT/{sub("AC_INIT\(\[nautilus-dropbox\], ", ""); sub("\)", ""); print $0}' configure.ac)
. ./distro-info.sh
if [ ! -x configure ]; then
./autogen.sh
fi
if [ ! -e Makefile ]; then
./configure
fi
# first generate package binary
make dist
# untar package
tar xjf nautilus-dropbox-$CURVER.tar.bz2
# go into package dir
cd nautilus-dropbox-$CURVER
# make debian dir
mkdir debian
# add our files
cat > debian/rules <<EOF
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
# Avoid postinst-has-useless-call-to-ldconfig and pkg-has-shlibs-control-file-but-no-actual-shared-libs
DEB_DH_MAKESHLIBS_ARGS=-Xnautilus-dropbox
EOF
chmod a+x debian/rules
cat > debian/changelog <<EOF
dropbox ($CURVER) stable; urgency=low
* Initial Release, This package doesn't use a changelog
-- Dropbox <[email protected]> $(date -R)
EOF
cat > debian/copyright <<EOF
This package was debianized by Dropbox <[email protected]> on
$(date -R).
It was downloaded from https://www.dropbox.com/download?dl=packages/nautilus-dropbox-$CURVER.tar.bz2
Copyright:
Copyright Dropbox, Inc.
All images included in this package constitute data and are licensed under the
Creative Commons Attribution-No Derivative Works 3.0 Unported License [1]. This
includes the files:
data/icons/hicolor/16x16/apps/dropbox.png
data/icons/hicolor/22x22/apps/dropbox.png
data/icons/hicolor/24x24/apps/dropbox.png
data/icons/hicolor/32x32/apps/dropbox.png
data/icons/hicolor/48x48/apps/dropbox.png
data/icons/hicolor/64x64/apps/dropbox.png
data/icons/hicolor/64x64/emblems/emblem-dropbox-syncing.png
data/icons/hicolor/64x64/emblems/emblem-dropbox-uptodate.png
data/icons/hicolor/64x64/emblems/emblem-dropbox-unsyncable.png
[1] http://creativecommons.org/licenses/by-nd/3.0/
All program source in this package is released under the terms of the
GNU GPL version 3 below.
This program 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 program 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 program. If not, see <http://www.gnu.org/licenses/>.
On Debian systems, the complete text of the GNU General
Public License can be found in \`/usr/share/common-licenses/GPL-3'.
The Debian packaging is Copyright (C) Dropbox, Inc. and
is licensed under the GPL, see above.
EOF
cat > debian/dropbox.postinst<<EOF
#!/bin/sh
# postinst script for dropbox
#
# see: dh_installdeb(1)
# summary of how this script can be called:
# * <postinst> \`configure' <most-recently-configured-version>
# * <old-postinst> abort-upgrade' <new version>
# * <conflictor's-postinst> \`abort-remove' \`in-favour' <package>
# <new-version>
# * <postinst> \`abort-remove'
# * <deconfigured's-postinst> \`abort-deconfigure' \`in-favour'
# <failed-install-package> <version> \`removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
DEFAULTS_FILE="/etc/default/dropbox-repo"
UBUNTU_CODENAMES="$UBUNTU_CODENAMES"
DEBIAN_CODENAMES="$DEBIAN_CODENAMES"
EOF
# We split this into two so that we can replace variables in the first part but
# not have to escape everything in the 2nd part. NB: Apparently the 'EOF' vs
# EOF makes a difference.
cat >> debian/dropbox.postinst<<'EOF'
case "$1" in
configure)
gtk-update-icon-cache /usr/share/icons/hicolor > /dev/null 2>&1
DISTRO=`lsb_release -s -i`
if [ "$DISTRO" = "Ubuntu" ]; then
DISTS=$UBUNTU_CODENAMES
DISTRO="ubuntu"
elif [ "$DISTRO" = "Debian" ]; then
DISTS=$DEBIAN_CODENAMES
DISTRO="debian"
else
echo "You are not running Debian or Ubuntu. Not adding Dropbox repository."
DISTRO=""
fi
if [ -n "$DISTRO" -a ! -e "$DEFAULTS_FILE" ]; then
# Add the Dropbox repository.
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license.
# Install the repository signing key (see also:
# https://linux.dropbox.com/fedora/rpm-public-key.asc)
install_key() {
cat >/etc/apt/keyrings/dropbox.asc <<KEYDATA
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.9 (GNU/Linux)
mQENBEt0ibEBCACv4hZRPqwtpU6z8+BB5YZU1a3yjEvg2W68+a6hEwxtCa2U++4d
zQ+7EqaUq5ybQnwtbDdpFpsOi9x31J+PCpufPUfIG694/0rlEpmzl2GWzY8NqfdB
FGGm/SPSSwvKbeNcFMRLu5neo7W9kwvfMbGjHmvUbzBUVpCVKD0OEEf1q/Ii0Qce
kx9CMoLvWq7ZwNHEbNnij7ecnvwNlE2MxNsOSJj+hwZGK+tM19kuYGSKw4b5mR8I
yThlgiSLIfpSBh1n2KX+TDdk9GR+57TYvlRu6nTPu98P05IlrrCP+KF0hYZYOaMv
Qs9Rmc09tc/eoQlN0kkaBWw9Rv/dvLVc0aUXABEBAAG0MURyb3Bib3ggQXV0b21h
dGljIFNpZ25pbmcgS2V5IDxsaW51eEBkcm9wYm94LmNvbT6JATYEEwECACAFAkt0
ibECGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRD8kYszUESRLi/zB/wMscEa
15rS+0mIpsORknD7kawKwyda+LHdtZc0hD/73QGFINR2P23UTol/R4nyAFEuYNsF
0C4IAD6y4pL49eZ72IktPrr4H27Q9eXhNZfJhD7BvQMBx75L0F5gSQwuC7GdYNlw
SlCD0AAhQbi70VBwzeIgITBkMQcJIhLvllYo/AKD7Gv9huy4RLaIoSeofp+2Q0zU
HNPl/7zymOqu+5Oxe1ltuJT/kd/8hU+N5WNxJTSaOK0sF1/wWFM6rWd6XQUP03Vy
NosAevX5tBo++iD1WY2/lFVUJkvAvge2WFk3c6tAwZT/tKxspFy4M/tNbDKeyvr6
85XKJw9ei6GcOGHD
=5rWG
-----END PGP PUBLIC KEY BLOCK-----
KEYDATA
}
DISTRIB_CODENAME=`lsb_release -s -c`
for DIST in $DISTS; do
REPO=$DIST
if [ "$DIST" = "$DISTRIB_CODENAME" ]; then
break
fi
done
REPOCONFIG="deb [arch=i386,amd64 signed-by=/etc/apt/keyrings/dropbox.asc] http://linux.dropbox.com/$DISTRO $REPO main"
APT_GET="`which apt-get 2> /dev/null`"
APT_CONFIG="`which apt-config 2> /dev/null`"
# Parse apt configuration and return requested variable value.
apt_config_val() {
APTVAR="$1"
if [ -x "$APT_CONFIG" ]; then
"$APT_CONFIG" dump | sed -e "/^$APTVAR /"'!d' -e "s/^$APTVAR \"\(.*\)\".*/\1/"
fi
}
# Set variables for the locations of the apt sources lists.
find_apt_sources() {
APTDIR=$(apt_config_val Dir)
APTETC=$(apt_config_val 'Dir::Etc')
APT_SOURCESDIR="$APTDIR$APTETC/$(apt_config_val 'Dir::Etc::sourceparts')"
}
# Add the Dropbox repository to the apt sources.
# Returns:
# 0 - no update necessary
# 1 - sources were updated
# 2 - error
update_sources_lists() {
if [ ! "$REPOCONFIG" ]; then
return 0
fi
find_apt_sources
if [ -d "$APT_SOURCESDIR" ]; then
# Nothing to do if it's already there.
SOURCELIST=$(grep -H "$REPOCONFIG" "$APT_SOURCESDIR/dropbox.list" \
2>/dev/null | cut -d ':' -f 1)
if [ -n "$SOURCELIST" ]; then
return 0
fi
printf "$REPOCONFIG\n" > "$APT_SOURCESDIR/dropbox.list"
if [ $? -eq 0 ]; then
return 1
fi
fi
return 2
}
install_key
update_sources_lists
fi
for I in /home/*/.dropbox-dist; do
# require a minimum version of 1.0.0
DROPBOX_VERSION="$I/VERSION"
if test -e "$DROPBOX_VERSION"; then
VERSION=`cat "$DROPBOX_VERSION"`
case "$VERSION" in
2.[0-9].*|1.*.*|0.*.*)
# Anything below 2.10 is deprecated!
# stop dropbox
pkill -xf $I/dropbox > /dev/null 2>&1
sleep 0.5
rm -rf "$I"
esac
fi
done
UPDATENOTIFIERDIR=/var/lib/update-notifier/user.d
echo "Please restart all running instances of Nautilus, or you will experience problems. i.e. nautilus --quit"
if [ -d $UPDATENOTIFIERDIR ] ; then
# pgrep matches application names from /proc/<pid>/status which is
# truncated according to sys/procfs.h definition. Problem is it's
# platform dependent. Either 15 or 16 chars.
if pgrep -x nautilus > /dev/null 2>&1 ; then
cat > $UPDATENOTIFIERDIR/dropbox-restart-required <<DROPBOXEND
Name: Nautilus Restart Required
Priority: High
Terminal: False
Command: nautilus -q
ButtonText: _Restart Nautilus
DontShowAfterReboot: True
DisplayIf: pgrep -x nautilus -U \$(id -u) > /dev/null
Description: Dropbox requires Nautilus to be restarted to function properly.
DROPBOXEND
# sometimes this doesn't happen:
touch /var/lib/update-notifier/dpkg-run-stamp
else
rm -f $UPDATENOTIFIERDIR/dropbox-restart-required
fi
fi
echo 'Dropbox installation successfully completed! You can start Dropbox from your applications menu.'
if [ -d $UPDATENOTIFIERDIR ] ; then
cat > $UPDATENOTIFIERDIR/dropbox-start-required <<DROPBOXEND
Name: Dropbox Start Required
Priority: High
Command: dropbox start -i
Terminal: False
DontShowAfterReboot: True
DisplayIf: dropbox running > /dev/null
Description: Start Dropbox to finish installation.
ButtonText: _Start Dropbox
DROPBOXEND
# sometimes this doesn't happen:
touch /var/lib/update-notifier/dpkg-run-stamp
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument '$1'" >&2
exit 1
;;
esac
set -e
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
EOF
cat > debian/postrm <<'EOF'
#!/bin/sh
# Remove the Dropbox repository.
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license.
set -e
action="$1"
# Only do complete clean-up on purge.
if [ "$action" != "purge" ] ; then
exit 0
fi
APT_GET="`which apt-get 2> /dev/null`"
APT_CONFIG="`which apt-config 2> /dev/null`"
# Parse apt configuration and return requested variable value.
apt_config_val() {
APTVAR="$1"
if [ -x "$APT_CONFIG" ]; then
"$APT_CONFIG" dump | sed -e "/^$APTVAR /"'!d' -e "s/^$APTVAR \"\(.*\)\".*/\1/"
fi
}
uninstall_key() {
APT_KEY="`which apt-key 2> /dev/null`"
if [ -x "$APT_KEY" ]; then
# don't fail if the key wasn't found
"$APT_KEY" rm 5044912E >/dev/null 2>&1 || true
fi
}
# Set variables for the locations of the apt sources lists.
find_apt_sources() {
APTDIR=$(apt_config_val Dir)
APTETC=$(apt_config_val 'Dir::Etc')
APT_SOURCESDIR="$APTDIR$APTETC/$(apt_config_val 'Dir::Etc::sourceparts')"
}
# Remove a repository from the apt sources.
# Returns:
# 0 - successfully removed, or not configured
# 1 - failed to remove
clean_sources_lists() {
find_apt_sources
if [ -d "$APT_SOURCESDIR" ]; then
rm -f "$APT_SOURCESDIR/dropbox.list"
fi
return 0
}
uninstall_key
clean_sources_lists
rm -rf /var/lib/update-notifier/user.d/dropbox-restart-required
rm -rf /var/lib/update-notifier/user.d/dropbox-start-required
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
EOF
echo "10" > debian/compat
cat > debian/dropbox.install <<EOF
debian/tmp/usr/*
EOF
# NOTE: When updating dependencies, make sure to test the package on
# the minimum and maximum supported versions for each distro. In
# particular, debian version ordering can be tricky. E.g.
# "1.3.0~somestring" is considered lower than "1.3.0" since usually
# the "~" is appended to denote a beta version.
#
# For more info, see: https://askubuntu.com/a/229749
cat > debian/control <<EOF
Source: dropbox
Section: gnome
Priority: optional
Maintainer: Dropbox <[email protected]>
Build-Depends: cdbs, debhelper (>= 10), build-essential, libnautilus-extension-dev (>= 43.0), libgtk-4-dev (>= 4.8), libglib2.0-dev (>= 2.40), python3-docutils, python3-gi (>= 3.12)
Standards-Version: 3.9.4.0
Package: dropbox
Replaces: nautilus-dropbox
Breaks: nautilus-dropbox
Provides: nautilus-dropbox
Architecture: any
Depends: procps, python3-gi (>= 3.12), python3 (>= 3.4.0), \${python3:Depends}, \${misc:Depends}, libatk1.0-0 (>= 2.10), libc6 (>= 2.19), libcairo2 (>= 1.13), libglib2.0-0 (>= 2.40), libgtk-4-1 (>= 4.8.0), libpango1.0-0 (>= 1.36.3) | libpango-1.0-0 (>= 1.36.3), lsb-release, gir1.2-gdkpixbuf-2.0 (>= 2.30.7), gir1.2-glib-2.0 (>= 1.40.0), gir1.2-gtk-4.0 (>= 4.8.0), gir1.2-pango-1.0 (>= 1.36.3)
Suggests: nautilus (>= 43.0), python3-gpg (>= 1.8.0)
Homepage: https://www.dropbox.com/
Description: cloud synchronization engine - CLI and Nautilus extension
Dropbox is a free service that lets you bring your photos, docs, and videos
anywhere and share them easily.
.
This package provides a command-line tool and a Nautilus extension that
integrates the Dropbox web service with your GNOME Desktop.
Package: nautilus-dropbox
Depends: dropbox, \${misc:Depends}
Architecture: all
Section: oldlibs
Description: transitional dummy package for dropbox
This is a transitional dummy package. It can safely be removed.
EOF
# Actually build the deb package.
debuild -i -us -uc -b
# Copy outputs to the build/$distro dir.
DISTRO=$(lsb_release -s -i | tr '[:upper:]' '[:lower:]')
OUTDIR=$SRCDIR/build/$DISTRO/pool/main
mkdir -p $OUTDIR
cp $TMPDIR/*.deb $TMPDIR/*.changes $TMPDIR/*.build $TMPDIR/*.buildinfo $OUTDIR/