Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Chris Sosa | 136418c | 2010-11-10 16:27:14 -0800 | [diff] [blame^] | 3 | # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
Chris Sosa | 136418c | 2010-11-10 16:27:14 -0800 | [diff] [blame^] | 7 | # Prints the arguments and dies. |
| 8 | print_and_die() { |
| 9 | echo $* |
| 10 | exit 1 |
| 11 | } |
| 12 | |
jglasgow | cc71f3a | 2010-03-12 14:30:21 -0500 | [diff] [blame] | 13 | set -e |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 14 | |
Chris Sosa | 136418c | 2010-11-10 16:27:14 -0800 | [diff] [blame^] | 15 | # Get variables for the devserver from the lsb-release file. |
| 16 | DEVKIT_URL=$(grep ^CHROMEOS_DEVSERVER /etc/lsb-release | cut -d = -f 2-) |
| 17 | BOARD_NAME=$(grep ^CHROMEOS_RELEASE_BOARD /etc/lsb-release | cut -d = -f 2-) |
| 18 | [ -z "${BOARD_NAME}" ] && print_and_die "No board in /etc/lsb-release" |
| 19 | [ -z "${DEVKIT_URL}" ] && print_and_die "No dev server url in /etc/lsb-release" |
| 20 | |
| 21 | # Determine if we should send a build command to the devserver. |
| 22 | BUILD=1 |
| 23 | if [ x$1 == x-n ]; then |
| 24 | BUILD=0 |
David James | e3d542a | 2010-09-24 16:21:19 -0700 | [diff] [blame] | 25 | shift |
| 26 | fi |
jglasgow | cc71f3a | 2010-03-12 14:30:21 -0500 | [diff] [blame] | 27 | |
Chris Sosa | 605fe88 | 2010-04-22 17:01:32 -0700 | [diff] [blame] | 28 | # Package name is the last argument. |
Chris Sosa | 136418c | 2010-11-10 16:27:14 -0800 | [diff] [blame^] | 29 | # TODO(sosa) - Support multiple packages. |
| 30 | PACKAGE_NAME=${!#} |
Chris Sosa | 605fe88 | 2010-04-22 17:01:32 -0700 | [diff] [blame] | 31 | |
David James | e3d542a | 2010-09-24 16:21:19 -0700 | [diff] [blame] | 32 | # If no package name is provided skip to emerge options. |
Chris Sosa | 136418c | 2010-11-10 16:27:14 -0800 | [diff] [blame^] | 33 | [[ ${PACKAGE_NAME} == -* ]] && BUILD=0 |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 34 | |
| 35 | mount -o remount,rw / |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 36 | |
Chris Sosa | 136418c | 2010-11-10 16:27:14 -0800 | [diff] [blame^] | 37 | # Re-mount /tmp as exec. |
Frank Swiderski | dc13081 | 2010-10-08 15:42:28 -0700 | [diff] [blame] | 38 | mount -o remount,exec /tmp |
| 39 | |
Mandeep Singh Baines | ea6b7a5 | 2010-08-17 14:03:57 -0700 | [diff] [blame] | 40 | # Delete the local binary package cache. |
| 41 | sudo rm -rf /usr/portage/packages |
| 42 | |
Chris Sosa | 136418c | 2010-11-10 16:27:14 -0800 | [diff] [blame^] | 43 | if [ ${BUILD} == 1 ]; then |
| 44 | echo "Building ${PACKAGE_NAME}" |
Chris Sosa | 605fe88 | 2010-04-22 17:01:32 -0700 | [diff] [blame] | 45 | ESCAPED_PACKAGE=$(python -c \ |
Chris Sosa | 136418c | 2010-11-10 16:27:14 -0800 | [diff] [blame^] | 46 | "import urllib; print urllib.quote('''${PACKAGE_NAME}''')") |
jglasgow | cc71f3a | 2010-03-12 14:30:21 -0500 | [diff] [blame] | 47 | ESCAPED_BOARD=$(python -c \ |
Chris Sosa | 136418c | 2010-11-10 16:27:14 -0800 | [diff] [blame^] | 48 | "import urllib; print urllib.quote('''${BOARD_NAME}''')") |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 49 | |
Chris Sosa | 605fe88 | 2010-04-22 17:01:32 -0700 | [diff] [blame] | 50 | wget $DEVKIT_URL/build \ |
| 51 | --post-data="pkg=${ESCAPED_PACKAGE}&board=${ESCAPED_BOARD}" |
jglasgow | cc71f3a | 2010-03-12 14:30:21 -0500 | [diff] [blame] | 52 | fi |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 53 | |
Chris Sosa | 136418c | 2010-11-10 16:27:14 -0800 | [diff] [blame^] | 54 | echo "Emerging ${PACKAGE_NAME}" |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 55 | |
| 56 | export PORTAGE_BINHOST="${DEVKIT_URL}/static/pkgroot/${BOARD_NAME}/packages" |
| 57 | export PORTAGE_TMPDIR=/tmp |
Chris Sosa | 87510aa | 2010-06-28 16:10:00 -0700 | [diff] [blame] | 58 | |
| 59 | # Accept keywords only for stable ebuilds by default. |
Chris Sosa | 136418c | 2010-11-10 16:27:14 -0800 | [diff] [blame^] | 60 | [ -z "${ACCEPT_KEYWORDS}" ] && ACCEPT_KEYWORDS='arm x86 ~arm ~x86' |
Chris Sosa | 87510aa | 2010-06-28 16:10:00 -0700 | [diff] [blame] | 61 | export ACCEPT_KEYWORDS |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 62 | |
Mandeep Singh Baines | 44714d3 | 2010-08-26 16:08:54 -0700 | [diff] [blame] | 63 | # Disable CONFIG_PROTECT. |
| 64 | export CONFIG_PROTECT="-*" |
| 65 | |
David James | e3d542a | 2010-09-24 16:21:19 -0700 | [diff] [blame] | 66 | FEATURES="-sandbox" emerge --getbinpkgonly --usepkgonly "$@" |
Frank Swiderski | dc13081 | 2010-10-08 15:42:28 -0700 | [diff] [blame] | 67 | |
Chris Sosa | 136418c | 2010-11-10 16:27:14 -0800 | [diff] [blame^] | 68 | # Re-mount /tmp as noexec. |
Frank Swiderski | dc13081 | 2010-10-08 15:42:28 -0700 | [diff] [blame] | 69 | mount -o remount,noexec /tmp |