Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
David James | e3d542a | 2010-09-24 16:21:19 -0700 | [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 | |
jglasgow | cc71f3a | 2010-03-12 14:30:21 -0500 | [diff] [blame] | 7 | set -e |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 8 | |
jglasgow | cc71f3a | 2010-03-12 14:30:21 -0500 | [diff] [blame] | 9 | build=1 |
David James | e3d542a | 2010-09-24 16:21:19 -0700 | [diff] [blame] | 10 | if [ x$1 == x-n ] |
| 11 | then |
| 12 | # eat the gmerge -n option to avoid passing it to emerge |
| 13 | build=0 |
| 14 | shift |
| 15 | fi |
jglasgow | cc71f3a | 2010-03-12 14:30:21 -0500 | [diff] [blame] | 16 | |
Chris Sosa | 605fe88 | 2010-04-22 17:01:32 -0700 | [diff] [blame] | 17 | # Package name is the last argument. |
| 18 | package_name=${!#} |
| 19 | |
David James | e3d542a | 2010-09-24 16:21:19 -0700 | [diff] [blame] | 20 | # If no package name is provided skip to emerge options. |
| 21 | if [[ $package_name == -* ]] |
Chris Sosa | 605fe88 | 2010-04-22 17:01:32 -0700 | [diff] [blame] | 22 | then |
jglasgow | cc71f3a | 2010-03-12 14:30:21 -0500 | [diff] [blame] | 23 | build=0 |
| 24 | fi |
| 25 | |
| 26 | DEVKIT_URL=$(grep ^CHROMEOS_DEVSERVER /etc/lsb-release | cut -d = -f 2-) |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 27 | BOARD_NAME=$(grep ^CHROMEOS_RELEASE_BOARD $dir/etc/lsb-release | cut -d = -f 2-) |
| 28 | |
| 29 | if [ -z $DEVKIT_URL ] |
| 30 | then |
| 31 | echo "No devkit server specified in /etc/lsb-release" |
| 32 | exit 1 |
| 33 | fi |
| 34 | |
| 35 | if [ -z $BOARD_NAME ] |
| 36 | then |
| 37 | echo "No board specified in /etc/lsb-release" |
| 38 | exit 1 |
| 39 | fi |
| 40 | |
| 41 | mount -o remount,rw / |
jglasgow | cc71f3a | 2010-03-12 14:30:21 -0500 | [diff] [blame] | 42 | mkdir -p /etc/make.profile |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 43 | |
Frank Swiderski | dc13081 | 2010-10-08 15:42:28 -0700 | [diff] [blame^] | 44 | # Re-mount /tmp as exec |
| 45 | mount -o remount,exec /tmp |
| 46 | |
Mandeep Singh Baines | ea6b7a5 | 2010-08-17 14:03:57 -0700 | [diff] [blame] | 47 | # Delete the local binary package cache. |
| 48 | sudo rm -rf /usr/portage/packages |
| 49 | |
jglasgow | cc71f3a | 2010-03-12 14:30:21 -0500 | [diff] [blame] | 50 | if [ $build == 1 ] ; then |
Chris Sosa | 605fe88 | 2010-04-22 17:01:32 -0700 | [diff] [blame] | 51 | echo "Building $package_name" |
| 52 | ESCAPED_PACKAGE=$(python -c \ |
| 53 | "import urllib; print urllib.quote('''$package_name''')") |
jglasgow | cc71f3a | 2010-03-12 14:30:21 -0500 | [diff] [blame] | 54 | ESCAPED_BOARD=$(python -c \ |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 55 | "import urllib; print urllib.quote('''${BOARD_NAME}''')") |
| 56 | |
Chris Sosa | 605fe88 | 2010-04-22 17:01:32 -0700 | [diff] [blame] | 57 | wget $DEVKIT_URL/build \ |
| 58 | --post-data="pkg=${ESCAPED_PACKAGE}&board=${ESCAPED_BOARD}" |
jglasgow | cc71f3a | 2010-03-12 14:30:21 -0500 | [diff] [blame] | 59 | fi |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 60 | |
Chris Sosa | 605fe88 | 2010-04-22 17:01:32 -0700 | [diff] [blame] | 61 | # Installing emerge into /usr/local installs make.globals needed in |
| 62 | # /usr/local/etc rather than /etc. |
| 63 | if [ ! -f /etc/make.globals ] |
| 64 | then |
| 65 | if [ -f /usr/local/etc/make.globals ] |
| 66 | then |
| 67 | echo "Missing /etc/make.globals, copying over from /usr/local/etc" |
| 68 | sudo cp /usr/local/etc/make.globals /etc |
| 69 | else |
| 70 | echo "Missing /etc/make.globals and none in /usr/local/etc. Aborting." |
| 71 | exit 1 |
| 72 | fi |
| 73 | fi |
| 74 | |
| 75 | echo "Emerging $package_name" |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 76 | |
| 77 | export PORTAGE_BINHOST="${DEVKIT_URL}/static/pkgroot/${BOARD_NAME}/packages" |
| 78 | export PORTAGE_TMPDIR=/tmp |
Chris Sosa | 87510aa | 2010-06-28 16:10:00 -0700 | [diff] [blame] | 79 | |
| 80 | # Accept keywords only for stable ebuilds by default. |
| 81 | if [ -z "$ACCEPT_KEYWORDS" ] ; then |
Mandeep Singh Baines | ea6b7a5 | 2010-08-17 14:03:57 -0700 | [diff] [blame] | 82 | ACCEPT_KEYWORDS='arm x86 ~arm ~x86' |
Chris Sosa | 87510aa | 2010-06-28 16:10:00 -0700 | [diff] [blame] | 83 | fi |
| 84 | export ACCEPT_KEYWORDS |
Ryan Cairns | dd1ceb8 | 2010-03-02 21:35:01 -0800 | [diff] [blame] | 85 | |
Mandeep Singh Baines | 44714d3 | 2010-08-26 16:08:54 -0700 | [diff] [blame] | 86 | # Disable CONFIG_PROTECT. |
| 87 | export CONFIG_PROTECT="-*" |
| 88 | |
David James | e3d542a | 2010-09-24 16:21:19 -0700 | [diff] [blame] | 89 | FEATURES="-sandbox" emerge --getbinpkgonly --usepkgonly "$@" |
Frank Swiderski | dc13081 | 2010-10-08 15:42:28 -0700 | [diff] [blame^] | 90 | |
| 91 | # Re-mount /tmp as noexec |
| 92 | mount -o remount,noexec /tmp |