blob: 32e20119a8a567459dbdf18cbf9bfd40b85c0f0f [file] [log] [blame]
# Copyright 2021 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 up rust packages which no longer have corresponding ebuilds
#
# This is approxmiated by removing versions with no binary package since
# eclean will remove binary packages without a corresponding ebuild.
export CLEAN_DELAY=0
do_clean() {
local suffix="$1"
local emerge_cmd=()
local args
if [[ -z "${suffix}" ]]; then
emerge_cmd+=( sudo )
fi
emerge_cmd+=( "emerge${suffix}" )
args=( $("equery${suffix}" l -b --format='=$cpv' 'dev-rust/*' ) )
if [[ ${#args[@]} -eq 0 ]]; then
return
fi
"${emerge_cmd[@]}" -C "${args[@]}"
}
do_clean
for board_root in /build/*; do
board_name=${board_root##*/}
if [[ -d "${board_root}/var/db/pkg/dev-rust" ]]; then
do_clean "-${board_name}"
fi
done