blob: 0db325dd0c673299f66dea80cc66f0d737f3d231 [file] [log] [blame]
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -08001#!/bin/bash
2
Chris Sosa136418c2010-11-10 16:27:14 -08003# Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved.
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -08004# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
Chris Sosa136418c2010-11-10 16:27:14 -08007# Prints the arguments and dies.
8print_and_die() {
9 echo $*
10 exit 1
11}
12
jglasgowcc71f3a2010-03-12 14:30:21 -050013set -e
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080014
Chris Sosa136418c2010-11-10 16:27:14 -080015# Get variables for the devserver from the lsb-release file.
16DEVKIT_URL=$(grep ^CHROMEOS_DEVSERVER /etc/lsb-release | cut -d = -f 2-)
17BOARD_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.
22BUILD=1
23if [ x$1 == x-n ]; then
24 BUILD=0
David Jamese3d542a2010-09-24 16:21:19 -070025 shift
26fi
jglasgowcc71f3a2010-03-12 14:30:21 -050027
Chris Sosa605fe882010-04-22 17:01:32 -070028# Package name is the last argument.
Chris Sosa136418c2010-11-10 16:27:14 -080029# TODO(sosa) - Support multiple packages.
30PACKAGE_NAME=${!#}
Chris Sosa605fe882010-04-22 17:01:32 -070031
David Jamese3d542a2010-09-24 16:21:19 -070032# If no package name is provided skip to emerge options.
Chris Sosa136418c2010-11-10 16:27:14 -080033[[ ${PACKAGE_NAME} == -* ]] && BUILD=0
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080034
35mount -o remount,rw /
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080036
Chris Sosa136418c2010-11-10 16:27:14 -080037# Re-mount /tmp as exec.
Frank Swiderskidc130812010-10-08 15:42:28 -070038mount -o remount,exec /tmp
39
Mandeep Singh Bainesea6b7a52010-08-17 14:03:57 -070040# Delete the local binary package cache.
41sudo rm -rf /usr/portage/packages
42
Chris Sosa136418c2010-11-10 16:27:14 -080043if [ ${BUILD} == 1 ]; then
44 echo "Building ${PACKAGE_NAME}"
Chris Sosa605fe882010-04-22 17:01:32 -070045 ESCAPED_PACKAGE=$(python -c \
Chris Sosa136418c2010-11-10 16:27:14 -080046 "import urllib; print urllib.quote('''${PACKAGE_NAME}''')")
jglasgowcc71f3a2010-03-12 14:30:21 -050047 ESCAPED_BOARD=$(python -c \
Chris Sosa136418c2010-11-10 16:27:14 -080048 "import urllib; print urllib.quote('''${BOARD_NAME}''')")
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080049
Chris Sosa605fe882010-04-22 17:01:32 -070050 wget $DEVKIT_URL/build \
51 --post-data="pkg=${ESCAPED_PACKAGE}&board=${ESCAPED_BOARD}"
jglasgowcc71f3a2010-03-12 14:30:21 -050052fi
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080053
Chris Sosa136418c2010-11-10 16:27:14 -080054echo "Emerging ${PACKAGE_NAME}"
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080055
56export PORTAGE_BINHOST="${DEVKIT_URL}/static/pkgroot/${BOARD_NAME}/packages"
57export PORTAGE_TMPDIR=/tmp
Chris Sosa87510aa2010-06-28 16:10:00 -070058
59# Accept keywords only for stable ebuilds by default.
Chris Sosa136418c2010-11-10 16:27:14 -080060[ -z "${ACCEPT_KEYWORDS}" ] && ACCEPT_KEYWORDS='arm x86 ~arm ~x86'
Chris Sosa87510aa2010-06-28 16:10:00 -070061export ACCEPT_KEYWORDS
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080062
Mandeep Singh Baines44714d32010-08-26 16:08:54 -070063# Disable CONFIG_PROTECT.
64export CONFIG_PROTECT="-*"
65
David Jamese3d542a2010-09-24 16:21:19 -070066FEATURES="-sandbox" emerge --getbinpkgonly --usepkgonly "$@"
Frank Swiderskidc130812010-10-08 15:42:28 -070067
Chris Sosa136418c2010-11-10 16:27:14 -080068# Re-mount /tmp as noexec.
Frank Swiderskidc130812010-10-08 15:42:28 -070069mount -o remount,noexec /tmp