Home | History | Annotate | Download | only in linux
      1 #!/bin/bash -e
      2 
      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.
      6 
      7 SCRIPTDIR="$(dirname "$(readlink -f "$0")")"
      8 PACKAGE="chrome-remote-desktop"
      9 ARCHITECTURE=$(dpkg-architecture | awk -F '=' '/DEB_BUILD_ARCH=/{print $2}')
     10 REPOCONFIG="deb http://dl.google.com/linux/chrome-remote-desktop/deb/ stable main"
     11 
     12 source ${SCRIPTDIR}/../../../../chrome/installer/linux/common/installer.include
     13 
     14 guess_filename() {
     15   VERSION_FULL=$(get_version_full)
     16   echo ${PACKAGE}_${VERSION_FULL}_${ARCHITECTURE}.deb
     17 }
     18 
     19 get_version_full() {
     20   src_root=${src_root:-./../../../..}
     21   remoting_version_path=$src_root/remoting/VERSION
     22   chrome_version_path=$src_root/chrome/VERSION
     23   version_helper=$src_root/build/util/version.py
     24 
     25   # TODO(lambroslambrou): Refactor to share the logic with remoting.gyp.
     26   version_major=$($version_helper -f $chrome_version_path \
     27                   -f $remoting_version_path -t "@MAJOR@")
     28   version_minor=$($version_helper -f $remoting_version_path \
     29                   -t "@REMOTING_PATCH@")
     30   version_build=$($version_helper -f $chrome_version_path \
     31                   -f $remoting_version_path -t "@BUILD@")
     32   version_patch=$($version_helper -f $chrome_version_path \
     33                   -f $remoting_version_path -t "@PATCH@")
     34   version_full="$version_major.$version_minor.$version_build.$version_patch"
     35   echo $version_full
     36 }
     37 
     38 usage() {
     39   echo "usage: $(basename $0) [-hp] [-o path] [-s path]"
     40   echo "-h     this help message"
     41   echo "-p     just print the expected DEB filename that this will build."
     42   echo "-s     path to the top of the src tree."
     43   echo "-o     path to write the DEB file to."
     44 }
     45 
     46 while getopts ":s:o:ph" OPTNAME
     47 do
     48   case $OPTNAME in
     49     s )
     50       src_root="$(readlink -f "$OPTARG")"
     51       ;;
     52     o )
     53       OUTPUT_PATH="$(readlink -f "$OPTARG")"
     54       ;;
     55     p )
     56       PRINTDEBNAME=1
     57       ;;
     58     h )
     59       usage
     60       exit 0
     61       ;;
     62     \: )
     63       echo "'-$OPTARG' needs an argument."
     64       usage
     65       exit 1
     66       ;;
     67     * )
     68       echo "invalid command-line option: $OPTARG"
     69       usage
     70       exit 1
     71       ;;
     72   esac
     73 done
     74 shift $(($OPTIND - 1))
     75 
     76 # This just prints the expected package filename, then exits. It's needed so the
     77 # gyp packaging target can track the output file, to know whether or not it
     78 # needs to be built/rebuilt.
     79 if [[ -n "$PRINTDEBNAME" ]]; then
     80   guess_filename
     81   exit 0
     82 fi
     83 
     84 # TODO: Make this all happen in a temp dir to keep intermediate files out of the
     85 # build tree?
     86 cd "$SCRIPTDIR"
     87 
     88 if [[ -z "$version_full" ]]; then
     89   version_full=$(get_version_full)
     90 fi
     91 
     92 if [[ ! "$version_full" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
     93   echo "Error: Invalid \$version_full value: $version_full" >&2
     94   exit 1
     95 fi
     96 
     97 # Include revision information in changelog when building from a local
     98 # git-based checkout.
     99 merge_head="$(git merge-base HEAD origin/git-svn 2>/dev/null || true)"
    100 if [[ -n "$merge_head" ]]; then
    101   revision="$(git svn find-rev "$merge_head" 2>/dev/null || true)"
    102 else
    103   # Official builders still use svn-based builds.
    104   revision="$(svn info . | awk '/^Revision: /{print $2}')"
    105 fi
    106 if [[ -n "$revision" ]]; then
    107   revision_text="(r$revision)"
    108 fi
    109 
    110 echo "Building version $version_full $revision_text"
    111 
    112 # Create a fresh debian/changelog.
    113 export DEBEMAIL="The Chromium Authors <chromium-dev (at] chromium.org>"
    114 rm -f debian/changelog
    115 debchange --create \
    116   --package "$PACKAGE" \
    117   --newversion "$version_full" \
    118   --force-distribution \
    119   --distribution unstable \
    120   "New Debian package $revision_text"
    121 
    122 
    123 CRON_SCRIPT_DIR="${SCRIPTDIR}/../../../../out/Release/remoting/installer/cron"
    124 mkdir -p ${CRON_SCRIPT_DIR}
    125 process_template \
    126     "${SCRIPTDIR}/../../../../chrome/installer/linux/common/repo.cron" \
    127     "${CRON_SCRIPT_DIR}/chrome-remote-desktop"
    128 
    129 # TODO(mmoss): This is a workaround for a problem where dpkg-shlibdeps was
    130 # resolving deps using some of our build output shlibs (i.e.
    131 # out/Release/lib.target/libfreetype.so.6), and was then failing with:
    132 #   dpkg-shlibdeps: error: no dependency information found for ...
    133 # It's not clear if we ever want to look in LD_LIBRARY_PATH to resolve deps,
    134 # but it seems that we don't currently, so this is the most expediant fix.
    135 SAVE_LDLP=$LD_LIBRARY_PATH
    136 unset LD_LIBRARY_PATH
    137 dpkg-buildpackage -b -us -uc
    138 LD_LIBRARY_PATH=$SAVE_LDLP
    139 
    140 if [[ "$OUTPUT_PATH" ]]; then
    141   mv ../${PACKAGE}_*.deb "$OUTPUT_PATH"/
    142   mv ../${PACKAGE}_*.changes "$OUTPUT_PATH"/
    143 fi
    144