blob: bc9ab47e475de001a50f3dc2fc150371bbfb9760 [file] [log] [blame]
Alex Kleineb77ffa2019-05-28 14:47:44 -06001# -*- coding: utf-8 -*-
2# Copyright 2019 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""Package related functionality."""
7
8from __future__ import print_function
9
10from chromite.api.controller import controller_util
11from chromite.api.gen.chromite.api import binhost_pb2
12from chromite.lib import build_target_util
13from chromite.lib import constants
14from chromite.lib import cros_build_lib
15from chromite.service import packages
16
17
18_OVERLAY_TYPE_TO_NAME = {
19 binhost_pb2.OVERLAYTYPE_PUBLIC: constants.PUBLIC_OVERLAYS,
20 binhost_pb2.OVERLAYTYPE_PRIVATE: constants.PRIVATE_OVERLAYS,
21 binhost_pb2.OVERLAYTYPE_BOTH: constants.BOTH_OVERLAYS,
22}
23
24
25def Uprev(input_proto, _output_proto):
26 """Uprev all cros workon ebuilds that have changes."""
27 if not input_proto.overlay_type:
28 cros_build_lib.Die('Overlay type is required.')
29 elif input_proto.overlay_type not in _OVERLAY_TYPE_TO_NAME:
30 cros_build_lib.Die('Overlay type must be one of: %s',
31 ', '.join(_OVERLAY_TYPE_TO_NAME.values()))
32
33 target_names = [t.name for t in input_proto.build_targets]
34 build_targets = [build_target_util.BuildTarget(t) for t in target_names]
35 overlay_type = _OVERLAY_TYPE_TO_NAME[input_proto.overlay_type]
36 chroot = controller_util.ParseChroot(input_proto.chroot)
37 output_dir = input_proto.output_dir or None
38
39 try:
40 packages.uprev_build_targets(build_targets, overlay_type, chroot,
41 output_dir)
42 except packages.Error as e:
43 # Handle module errors nicely, let everything else bubble up.
44 cros_build_lib.Die(e.message)