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 111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciset -o pipefail 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if [ "$VERBOSE" ]; then 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) set -x 14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)fi 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)set -u 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Create the Debian changelog file needed by dpkg-gencontrol. This just adds a 18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# placeholder change, indicating it is the result of an automatic build. 19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# TODO(mmoss) Release packages should create something meaningful for a 20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# changelog, but simply grabbing the actual 'svn log' is way too verbose. Do we 21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# have any type of "significant/visible changes" log that we could use for this? 22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)gen_changelog() { 23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) rm -f "${DEB_CHANGELOG}" 24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${SCRIPTDIR}/changelog.template" "${DEB_CHANGELOG}" 25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) debchange -a --nomultimaint -m --changelog "${DEB_CHANGELOG}" \ 26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "Release Notes: ${RELEASENOTES}" 27d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) GZLOG="${STAGEDIR}/usr/share/doc/${PACKAGE}-${CHANNEL}/changelog.gz" 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) mkdir -p "$(dirname "${GZLOG}")" 29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) gzip -9 -c "${DEB_CHANGELOG}" > "${GZLOG}" 30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chmod 644 "${GZLOG}" 31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Create the Debian control file needed by dpkg-deb. 34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)gen_control() { 35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) dpkg-gencontrol -v"${VERSIONFULL}" -c"${DEB_CONTROL}" -l"${DEB_CHANGELOG}" \ 36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) -f"${DEB_FILES}" -p"${PACKAGE}-${CHANNEL}" -P"${STAGEDIR}" \ 37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) -O > "${STAGEDIR}/DEBIAN/control" 38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) rm -f "${DEB_CONTROL}" 39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Setup the installation directory hierachy in the package staging area. 42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)prep_staging_debian() { 43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) prep_staging_common 44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) install -m 755 -d "${STAGEDIR}/DEBIAN" \ 45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/etc/cron.daily" \ 46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/usr/share/menu" \ 47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/usr/share/doc/${PACKAGE}" 48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Put the package contents in the staging area. 51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)stage_install_debian() { 524e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) # Always use a different name for /usr/bin symlink depending on channel. 534e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) # First, to avoid file collisions. Second, to make it possible to 544e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) # use update-alternatives for /usr/bin/google-chrome. 554e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) local USR_BIN_SYMLINK_NAME="${PACKAGE}-${CHANNEL}" 56d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 574e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) if [ "$CHANNEL" != "stable" ]; then 58868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # This would ideally be compiled into the app, but that's a bit too 59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # intrusive of a change for these limited use channels, so we'll just hack 60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # it into the wrapper script. The user can still override since it seems to 61868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # work to specify --user-data-dir multiple times on the command line, with 62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) # the last occurrence winning. 634e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) local SXS_USER_DATA_DIR="\${XDG_CONFIG_HOME:-\${HOME}/.config}/${PACKAGE}-${CHANNEL}" 64d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) local DEFAULT_FLAGS="--user-data-dir=\"${SXS_USER_DATA_DIR}\"" 654e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 664e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) # Avoid file collisions between channels. 67f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) local INSTALLDIR="${INSTALLDIR}-${CHANNEL}" 68f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 69a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) local PACKAGE="${PACKAGE}-${CHANNEL}" 704e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 714e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) # Make it possible to distinguish between menu entries 724e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) # for different channels. 734e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) local MENUNAME="${MENUNAME} (${CHANNEL})" 74868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) fi 75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) prep_staging_debian 76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) stage_install_common 77868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "Staging Debian install files in '${STAGEDIR}'..." 78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) install -m 755 -d "${STAGEDIR}/${INSTALLDIR}/cron" 79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${BUILDDIR}/installer/common/repo.cron" \ 80868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/${INSTALLDIR}/cron/${PACKAGE}" 81868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chmod 755 "${STAGEDIR}/${INSTALLDIR}/cron/${PACKAGE}" 82868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) pushd "${STAGEDIR}/etc/cron.daily/" 83868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ln -snf "${INSTALLDIR}/cron/${PACKAGE}" "${PACKAGE}" 84868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) popd 85868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${BUILDDIR}/installer/debian/debian.menu" \ 86868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/usr/share/menu/${PACKAGE}.menu" 87868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chmod 644 "${STAGEDIR}/usr/share/menu/${PACKAGE}.menu" 88868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${BUILDDIR}/installer/debian/postinst" \ 89868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/DEBIAN/postinst" 90868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chmod 755 "${STAGEDIR}/DEBIAN/postinst" 91868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${BUILDDIR}/installer/debian/prerm" \ 92868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/DEBIAN/prerm" 93868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chmod 755 "${STAGEDIR}/DEBIAN/prerm" 94868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) process_template "${BUILDDIR}/installer/debian/postrm" \ 95868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${STAGEDIR}/DEBIAN/postrm" 96868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) chmod 755 "${STAGEDIR}/DEBIAN/postrm" 97868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 98868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 99868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Actually generate the package file. 100868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)do_package() { 101868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "Packaging ${ARCHITECTURE}..." 102868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) PREDEPENDS="$COMMON_PREDEPS" 103868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) DEPENDS="${COMMON_DEPS}" 104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) REPLACES="" 105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) CONFLICTS="" 106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) PROVIDES="www-browser" 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 "$@" 2205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)BUILDDIR=${BUILDDIR:=$(readlink -f "${SCRIPTDIR}/../../../../out/Release")} 221868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 222868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)source ${BUILDDIR}/installer/common/installer.include 223868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 224868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)get_version_info 225eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen MurdochVERSIONFULL="${VERSION}-${PACKAGE_RELEASE}" 226868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 227868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if [ "$CHROMIUM_BUILD" = "_google_chrome" ]; then 228868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) source "${BUILDDIR}/installer/common/google-chrome.info" 229868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)else 230868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) source "${BUILDDIR}/installer/common/chromium-browser.info" 231868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)fi 232868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)eval $(sed -e "s/^\([^=]\+\)=\(.*\)$/export \1='\2'/" \ 233868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) "${BUILDDIR}/installer/theme/BRANDING") 234868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 235d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)REPOCONFIG="deb http://dl.google.com/linux/chrome/deb/ stable main" 236868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)verify_channel 237868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 238868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Some Debian packaging tools want these set. 239868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)export DEBFULLNAME="${MAINTNAME}" 240868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)export DEBEMAIL="${MAINTMAIL}" 241868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 242868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# We'd like to eliminate more of these deps by relying on the 'lsb' package, but 243868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# that brings in tons of unnecessary stuff, like an mta and rpm. Until that full 244868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# 'lsb' package is installed by default on DEB distros, we'll have to stick with 245868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# the LSB sub-packages, to avoid pulling in all that stuff that's not installed 246868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# by default. 247868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 248868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Need a dummy debian/control file for dpkg-shlibdeps. 249868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)DUMMY_STAGING_DIR="${TMPFILEDIR}/dummy_staging" 250868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)mkdir "$DUMMY_STAGING_DIR" 251868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)cd "$DUMMY_STAGING_DIR" 252868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)mkdir debian 253868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)touch debian/control 254868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 255868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Generate the dependencies, 256868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# TODO(mmoss): This is a workaround for a problem where dpkg-shlibdeps was 257868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# resolving deps using some of our build output shlibs (i.e. 258868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# out/Release/lib.target/libfreetype.so.6), and was then failing with: 259868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# dpkg-shlibdeps: error: no dependency information found for ... 260868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# It's not clear if we ever want to look in LD_LIBRARY_PATH to resolve deps, 261868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# but it seems that we don't currently, so this is the most expediant fix. 262868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)SAVE_LDLP=${LD_LIBRARY_PATH:-} 263868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)unset LD_LIBRARY_PATH 2641320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciDPKG_SHLIB_DEPS=$(dpkg-shlibdeps -O "$BUILDDIR/chrome" | \ 265868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) sed 's/^shlibs:Depends=//') 266868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if [ -n "$SAVE_LDLP" ]; then 267868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) LD_LIBRARY_PATH=$SAVE_LDLP 268868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)fi 269868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 270868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Format it nicely and save it for comparison. 271868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# The grep -v is for a duplicate libc6 dep caused by Lucid glibc silliness. 272868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)echo "$DPKG_SHLIB_DEPS" | sed 's/, /\n/g' | \ 273868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) grep -v '^libc6 (>= 2.3.6-6~)$' > actual 274868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 275868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Compare the expected dependency list to the generate list. 276868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)BAD_DIFF=0 277116680a4aac90f2aa7413d9095a592090648e557Ben Murdochdiff "$SCRIPTDIR/expected_deps_$TARGETARCH" actual || BAD_DIFF=1 278868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if [ $BAD_DIFF -ne 0 ] && [ -z "${IGNORE_DEPS_CHANGES:-}" ]; then 279868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo 280868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "ERROR: Shared library dependencies changed!" 281868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "If this is intentional, please update:" 282116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch echo "chrome/installer/linux/debian/expected_deps_ia32" 283116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch echo "chrome/installer/linux/debian/expected_deps_x64" 284868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo 285868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) exit $BAD_DIFF 286868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)fi 287868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)rm -rf "$DUMMY_STAGING_DIR" 288868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 289868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Additional dependencies not in the dpkg-shlibdeps output. 290bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch# Pull a more recent version of NSS than required by runtime linking, for 291bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch# security and stability updates in NSS. 292cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)ADDITION_DEPS="ca-certificates, libappindicator1, libcurl3, \ 293cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) libnss3 (>= 3.14.3), lsb-base (>=3.2), xdg-utils (>= 1.0.2), wget" 294868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 295868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Fix-up libnspr dependency due to renaming in Ubuntu (the old package still 296868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# exists, but it was moved to "universe" repository, which isn't installed by 297868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# default). 298868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)DPKG_SHLIB_DEPS=$(sed \ 299bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 's/\(libnspr4-0d ([^)]*)\), /\1 | libnspr4 (>= 4.9.5-0ubuntu0), /g' \ 300868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) <<< $DPKG_SHLIB_DEPS) 301868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 302868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Fix-up libudev dependency because Ubuntu 13.04 has libudev1 instead of 303868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# libudev0. 304868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)DPKG_SHLIB_DEPS=$(sed 's/\(libudev0 ([^)]*)\), /\1 | libudev1 (>= 198), /g' \ 305868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) <<< $DPKG_SHLIB_DEPS) 306868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 307868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)COMMON_DEPS="${DPKG_SHLIB_DEPS}, ${ADDITION_DEPS}" 308868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)COMMON_PREDEPS="dpkg (>= 1.14.0)" 309868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 310868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 311868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Make everything happen in the OUTPUTDIR. 312868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)cd "${OUTPUTDIR}" 313868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 314868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)case "$TARGETARCH" in 315868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ia32 ) 316868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) export ARCHITECTURE="i386" 317868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) stage_install_debian 318868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 319868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) x64 ) 320868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) export ARCHITECTURE="amd64" 321868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) stage_install_debian 322868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 323868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) * ) 324868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo 325868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo "ERROR: Don't know how to build DEBs for '$TARGETARCH'." 326868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) echo 327868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) exit 1 328868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ;; 329868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)esac 330868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 331868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)do_package 332