fix(update_chroot): Replace old chroot version scheme.

The old chroot version system we inherited from Chromium OS always
assumes that a newly unpacked tarball is the latest and greatest but
since we version the SDK in the same way as target builds we can use
that version for these sorts of upgrade scripts and not make assumptions
about how late and great the starting tarball was.

The first upgrade script simply aborts to force the user to recreate
their chroot when moving from python 2.6 to 2.7.
This commit is contained in:
Michael Marineau 2013-08-06 13:54:18 -04:00
parent 19caadc8c9
commit 74c4f21b68
54 changed files with 45 additions and 1210 deletions

View File

@ -1,16 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Make sure existing chroot's have default locales enabled
# to match the new make_chroot behavior
# http://crosbug.com/20378
if ! grep -q -v -e '^#' -e '^$' /etc/locale.gen ; then
sudo_append /etc/locale.gen <<EOF
en_US ISO-8859-1
en_US.UTF-8 UTF-8
EOF
fi
info "Chroot upgraded to version 10: Set default locale sets"
exit 0

View File

@ -1,8 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Delete /does/not to fix metrics unit test, which depends on this
# directory not existing.
sudo rm -rf /does/not
exit 0

View File

@ -1,24 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
info "Cleaning old configuration files, crosbug.com/13987"
# The filesystem may be polluted by a lot of pending config file updates
# at this point. By changing CONFIG_PROTECT, several of these have become
# permanently stale, as neither tool considers them updates anymore.
# First discard all updates in config files that are still protected, as
# governed by the current CONFIG_PROTECT.
# Autodiscard is option "-9" followed by the "YES" confirmation.
info "Discarding bad updates"
printf '%s\nYES\n' -9 | sudo etc-update
# Overload CONFIG_PROTECT and automerge all possible updates in all sensible
# locations, that is all updates that should've been merged immediately in
# the first place.
# Automerge is the "-5" option.
info "Automerging good updates"
echo "-5" | sudo CONFIG_PROTECT="/etc /usr/share" etc-update
exit 0

View File

@ -1,10 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
for toolchain in i686-pc-linux-gnu x86_64-cros-linux-gnu; do
if label=$(binutils-config -c $toolchain); then
sudo binutils-config ${label%-gold}-gold
fi
done
exit 0

View File

@ -1,19 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
cfgd="/usr/local/portage/chromiumos/chromeos/config"
# Make sure the board's /etc/portage/env is a symlink and not a dir.
for board_root in /build/*; do
envd="${board_root}/etc/portage/env"
if [ -d "${envd}" ]; then
sudo rm -rf "${envd}"
sudo ln -s "${cfgd}/env" "${envd}"
fi
done
# Make sure we have bashrc on the host.
sudo ln -sf "${cfgd}/bashrc-host" /etc/portage/bashrc
exit 0

View File

@ -1,19 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Make sure the board's /etc/portage/env is no longer a symlink.
# This basically reverts the old 14_board_portage_env.
for board_root in /build/*; do
envd="${board_root}/etc/portage/env"
if [ -L "${envd}" ]; then
sudo rm -f "${envd}"
fi
done
# Then undo the host bashrc.
if [ -L /etc/portage/bashrc ]; then
sudo rm -f /etc/portage/bashrc
fi
exit 0

View File

@ -1,9 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# We used to install an /etc/localtime symlink for the cros sdk when
# we really only wanted it for the target boards.
sudo rm -f /etc/._cfg????_localtime
exit 0

View File

@ -1,7 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This upgrade is a dummy since there was a mid air collision; moved to 19_*
exit 0

View File

@ -1,6 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# No-op, this change is being reverted
exit 0

View File

@ -1,32 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Older chroots used to tweak /etc/sudoers directly, but we split that
# off into files in /etc/sudoers.d/. One of those is handled by the
# make_chroot helper, so make sure we upgrade old chroots which missed
# the migration to /etc/sudoers.d/90_cros.
frag="/etc/sudoers.d/90_cros"
if [ ! -e ${frag} ]; then
tmp=$(mktemp 2>/dev/null || echo /tmp/17_upgrade_hook.$$)
cat <<EOF > "${tmp}" || exit 1
Defaults env_keep += CROS_WORKON_SRCROOT
Defaults env_keep += COREOS_OFFICIAL
Defaults env_keep += PORTAGE_USERNAME
Defaults env_keep += http_proxy
Defaults env_keep += ftp_proxy
Defaults env_keep += all_proxy
%adm ALL=(ALL) ALL
root ALL=(ALL) ALL
$USER ALL=NOPASSWD: ALL
EOF
cmds=(
"mkdir -p -m 0750 '${frag%/*}'"
"chmod 0440 '${tmp}'"
"chown root:root '${tmp}'"
"mv '${tmp}' '${frag}'"
)
sudo_multi "${cmds[@]}"
fi
exit 0

View File

@ -1,6 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
info "You have just been upgraded to chroot version 1! Congratulations!"
exit 0

View File

@ -1,9 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Punt the old board's /etc/portage/bashrc as we don't use it anymore,
# and it conflicts with newer bashrc stacking.
sudo rm -f /build/*/etc/portage/bashrc
exit 0

View File

@ -1,8 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
CLEAN_DELAY=0 sudo emerge --unmerge =sys-boot/grub-1.99-r2
exit 0

View File

@ -1,24 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# We used to place bashrc niceties into the user's .bashrc. Use
# profile.d instead.
sudo_clobber /etc/profile.d/chromiumos-niceties.sh << EOF
# Niceties for interactive logins. (cr) denotes this is a chroot, the
# __git_branch_ps1 prints current git branch in ./ . The $r behavior is to
# make sure we don't reset the previous $? value which later formats in
# $PS1 might rely on.
PS1='\$(r=\$?; __git_branch_ps1 "(%s) "; exit \$r)'"\${PS1}"
PS1="(cr) \${PS1}"
EOF
# Also, get rid of the leftover stuff in the user's .bashrc.
# These are the two originally added lines:
STR1='export PS1='"'"'$(r=$?; __git_branch_ps1 "(%s) "; exit $r)'"'"'"${PS1}"'
STR2='export PS1="(cr) ${PS1}"'
sed -e "/${STR1}/d" -e "/${STR2}/d" -i ~/.bashrc
exit 0

View File

@ -1,13 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# The dev-util -> dev-vcs migration isn't as smooth as we'd like due to
# the profiles/updates/ files only applying to packages installed from
# that overlay. Force unmerge the old packages if they were not auto
# migrated for the user. See https://gerrit.chromium.org/gerrit/13148
# for some in-depth details.
sudo CLEAN_DELAY=0 emerge -C dev-util/{git,subversion} net-misc/neon
exit 0

View File

@ -1,33 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Previously distfiles were stored entirely in the chroot, forcing us
# to download it everytime. This content is now stored externally, exposed
# to the chroot via mount binds.
#
# What we're doing here is moving any existing content from the old locations,
# into the new locations- which will already have a mount bind in place.
# If it *doesn't*, meaning parallel cros_sdk usage, we just wipe the content
# (user can redownload it after all).
#
# Once that's done, upgrade the chroot directory structure installing
# syms pointing back to the new location.
upgrade_path() {
local src="/var/lib/portage/$1"
local dest="/var/cache/distfiles/$2"
if [ -L "$src" ]; then
# Already upgraded- skip this one.
return 0
fi
# Suppress failures. User just has to download in that case.
sudo find "$src"/ -maxdepth 1 -mindepth 1 -exec sudo mv -t "$dest/" {} + || :
sudo rm -rf "$src"
sudo ln -s ../../cache/distfiles/"$2" "$src"
}
upgrade_path distfiles host
upgrade_path distfiles-target target
exit 0

View File

@ -1,37 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# As of update 24, we preserve distfiles across chroot rebuilds via storing
# the content outside of the chroot, and binding it in.
#
# chromeos-chrome stores its build output in distdir however, which we
# don't currently want preserved across chroot builds, thus this script
# pulls the content out to the new location within the chroot.
upgrade_path() {
local src="/var/cache/distfiles/target/$2"
local dest="/var/cache/chromeos-chrome/$2"
info "[$1/4] Checking $src vs $dest"
if [ -d "$src" ]; then
if [ -d "$dest" ]; then
# User has already built it- thus wipe the src and use what's in
# the chrome specific cache.
info "[$1/4] Cleaning $src; this could take a while"
sudo rm -rf "$src"
else
sudo mv "$src" "$dest"
fi
fi
}
sudo mkdir -p 0775 /var/cache/chromeos-chrome/
sudo chown "$USER:portage" /var/cache/chromeos-chrome/
upgrade_path 1 chrome-src
upgrade_path 2 chrome-src-internal
upgrade_path 3 chrome-src-custom
upgrade_path 4 chrome-src-custom-internal
exit 0

View File

@ -1,28 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# We've been dropping packages of late from the target, so make sure the
# old stuff gets cleaned out.
pkgs=(
dev-libs/shflags
mail-mta/ssmtp
net-libs/gssdp
net-libs/gupnp
net-mail/mailbase
sys-fs/sysfsutils
sys-process/cronbase
sys-process/vixie-cron
)
for board_root in /build/* ; do
board=${board_root##*/}
emerge_board=$(type -P emerge-${board} 2>/dev/null || true)
if [[ -x "${emerge_board}" ]]; then
CLEAN_DELAY=0 ${emerge_board} -q --unmerge ${pkgs[@]} || true
eclean-${board} -d packages || true
fi
done
exit 0

View File

@ -1,19 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This is meant to happen immediately after we update these boards
# from 32bit to 64bit. It moves the existing build root out of the
# way and re-creates the build root. The user must remove the copy
# of the old build root manually if it is not needed.
board="lumpy"
build="/build/${board}"
if [[ -d ${build} ]] ; then
info "Moving 32bit ${board} to ${board}.32bit"
info "If you don't need it, please run "
info "sudo rm -rf ${build}.32bit"
sudo mv ${build}{,.32bit}
info "Running setup_board --board=${board}"
~/trunk/src/scripts/setup_board --board=${board} --skip_chroot_upgrade
fi

View File

@ -1,14 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# There was a bug in the setup_board script where it added the cross-compilers
# to the @world set. Make sure we don't do that since letting emerge do the
# upgrade rather than crossdev (currently) doesn't work.
world="/var/lib/portage/world"
if [[ -e ${world} ]] ; then
sudo sed -i '/^cross-/d' "${world}"
fi
exit 0

View File

@ -1,19 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This is meant to happen immediately after we update these boards
# from 32bit to 64bit. It moves the existing build root out of the
# way and re-creates the build root. The user must remove the copy
# of the old build root manually if it is not needed.
board="stumpy"
build="/build/${board}"
if [[ -d ${build} ]] ; then
info "Moving 32bit ${board} to ${board}.32bit"
info "If you don't need it, please run "
info "sudo rm -rf ${build}.32bit"
sudo mv ${build}{,.32bit}
info "Running setup_board --board=${board}"
~/trunk/src/scripts/setup_board --board=${board} --skip_chroot_upgrade
fi

View File

@ -1,15 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
target="/etc/env.d/99chromiumos"
sudo_clobber "${target}" <<EOF
PATH=/home/$USER/trunk/chromite/bin:/home/$USER/depot_tools
CROS_WORKON_SRCROOT=/home/$USER/trunk
PORTAGE_USERNAME=$USER
EOF
sudo env-update
info "Chroot upgraded to version 2: PATH is updated globally"
exit 0

View File

@ -1,28 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Newer crossdev will create a metadata layout for us, but the older one used
# a symlink for the dir, and crossdev won't auto-migrate for us. Delete the
# symlink and automatically seed a file that crossdev will update itself. We
# can't just delete the symlink and wait for setup_board to run as that will
# break the metadata lookup needed by the cross-compilers in the meantime.
dir="/usr/local/portage/crossdev"
if [[ ! -d ${dir} || ! -L ${dir}/metadata ]] ; then
# Nothing for us to do. Great! (?)
exit 0
fi
set -e
cd "${dir}"
sudo rm -f metadata
sudo mkdir metadata
sudo_clobber metadata/layout.conf <<-EOF
# Autogenerated and managed by crossdev
# Delete the above line if you want to manage this file yourself
masters = chromiumos portage-stable
EOF
exit 0

View File

@ -1,20 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This is meant to happen immediately after we update these boards
# from 32bit to 64bit. It moves the existing build root out of the
# way and re-creates the build root. The user must remove the copy
# of the old build root manually if it is not needed.
for board in x86-mario x86-alex x86-zgb ; do
build="/build/${board}"
if [[ -d ${build} ]] ; then
info "Moving 32bit ${board} to ${board}.32bit"
info "If you don't need it, please run "
info "sudo rm -rf ${build}.32bit"
sudo mv ${build}{,.32bit}
info "Running setup_board --board=${board}"
~/trunk/src/scripts/setup_board --board=${board} --skip_chroot_upgrade
fi
done

View File

@ -1,28 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# We've been migrating packages of late, so make sure the old stuff gets
# cleaned out.
pkgs=(
dev-util/cvs
dev-util/cvsps
dev-util/git
dev-util/subversion
'<=media-libs/jpeg-6b-r9:62'
'<media-libs/libpng-1.2.45-r2:1.2'
net-misc/neon
sys-apps/parted
)
for board_root in /build/* ; do
board=${board_root##*/}
emerge_board=$(type -P emerge-${board} 2>/dev/null || true)
if [[ -x "${emerge_board}" ]]; then
CLEAN_DELAY=0 ${emerge_board} -q --unmerge "${pkgs[@]}" || true
eclean-${board} -d packages || true
fi
done
exit 0

View File

@ -1,12 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# We intended to use some extra python modules for autotest in the chroot,
# but decided against it. They're removed from hard-host-depends in
# https://gerrit.chromium.org/gerrit/21816
pkgs=( dev-python/requests dev-python/chardet dev-python/certifi )
sudo CLEAN_DELAY=0 emerge -q --unmerge "${pkgs[@]}"
exit 0

View File

@ -1,26 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# For people who have arm builds with softfp, automatically move them
# away so we can deploy them with hardfp.
# See also 29_64bit_convert_stumpy.
# In case the dev has no arm boards.
shopt -s nullglob
for ldso in /build/*/lib/ld-linux.so.3; do
# See if this is an ARM softfp ldso.
if ! readelf -A "${ldso}" | grep -q Tag_ABI_VFP_args; then
build=${ldso%/lib/*}
board=${build##*/}
info "Migrating ${board} to ${board}.softfp"
info "If you don't need it, please run "
info "sudo rm -rf ${build}.softfp"
sudo mv ${build}{,.softfp}
info "Running setup_board --board=${board}"
~/trunk/src/scripts/setup_board \
--board=${board} \
--skip_chroot_upgrade
fi
done

View File

@ -1,20 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This is meant to happen immediately after we update these boards
# from 64bit to 32bit. It moves the existing build root out of the
# way and re-creates the build root. The user must remove the copy
# of the old build root manually if it is not needed.
for board in x86-mario x86-alex x86-zgb x86-alex_he x86-zgb_he kiev; do
build="/build/${board}"
if [[ -d ${build} ]] ; then
info "Moving 64bit ${board} to ${board}.64bit"
info "If you don't need it, please run "
info "sudo rm -rf ${build}.64bit"
sudo mv ${build}{,.64bit}
info "Running setup_board --board=${board}"
~/trunk/src/scripts/setup_board --board=${board} --skip_chroot_upgrade
fi
done

View File

@ -1,9 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Rebuild openssl to pick up the 0.9.8 -> 1.0.1 ABI change. Fetch everything
# first, since this upgrade will break curl.
sudo ~/trunk/chromite/bin/parallel_emerge -uDNvgf --rebuilt-binaries world
sudo ~/trunk/chromite/bin/parallel_emerge -uDNvg --rebuilt-binaries world
sudo update-ca-certificates

View File

@ -1,21 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This fixes a problem, where some chroots have old cross linux-headers
# installed with invalid slot settings, conflicting with the proper new
# ones.
TARGETS="arm-none-eabi
armv7a-cros-linux-gnueabi
i686-pc-linux-gnu
x86_64-cros-linux-gnu
x86_64-pc-linux-gnu"
VERSION=3.4
ATOMS=(
$(printf "<cross-%s/linux-headers-${VERSION} " $TARGETS)
)
sudo emerge --unmerge "${ATOMS[@]}"

View File

@ -1,7 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# The previous one had a bug, so we moved it to 39 and fixed the bug
# (missing -H flag to find).
exit 0

View File

@ -1,17 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Migrate to userpriv for building things. We need to clean out old
# dirs that might have files owned by root:root.
eval $(portageq envvar -v PORTAGE_{TMPDIR,USERNAME,GRPNAME} DISTDIR PKGDIR)
: ${PORTAGE_TMPDIR:=/var/tmp/portage}
: ${PORTAGE_USERNAME:=${USER}}
: ${PORTAGE_GRPNAME:=portage}
: ${DISTDIR:=/var/cache/distfiles/host}
: ${PKGDIR:=/var/lib/portage/pkgs}
exec sudo find -H "${PORTAGE_TMPDIR}" "${DISTDIR}" "${PKGDIR}" \
'(' -uid 0 -o -gid 0 ')' \
-exec chown -h "${PORTAGE_USERNAME}:${PORTAGE_GRPNAME}" {} +

View File

@ -1,53 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
update_pkgconfig_wrapper() {
local board="$1"
local board_root="/build/${board}"
local target="/usr/local/bin/pkg-config-${board}"
sudo_clobber "${target}" <<EOF
#!/bin/bash
PKG_CONFIG_LIBDIR="${board_root}/usr/lib/pkgconfig"
PKG_CONFIG_LIBDIR="\${PKG_CONFIG_LIBDIR}:${board_root}/usr/share/pkgconfig"
export PKG_CONFIG_LIBDIR
export PKG_CONFIG_SYSROOT_DIR="${board_root}"
exec pkg-config "\$@"
EOF
sudo chmod a+rx ${target}
sudo chown root:root ${target}
info "Created wrapper pkg-config for ${board}"
local board_setup="${board_root}/etc/make.conf.board_setup"
if ! grep -q PKG_CONFIG "${board_setup}"; then
info "Added PKG_CONFIG to ${board_setup}"
sudo_append "${board_setup}" <<EOF
PKG_CONFIG="pkg-config-${board}"
EOF
fi
}
info "Deleting masked *.la files for in /usr/lib64"
sudo find /usr/lib64 -maxdepth 1 \
'(' -name 'lib*.la' -not -name 'libltdl.la' ')' -delete
for board_root in /build/*; do
if [ -d "${board_root}" ]; then
board=$(basename "${board_root}")
update_pkgconfig_wrapper "${board}"
info "Deleting masked *.la files for ${board}"
sudo find "${board_root}/usr/lib" -maxdepth 1 \
'(' -name 'lib*.la' -not -name 'libltdl.la' ')' -delete
info "Removing hard-coded paths to ${board_root} in *.pc files"
sudo find "${board_root}/usr" -type f -name '*.pc' | xargs sudo \
sed -i -e "s|${board_root}/|/|g"
fi
done
info "Chroot upgraded to version 3: libtool upgrade"
exit 0

View File

@ -1,38 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Move from chromeos-base/kernel-headers to sys-kernel/linux-headers.
opkg="chromeos-base/kernel-headers"
npkg="sys-kernel/linux-headers"
export CLEAN_DELAY=0
update() {
local root=$1 board=$2 emerge
if [[ -z ${board} ]]; then
board="root"
emerge="sudo -E emerge"
else
emerge="emerge-${board}"
fi
if portageq has_version ${root} ${opkg}; then
info "Migrating ${board} from ${opkg} to ${npkg}"
${emerge} -Cq ${opkg}
fi
if ! portageq has_version ${root} ${npkg}; then
${emerge} -1gq ${npkg}
fi
}
update / &
for board_root in /build/*; do
board=${board_root##*/}
update ${board_root} ${board} &
done
wait

View File

@ -1,35 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# For people who have arm builds with the old hardfp ldso name,
# automatically move them away so we can deploy them with the
# right path. This works in tandem with 34_arm_softfp_to_hardfp
# to make sure we don't rebuild multiple times.
# In case the dev has no arm boards.
shopt -s nullglob
# Old name: ld-linux.so.3
# New name: ld-linux-armhf.so.3
for ldso in /build/*/lib/ld-linux.so.3; do
# See if this is an ARM ldso (sanity check).
if LC_ALL=C readelf -h "${ldso}" | awk \
'$1 == "Machine:" && $2 == "ARM" { found=1 } END { exit !found }'; then
build=${ldso%/lib/*}
board=${build##*/}
if [[ ${board} == *.* ]]; then
# For older dirs that have been migrated, skip them.
continue
fi
info "Migrating ${board} to ${board}.old.ldso"
info "If you don't need it, please run "
info "sudo rm -rf ${build}.old.ldso"
if [[ -e ${build}.old.ldso ]]; then
sudo rm -rf ${build}.old.ldso
fi
sudo mv ${build}{,.old.ldso}
info "Running setup_board --board=${board}"
~/trunk/src/scripts/setup_board --board=${board} --skip_chroot_upgrade
fi
done

View File

@ -1,14 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Like 41_arm_new_hardfp_ldso, but specifically for daisy. The daisy
# PFQ did not regenerate its binpkgs properly, so some people still have
# old ldso's in /build/ as they pulled down stale binpkgs.
if scanelf -qRiy /build/daisy/ 2>/dev/null | grep -q '^/lib/ld-linux.so.3'; then
info "You have a stale daisy build; punting!"
sudo rm -rf /build/daisy/
info "Running setup_board --board=daisy"
~/trunk/src/scripts/setup_board --board=daisy --skip_chroot_upgrade
fi

View File

@ -1,20 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This is meant to happen immediately after we update these boards
# from 32bit to 64bit. It moves the existing build root out of the
# way and re-creates the build root. The user must remove the copy
# of the old build root manually if it is not needed.
for board in kiev; do
build="/build/${board}"
if [[ -d ${build} ]] ; then
info "Moving 32bit ${board} to ${board}.32bit"
info "If you don't need it, please run "
info "sudo rm -rf ${build}.32bit"
sudo mv ${build}{,.32bit}
info "Running setup_board --board=${board}"
~/trunk/src/scripts/setup_board --board=${board} --skip_chroot_upgrade
fi
done

View File

@ -1,36 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Move users of CHROME_ORIGIN=GERRIT_SOURCE to the new gerrit-source.xml
# manifest, as well as setting up the chromium/src repository properly for
# submodules. crosbug.com/32963.
# We only want to run this hook once. Since this also gets called from
# enter_chroot, look for the marker.
MARKER="/tmp/44_fix_gerrit_chrome"
if [ -e "${MARKER}" ]; then
exit 0
fi
chrome_workon="=chromeos-base/chromeos-chrome-9999"
cros_workon_dir="${HOME}/trunk/.config/cros_workon/*"
manifest="${HOME}/trunk/.repo/manifest.xml"
if grep -q "${chrome_workon}" ${cros_workon_dir} &> /dev/null; then
if [ $(readlink "${manifest}") != "manifests/minilayout.xml" ]; then
repo selfupdate && repo init -m gerrit-source.xml
fi
fi
chromium_dir="${HOME}/trunk/chromium/src"
if [ -d "${chromium_dir}" ]; then
(
cd "${chromium_dir}"
ignore_cmd='git config -f $toplevel/.git/config submodule.$name.ignore all'
git submodule foreach "${ignore_cmd}" &> /dev/null
)
fi
touch "${MARKER}"
exit 0

View File

@ -1,42 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Note that this script is invoked by make_chroot in addition
# to normal upgrade pathways.
if [ "${UID:-$(id -u)}" != 0 ]; then
# Note that since we're screwing w/ sudo variables, this script
# explicitly bounces up to root for everything it does- that way
# if anyone introduces a temp depriving in the sudo setup, it can't break
# mid upgrade.
load_environment_whitelist
exec sudo bash -e "${VERSION_HOOKS_DIR}/45_rewrite_sudoers.d" \
/ "${USER}" "${ENVIRONMENT_WHITELIST[@]}"
exit 1
fi
# Reaching here means we're root.
if [ $# -lt 2 ]; then
echo "Invoked with wrong number of args; expected root USER [variables]*"
exit 1
fi
root=$1
username=$2
shift
shift
set -- "${@}" CROS_WORKON_SRCROOT PORTAGE_USERNAME
cat > "${root}/etc/sudoers.d/90_cros" <<EOF
Defaults env_keep += "${*}"
%adm ALL=(ALL) ALL
root ALL=(ALL) ALL
${username} ALL=NOPASSWD: ALL
EOF
chmod 0440 "${root}/etc/sudoers.d/90_cros"
chown root:root "${root}/etc/sudoers.d/90_cros"
exit 0

View File

@ -1,28 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This is meant to happen immediately after we update these boards
# from 64bit to 32bit. It moves the existing build root out of the
# way and re-creates the build root. The user must remove the copy
# of the old build root manually if it is not needed.
for board in butterfly; do
build="/build/${board}"
if [[ -d ${build} ]] ; then
case ${HOSTNAME:-$(hostname)} in
*.golo.chromium.org)
# Do not keep on buildbots.
sudo rm -rf "${build}"
;;
*)
info "Moving 64bit ${board} to ${board}.64bit"
info "If you don't need it, please run "
info "sudo rm -rf ${build}.64bit"
sudo mv ${build}{,.64bit}
info "Running setup_board --board=${board}"
~/trunk/src/scripts/setup_board --board=${board} --skip_chroot_upgrade
;;
esac
fi
done

View File

@ -1,5 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Path overrides are no longer in use, so this script is just a placeholder.

View File

@ -1,18 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Clean out some packages that we dropped from hard-host-depends.
pkgs=(
dev-libs/eggdbus
dev-perl/File-Next
dev-python/requests
perl-core/MIME-Base64
sys-apps/ack
sys-apps/fakeroot
sys-devel/asan-clang
)
sudo CLEAN_DELAY=0 emerge -qC "${pkgs[@]}"
exit 0

View File

@ -1,12 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Update libtool to make sure it's in sync with toolchain.
if grep -q 4.6.x-google /usr/bin/libtool; then
info "Rebuilding libtool after gcc upgrade"
sudo -E emerge libtool -q
fi
exit 0

View File

@ -1,18 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# 1. Unmerge sys-auth/policykit because it's replaced by polkit.
# 2. Unmerge sys-boot/chromeos-u-boot-next and friends because it's replaced
# by sys-boot/chromeos-u-boot.
for board_root in /build/*; do
if [ -d "${board_root}" ]; then
board=$(basename "${board_root}")
CLEAN_DELAY=0 emerge-${board} --unmerge sys-auth/policykit \
sys-boot/chromeos-u-boot-next-build-env sys-boot/chromeos-u-boot-next \
chromeos-base/vboot_reference-firmware || true
fi
done
info "Chroot upgraded to version 4: policykit -> polkit"
exit 0

View File

@ -1,13 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
python_path=$(python -c 'import sys;print sys.version[:3]')
python_path="/usr/lib/python${python_path}/site-packages/chromite"
if [ ! -L "${python_path}" ]; then
sudo rm -rf "${python_path}" \
"/home/${PORTAGE_USERNAME:-${SUDO_USER:-${USER}}}/.local/lib/python2.6/site-packages/chromite"
sudo mkdir -p "$(dirname "${python_path}")"
sudo ln -s "${CHROOT_TRUNK_DIR}"/chromite "${python_path}"
fi
exit 0

View File

@ -1,33 +0,0 @@
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Upgrade people to the new style generic virtual/chromeos-bsp.
opkg="chromeos-base/chromeos-bsp-null"
export CLEAN_DELAY=0
update() {
local root=$1 board=$2 emerge
if [[ -z ${board} ]]; then
board="root"
emerge="sudo -E emerge"
else
emerge="emerge-${board}"
fi
if portageq has_version ${root} ${opkg}; then
${emerge} -Cq ${opkg}
fi
}
update / &
for board_root in /build/*; do
board=${board_root##*/}
update ${board_root} ${board} &
done
wait

View File

@ -1,15 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
for board_root in /build/*; do
if [ -h "${board_root}" ]; then
board=$(basename "${board_root}")
info "Removing hard-coded paths to ${board_root} in *.pc files"
sudo find "${board_root}/usr" -type f -name '*.pc' | xargs sudo \
sed -i -e "s|${board_root}/|/|g"
fi
done
info "Chroot upgraded to version 5: fix symlinked *.pc files"
exit 0

View File

@ -1,16 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Unmerge net-misc/mobile-broadband-provider-info because it's
# been replaced by chromeos-base/mobile-providers.
for board_root in /build/*; do
if [ -d "${board_root}" ]; then
board=$(basename "${board_root}")
CLEAN_DELAY=0 emerge-${board} \
--unmerge net-misc/mobile-broadband-provider-info || true
fi
done
info "Chroot upgraded to version 6: mobile-broadband-provider-info removed"
exit 0

View File

@ -1,54 +0,0 @@
#!/bin/bash
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This is a generic script for upgrading the host toolchain. It should:
# - be able to run repeatedly, in case someone has ancient chroot with
# several missed gcc upgrades
# - be easily tweakable for future upgrades of the same kind, if needed
CHOST="$(portageq envvar CHOST)"
# This is the lowest we want to go in this particular case.
MINIMUM_GCC="4.4.6"
env_setup() {
GCC_VERSIONS="$(gcc-config -l | grep "${CHOST}" | \
cut -f3 -d' ')"
GCC_LATEST="$(gcc-config -l | grep "${CHOST}" | tail -n1 | \
cut -f3 -d' ')"
}
env_setup
if ! [ "$(portageq match / ">=sys-devel/gcc-${MINIMUM_GCC}")" ];
then
info "You don't have the latest gcc installed, trying to build it"
if ! sudo emerge -u --getbinpkg sys-devel/gcc; then
error "Emerging gcc failed. Please recreate your chroot."
exit 1
fi
if ! [ "$(portageq match / ">=sys-devel/gcc-${MINIMUM_GCC}")" ];
then
error "You still don't have the latest gcc. Something is very"
error "wrong with your tree. Recreating your chroot will likely fix it."
exit 1
fi
fi
env_setup
info "Updating the host toolchain. crosbug.com/19613"
info "Currently installed host gcc versions: $(echo -n ${GCC_VERSIONS})"
if ! sudo gcc-config "${GCC_LATEST}"; then
error "gcc-config failed. This is really bad. Recreate your chroot."
exit 1
fi
info "Cleaning up the old toolchain"
sudo emerge --unmerge "<sys-devel/gcc-${MINIMUM_GCC}"
exit 0

View File

@ -1,18 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Unmerge dev-libs/gmp in all boards where it's still linked against the old
# version.
for board_root in /build/*; do
board=$(basename "${board_root}")
emerge_board=$(which emerge-${board} 2>/dev/null || true)
scanelf_out=$(scanelf -qn ${board_root}/usr/lib/libgmpxx.so.4 || true)
if [ -x "${emerge_board}" ] && [[ "$scanelf_out" == *libgmp.so.3* ]]; then
CLEAN_DELAY=0 ${emerge_board} --unmerge dev-libs/gmp || true
eclean-${board} -d packages || true
fi
done
info "Chroot upgraded to version 8: Unmerge old dev-libs/gmp"
exit 0

View File

@ -1,24 +0,0 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Make sure the BOARD_USE variable is set in make.conf.board_setup.
for board_root in /build/*; do
board=$(basename "${board_root}")
# Make sure this is a real board by looking for emerge-<board>.
emerge_board=$(which emerge-${board} 2>/dev/null || true)
if [ -x "${emerge_board}" ]; then
board_setup="/build/${board}/etc/make.conf.board_setup"
if [ -f "${board_setup}" ] && ! grep -q BOARD_USE "${board_setup}"; then
sudo_append "${board_setup}" << EOF
BOARD_USE="${board}"
EOF
info "Added BOARD_USE to ${board_setup}"
fi
fi
done
info "Chroot upgraded to version 9: Insert BOARD_USE in make.conf.board_setup"
exit 0

View File

@ -1,154 +0,0 @@
#!/bin/bash
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Load common CrOS utilities. Inside the chroot this file is installed in
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
# location.
. "$(dirname "$0")/common.sh" || exit 1
# Script must run inside the chroot.
assert_inside_chroot
# May not be run as root.
assert_not_root_user
DEFINE_string version "" \
"Assume current chroot version is this."
DEFINE_boolean force_latest "${FLAGS_FALSE}" \
"Assume latest version and recreate the version file"
DEFINE_boolean skipfirst "${FLAGS_FALSE}" \
"Skip the first upgrade. This may be dangerous."
FLAGS "$@" || exit 1
VERSION_FILE=/etc/cros_chroot_version
VERSION_HOOKS_DIR="$(dirname "$(readlink -f "${0}")")/chroot_version_hooks.d"
update_version() {
sudo touch ${VERSION_FILE}
sudo chown ${USER} ${VERSION_FILE}
echo "${1}" > "${VERSION_FILE}"
}
######################################################################
# Sanity checks:
if [ -n "${FLAGS_version}" ] && \
( [ "${FLAGS_skipfirst}" == "${FLAGS_TRUE}" ] || \
[ "${FLAGS_force_latest}" == "${FLAGS_TRUE}" ] ); then
error "The option --version cannot be combined with either"
error "--skipfirst or --force_latest."
exit 1
fi
if [ "${FLAGS_skipfirst}" == "${FLAGS_TRUE}" ] &&
[ "${FLAGS_force_latest}" == "${FLAGS_TRUE}" ]; then
error "--skipfirst and --force_latest cannot be combined."
exit 1
fi
# Latest version is the version of last upgrade.d file.
# Name format is ${number}_${short_description}
# Versions must be -n sorted, that is, the first continuous sequence
# of numbers is what counts. 12_ is before 111_, etc.
LATEST_VERSION=$(
cd "${VERSION_HOOKS_DIR}"
ls [0-9]*_* | cut -d_ -f1 | sort -rn | head -n1)
if [ "${FLAGS_force_latest}" == "${FLAGS_TRUE}" ]; then
update_version "${LATEST_VERSION}"
exit 0
fi
# If the file does not exist at all, chroot is old and does not have a version.
# default goes here
if ! [ -f "${VERSION_FILE}" ]; then
info "Chroot of unknown version, initializing to 0"
update_version 0
fi
CHROOT_VERSION=$(<"${VERSION_FILE}")
# Check if version is a number.
if ! [ "${CHROOT_VERSION}" -ge "0" ] &> /dev/null; then
error "Your chroot version file ${VERSION_FILE} is bogus: ${CHROOT_VERSION}"
exit 1
fi
if [ "${FLAGS_skipfirst}" == "${FLAGS_TRUE}" ]; then
if [ "${CHROOT_VERSION}" -lt "${LATEST_VERSION}" ]; then
# if the new one is latest, this becomes noop
CHROOT_VERSION=$(expr ${CHROOT_VERSION} + 1)
update_version "${CHROOT_VERSION}"
else
error "Nothing to skip"
exit 1
fi
fi
if [ -n "${FLAGS_version}" ]; then
# Check if it's a number.
if ! [ "${FLAGS_version}" -ge "0" ] &> /dev/null; then
error "Trying to force invalid version: ${FLAGS_version}"
exit 1
fi
if [ "${FLAGS_version}" -gt "${LATEST_VERSION}" ]; then
error "Forcing nonexistant version: ${FLAGS_version}"
exit 1
fi
CHROOT_VERSION="${FLAGS_version}"
fi
if [ "${LATEST_VERSION}" -gt "${CHROOT_VERSION}" ]; then
info "Old chroot version (${CHROOT_VERSION}) found, running upgrade hooks"
pushd "${VERSION_HOOKS_DIR}" 1> /dev/null
for n in $(seq "$(expr ${CHROOT_VERSION} + 1)" "${LATEST_VERSION}"); do
hook=(${n}_*)
# Sanity check: if there are multiple ${n}_* files, then CL's landed
# at the same time and people didn't notice. Let's notice for them.
if [ ${#hook[@]} -gt 1 ]; then
error "Fatal: Upgrade ${n} has multiple hooks:"
error " ${hook[*]}"
error "Connor MacLeod knows: There can be only one."
exit 1
fi
hook=${hook[0]}
# Deprecation check; Deprecation can be done by removing old upgrade
# scripts and causing too old chroots to have to start over.
# Upgrades have to form a continuous sequence.
if ! [ -f ${hook} ]; then
error "Fatal: Upgrade ${n} doesn't exist."
error "Your chroot is so old, that some updates have been deprecated!"
error "You need to re-create it!"
exit 1
fi
info "Rollup ${hook}"
# Attempt the upgrade.
# NOTE: We source the upgrade scripts because:
# 1) We can impose set -something on them.
# 2) They can reuse local variables and functions (fe. from common.sh)
# 3) They're allowed to use VERSION_HOOKS_DIR and VERSION_FILE.
# Note that the upgrade scripts have to be subshelled to protect ourselves,
# else a script running exit would stop the upgrade process entirely.
if ! ( source ${hook} ); then
error "Fatal: failed to upgrade ${n}!"
exit 1
fi
# Each upgrade is atomic. If a middle upgrade fails, we won't retry
# all the ones that passed on a previous run.
update_version "${n}"
done
popd 1> /dev/null
fi
command_completed

View File

@ -0,0 +1,21 @@
#!/bin/bash
# Copyright (c) 2013 The CoreOS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
cat >&2 <<EOF
Your SDK chroot is too old! (or the version wasn't detected properly)
As of v36 CoreOS has switched from python2.6 to 2.7 but the easiest way
to upgrade is to recreate the chroot. On the host system please run:
repo sync
./chromite/bin/cros_sdk --replace
Note: This will delete your existing chroot (but not your source tree)
so if you have anything kicking around in there like fancy dot files in
chroot/home/$USER be sure to copy them elsewhere first!
EOF
exit 1

View File

@ -47,7 +47,30 @@ switch_to_strict_mode
. ${SCRIPTS_DIR}/sdk_lib/make_conf_util.sh . ${SCRIPTS_DIR}/sdk_lib/make_conf_util.sh
# Run version hooks as pre-update # Run version hooks as pre-update
${SCRIPTS_DIR}/run_chroot_version_hooks if [[ -f /etc/lsb-release ]]; then
OLDVER=$(grep "^COREOS_RELEASE_VERSION=" /etc/lsb-release | cut -d = -f 2-)
else
OLDVER="0.0.0"
fi
# Updates should be of the form 1.2.3_desc.sh
for update_script in ${SCRIPTS_DIR}/sdk_lib/updates/*.sh; do
update_name="${update_script##*/}"
update_ver="${update_name%%_*}"
echo "$COREOS_VERSION_STRING" "$update_ver"
# Run newer updates but don't pass our current version
if ! cmp_ver le "$update_ver" "$COREOS_VERSION_STRING"; then
warn "Skipping update from the future: $update_name"
warn "Perhaps it is time to run a repo sync?"
elif ! cmp_ver ge "$OLDVER" "$update_ver"; then
info "Running chroot update $update_name"
bash -e "$update_script" || die "Update failed: $update_name"
fi
done
"${BUILD_LIBRARY_DIR}/set_lsb_release" \
--root / --production_track sdk \
--board "$(portageq envvar ARCH)-host"
# Create /etc/make.conf.host_setup. The file content is regenerated # Create /etc/make.conf.host_setup. The file content is regenerated
# from scratch every update. There are various reasons to do this: # from scratch every update. There are various reasons to do this: