@@ -16,11 +16,20 @@ const MIN_REQUIRED_GNU_TAR_VERSION = "1.31";
1616
1717export type TarVersion = {
1818 type : "gnu" | "bsd" ;
19+ name : string ;
1920 version : string ;
2021} ;
2122
2223async function getTarVersion ( ) : Promise < TarVersion > {
23- const tar = await io . which ( "tar" , true ) ;
24+ let tarName = "" ;
25+ let tar = "" ;
26+ try {
27+ tarName = "gtar" ;
28+ tar = await io . which ( tarName , true ) ;
29+ } catch {
30+ tarName = "tar" ;
31+ tar = await io . which ( tarName , true ) ;
32+ }
2433 let stdout = "" ;
2534 const exitCode = await new ToolRunner ( tar , [ "--version" ] , {
2635 listeners : {
@@ -39,14 +48,14 @@ async function getTarVersion(): Promise<TarVersion> {
3948 throw new Error ( "Failed to parse output of tar --version." ) ;
4049 }
4150
42- return { type : "gnu" , version : match [ 1 ] } ;
51+ return { type : "gnu" , name : tarName , version : match [ 1 ] } ;
4352 } else if ( stdout . includes ( "bsdtar" ) ) {
4453 const match = stdout . match ( / b s d t a r ( [ 0 - 9 . ] + ) / ) ;
4554 if ( ! match || ! match [ 1 ] ) {
4655 throw new Error ( "Failed to parse output of tar --version." ) ;
4756 }
4857
49- return { type : "bsd" , version : match [ 1 ] } ;
58+ return { type : "bsd" , name : tarName , version : match [ 1 ] } ;
5059 } else {
5160 throw new Error ( "Unknown tar version" ) ;
5261 }
@@ -162,10 +171,10 @@ export async function extractTarZst(
162171
163172 args . push ( "-f" , tar instanceof stream . Readable ? "-" : tar , "-C" , dest ) ;
164173
165- process . stdout . write ( `[command]tar ${ args . join ( " " ) } \n` ) ;
174+ process . stdout . write ( `[command]${ tarVersion . name } ${ args . join ( " " ) } \n` ) ;
166175
167176 await new Promise < void > ( ( resolve , reject ) => {
168- const tarProcess = spawn ( "tar" , args , { stdio : "pipe" } ) ;
177+ const tarProcess = spawn ( tarVersion . name , args , { stdio : "pipe" } ) ;
169178
170179 let stdout = "" ;
171180 tarProcess . stdout ?. on ( "data" , ( data : Buffer ) => {
@@ -196,7 +205,7 @@ export async function extractTarZst(
196205 if ( code !== 0 ) {
197206 reject (
198207 new CommandInvocationError (
199- "tar" ,
208+ tarVersion . name ,
200209 args ,
201210 code ?? undefined ,
202211 stdout ,
0 commit comments