3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # TODO(mmoss) This currently only works with official builds, since non-official
8 # builds don't add the "${BUILDDIR}/installer/" files needed for packaging.
12 if [ "$VERBOSE" ]; then
17 # Create the Debian changelog file needed by dpkg-gencontrol. This just adds a
18 # placeholder change, indicating it is the result of an automatic build.
19 # TODO(mmoss) Release packages should create something meaningful for a
20 # changelog, but simply grabbing the actual 'svn log' is way too verbose. Do we
21 # have any type of "significant/visible changes" log that we could use for this?
23 rm -f "${DEB_CHANGELOG}"
24 process_template
"${SCRIPTDIR}/changelog.template" "${DEB_CHANGELOG}"
25 debchange
-a --nomultimaint -m --changelog "${DEB_CHANGELOG}" \
26 "Release Notes: ${RELEASENOTES}"
27 GZLOG
="${STAGEDIR}/usr/share/doc/${PACKAGE}-${CHANNEL}/changelog.gz"
28 mkdir
-p "$(dirname "${GZLOG}")"
29 gzip -9 -c "${DEB_CHANGELOG}" > "${GZLOG}"
33 # Create the Debian control file needed by dpkg-deb.
35 dpkg-gencontrol
-v"${VERSIONFULL}" -c"${DEB_CONTROL}" -l"${DEB_CHANGELOG}" \
36 -f"${DEB_FILES}" -p"${PACKAGE}-${CHANNEL}" -P"${STAGEDIR}" \
37 -O > "${STAGEDIR}/DEBIAN/control"
38 rm -f "${DEB_CONTROL}"
41 # Setup the installation directory hierachy in the package staging area.
42 prep_staging_debian
() {
44 install -m 755 -d "${STAGEDIR}/DEBIAN" \
45 "${STAGEDIR}/etc/cron.daily" \
46 "${STAGEDIR}/usr/share/menu" \
47 "${STAGEDIR}/usr/share/doc/${PACKAGE}"
50 # Put the package contents in the staging area.
51 stage_install_debian
() {
52 # Always use a different name for /usr/bin symlink depending on channel.
53 # First, to avoid file collisions. Second, to make it possible to
54 # use update-alternatives for /usr/bin/google-chrome.
55 local USR_BIN_SYMLINK_NAME
="${PACKAGE}-${CHANNEL}"
57 if [ "$CHANNEL" != "stable" ]; then
58 # This would ideally be compiled into the app, but that's a bit too
59 # intrusive of a change for these limited use channels, so we'll just hack
60 # it into the wrapper script. The user can still override since it seems to
61 # work to specify --user-data-dir multiple times on the command line, with
62 # the last occurrence winning.
63 local SXS_USER_DATA_DIR
="\${XDG_CONFIG_HOME:-\${HOME}/.config}/${PACKAGE}-${CHANNEL}"
64 local DEFAULT_FLAGS
="--user-data-dir=\"${SXS_USER_DATA_DIR}\""
66 # Avoid file collisions between channels.
67 local INSTALLDIR
="${INSTALLDIR}-${CHANNEL}"
69 local PACKAGE
="${PACKAGE}-${CHANNEL}"
71 # Make it possible to distinguish between menu entries
72 # for different channels.
73 local MENUNAME
="${MENUNAME} (${CHANNEL})"
77 echo "Staging Debian install files in '${STAGEDIR}'..."
78 install -m 755 -d "${STAGEDIR}/${INSTALLDIR}/cron"
79 process_template
"${BUILDDIR}/installer/common/repo.cron" \
80 "${STAGEDIR}/${INSTALLDIR}/cron/${PACKAGE}"
81 chmod 755 "${STAGEDIR}/${INSTALLDIR}/cron/${PACKAGE}"
82 pushd "${STAGEDIR}/etc/cron.daily/"
83 ln -snf "${INSTALLDIR}/cron/${PACKAGE}" "${PACKAGE}"
85 process_template
"${BUILDDIR}/installer/debian/debian.menu" \
86 "${STAGEDIR}/usr/share/menu/${PACKAGE}.menu"
87 chmod 644 "${STAGEDIR}/usr/share/menu/${PACKAGE}.menu"
88 process_template
"${BUILDDIR}/installer/debian/postinst" \
89 "${STAGEDIR}/DEBIAN/postinst"
90 chmod 755 "${STAGEDIR}/DEBIAN/postinst"
91 process_template
"${BUILDDIR}/installer/debian/prerm" \
92 "${STAGEDIR}/DEBIAN/prerm"
93 chmod 755 "${STAGEDIR}/DEBIAN/prerm"
94 process_template
"${BUILDDIR}/installer/debian/postrm" \
95 "${STAGEDIR}/DEBIAN/postrm"
96 chmod 755 "${STAGEDIR}/DEBIAN/postrm"
99 # Actually generate the package file.
101 echo "Packaging ${ARCHITECTURE}..."
102 PREDEPENDS
="$COMMON_PREDEPS"
103 DEPENDS
="${COMMON_DEPS}"
106 PROVIDES
="www-browser"
108 process_template
"${SCRIPTDIR}/control.template" "${DEB_CONTROL}"
109 export DEB_HOST_ARCH
="${ARCHITECTURE}"
110 if [ -f "${DEB_CONTROL}" ]; then
113 fakeroot dpkg-deb
-Zxz -z9 -b "${STAGEDIR}" .
116 # Remove temporary files and unwanted packaging output.
120 rm -rf "${TMPFILEDIR}"
124 echo "usage: $(basename $0) [-c channel] [-a target_arch] [-o 'dir'] "
126 echo "-c channel the package channel (trunk, asan, unstable, beta, stable)"
127 echo "-a arch package architecture (ia32 or x64)"
128 echo "-o dir package output directory [${OUTPUTDIR}]"
129 echo "-b dir build input directory [${BUILDDIR}]"
130 echo "-h this help message"
133 # Check that the channel name is one of the allowable ones.
138 RELEASENOTES
="http://googlechromereleases.blogspot.com/search/label/Stable%20updates"
142 RELEASENOTES
="http://googlechromereleases.blogspot.com/search/label/Dev%20updates"
146 RELEASENOTES
="http://googlechromereleases.blogspot.com/search/label/Beta%20updates"
149 # Setting this to empty will prevent it from updating any existing configs
150 # from release packages.
152 RELEASENOTES
="http://googlechromereleases.blogspot.com/"
156 echo "ERROR: '$CHANNEL' is not a valid channel type."
164 while getopts ":o:b:c:a:h" OPTNAME
168 OUTPUTDIR
=$
(readlink
-f "${OPTARG}")
169 mkdir
-p "${OUTPUTDIR}"
172 BUILDDIR
=$
(readlink
-f "${OPTARG}")
185 echo "'-$OPTARG' needs an argument."
190 echo "invalid command-line option: $OPTARG"
202 SCRIPTDIR
=$
(readlink
-f "$(dirname "$0")")
204 STAGEDIR
=$
(mktemp
-d -t deb.build.XXXXXX
) ||
exit 1
205 TMPFILEDIR
=$
(mktemp
-d -t deb.tmp.XXXXXX
) ||
exit 1
206 DEB_CHANGELOG
="${TMPFILEDIR}/changelog"
207 DEB_FILES
="${TMPFILEDIR}/files"
208 DEB_CONTROL
="${TMPFILEDIR}/control"
210 # Default target architecture to same as build host.
211 if [ "$(uname -m)" = "x86_64" ]; then
217 # call cleanup() on exit
220 BUILDDIR
=${BUILDDIR:=$(readlink -f "${SCRIPTDIR}/../../../../out/Release")}
222 source ${BUILDDIR}/installer
/common
/installer.include
225 VERSIONFULL
="${VERSION}-${PACKAGE_RELEASE}"
227 if [ "$CHROMIUM_BUILD" = "_google_chrome" ]; then
228 source "${BUILDDIR}/installer/common/google-chrome.info"
230 source "${BUILDDIR}/installer/common/chromium-browser.info"
232 eval $
(sed -e "s/^\([^=]\+\)=\(.*\)$/export \1='\2'/" \
233 "${BUILDDIR}/installer/theme/BRANDING")
235 REPOCONFIG
="deb http://dl.google.com/linux/chrome/deb/ stable main"
236 SSLREPOCONFIG
="deb https://dl.google.com/linux/chrome/deb/ stable main"
239 # Some Debian packaging tools want these set.
240 export DEBFULLNAME
="${MAINTNAME}"
241 export DEBEMAIL
="${MAINTMAIL}"
243 # We'd like to eliminate more of these deps by relying on the 'lsb' package, but
244 # that brings in tons of unnecessary stuff, like an mta and rpm. Until that full
245 # 'lsb' package is installed by default on DEB distros, we'll have to stick with
246 # the LSB sub-packages, to avoid pulling in all that stuff that's not installed
249 # Need a dummy debian/control file for dpkg-shlibdeps.
250 DUMMY_STAGING_DIR
="${TMPFILEDIR}/dummy_staging"
251 mkdir
"$DUMMY_STAGING_DIR"
252 cd "$DUMMY_STAGING_DIR"
256 # Generate the dependencies,
257 # TODO(mmoss): This is a workaround for a problem where dpkg-shlibdeps was
258 # resolving deps using some of our build output shlibs (i.e.
259 # out/Release/lib.target/libfreetype.so.6), and was then failing with:
260 # dpkg-shlibdeps: error: no dependency information found for ...
261 # It's not clear if we ever want to look in LD_LIBRARY_PATH to resolve deps,
262 # but it seems that we don't currently, so this is the most expediant fix.
263 SAVE_LDLP
=${LD_LIBRARY_PATH:-}
264 unset LD_LIBRARY_PATH
265 DPKG_SHLIB_DEPS
=$
(dpkg-shlibdeps
-O "$BUILDDIR/chrome" | \
266 sed 's/^shlibs:Depends=//')
267 if [ -n "$SAVE_LDLP" ]; then
268 LD_LIBRARY_PATH
=$SAVE_LDLP
271 # Format it nicely and save it for comparison.
272 # The grep -v is for a duplicate libc6 dep caused by Lucid glibc silliness.
273 echo "$DPKG_SHLIB_DEPS" |
sed 's/, /\n/g' | \
274 grep -v '^libc6 (>= 2.3.6-6~)$' > actual
276 # Compare the expected dependency list to the generate list.
278 diff "$SCRIPTDIR/expected_deps_$TARGETARCH" actual || BAD_DIFF
=1
279 if [ $BAD_DIFF -ne 0 ] && [ -z "${IGNORE_DEPS_CHANGES:-}" ]; then
281 echo "ERROR: Shared library dependencies changed!"
282 echo "If this is intentional, please update:"
283 echo "chrome/installer/linux/debian/expected_deps_ia32"
284 echo "chrome/installer/linux/debian/expected_deps_x64"
288 rm -rf "$DUMMY_STAGING_DIR"
290 # Additional dependencies not in the dpkg-shlibdeps output.
291 # - Pull a more recent version of NSS than required by runtime linking, for
292 # security and stability updates in NSS.
293 ADDITION_DEPS
="ca-certificates, fonts-liberation, libappindicator1, libcurl3, \
294 libnss3 (>= 3.14.3), lsb-base (>=3.2), xdg-utils (>= 1.0.2), wget"
296 # Fix-up libnspr dependency due to renaming in Ubuntu (the old package still
297 # exists, but it was moved to "universe" repository, which isn't installed by
299 DPKG_SHLIB_DEPS
=$
(sed \
300 's/\(libnspr4-0d ([^)]*)\), /\1 | libnspr4 (>= 4.9.5-0ubuntu0), /g' \
301 <<< $DPKG_SHLIB_DEPS)
303 COMMON_DEPS
="${DPKG_SHLIB_DEPS}, ${ADDITION_DEPS}"
304 COMMON_PREDEPS
="dpkg (>= 1.14.0)"
307 # Make everything happen in the OUTPUTDIR.
310 case "$TARGETARCH" in
312 export ARCHITECTURE
="i386"
316 export ARCHITECTURE
="amd64"
321 echo "ERROR: Don't know how to build DEBs for '$TARGETARCH'."