summaryrefslogtreecommitdiff
path: root/scripts/uprev-srcrev
blob: 61afab56e24d6ab4763e8048cc81c336351a84af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python3
#
# Tool to update Toradex recipes using AUTOREV
#
# Copyright (c) 2020, Toradex
#
# SPDX-License-Identifier: GPL-2.0-only
#

import os
import sys
import argparse
import logging
import subprocess
script_path = os.path.dirname(os.path.realpath(__file__))
lib_path = os.path.join(script_path, '../../openembedded-core/scripts/lib')
sys.path = sys.path + [lib_path]
import argparse_oe
import scriptutils

logger = scriptutils.logger_create('uprev-srcrev')

recipes_tdxref = [
    "../layers/meta-toradex-bsp-common/recipes-kernel/backports/backports_5.4.bb",
    "../layers/meta-toradex-bsp-common/recipes-kernel/linux/linux-toradex-mainline_5.4.bb",
    "../layers/meta-toradex-bsp-common/recipes-kernel/linux/device-tree-overlays-mainline_git.bb",
    "../layers/meta-toradex-nxp/recipes-kernel/linux/linux-toradex_5.4-2.1.x.bb",
    "../layers/meta-toradex-nxp/recipes-kernel/linux/device-tree-overlays_git.bb",
    "../layers/meta-toradex-nxp/recipes-bsp/imx-sc-firmware/imx-sc-firmware-toradex_1.5.1.bb",
    "../layers/meta-toradex-nxp/recipes-bsp/u-boot/u-boot-toradex_2020.04.bb",
    "../layers/meta-toradex-nxp/recipes-bsp/u-boot/u-boot-toradex_2020.07.bb",
    "../layers/meta-toradex-tegra/recipes-bsp/u-boot/u-boot-toradex-tk1_2019.07.bb",
    ]

recipes_torizon = [
    "../layers/meta-toradex-bsp-common/recipes-kernel/backports/backports_5.4.bb",
    "../layers/meta-toradex-bsp-common/recipes-kernel/linux/linux-toradex-mainline_5.4.bb",
    "../layers/meta-toradex-bsp-common/recipes-kernel/linux/device-tree-overlays-mainline_git.bb",
    "../layers/meta-toradex-nxp/recipes-kernel/linux/linux-toradex_5.4-2.1.x.bb",
    "../layers/meta-toradex-nxp/recipes-kernel/linux/device-tree-overlays_git.bb",
    "../layers/meta-toradex-nxp/recipes-bsp/imx-sc-firmware/imx-sc-firmware-toradex_1.5.1.bb",
    "../layers/meta-toradex-nxp/recipes-bsp/u-boot/u-boot-toradex_2020.04.bb",
    "../layers/meta-toradex-nxp/recipes-bsp/u-boot/u-boot-toradex_2020.07.bb",
    "../layers/meta-toradex-torizon/recipes-kernel/linux/linux-toradex-kmeta.inc",
    ]

def uprev_recipe(args, env, recipe):

    try:
        result = subprocess.run(
                'recipetool updatesrcrev {}'.format(recipe),
                stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                env=env, universal_newlines=True,
                shell=True)
        if not args.quiet:
            print(result.stdout)
    except subprocess.CalledProcessError as e:
        print('ERROR: recipetool failed:\n%s' % e.output.decode('utf-8'))
        return e.returncode
 

def uprev(args):
    env = os.environ.copy()
    # make sure that we query the remote repo as we execute the script, not
    # the clone we have in the local download.
    env['BB_SRCREV_POLICY'] = "clear"

    # decide if we build torizon or tdxref. Use the existence of meta-toradex-torizon
    if os.path.exists(os.path.join(script_path, '../../meta-toradex-torizon')):
        recipes = recipes_torizon
    else:
        recipes = recipes_tdxref

    for recipe in recipes:
        logger.info('Processing recipe {}'.format(recipe))
        uprev_recipe(args, env, recipe)

def main():
    parser = argparse_oe.ArgumentParser(description='SRCREV uprev tool.')

    parser.add_argument('-d', '--debug', help='enable debug output', action='store_true')
    parser.add_argument('-q', '--quiet', help='print only errors', action='store_true')

    parser.set_defaults(func=uprev)

    args = parser.parse_args()

    if args.debug:
        logger.setLevel(logging.DEBUG)
    elif args.quiet:
        logger.setLevel(logging.ERROR)

    ret = args.func(args)

    return ret

if __name__ == "__main__":
    sys.exit(main())