@@ -14,14 +14,12 @@ from pathlib import Path
14
14
from urllib import request
15
15
16
16
from tuf .api .exceptions import DownloadError , RepositoryError
17
- from tuf .ngclient import Updater , UpdaterConfig
18
- from tuf .ngclient .config import EnvelopeType
17
+ from tuf .ngclient import Updater
19
18
20
19
# constants
21
20
DOWNLOAD_DIR = "./downloads"
22
21
CLIENT_EXAMPLE_DIR = os .path .dirname (os .path .abspath (__file__ ))
23
22
24
-
25
23
def build_metadata_dir (base_url : str ) -> str :
26
24
"""build a unique and reproducible directory name for the repository url"""
27
25
name = sha256 (base_url .encode ()).hexdigest ()[:8 ]
@@ -48,7 +46,7 @@ def init_tofu(base_url: str) -> bool:
48
46
return True
49
47
50
48
51
- def download (base_url : str , target : str , use_dsse : bool ) -> bool :
49
+ def download (base_url : str , target : str ) -> bool :
52
50
"""
53
51
Download the target file using ``ngclient`` Updater.
54
52
@@ -74,16 +72,12 @@ def download(base_url: str, target: str, use_dsse: bool) -> bool:
74
72
if not os .path .isdir (DOWNLOAD_DIR ):
75
73
os .mkdir (DOWNLOAD_DIR )
76
74
77
- config = UpdaterConfig ()
78
- config .envelope_type = EnvelopeType .SIMPLE
79
-
80
75
try :
81
76
updater = Updater (
82
77
metadata_dir = metadata_dir ,
83
78
metadata_base_url = f"{ base_url } /metadata/" ,
84
79
target_base_url = f"{ base_url } /targets/" ,
85
80
target_dir = DOWNLOAD_DIR ,
86
- config = config ,
87
81
)
88
82
updater .refresh ()
89
83
@@ -152,13 +146,6 @@ def main() -> None:
152
146
help = "Target file" ,
153
147
)
154
148
155
- download_parser .add_argument (
156
- "--use-dsse" ,
157
- help = "Parse TUF metadata as DSSE" ,
158
- default = False ,
159
- action = "store_true" ,
160
- )
161
-
162
149
command_args = client_args .parse_args ()
163
150
164
151
if command_args .verbose == 0 :
@@ -177,9 +164,7 @@ def main() -> None:
177
164
if not init_tofu (command_args .url ):
178
165
return "Failed to initialize local repository"
179
166
elif command_args .sub_command == "download" :
180
- if not download (
181
- command_args .url , command_args .target , command_args .use_dsse
182
- ):
167
+ if not download (command_args .url , command_args .target ):
183
168
return f"Failed to download { command_args .target } "
184
169
else :
185
170
client_args .print_help ()
0 commit comments