Skip to content

Commit a6df132

Browse files
rossburtondavidvincze
authored andcommitted
imgtool: prefer cbor2 over cbor
The cbor module is unmaintained, with the last release in 2016[1]. The cbor2 module however is under active development and was last released just last month[2]. As the APIs are identical, we can import cbor2 and if that fails fall back to cbor. [1] https://pypi.org/project/cbor/#history [2] https://pypi.org/project/cbor2/#history Closes #1189 Signed-off-by: Ross Burton <[email protected]> Change-Id: Iaf2d0df625a200a5cebf72dec4a89877a26194ea
1 parent 1a9c6d8 commit a6df132

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

scripts/imgtool.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let
2020
python37.pkgs.cryptography
2121
python37.pkgs.intelhex
2222
python37.pkgs.setuptools
23-
python37.pkgs.cbor
23+
python37.pkgs.cbor2
2424
]
2525
);
2626
in

scripts/imgtool/boot_record.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019, Arm Limited.
1+
# Copyright (c) 2019-2021, Arm Limited.
22
# Copyright (c) 2020, Linaro Limited
33
#
44
# SPDX-License-Identifier: Apache-2.0
@@ -16,8 +16,11 @@
1616
# limitations under the License.
1717

1818
from enum import Enum
19-
import cbor
2019

20+
try:
21+
from cbor2 import dumps
22+
except ImportError:
23+
from cbor import dumps
2124

2225
class SwComponent(int, Enum):
2326
"""
@@ -46,4 +49,4 @@ def create_sw_component_data(sw_type, sw_version, sw_measurement_description,
4649
# list because later it will be modified by the bootloader.
4750
properties[SwComponent.MEASUREMENT_VALUE] = sw_measurement_value
4851

49-
return cbor.dumps(properties)
52+
return dumps(properties)

scripts/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cryptography>=2.6
22
intelhex
33
click
4-
cbor>=1.0.0
4+
cbor2

scripts/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
'cryptography>=2.4.2',
1818
'intelhex>=2.2.1',
1919
'click',
20-
'cbor>=1.0.0',
20+
'cbor2',
2121
],
2222
entry_points={
2323
"console_scripts": ["imgtool=imgtool.main:imgtool"]

0 commit comments

Comments
 (0)