1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#!/bin/bash 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Copyright (c) 2012 The Chromium Authors. All rights reserved. 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be 5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# found in the LICENSE file. 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# TODO(mmoss) This currently only works with official builds, since non-official 8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# builds don't add the "${BUILDDIR}/installer/" files needed for packaging. 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)set -e 11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if [ "$VERBOSE" ]; then 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) set -x 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)fi 14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)set -u 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Create the Debian changelog file needed by dpkg-gencontrol. This just adds a 17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# placeholder change, indicating it is the result of an automatic build. 18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# TODO(mmoss) Release packages should create something meaningful for a 19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# changelog, but simply grabbing the actual 'svn log' is way too verbose. Do we 20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# have any type of "significant/visible changes" log that we could use for this? 21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)gen_changelog() { 22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) rm -f "${DEB_CHANGELOG}" 23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${SCRIPTDIR}/changelog.template" "${DEB_CHANGELOG}" 24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) debchange -a --nomultimaint -m --changelog "${DEB_CHANGELOG}" \ 25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "Release Notes: ${RELEASENOTES}" 26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # Trunk packages need to install to a custom path and with custom filenames 27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # (e.g. not /usr/bin/google-chrome) so they don't conflict with release 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # channel packages. 29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if [ "$CHANNEL" = "trunk" ] || [ "$CHANNEL" = "asan" ]; then 30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) local PACKAGE="${PACKAGE}-${CHANNEL}" 31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) fi 32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) GZLOG="${STAGEDIR}/usr/share/doc/${PACKAGE}/changelog.gz" 33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) mkdir -p "$(dirname "${GZLOG}")" 34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) gzip -9 -c "${DEB_CHANGELOG}" > "${GZLOG}" 35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chmod 644 "${GZLOG}" 36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Create the Debian control file needed by dpkg-deb. 39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)gen_control() { 40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) dpkg-gencontrol -v"${VERSIONFULL}" -c"${DEB_CONTROL}" -l"${DEB_CHANGELOG}" \ 41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) -f"${DEB_FILES}" -p"${PACKAGE}-${CHANNEL}" -P"${STAGEDIR}" \ 42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) -O > "${STAGEDIR}/DEBIAN/control" 43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) rm -f "${DEB_CONTROL}" 44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Setup the installation directory hierachy in the package staging area. 47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)prep_staging_debian() { 48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) prep_staging_common 49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) install -m 755 -d "${STAGEDIR}/DEBIAN" \ 50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/etc/cron.daily" \ 51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/usr/share/menu" \ 52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/usr/share/doc/${PACKAGE}" 53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 54868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Put the package contents in the staging area. 56868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)stage_install_debian() { 57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # Trunk packages need to install to a custom path and with custom filenames 58868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # (e.g. not /usr/bin/google-chrome) so they don't conflict with release 59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # channel packages. 60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if [ "$CHANNEL" = "trunk" ] || [ "$CHANNEL" = "asan" ]; then 61868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) local PACKAGE="${PACKAGE}-${CHANNEL}" 62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) local INSTALLDIR="${INSTALLDIR}-${CHANNEL}" 63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # This would ideally be compiled into the app, but that's a bit too 64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # intrusive of a change for these limited use channels, so we'll just hack 65868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # it into the wrapper script. The user can still override since it seems to 66868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # work to specify --user-data-dir multiple times on the command line, with 67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # the last occurrence winning. 68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) local DEFAULT_FLAGS="--user-data-dir=\"\${HOME}/.config/${PACKAGE}\"" 69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) local MENUNAME="${MENUNAME} (${CHANNEL})" 70868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) fi 71868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) prep_staging_debian 72868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) stage_install_common 73868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "Staging Debian install files in '${STAGEDIR}'..." 74868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) install -m 755 -d "${STAGEDIR}/${INSTALLDIR}/cron" 75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${BUILDDIR}/installer/common/repo.cron" \ 76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/${INSTALLDIR}/cron/${PACKAGE}" 77868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chmod 755 "${STAGEDIR}/${INSTALLDIR}/cron/${PACKAGE}" 78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) pushd "${STAGEDIR}/etc/cron.daily/" 79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ln -snf "${INSTALLDIR}/cron/${PACKAGE}" "${PACKAGE}" 80868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) popd 81868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${BUILDDIR}/installer/debian/debian.menu" \ 82868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/usr/share/menu/${PACKAGE}.menu" 83868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chmod 644 "${STAGEDIR}/usr/share/menu/${PACKAGE}.menu" 84868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${BUILDDIR}/installer/debian/postinst" \ 85868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/DEBIAN/postinst" 86868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chmod 755 "${STAGEDIR}/DEBIAN/postinst" 87868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${BUILDDIR}/installer/debian/prerm" \ 88868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/DEBIAN/prerm" 89868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chmod 755 "${STAGEDIR}/DEBIAN/prerm" 90868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${BUILDDIR}/installer/debian/postrm" \ 91868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/DEBIAN/postrm" 92868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chmod 755 "${STAGEDIR}/DEBIAN/postrm" 93868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 94868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 95868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Actually generate the package file. 96868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)do_package() { 97868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "Packaging ${ARCHITECTURE}..." 98868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) PREDEPENDS="$COMMON_PREDEPS" 99868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) DEPENDS="${COMMON_DEPS}" 100868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # Trunk is a special package, mostly for development testing, so don't make 101868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # it replace any installed release packages. 102868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if [ "$CHANNEL" != "trunk" ] && [ "$CHANNEL" != "asan" ]; then 103868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) REPLACES="${PACKAGE}" 104868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) CONFLICTS="${PACKAGE}" 105868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) PROVIDES="${PACKAGE}, www-browser" 106868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) fi 107868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) gen_changelog 108868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${SCRIPTDIR}/control.template" "${DEB_CONTROL}" 109868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) export DEB_HOST_ARCH="${ARCHITECTURE}" 110868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if [ -f "${DEB_CONTROL}" ]; then 111868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) gen_control 112868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) fi 113868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) fakeroot dpkg-deb -Zlzma -b "${STAGEDIR}" . 114868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 115868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 116868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Remove temporary files and unwanted packaging output. 117868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)cleanup() { 118868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "Cleaning..." 119868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) rm -rf "${STAGEDIR}" 120868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) rm -rf "${TMPFILEDIR}" 121868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 122868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 123868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)usage() { 124868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "usage: $(basename $0) [-c channel] [-a target_arch] [-o 'dir'] " 125868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo " [-b 'dir']" 126868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "-c channel the package channel (trunk, asan, unstable, beta, stable)" 127868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "-a arch package architecture (ia32 or x64)" 128868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "-o dir package output directory [${OUTPUTDIR}]" 129868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "-b dir build input directory [${BUILDDIR}]" 130868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "-h this help message" 131868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 132868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 133868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Check that the channel name is one of the allowable ones. 134868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)verify_channel() { 135868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) case $CHANNEL in 136868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) stable ) 137868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) CHANNEL=stable 138868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) RELEASENOTES="http://googlechromereleases.blogspot.com/search/label/Stable%20updates" 139868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 140868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) unstable|dev|alpha ) 141868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) CHANNEL=unstable 142868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) RELEASENOTES="http://googlechromereleases.blogspot.com/search/label/Dev%20updates" 143868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 144868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) testing|beta ) 145868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) CHANNEL=beta 146868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) RELEASENOTES="http://googlechromereleases.blogspot.com/search/label/Beta%20updates" 147868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 148868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) trunk|asan ) 149868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # Setting this to empty will prevent it from updating any existing configs 150868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # from release packages. 151868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) REPOCONFIG="" 152868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) RELEASENOTES="http://googlechromereleases.blogspot.com/" 153868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 154868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) * ) 155868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo 156868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "ERROR: '$CHANNEL' is not a valid channel type." 157868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo 158868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) exit 1 159868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 160868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) esac 161868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 162868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 163868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)process_opts() { 164868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) while getopts ":o:b:c:a:h" OPTNAME 165868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) do 166868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) case $OPTNAME in 167868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) o ) 168868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) OUTPUTDIR=$(readlink -f "${OPTARG}") 169868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) mkdir -p "${OUTPUTDIR}" 170868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 171868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) b ) 172868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) BUILDDIR=$(readlink -f "${OPTARG}") 173868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 174868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) c ) 175868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) CHANNEL="$OPTARG" 176868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 177868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) a ) 178868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) TARGETARCH="$OPTARG" 179868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 180868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) h ) 181868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) usage 182868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) exit 0 183868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 184868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) \: ) 185868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "'-$OPTARG' needs an argument." 186868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) usage 187868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) exit 1 188868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 189868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) * ) 190868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "invalid command-line option: $OPTARG" 191868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) usage 192868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) exit 1 193868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 194868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) esac 195868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) done 196868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 197868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 198868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#========= 199868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# MAIN 200868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#========= 201868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 202868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)SCRIPTDIR=$(readlink -f "$(dirname "$0")") 203868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)OUTPUTDIR="${PWD}" 204868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)STAGEDIR=$(mktemp -d -t deb.build.XXXXXX) || exit 1 205868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)TMPFILEDIR=$(mktemp -d -t deb.tmp.XXXXXX) || exit 1 206868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)DEB_CHANGELOG="${TMPFILEDIR}/changelog" 207868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)DEB_FILES="${TMPFILEDIR}/files" 208868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)DEB_CONTROL="${TMPFILEDIR}/control" 209868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)CHANNEL="trunk" 210868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Default target architecture to same as build host. 211868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if [ "$(uname -m)" = "x86_64" ]; then 212868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) TARGETARCH="x64" 213868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)else 214868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) TARGETARCH="ia32" 215868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)fi 216868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 217868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# call cleanup() on exit 218868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)trap cleanup 0 219868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)process_opts "$@" 220868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if [ ! "$BUILDDIR" ]; then 221868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) BUILDDIR=$(readlink -f "${SCRIPTDIR}/../../../../../out/Release") 222868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)fi 223868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 224868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)source ${BUILDDIR}/installer/common/installer.include 225868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 226868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)get_version_info 227eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen MurdochVERSIONFULL="${VERSION}-${PACKAGE_RELEASE}" 228868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 229868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if [ "$CHROMIUM_BUILD" = "_google_chrome" ]; then 230868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) source "${BUILDDIR}/installer/common/google-chrome.info" 231868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)else 232868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) source "${BUILDDIR}/installer/common/chromium-browser.info" 233868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)fi 234868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)eval $(sed -e "s/^\([^=]\+\)=\(.*\)$/export \1='\2'/" \ 235868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${BUILDDIR}/installer/theme/BRANDING") 236868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 237868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)REPOCONFIG="deb http://dl.google.com/linux/${PACKAGE#google-}/deb/ stable main" 238868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)verify_channel 239868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 240868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Some Debian packaging tools want these set. 241868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)export DEBFULLNAME="${MAINTNAME}" 242868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)export DEBEMAIL="${MAINTMAIL}" 243868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 244868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# We'd like to eliminate more of these deps by relying on the 'lsb' package, but 245868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# that brings in tons of unnecessary stuff, like an mta and rpm. Until that full 246868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# 'lsb' package is installed by default on DEB distros, we'll have to stick with 247868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# the LSB sub-packages, to avoid pulling in all that stuff that's not installed 248868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# by default. 249868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 250868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Need a dummy debian/control file for dpkg-shlibdeps. 251868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)DUMMY_STAGING_DIR="${TMPFILEDIR}/dummy_staging" 252868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)mkdir "$DUMMY_STAGING_DIR" 253868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)cd "$DUMMY_STAGING_DIR" 254868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)mkdir debian 255868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)touch debian/control 256868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 257868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Generate the dependencies, 258868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# TODO(mmoss): This is a workaround for a problem where dpkg-shlibdeps was 259868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# resolving deps using some of our build output shlibs (i.e. 260868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# out/Release/lib.target/libfreetype.so.6), and was then failing with: 261868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# dpkg-shlibdeps: error: no dependency information found for ... 262868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# It's not clear if we ever want to look in LD_LIBRARY_PATH to resolve deps, 263868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# but it seems that we don't currently, so this is the most expediant fix. 264868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)SAVE_LDLP=${LD_LIBRARY_PATH:-} 265868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)unset LD_LIBRARY_PATH 266868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)DPKG_SHLIB_DEPS=$(dpkg-shlibdeps -O "$BUILDDIR/chrome" 2> /dev/null | \ 267868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) sed 's/^shlibs:Depends=//') 268868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if [ -n "$SAVE_LDLP" ]; then 269868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) LD_LIBRARY_PATH=$SAVE_LDLP 270868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)fi 271868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 272868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Format it nicely and save it for comparison. 273868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# The grep -v is for a duplicate libc6 dep caused by Lucid glibc silliness. 274868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)echo "$DPKG_SHLIB_DEPS" | sed 's/, /\n/g' | \ 275868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) grep -v '^libc6 (>= 2.3.6-6~)$' > actual 276868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 277868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Compare the expected dependency list to the generate list. 278868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)BAD_DIFF=0 279eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochdiff "$SCRIPTDIR/expected_deps" actual || BAD_DIFF=1 280868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if [ $BAD_DIFF -ne 0 ] && [ -z "${IGNORE_DEPS_CHANGES:-}" ]; then 281868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo 282868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "ERROR: Shared library dependencies changed!" 283868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "If this is intentional, please update:" 284eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch echo "chrome/installer/linux/debian/expected_deps" 285868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo 286868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) exit $BAD_DIFF 287868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)fi 288868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)rm -rf "$DUMMY_STAGING_DIR" 289868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 290868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Additional dependencies not in the dpkg-shlibdeps output. 291bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch# Pull a more recent version of NSS than required by runtime linking, for 292bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch# security and stability updates in NSS. 293bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben MurdochADDITION_DEPS="ca-certificates, libcurl3, libnss3 (>= 3.14.3), \ 294868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) lsb-base (>=3.2), xdg-utils (>= 1.0.2), wget" 295868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 296868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Fix-up libnspr dependency due to renaming in Ubuntu (the old package still 297868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# exists, but it was moved to "universe" repository, which isn't installed by 298868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# default). 299868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)DPKG_SHLIB_DEPS=$(sed \ 300bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 's/\(libnspr4-0d ([^)]*)\), /\1 | libnspr4 (>= 4.9.5-0ubuntu0), /g' \ 301868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) <<< $DPKG_SHLIB_DEPS) 302868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 303868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Fix-up libudev dependency because Ubuntu 13.04 has libudev1 instead of 304868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# libudev0. 305868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)DPKG_SHLIB_DEPS=$(sed 's/\(libudev0 ([^)]*)\), /\1 | libudev1 (>= 198), /g' \ 306868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) <<< $DPKG_SHLIB_DEPS) 307868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 308868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)COMMON_DEPS="${DPKG_SHLIB_DEPS}, ${ADDITION_DEPS}" 309868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)COMMON_PREDEPS="dpkg (>= 1.14.0)" 310868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 311868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 312868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Make everything happen in the OUTPUTDIR. 313868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)cd "${OUTPUTDIR}" 314868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 315868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)case "$TARGETARCH" in 316868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ia32 ) 317868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) export ARCHITECTURE="i386" 318868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) stage_install_debian 319868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 320868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) x64 ) 321868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) export ARCHITECTURE="amd64" 322868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) stage_install_debian 323868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 324868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) * ) 325868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo 326868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "ERROR: Don't know how to build DEBs for '$TARGETARCH'." 327868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo 328868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) exit 1 329868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 330868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)esac 331868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 332868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)do_package 333