summaryrefslogtreecommitdiffstats
path: root/gnuzilla/build
blob: 45e8ae16f5ddbf22bf0fbd0d9fac236e9e9f2caf (plain)
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
#!/bin/sh

set -eu

MKBUILDDEPS_TOOL='/usr/bin/apt-get -o Debug::pkgProblemResolver=yes'
MKBUILDDEPS_TOOL="${MKBUILDDEPS_TOOL} --no-install-recommends -y"

header()
{
	local fmt="${1}"
	shift 1

	printf "\n${fmt}\n" "${@}"
	printf "${fmt}\n\n" "${@}" | tr -C '\n' '-'

	return 0
}

# Get the newest version.
sed_s='s/uscan: Newest version of icecat on remote site is \([^,][^,]*\),'
sed_s="${sed_s}"' local version is 0$/\1/p;'
version="$(uscan --package 'icecat' --upstream-version '0' \
	--watchfile "${0%/*}/watch" 2>&1 | sed -n "${sed_s}")"
upstream_version="${version%-*}"

printf '%-47s  %31s\n' "icecat (${version})" \
	"$(LC_ALL='POSIX' date '+%a, %d %b %Y %H:%M:%S %z')"
cat <<EOF
================================================================================
EOF

header 'Download Upstream Sources'

# Download.
uscan --package icecat --upstream-version '0' --watchfile "${0%/*}/watch" \
	--download --download-version "${version}" --destdir '.'

header 'Unpack Package'

# Create package directory and mount a temporary file system on it.
mkdir "icecat-${upstream_version}/"
sudo mount -t 'tmpfs' -o "uid=$(id -u),gid=$(id -g)" \
	'tmpfs' "icecat-${upstream_version}/"

# Unpack package.
tar -xjf "icecat-${version}.tar.bz2"

# hardening-wrapper was deprecated and removed.
sed -i '/^\thardening-wrapper,$/d;' \
	"icecat-${upstream_version}/debian/control" \
	"icecat-${upstream_version}/debian/control.in"

# Instead, let CDBS set CFLAGS, CXXFLAGS, and LDFLAGS to output of
# dpkg-buildflags.
#sed -i '/^CFLAGS[ \t]*:=.*$/d; /^CXXFLAGS[ \t]*:=.*$/d;
#	/^LDFLAGS[ \t]*:=.*$/d;' \
#	"icecat-${upstream_version}/debian/build/rules.mk"
sed -i '
	s/^\(CFLAGS\)\([ \t]*:=\).*$/\1\2 $(shell dpkg-buildflags --get \1)/;
	s/^\(CXXFLAGS\)\([ \t]*:=\).*$/\1\2 $(shell dpkg-buildflags --get \1)/;
	s/^\(LDFLAGS\)\([ \t]*:=\).*$/\1\2 $(shell dpkg-buildflags --get \1)/;
	' \
	"icecat-${upstream_version}/debian/build/rules.mk"

# "3.0 (native)" source packages may not have a revision.
sed -i '1s/-gnu/~gnu/;' "icecat-${upstream_version}/debian/changelog"

# Since 2017-11-11, there are two search plugins matching "google*.xml":
# google.xml and google-2018.xml.  debian/install-distribution-searchplugins.py
# throws an error: "More than one search plugin found for 'Google'".
# Cf.:
# * <https://hg.mozilla.org/mozilla-central/log/tip/browser/locales/searchplugins/google-2018.xml>
# * <https://bugzilla.mozilla.org/show_bug.cgi?id=1416484>
# * <https://bazaar.launchpad.net/~mozillateam/firefox/firefox-trunk.head/revision/2155/debian/config/searchplugins.conf>
sed -i 's/google\*\.xml/google.xml/' \
	"icecat-${upstream_version}/debian/config/searchplugins.conf"

header 'Install Build Dependencies'

# Make sure build dependencies are installed.
mk-build-deps -i -t "${MKBUILDDEPS_TOOL}" -r -s sudo \
	"icecat-${upstream_version}/debian/control"

header 'Build Package'

# Build source and binary packages.
cd "icecat-${upstream_version}/"
dpkg-buildpackage -j4 -us -uc
cd '../'

header 'Clean Up'

# Unmount and remove package directory.
sudo umount "icecat-${upstream_version}/"
rmdir "icecat-${upstream_version}/"