@@ -106,8 +106,16 @@ async def extract_file_rpm(self, filename, extraction_path):
106
106
if stderr or not stdout :
107
107
return 1
108
108
filenames = await aio_glob (os .path .join (extraction_path , "*.cpio" ))
109
+ if not filenames :
110
+ filenames = await aio_glob (
111
+ os .path .join (extraction_path , "*.cpio.zstd" )
112
+ )
113
+ filename = filenames [0 ]
114
+ exit_code = await self .extract_file_zst (filename , extraction_path )
115
+ if exit_code :
116
+ return 1
117
+ filenames = await aio_glob (os .path .join (extraction_path , "*.cpio" ))
109
118
filename = filenames [0 ]
110
-
111
119
stdout , stderr , _ = await aio_run_command (["7z" , "x" , filename ])
112
120
if stderr or not stdout :
113
121
return 1
@@ -118,11 +126,19 @@ async def extract_file_zst(self, filename: str, extraction_path: str) -> int:
118
126
119
127
dctx = zstandard .ZstdDecompressor ()
120
128
with ErrorHandler (mode = ErrorMode .Ignore ) as e :
121
- with open (filename , "rb" ) as f :
122
- with dctx .stream_reader (f ) as reader :
123
- with tarfile .open (mode = "r|" , fileobj = reader ) as tar :
124
- tar .extractall (extraction_path )
125
- tar .close ()
129
+ if filename .endswith (".cpio.zstd" ):
130
+ with open (filename , "rb" ) as compressed :
131
+ base = os .path .basename (filename )
132
+ file = os .path .splitext (base )[0 ]
133
+ output_path = os .path .join (extraction_path , file )
134
+ with open (output_path , "wb" ) as destination :
135
+ dctx .copy_stream (compressed , destination )
136
+ else :
137
+ with open (filename , "rb" ) as f :
138
+ with dctx .stream_reader (f ) as reader :
139
+ with tarfile .open (mode = "r|" , fileobj = reader ) as tar :
140
+ tar .extractall (extraction_path )
141
+ tar .close ()
126
142
return e .exit_code
127
143
128
144
async def extract_file_pkg (self , filename : str , extraction_path : str ) -> int :
0 commit comments