blob: 52265ea5ab380de9791c243ea525d0a5ca4624c7 [file] [log] [blame]
# 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
# 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 --one-file-system "$src"
sudo ln -s ../../cache/distfiles/"$2" "$src"
upgrade_path distfiles host
upgrade_path distfiles-target target
exit 0