1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package com.hazendaz.maven.makeself;
19
20 import java.io.BufferedInputStream;
21 import java.io.BufferedReader;
22 import java.io.File;
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.io.InputStreamReader;
26 import java.nio.charset.StandardCharsets;
27 import java.nio.file.Files;
28 import java.nio.file.Path;
29 import java.nio.file.StandardCopyOption;
30 import java.nio.file.attribute.PosixFilePermission;
31 import java.nio.file.attribute.PosixFilePermissions;
32 import java.util.ArrayList;
33 import java.util.Arrays;
34 import java.util.List;
35 import java.util.Map;
36 import java.util.Set;
37
38 import javax.inject.Inject;
39
40 import org.apache.commons.compress.archivers.ArchiveEntry;
41 import org.apache.commons.compress.archivers.ArchiveInputStream;
42 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
43 import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
44 import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
45 import org.apache.commons.io.FilenameUtils;
46 import org.apache.maven.plugin.AbstractMojo;
47 import org.apache.maven.plugin.MojoExecutionException;
48 import org.apache.maven.plugin.MojoFailureException;
49 import org.apache.maven.plugins.annotations.LifecyclePhase;
50 import org.apache.maven.plugins.annotations.Mojo;
51 import org.apache.maven.plugins.annotations.Parameter;
52 import org.apache.maven.project.MavenProject;
53 import org.apache.maven.project.MavenProjectHelper;
54 import org.eclipse.aether.RepositorySystem;
55 import org.eclipse.aether.RepositorySystemSession;
56 import org.eclipse.aether.artifact.Artifact;
57 import org.eclipse.aether.artifact.DefaultArtifact;
58 import org.eclipse.aether.repository.RemoteRepository;
59 import org.eclipse.aether.resolution.ArtifactRequest;
60 import org.eclipse.aether.resolution.ArtifactResolutionException;
61 import org.eclipse.aether.resolution.ArtifactResult;
62
63
64
65
66 @Mojo(name = "makeself", defaultPhase = LifecyclePhase.VERIFY, requiresProject = false)
67 public class MakeselfMojo extends AbstractMojo {
68
69
70 private static final boolean WINDOWS = System.getProperty("os.name").startsWith("Windows");
71
72
73 private static final String PERMISSIONS = "rwxr-xr--";
74
75
76 private static final boolean ATTACH_ARTIFACT = true;
77
78
79 private static final String GIT_USER_BIN = "/usr/bin/";
80
81
82
83
84
85 @Parameter(defaultValue = "", property = "gitPath")
86 private String gitPath;
87
88
89
90
91 @Parameter(defaultValue = "makeself", property = "archiveDir", required = true)
92 private String archiveDir;
93
94
95
96
97 @Parameter(defaultValue = "makeself.sh", property = "fileName", required = true)
98 private String fileName;
99
100
101
102
103 @Parameter(defaultValue = "Makeself self-extractable archive", property = "label", required = true)
104 private String label;
105
106
107
108
109
110
111 @Parameter(defaultValue = "./makeself.sh", property = "startupScript", required = true)
112 private String startupScript;
113
114
115
116
117
118
119
120
121 @Parameter(defaultValue = "sh", property = "extension")
122 private String extension;
123
124
125
126
127
128
129
130
131 @Parameter(property = "classifier")
132 private String classifier;
133
134
135
136
137
138
139
140
141
142 @Parameter(property = "inlineScript")
143 private boolean inlineScript;
144
145
146
147
148
149
150
151
152
153
154
155
156
157 @Parameter(property = "scriptArgs")
158 private List<String> scriptArgs;
159
160
161
162
163
164
165 @Parameter(property = "version")
166 private Boolean version;
167
168
169
170
171 @Parameter(property = "help")
172 private Boolean help;
173
174
175
176
177
178
179 @Parameter(property = "tarQuietly")
180 private Boolean tarQuietly;
181
182
183
184
185
186
187 @Parameter(property = "quiet")
188 private Boolean quiet;
189
190
191
192
193 @Parameter(property = "gzip")
194 private Boolean gzip;
195
196
197
198
199
200
201 @Parameter(property = "bzip2")
202 private Boolean bzip2;
203
204
205
206
207
208
209
210
211 @Parameter(property = "bzip3")
212 private Boolean bzip3;
213
214
215
216
217
218
219 @Parameter(property = "pbzip2")
220 private Boolean pbzip2;
221
222
223
224
225
226
227 @Parameter(property = "xz")
228 private Boolean xz;
229
230
231
232
233
234
235 @Parameter(property = "lzo")
236 private Boolean lzo;
237
238
239
240
241
242
243 @Parameter(property = "lz4")
244 private Boolean lz4;
245
246
247
248
249 @Parameter(property = "zstd")
250 private Boolean zstd;
251
252
253
254
255 @Parameter(property = "pigz")
256 private Boolean pigz;
257
258
259
260
261 @Parameter(property = "base64")
262 private Boolean base64;
263
264
265
266
267
268 @Parameter(property = "gpgEncrypt")
269 private Boolean gpgEncrypt;
270
271
272
273
274 @Parameter(property = "gpgAsymmetricEncryptSign")
275 private Boolean gpgAsymmetricEncryptSign;
276
277
278
279
280
281 @Parameter(property = "sslEncrypt")
282 private Boolean sslEncrypt;
283
284
285
286
287 @Parameter(property = "sslPasswd")
288 private String sslPasswd;
289
290
291
292
293
294
295 @Parameter(property = "sslPassSrc")
296 private String sslPassSrc;
297
298
299
300
301 @Parameter(property = "sslNoMd")
302 private Boolean sslNoMd;
303
304
305
306
307
308 @Parameter(property = "compress")
309 private Boolean compress;
310
311
312
313
314 @Parameter(property = "complevel")
315 private Integer complevel;
316
317
318
319
320 @Parameter(property = "compExtra")
321 private String compExtra;
322
323
324
325
326
327
328 @Parameter(property = "nochown")
329 private Boolean nochown;
330
331
332
333
334
335
336 @Parameter(property = "chown")
337 private Boolean chown;
338
339
340
341
342 @Parameter(property = "nocomp")
343 private Boolean nocomp;
344
345
346
347
348
349
350
351 @Parameter(property = "threads")
352 private Integer threads;
353
354
355
356
357
358
359 @Parameter(property = "notemp")
360 private Boolean notemp;
361
362
363
364
365
366
367 @Parameter(property = "needroot")
368 private Boolean needroot;
369
370
371
372
373
374 @Parameter(property = "current")
375 private Boolean current;
376
377
378
379
380
381 @Parameter(property = "follow")
382 private Boolean follow;
383
384
385
386
387
388
389 @Parameter(property = "noprogress")
390 private Boolean noprogress;
391
392
393
394
395
396
397 @Parameter(property = "append")
398 private Boolean append;
399
400
401
402
403
404
405 @Parameter(property = "headerFile")
406 private String headerFile;
407
408
409
410
411
412
413
414 @Parameter(property = "preextractScript")
415 private String preextractScript;
416
417
418
419
420
421 @Parameter(property = "cleanupScript")
422 private String cleanupScript;
423
424
425
426
427
428
429
430 @Parameter(property = "copy")
431 private Boolean copy;
432
433
434 @Parameter(property = "nox11")
435 private Boolean nox11;
436
437
438 @Parameter(property = "nowait")
439 private Boolean nowait;
440
441
442
443
444
445 @Parameter(property = "nomd5")
446 private Boolean nomd5;
447
448
449
450
451
452 @Parameter(property = "nocrc")
453 private Boolean nocrc;
454
455
456
457
458 @Parameter(property = "sha256")
459 private Boolean sha256;
460
461
462
463
464
465
466 @Parameter(property = "signPassphrase")
467 private String signPassphrase;
468
469
470
471
472
473
474 @Parameter(property = "lsmFile")
475 private String lsmFile;
476
477
478
479
480 @Parameter(property = "gpgExtraOpt")
481 private String gpgExtraOpt;
482
483
484
485
486
487 @Parameter(property = "tarFormatOpt")
488 private String tarFormatOpt;
489
490
491
492
493
494
495
496 @Parameter(property = "tarExtraOpt")
497 private String tarExtraOpt;
498
499
500
501
502 @Parameter(property = "untarExtraOpt")
503 private String untarExtraOpt;
504
505
506
507
508
509
510
511 private String extractTargetDir;
512
513
514
515
516
517 @Parameter(property = "keepUmask")
518 private Boolean keepUmask;
519
520
521
522
523 @Parameter(property = "exportConf")
524 private Boolean exportConf;
525
526
527
528
529 @Parameter(property = "packagingDate")
530 private String packagingDate;
531
532
533
534
535 @Parameter(property = "licenseFile")
536 private String licenseFile;
537
538
539
540
541 @Parameter(property = "nooverwrite")
542 private Boolean nooverwrite;
543
544
545
546
547 @Parameter(property = "helpHeaderFile")
548 private String helpHeaderFile;
549
550
551 @Parameter(defaultValue = "false", property = "makeself.skip")
552 private boolean skip;
553
554
555 @Parameter(defaultValue = "false", property = "autoRun")
556 private boolean autoRun;
557
558
559 @Parameter(defaultValue = "${project.build.directory}/", readonly = true)
560 private String buildTarget;
561
562
563 @Parameter(defaultValue = "${project.build.directory}/makeself-tmp/", readonly = true)
564 private File makeselfTempDirectory;
565
566
567 @Inject
568 private MavenProjectHelper projectHelper;
569
570
571 @Inject
572 private RepositorySystem repositorySystem;
573
574
575 @Parameter(defaultValue = "${project}", readonly = true, required = true)
576 private MavenProject project;
577
578
579 @Parameter(defaultValue = "${repositorySystemSession}", readonly = true, required = true)
580 private RepositorySystemSession repoSession;
581
582
583 @Parameter(defaultValue = "${project.remoteProjectRepositories}", readonly = true, required = true)
584 protected List<RemoteRepository> remoteRepositories;
585
586
587 private Path makeself;
588
589
590 private PortableGit portableGit;
591
592 @Override
593 public void execute() throws MojoExecutionException, MojoFailureException {
594
595 if (gitPath == null) {
596 gitPath = "";
597 }
598
599
600 if (this.skip) {
601 getLog().info("Makeself is skipped");
602 return;
603 }
604
605
606 Path path = Path.of(buildTarget.concat(archiveDir));
607 if (!Files.exists(path)) {
608 throw new MojoExecutionException("ArchiveDir: missing '" + buildTarget.concat(archiveDir) + "'");
609 }
610
611
612 if (inlineScript) {
613
614 if (scriptArgs == null) {
615 throw new MojoExecutionException("ScriptArgs required when running inlineScript");
616 }
617 } else {
618
619 if (!startupScript.startsWith("./")) {
620 throw new MojoExecutionException("StartupScript required to start with './'");
621 }
622
623
624 path = Path.of(buildTarget.concat(archiveDir).concat(startupScript.substring(1)));
625 if (!Files.exists(path)) {
626 throw new MojoExecutionException("StartupScript: missing '"
627 + buildTarget.concat(archiveDir).concat(startupScript.substring(1)) + "'");
628 }
629 }
630
631
632 this.extractMakeself();
633
634
635 if (MakeselfMojo.WINDOWS) {
636 if (!gitPath.isEmpty() && Files.exists(Path.of(gitPath))) {
637 getLog().debug("Using existing 'Git' found at " + gitPath);
638 gitPath = gitPath + GIT_USER_BIN;
639 } else {
640 this.checkGitSetup();
641 }
642 }
643
644 try {
645
646 getLog().debug("Execute Bash Version");
647 execute(Arrays.asList(gitPath + "bash", "--version"), !ATTACH_ARTIFACT);
648
649
650 getLog().debug("Execute Makeself Version");
651 execute(Arrays.asList(gitPath + "bash", makeself.toAbsolutePath().toString(), "--version"),
652 !ATTACH_ARTIFACT);
653
654
655 if (isTrue(version)) {
656 return;
657 }
658
659
660 if (isTrue(help)) {
661 getLog().debug("Execute Makeself Help");
662 execute(Arrays.asList(gitPath + "bash", makeself.toAbsolutePath().toString(), "--help"),
663 !ATTACH_ARTIFACT);
664 return;
665 }
666
667
668 getLog().debug("Loading Makeself Basic Configuration");
669 List<String> target = new ArrayList<>(
670 Arrays.asList(gitPath + "bash", makeself.toAbsolutePath().toString()));
671 target.addAll(loadArgs());
672 target.add(buildTarget.concat(archiveDir));
673 target.add(buildTarget.concat(fileName));
674 target.add(label);
675 target.add(startupScript);
676 if (scriptArgs != null) {
677 target.addAll(scriptArgs);
678 }
679
680
681 getLog().info("Running makeself build");
682
683
684 getLog().debug("Execute Makeself Build");
685 execute(target, ATTACH_ARTIFACT);
686
687
688 getLog().debug("Execute Makeself Info on Resulting Shell Script");
689 execute(Arrays.asList(gitPath + "bash", buildTarget.concat(fileName), "--info"), !ATTACH_ARTIFACT);
690
691
692 if (!MakeselfMojo.WINDOWS) {
693 getLog().debug("Execute Makeself List on Resulting Shell Script");
694 execute(Arrays.asList(gitPath + "bash", buildTarget.concat(fileName), "--list"), !ATTACH_ARTIFACT);
695 }
696
697
698 if (this.autoRun) {
699 getLog().info("Auto-run created shell (this may take a few minutes)");
700 execute(Arrays.asList(gitPath + "bash", buildTarget.concat(fileName)), !ATTACH_ARTIFACT);
701 }
702 } catch (IOException e) {
703 getLog().error("", e);
704 } catch (InterruptedException e) {
705 getLog().error("", e);
706
707 Thread.currentThread().interrupt();
708 }
709 }
710
711 private void execute(List<String> target, boolean attach) throws IOException, InterruptedException {
712
713
714 getLog().debug("Execution commands: " + target);
715
716
717 ProcessBuilder processBuilder = new ProcessBuilder(target);
718 processBuilder.redirectErrorStream(true);
719
720
721 if (MakeselfMojo.WINDOWS) {
722 Map<String, String> envs = processBuilder.environment();
723 getLog().debug("Environment Variables: " + envs);
724 final String location = repoSession.getLocalRepository().getBasedir() + File.separator
725 + this.portableGit.getName() + File.separator + this.portableGit.getVersion();
726
727 if (envs.get("Path") != null) {
728 envs.put("Path", location + "/usr/bin;" + envs.get("Path"));
729 getLog().debug("Environment Path Variable: " + envs.get("Path"));
730
731 } else if (envs.get("PATH") != null) {
732 envs.put("PATH",
733 location + "/usr/bin;" + envs.get("PATH").replace("Program Files", "\"Program Files\""));
734 getLog().debug("Environment Path Variable: " + envs.get("PATH"));
735 }
736 }
737
738
739 Process process = processBuilder.start();
740
741
742 try (BufferedReader reader = new BufferedReader(
743 new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8))) {
744 String line = "";
745 while ((line = reader.readLine()) != null) {
746 getLog().info(line);
747 }
748 getLog().info("");
749 }
750
751
752 int status = process.waitFor();
753 if (status > 0) {
754 getLog().error(String.join(" ", "makeself failed with error status:", String.valueOf(status)));
755 }
756
757
758 if (status == 0 && attach) {
759 projectHelper.attachArtifact(project, this.extension, this.classifier,
760 Path.of(buildTarget, FilenameUtils.getName(fileName)).toFile());
761 }
762 }
763
764
765
766
767 private void extractMakeself() {
768 getLog().debug("Extracting Makeself");
769
770
771 Path makeselfTemp = Path.of(makeselfTempDirectory.getAbsolutePath());
772 if (!Files.exists(makeselfTemp) && !makeselfTemp.toFile().mkdirs()) {
773 getLog().error(String.join(" ", "Unable to make directory", makeselfTempDirectory.getAbsolutePath()));
774 return;
775 }
776 getLog().debug(String.join(" ", "Created directory for", makeselfTempDirectory.getAbsolutePath()));
777
778 ClassLoader classloader = this.getClass().getClassLoader();
779
780
781 makeself = makeselfTempDirectory.toPath().resolve("makeself.sh");
782 if (!Files.exists(makeself)) {
783 getLog().debug("Writing makeself.sh");
784 try (InputStream link = classloader.getResourceAsStream("META-INF/makeself/makeself.sh")) {
785 Path path = makeself.toAbsolutePath();
786 Files.copy(link, path);
787 setFilePermissions(makeself.toFile());
788 setPosixFilePermissions(path);
789 } catch (IOException e) {
790 getLog().error("", e);
791 }
792 }
793
794
795 Path makeselfHeader = makeselfTempDirectory.toPath().resolve("makeself-header.sh");
796 if (!Files.exists(makeselfHeader)) {
797 getLog().debug("Writing makeself-header.sh");
798 try (InputStream link = classloader.getResourceAsStream("META-INF/makeself/makeself-header.sh")) {
799 Path path = makeselfHeader.toAbsolutePath();
800 Files.copy(link, path);
801 setFilePermissions(makeselfHeader.toFile());
802 setPosixFilePermissions(path);
803 } catch (IOException e) {
804 getLog().error("", e);
805 }
806 }
807 }
808
809
810
811
812
813
814
815 private void checkGitSetup() throws MojoFailureException {
816
817 this.portableGit = new PortableGit(getLog());
818
819
820 this.extractPortableGit();
821 }
822
823
824
825
826
827
828
829 private void extractPortableGit() throws MojoFailureException {
830 final String location = repoSession.getLocalRepository().getBasedir() + File.separator
831 + this.portableGit.getName() + File.separator + this.portableGit.getVersion();
832 if (Files.exists(Path.of(location))) {
833 getLog().debug("Existing 'PortableGit' folder found at " + location);
834 gitPath = location + GIT_USER_BIN;
835 return;
836 }
837
838 getLog().info("Loading portable git");
839 final Artifact artifact = new DefaultArtifact(this.portableGit.getGroupId(), this.portableGit.getArtifactId(),
840 this.portableGit.getClassifier(), this.portableGit.getExtension(), this.portableGit.getVersion());
841 final ArtifactRequest artifactRequest = new ArtifactRequest().setRepositories(this.remoteRepositories)
842 .setArtifact(artifact);
843 ArtifactResult resolutionResult = null;
844 try {
845 resolutionResult = repositorySystem.resolveArtifact(repoSession, artifactRequest);
846 if (!resolutionResult.isResolved()) {
847 throw new MojoFailureException("Unable to resolve artifact: " + artifact.getGroupId() + ":"
848 + artifact.getArtifactId() + ":" + artifact.getVersion() + ":" + artifact.getClassifier() + ":"
849 + artifact.getExtension());
850 }
851 } catch (ArtifactResolutionException e) {
852 throw new MojoFailureException(
853 "Unable to resolve artifact: " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":"
854 + artifact.getVersion() + ":" + artifact.getClassifier() + ":" + artifact.getExtension());
855 }
856 this.installGit(resolutionResult.getArtifact(), location);
857 }
858
859
860
861
862
863
864
865
866
867 private void installGit(final Artifact artifact, final String location) {
868 Path currentFile = null;
869
870
871
872 try (InputStream inputStream = Files.newInputStream(artifact.getFile().toPath());
873 InputStream bufferedStream = new BufferedInputStream(inputStream);
874 InputStream gzipStream = new GzipCompressorInputStream(bufferedStream);
875 ArchiveInputStream<TarArchiveEntry> tarStream = new TarArchiveInputStream(gzipStream)) {
876 ArchiveEntry entry;
877 String directory = repoSession.getLocalRepository().getBasedir() + File.separator
878 + this.portableGit.getName();
879 while ((entry = tarStream.getNextEntry()) != null) {
880 if (entry.isDirectory()) {
881 continue;
882 }
883 currentFile = Path.of(directory, entry.getName());
884 if (!currentFile.normalize().startsWith(directory)) {
885 throw new IOException("Bad zip entry, possible directory traversal");
886 }
887 Path parent = currentFile.getParent();
888 if (!Files.exists(parent)) {
889 Files.createDirectory(parent);
890 }
891 getLog().debug("Current file: " + currentFile.getFileName());
892 Files.copy(tarStream, currentFile, StandardCopyOption.REPLACE_EXISTING);
893 }
894 } catch (IOException e) {
895 getLog().error("", e);
896 }
897
898 try {
899 if (currentFile != null) {
900
901 getLog().debug("Extract Portable Git");
902 execute(Arrays.asList(currentFile.toString(), "-y", "-o", location), !ATTACH_ARTIFACT);
903 gitPath = location + GIT_USER_BIN;
904 }
905 } catch (IOException e) {
906 getLog().error("", e);
907 } catch (InterruptedException e) {
908 getLog().error("", e);
909
910 Thread.currentThread().interrupt();
911 }
912 }
913
914 private void setFilePermissions(File file) {
915 if (!file.setExecutable(true, true)) {
916 getLog().error(String.join(" ", "Unable to set executable:", file.getName()));
917 } else {
918 getLog().debug(String.join(" ", "Set executable for", file.getName()));
919 }
920 }
921
922 private void setPosixFilePermissions(Path path) {
923 final Set<PosixFilePermission> permissions = PosixFilePermissions.fromString(PERMISSIONS);
924
925 try {
926 Files.setPosixFilePermissions(path, permissions);
927 getLog().debug(String.join(" ", "Set Posix File Permissions for", path.toString(), "as", PERMISSIONS));
928 } catch (IOException e) {
929 getLog().error("Failed attempted Posix permissions", e);
930 } catch (UnsupportedOperationException e) {
931
932 getLog().debug("Failed attempted Posix permissions", e);
933 }
934 }
935
936
937
938
939
940
941 private List<String> loadArgs() {
942 getLog().debug("Loading arguments");
943
944 List<String> args = new ArrayList<>(50);
945
946
947 if (isTrue(tarQuietly)) {
948 args.add("--tar-quietly");
949 }
950
951
952 if (isTrue(quiet)) {
953 args.add("--quiet");
954 }
955
956
957 if (isTrue(gzip)) {
958 args.add("--gzip");
959 }
960
961
962
963
964 if (isTrue(bzip2)) {
965 args.add("--bzip2");
966 }
967
968
969
970
971 if (isTrue(bzip3)) {
972 args.add("--bzip3");
973 }
974
975
976
977
978 if (isTrue(pbzip2)) {
979 args.add("--pbzip2");
980 }
981
982
983
984
985 if (isTrue(xz)) {
986 args.add("--xz");
987 }
988
989
990
991
992 if (isTrue(lzo)) {
993 args.add("--lzo");
994 }
995
996
997
998
999 if (isTrue(lz4)) {
1000 args.add("--lz4");
1001 }
1002
1003
1004 if (isTrue(zstd)) {
1005 args.add("--zstd");
1006 }
1007
1008
1009 if (isTrue(pigz)) {
1010 args.add("--pigz");
1011 }
1012
1013
1014 if (isTrue(base64)) {
1015 args.add("--base64");
1016 }
1017
1018
1019
1020 if (isTrue(gpgEncrypt)) {
1021 args.add("--gpg-encrypt");
1022 }
1023
1024
1025 if (isTrue(gpgAsymmetricEncryptSign)) {
1026 args.add("--gpg-asymmetric-encrypt-sign");
1027 }
1028
1029
1030
1031 if (isTrue(sslEncrypt)) {
1032 args.add("--ssl-encrypt");
1033 }
1034
1035
1036 if (sslPasswd != null) {
1037 args.add("--ssl-passwd");
1038 args.add(sslPasswd);
1039 }
1040
1041
1042
1043
1044 if (sslPassSrc != null) {
1045 args.add("--ssl-pass-src");
1046 args.add(sslPassSrc);
1047 }
1048
1049
1050 if (isTrue(sslNoMd)) {
1051 args.add("--ssl-no-md");
1052 }
1053
1054
1055
1056 if (isTrue(compress)) {
1057 args.add("--compress");
1058 }
1059
1060
1061 if (complevel != null) {
1062 args.add("--complevel");
1063 args.add(complevel.toString());
1064 }
1065
1066
1067 if (compExtra != null) {
1068 args.add("--comp-extra");
1069 args.add(compExtra);
1070 }
1071
1072
1073 if (isTrue(nochown)) {
1074 args.add("--nochown");
1075 }
1076
1077
1078 if (isTrue(chown)) {
1079 args.add("--chown");
1080 }
1081
1082
1083 if (isTrue(nocomp)) {
1084 args.add("--nocomp");
1085 }
1086
1087
1088
1089
1090
1091 if (threads != null) {
1092 args.add("--threads");
1093 args.add(threads.toString());
1094 }
1095
1096
1097
1098
1099 if (isTrue(notemp)) {
1100 args.add("--notemp");
1101 }
1102
1103
1104 if (isTrue(needroot)) {
1105 args.add("--needroot");
1106 }
1107
1108
1109
1110 if (isTrue(current)) {
1111 args.add("--current");
1112 }
1113
1114
1115
1116 if (isTrue(follow)) {
1117 args.add("--follow");
1118 }
1119
1120
1121 if (isTrue(noprogress)) {
1122 args.add("--noprogress");
1123 }
1124
1125
1126
1127
1128 if (isTrue(append)) {
1129 args.add("--append");
1130 }
1131
1132
1133
1134
1135 if (headerFile != null) {
1136 args.add("--header");
1137 args.add(headerFile);
1138 }
1139
1140
1141
1142 if (preextractScript != null) {
1143 args.add("--reextract");
1144 args.add(preextractScript);
1145 }
1146
1147
1148
1149 if (cleanupScript != null) {
1150 args.add("--cleanup");
1151 args.add(cleanupScript);
1152 }
1153
1154
1155
1156
1157
1158 if (isTrue(copy)) {
1159 args.add("--copy");
1160 }
1161
1162
1163 if (isTrue(nox11)) {
1164 args.add("--nox11");
1165 }
1166
1167
1168 if (isTrue(nowait)) {
1169 args.add("--nowait");
1170 }
1171
1172
1173
1174 if (isTrue(nomd5)) {
1175 args.add("--nomd5");
1176 }
1177
1178
1179
1180 if (isTrue(nocrc)) {
1181 args.add("--nocrc");
1182 }
1183
1184
1185 if (isTrue(sha256)) {
1186 args.add("--sha256");
1187 }
1188
1189
1190
1191
1192
1193 if (lsmFile != null) {
1194 args.add("--lsm");
1195 args.add(lsmFile);
1196 }
1197
1198
1199 if (gpgExtraOpt != null) {
1200 args.add("--gpg-extra");
1201 args.add(gpgExtraOpt);
1202 }
1203
1204
1205
1206 if (tarFormatOpt != null) {
1207 args.add("--tar-format");
1208 args.add(tarFormatOpt);
1209 }
1210
1211
1212
1213
1214 if (tarExtraOpt != null) {
1215 args.add("--tar-extra");
1216 args.add(tarExtraOpt);
1217 }
1218
1219
1220 if (untarExtraOpt != null) {
1221 args.add("--untar-extra");
1222 args.add(untarExtraOpt);
1223 }
1224
1225
1226 if (signPassphrase != null) {
1227 args.add("--sign");
1228 args.add(signPassphrase);
1229 }
1230
1231
1232
1233 if (extractTargetDir != null) {
1234 args.add("--target");
1235 args.add(extractTargetDir);
1236 }
1237
1238
1239
1240 if (isTrue(keepUmask)) {
1241 args.add("--keep-umask");
1242 }
1243
1244
1245 if (isTrue(exportConf)) {
1246 args.add("--export-conf");
1247 }
1248
1249
1250 if (packagingDate != null) {
1251 args.add("--packaging-date");
1252 args.add(packagingDate);
1253 }
1254
1255
1256 if (licenseFile != null) {
1257 args.add("--license");
1258 args.add(licenseFile);
1259 }
1260
1261
1262 if (isTrue(nooverwrite)) {
1263 args.add("--nooverwrite");
1264 }
1265
1266
1267 if (helpHeaderFile != null) {
1268 args.add("--help-header");
1269 args.add(helpHeaderFile);
1270 }
1271
1272 return args;
1273 }
1274
1275 private boolean isTrue(Boolean value) {
1276 if (value != null) {
1277 return value.booleanValue();
1278 }
1279 return false;
1280 }
1281
1282 }