Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/scripts/common.sh

Issue 429006: build: Make enter_chroot.sh fail if run as root. (Closed)
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/scripts/enter_chroot.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Common constants for build scripts 5 # Common constants for build scripts
6 # This must evaluate properly for both /bin/bash and /bin/sh 6 # This must evaluate properly for both /bin/bash and /bin/sh
7 7
8 # All scripts should die on error unless commands are specifically excepted 8 # All scripts should die on error unless commands are specifically excepted
9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. 9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'.
10 # TODO: Re-enable this once shflags is less prone to dying. 10 # TODO: Re-enable this once shflags is less prone to dying.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 # Fail if we're inside the chroot. This guards against creating or entering 164 # Fail if we're inside the chroot. This guards against creating or entering
165 # nested chroots, among other potential problems. 165 # nested chroots, among other potential problems.
166 function assert_outside_chroot { 166 function assert_outside_chroot {
167 if [ $INSIDE_CHROOT -ne 0 ] 167 if [ $INSIDE_CHROOT -ne 0 ]
168 then 168 then
169 echo "This script must be run outside the chroot." 169 echo "This script must be run outside the chroot."
170 exit 1 170 exit 1
171 fi 171 fi
172 } 172 }
173 173
174 function assert_not_root_user {
175 if [ `id -u` = 0 ]; then
176 echo "This script must be run as a non-root user."
177 exit 1
178 fi
179 }
180
174 # Install a package if it's not already installed 181 # Install a package if it's not already installed
175 function install_if_missing { 182 function install_if_missing {
176 # Positional parameters from calling script. :? means "fail if unset". 183 # Positional parameters from calling script. :? means "fail if unset".
177 PKG_NAME=${1:?} 184 PKG_NAME=${1:?}
178 shift 185 shift
179 186
180 if [ -z `which $PKG_NAME` ] 187 if [ -z `which $PKG_NAME` ]
181 then 188 then
182 echo "Can't find $PKG_NAME; attempting to install it." 189 echo "Can't find $PKG_NAME; attempting to install it."
183 sudo apt-get --yes --force-yes install $PKG_NAME 190 sudo apt-get --yes --force-yes install $PKG_NAME
184 fi 191 fi
185 } 192 }
OLDNEW
« no previous file with comments | « no previous file | src/scripts/enter_chroot.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698