blob: 5690e10c2ca79cc3a8e153f9209d3046e78e5bc0 [file] [log] [blame]
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -08001#!/bin/bash
2
3# Copyright (c) 2009 The Chromium OS 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
jglasgowcc71f3a2010-03-12 14:30:21 -05007set -e
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -08008
jglasgowcc71f3a2010-03-12 14:30:21 -05009build=1
10
Chris Sosa605fe882010-04-22 17:01:32 -070011# Package name is the last argument.
12package_name=${!#}
13
14# If no package name is provided skip to emerge options or if -n is given.
15if [[ $package_name == -* ]] || [ x$1 == x-n ]
16then
jglasgowcc71f3a2010-03-12 14:30:21 -050017 build=0
18fi
19
20DEVKIT_URL=$(grep ^CHROMEOS_DEVSERVER /etc/lsb-release | cut -d = -f 2-)
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080021BOARD_NAME=$(grep ^CHROMEOS_RELEASE_BOARD $dir/etc/lsb-release | cut -d = -f 2-)
22
23if [ -z $DEVKIT_URL ]
24then
25 echo "No devkit server specified in /etc/lsb-release"
26 exit 1
27fi
28
29if [ -z $BOARD_NAME ]
30then
31 echo "No board specified in /etc/lsb-release"
32 exit 1
33fi
34
35mount -o remount,rw /
jglasgowcc71f3a2010-03-12 14:30:21 -050036mkdir -p /etc/make.profile
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080037
jglasgowcc71f3a2010-03-12 14:30:21 -050038if [ $build == 1 ] ; then
Chris Sosa605fe882010-04-22 17:01:32 -070039 echo "Building $package_name"
40 ESCAPED_PACKAGE=$(python -c \
41 "import urllib; print urllib.quote('''$package_name''')")
jglasgowcc71f3a2010-03-12 14:30:21 -050042 ESCAPED_BOARD=$(python -c \
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080043 "import urllib; print urllib.quote('''${BOARD_NAME}''')")
44
Chris Sosa605fe882010-04-22 17:01:32 -070045 wget $DEVKIT_URL/build \
46 --post-data="pkg=${ESCAPED_PACKAGE}&board=${ESCAPED_BOARD}"
jglasgowcc71f3a2010-03-12 14:30:21 -050047fi
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080048
Chris Sosa605fe882010-04-22 17:01:32 -070049# Installing emerge into /usr/local installs make.globals needed in
50# /usr/local/etc rather than /etc.
51if [ ! -f /etc/make.globals ]
52then
53 if [ -f /usr/local/etc/make.globals ]
54 then
55 echo "Missing /etc/make.globals, copying over from /usr/local/etc"
56 sudo cp /usr/local/etc/make.globals /etc
57 else
58 echo "Missing /etc/make.globals and none in /usr/local/etc. Aborting."
59 exit 1
60 fi
61fi
62
63echo "Emerging $package_name"
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080064
65export PORTAGE_BINHOST="${DEVKIT_URL}/static/pkgroot/${BOARD_NAME}/packages"
66export PORTAGE_TMPDIR=/tmp
Jie Sun859a8da2010-04-29 15:38:45 -070067# TODO(rtc): Revisit setting ~x86 and ~arm.
jglasgowcc71f3a2010-03-12 14:30:21 -050068# If we add support to build recursive deps this might pull in
69# unstable changes from upstream for packages that you do not want.
Jie Sun859a8da2010-04-29 15:38:45 -070070export ACCEPT_KEYWORDS='~arm arm ~x86 x86'
Ryan Cairnsdd1ceb82010-03-02 21:35:01 -080071
Chris Sosa605fe882010-04-22 17:01:32 -070072FEATURES="-sandbox" emerge --getbinpkg --usepkgonly "$@"