@@ -90,6 +90,17 @@ const (
90
90
dockerMetadataFile = "metadata.yaml"
91
91
)
92
92
93
+ var (
94
+ compressor = "gzip"
95
+ )
96
+
97
+ func init () {
98
+ pigz , err := exec .LookPath ("pigz" )
99
+ if err == nil {
100
+ compressor = pigz
101
+ }
102
+ }
103
+
93
104
// buildProcessVersions contain the current version of the respective build processes.
94
105
// Increment this value if you change any of the build procedures.
95
106
var buildProcessVersions = map [PackageType ]int {
@@ -1058,7 +1069,7 @@ func (p *Package) buildYarn(buildctx *buildContext, wd, result string) (bld *pac
1058
1069
{"sh" , "-c" , fmt .Sprintf ("yarn generate-lock-entry --resolved file://./%s > _mirror/content_yarn.lock" , dst )},
1059
1070
{"sh" , "-c" , "cat yarn.lock >> _mirror/content_yarn.lock" },
1060
1071
{"yarn" , "pack" , "--filename" , dst },
1061
- {"tar" , "cfz " , result , "-C" , "_mirror" , "." },
1072
+ {"tar" , "cf " , result , fmt . Sprintf ( "--use-compress-program=%v" , compressor ) , "-C" , "_mirror" , "." },
1062
1073
}... )
1063
1074
resultDir = "_mirror"
1064
1075
} else if cfg .Packaging == YarnLibrary {
@@ -1082,11 +1093,11 @@ func (p *Package) buildYarn(buildctx *buildContext, wd, result string) (bld *pac
1082
1093
{"yarn" , "pack" , "--filename" , pkg },
1083
1094
{"sh" , "-c" , fmt .Sprintf ("cat yarn.lock %s > _pkg/yarn.lock" , pkgYarnLock )},
1084
1095
{"yarn" , "--cwd" , "_pkg" , "install" , "--prod" , "--frozen-lockfile" },
1085
- {"tar" , "cfz " , result , "-C" , "_pkg" , "." },
1096
+ {"tar" , "cf " , result , fmt . Sprintf ( "--use-compress-program=%v" , compressor ) , "-C" , "_pkg" , "." },
1086
1097
}... )
1087
1098
resultDir = "_pkg"
1088
1099
} else if cfg .Packaging == YarnArchive {
1089
- pkgCommands = append (pkgCommands , []string {"tar" , "cfz " , result , "." })
1100
+ pkgCommands = append (pkgCommands , []string {"tar" , "cf " , result , fmt . Sprintf ( "--use-compress-program=%v" , compressor ) , "." })
1090
1101
} else {
1091
1102
return nil , xerrors .Errorf ("unknown Yarn packaging: %s" , cfg .Packaging )
1092
1103
}
@@ -1246,7 +1257,7 @@ func (p *Package) buildGo(buildctx *buildContext, wd, result string) (res *packa
1246
1257
commands [PackageBuildPhaseBuild ] = append (commands [PackageBuildPhaseBuild ], []string {"rm" , "-rf" , "_deps" })
1247
1258
1248
1259
commands [PackageBuildPhasePackage ] = append (commands [PackageBuildPhasePackage ], []string {
1249
- "tar" , "cfz " , result , "." ,
1260
+ "tar" , "cf " , result , fmt . Sprintf ( "--use-compress-program=%v" , compressor ) , "." ,
1250
1261
})
1251
1262
if ! cfg .DontTest && ! buildctx .DontTest {
1252
1263
commands [PackageBuildPhasePackage ] = append (commands [PackageBuildPhasePackage ], [][]string {
@@ -1353,12 +1364,6 @@ func (p *Package) buildDocker(buildctx *buildContext, wd, result string) (res *p
1353
1364
pkgcmds = append (pkgcmds , []string {"tar" , "fr" , ef , "./" + provenanceBundleFilename })
1354
1365
}
1355
1366
1356
- compressor := "gzip"
1357
- pigz , err := exec .LookPath ("pigz" )
1358
- if err == nil {
1359
- compressor = pigz
1360
- }
1361
-
1362
1367
pkgcmds = append (pkgcmds , []string {compressor , ef })
1363
1368
commands [PackageBuildPhasePackage ] = pkgcmds
1364
1369
} else if len (cfg .Image ) > 0 {
@@ -1386,7 +1391,7 @@ func (p *Package) buildDocker(buildctx *buildContext, wd, result string) (res *p
1386
1391
}
1387
1392
pkgCommands = append (pkgCommands , []string {"sh" , "-c" , fmt .Sprintf ("echo %s | base64 -d > %s" , base64 .StdEncoding .EncodeToString (consts ), dockerMetadataFile )})
1388
1393
1389
- archiveCmd := []string {"tar" , "cfz " , result , "./" + dockerImageNamesFiles , "./" + dockerMetadataFile }
1394
+ archiveCmd := []string {"tar" , "cf " , result , fmt . Sprintf ( "--use-compress-program=%v" , compressor ) , "./" + dockerImageNamesFiles , "./" + dockerMetadataFile }
1390
1395
if p .C .W .Provenance .Enabled {
1391
1396
archiveCmd = append (archiveCmd , "./" + provenanceBundleFilename )
1392
1397
}
@@ -1544,14 +1549,14 @@ func (p *Package) buildGeneric(buildctx *buildContext, wd, result string) (res *
1544
1549
if p .C .W .Provenance .Enabled {
1545
1550
return & packageBuild {
1546
1551
Commands : map [PackageBuildPhase ][][]string {
1547
- PackageBuildPhasePackage : [][]string {{"tar" , "cfz " , result , "./" + provenanceBundleFilename }},
1552
+ PackageBuildPhasePackage : [][]string {{"tar" , "cf " , result , fmt . Sprintf ( "--use-compress-program=%v" , compressor ) , "./" + provenanceBundleFilename }},
1548
1553
},
1549
1554
}, nil
1550
1555
}
1551
1556
1552
1557
return & packageBuild {
1553
1558
Commands : map [PackageBuildPhase ][][]string {
1554
- PackageBuildPhasePackage : [][]string {{"tar" , "cfz " , result , "--files-from" , "/dev/null" }},
1559
+ PackageBuildPhasePackage : [][]string {{"tar" , "cf " , result , fmt . Sprintf ( "--use-compress-program=%v" , compressor ) , "--files-from" , "/dev/null" }},
1555
1560
},
1556
1561
}, nil
1557
1562
}
@@ -1579,7 +1584,7 @@ func (p *Package) buildGeneric(buildctx *buildContext, wd, result string) (res *
1579
1584
return & packageBuild {
1580
1585
Commands : map [PackageBuildPhase ][][]string {
1581
1586
PackageBuildPhaseBuild : commands ,
1582
- PackageBuildPhasePackage : {{"tar" , "cfz " , result , "." }},
1587
+ PackageBuildPhasePackage : {{"tar" , "cf " , result , fmt . Sprintf ( "--use-compress-program=%v" , compressor ) , "." }},
1583
1588
},
1584
1589
}, nil
1585
1590
}
0 commit comments