51
51
Md5File ,
52
52
Sha1File ,
53
53
Sha256File ,
54
+ Sha384File ,
54
55
)
55
56
from pyinfra .facts .server import Date , Which
56
57
@@ -67,6 +68,7 @@ def download(
67
68
mode : str | None = None ,
68
69
cache_time : int | None = None ,
69
70
force = False ,
71
+ sha384sum : str | None = None ,
70
72
sha256sum : str | None = None ,
71
73
sha1sum : str | None = None ,
72
74
md5sum : str | None = None ,
@@ -84,6 +86,7 @@ def download(
84
86
+ mode: permissions of the files
85
87
+ cache_time: if the file exists already, re-download after this time (in seconds)
86
88
+ force: always download the file, even if it already exists
89
+ + sha384sum: sha384 hash to checksum the downloaded file against
87
90
+ sha256sum: sha256 hash to checksum the downloaded file against
88
91
+ sha1sum: sha1 hash to checksum the downloaded file against
89
92
+ md5sum: md5 hash to checksum the downloaded file against
@@ -135,6 +138,10 @@ def download(
135
138
if sha256sum != host .get_fact (Sha256File , path = dest ):
136
139
download = True
137
140
141
+ if sha384sum :
142
+ if sha384sum != host .get_fact (Sha384File , path = dest ):
143
+ download = True
144
+
138
145
if md5sum :
139
146
if md5sum != host .get_fact (Md5File , path = dest ):
140
147
download = True
@@ -211,6 +218,17 @@ def download(
211
218
QuoteString ("SHA256 did not match!" ),
212
219
)
213
220
221
+ if sha384sum :
222
+ yield make_formatted_string_command (
223
+ (
224
+ "(( sha384sum {0} 2> /dev/null || shasum -a 384 {0} ) "
225
+ "| grep {1}) || ( echo {2} && exit 1 )"
226
+ ),
227
+ QuoteString (dest ),
228
+ sha384sum ,
229
+ QuoteString ("SHA384 did not match!" ),
230
+ )
231
+
214
232
if md5sum :
215
233
yield make_formatted_string_command (
216
234
(
0 commit comments