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