Skip to content

Commit ca7d0c9

Browse files
author
mdaraujo19
committed
Adds PPA creation, signing and publish functions.
1 parent 84ab051 commit ca7d0c9

32 files changed

+1799
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ target
55
.settings
66
.idea
77
.vscode
8+
.pmd
89
/bin/

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ There are some **requirements** (tools and programs) that are needed for the suc
1212

1313
- Have **Maven** installed.
1414
- Have **Java 11 SE** installed and configured.
15-
- Have access to the **dpkg**, **rpm**, **snap**, **snapcraft**, **lxd**, **gpg** and **curl** commands, as well as being on a GNU/Linux operating system.
15+
- Have access to the **dpkg**, **rpm**, **snap**, **snapcraft**, **lxd**, **gpg**, **curl**, **debuild**, **debsign** and **dput** commands, as well as being on a GNU/Linux operating system.
1616
- Recommended to have the **latests version of the Java to Distributable** project.
1717

1818
If you already meet this requirements, you are free to continue.
@@ -90,13 +90,20 @@ The tags that can be placed in the `choices.xml` file are:
9090
- `<nexusUsername>` represents the Nexus repository username that is allowed to publish RPMs.
9191
- `<nexusRepoUrl>` represents the Nexus repository URL were the RPM package will be published to.
9292
- `<releaseChannel>` represents the Snapcraft store release channel were the snap package will be published to.
93+
- `<contactName>` represents the name of the person responsible for contact.
94+
- `<contactEmail>` represents the E-mail of the person responsible for contact.
95+
- `<ubuntuCodeName>` represents the first word of the Ubuntu version code name.
96+
- `<key>` represents the GPG secret key ID for PPA package signing.
97+
- `<ppaUsername>` represents the Launchpad username of the PPA repository owner.
98+
- `<ppaName>` represents the name of the PPA repository.
9399

94100
## Commands
95101

96102
The execution of a command produces a **distributable** file. The commands available are:
97103
- `generate-deb-distributable`
98104
- `generate-snap-distributable`
99105
- `generate-rpm-distributable`
106+
- `generate-ppa-distributable`
100107

101108
### Debian package (.deb)
102109

doc/Example_Java_To_Distributable_commands.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,34 @@ jtd generate-rpm-distributable --maven --maven-remote-repositories https://maven
352352

353353
During the process, the user is required to enter the Nexus repository username's password interactively so keep that in mind.
354354

355+
## PPA (Personal Package Archive) Distributable File Generation (generate-ppa-distributable command)
356+
357+
A overview of the command syntax is:
358+
359+
```
360+
jtd generate-ppa-distributable [--verbose/-ve] {--maven/-mvn | --jar/-j} [--jar-file/-jf JAR_PATH...] [--input-pom-file/-ipf POM_PATH | { --maven-remote-repositories/-mrr URL_REPOSITORY… | --from-maven-central/-fmc | --from-maven-local/-fml } --maven-coordinates/-mc COORDINATE… ] [--ignore-central-repository/-icr] [--prioritize-local-m2-repository/-plr] [--main-name/-mn PACKAGE_MAIN_NAME] [--application-class-name/-acn MAIN_CLASS_NAME...] [--choices-file/-cf CHOICES_PATH] --output-directory/-od OUTPUT_DIRECTORY [--dependency/-d DEPENDENCY...] [--documentation/-d DOCUMENTATION_URL] [--target-command-name/-tcn TARGET_COMMAND_NAME...] [--application-name/-an APPLICATION_NAME] [--application-version/-av APPLICATION_VERSION] [--application-description/-ad APPLICATION_DESCRIPTION] [--java-dependency/-jd JAVA_DEPENDENCY] [--man-page/-mp MAN_PAGE_PATH] [--java-run-arg/-jra JAVA_RUN_ARGUMENT...] [--number-java-run-arg/-njra NUMBER_JAVA_RUN_ARGUMENT...] [--license/-l LICENSE] [--maintainer/-m MAINTAINER_NAME] [--category/-c CATEGORY...] [--contact-name/-cn CONTACT_NAME] [--contact-email/-ce CONTACT_EMAIL] [--ubuntu-code-name/-ucn UBUNTU_CODE_NAME] [--key/-k GPG_SECRET_KEY_ID] [--ppa-username/-pu PPA_OWNER_USERNAME] [--ppa-name/-pn PPA_NAME]
361+
```
362+
363+
### Sign a distributable
364+
365+
If you want to sign the resulting PPA distributable package after creation, you need to add the appropriate flag as follows:
366+
367+
```
368+
jtd generate-ppa-distributable --maven --maven-remote-repositories https://maven.sing-group.org/repository/maven-snapshots/ --maven-coordinates org.sing_group:seda:1.6.0-SNAPSHOT --maven-coordinates org.sing_group:seda-plugin-blast:1.6.0-SNAPSHOT --application-class-name org.sing_group.seda.cli.SedaCliApplication --output-directory <your_desired_output_path> --contact-name "John Doe" --contact-email "example@mail.com" --license gplv3 --sign --key <your_gpg_key>
369+
```
370+
371+
During the process, the user is required to enter the GPG key passphrase interactively so keep that in mind.
372+
373+
### Publish a distributable
374+
375+
If you want to publish the resulting PPA distributable package after creation, you need to add the appropriate flag and provide some additional information as follows:
376+
377+
```
378+
jtd generate-rpm-distributable --maven --maven-remote-repositories https://maven.sing-group.org/repository/maven-snapshots/ --maven-coordinates org.sing_group:seda:1.6.0-SNAPSHOT --maven-coordinates org.sing_group:seda-plugin-blast:1.6.0-SNAPSHOT --application-class-name org.sing_group.seda.cli.SedaCliApplication --output-directory <your_desired_output_path> --contact-name "John Doe" --contact-email example@mail.com --license gplv3 --sign --key <your_gpg_key> --publish --ppa-username jdoe24 --ppa-name exampleppa
379+
```
380+
381+
Note that it is required to also sign the package in order to publish in a PPA.
382+
355383
## Build a multi-command distributable
356384

357385
If you need to package multiple commands in the same distributable file, you can add more classes and command names as follows:

src/main/java/es/uvigo/esei/sing/java_to_distributable/cli/JavaToDistributableApplication.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import es.uvigo.esei.sing.java_to_distributable.cli.command.GenerateDebianDistributableCommand;
3737
import es.uvigo.esei.sing.java_to_distributable.cli.command.GenerateRPMDistributableCommand;
3838
import es.uvigo.esei.sing.java_to_distributable.cli.command.GenerateSnapcraftDistributableCommand;
39+
import es.uvigo.esei.sing.java_to_distributable.cli.command.GeneratePPADistributableCommand;
3940

4041
/**
4142
* A specialization of {@link CLIApplication} and represents the application
@@ -113,7 +114,7 @@ protected String getDescription() {
113114
protected List<Command> buildCommands() {
114115
return Arrays.asList(
115116
new GenerateDebianDistributableCommand(), new GenerateSnapcraftDistributableCommand(),
116-
new GenerateRPMDistributableCommand()
117+
new GenerateRPMDistributableCommand(), new GeneratePPADistributableCommand()
117118
);
118119
}
119120

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
/*
2+
* #%L
3+
* Java to distributable
4+
* %%
5+
* Copyright (C) 2023 - 2024 Miguel Jose Da Silva Araujo, Daniel Glez-Peña,
6+
* Hugo López-Fernández, and Miguel Reboiro-Jato
7+
* %%
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public
19+
* License along with this program. If not, see
20+
* <http://www.gnu.org/licenses/gpl-3.0.html>.
21+
* #L%
22+
*/
23+
/**
24+
*
25+
*/
26+
package es.uvigo.esei.sing.java_to_distributable.cli.command;
27+
28+
import java.io.File;
29+
import java.util.ArrayList;
30+
import java.util.Arrays;
31+
import java.util.List;
32+
import java.util.Map;
33+
34+
import org.slf4j.Logger;
35+
import org.slf4j.LoggerFactory;
36+
37+
import es.uvigo.ei.sing.yacli.command.option.EnumOption;
38+
import es.uvigo.ei.sing.yacli.command.option.Option;
39+
import es.uvigo.ei.sing.yacli.command.option.StringOption;
40+
import es.uvigo.esei.sing.java_to_distributable.enums.OptionCategoryEnum;
41+
import es.uvigo.esei.sing.java_to_distributable.enums.UbuntuCodeNameEnum;
42+
import es.uvigo.esei.sing.java_to_distributable.model.AppInfo;
43+
import es.uvigo.esei.sing.java_to_distributable.utils.output.AppOutputGenerator;
44+
import es.uvigo.esei.sing.java_to_distributable.utils.output.PPAAppOutputGenerator;
45+
import es.uvigo.esei.sing.java_to_distributable.utils.output.OutputGenerator;
46+
import es.uvigo.esei.sing.java_to_distributable.utils.output.sign.PPASignerAppOutputGenerator;
47+
import es.uvigo.esei.sing.java_to_distributable.utils.output.publish.PPAPublisherAppOutputGenerator;
48+
49+
/**
50+
* An specialization of {@link GenerateDistributableCommand} that generates a
51+
* Debian sources packages that can be published to a PPA.
52+
*
53+
* @author Miguel José Da Silva Araujo
54+
*
55+
*/
56+
public class GeneratePPADistributableCommand extends GenerateDistributableCommand {
57+
58+
private static final StringOption MAINTAINER_OPTION = new StringOption(
59+
Arrays.asList(OptionCategoryEnum.CUSTOM.getCategory()), "maintainer", "m",
60+
"The maintainer's name of the package/application.", true, true, false
61+
);
62+
63+
private static final StringOption CONTACT_NAME_OPTION = new StringOption(
64+
Arrays.asList(OptionCategoryEnum.CUSTOM.getCategory()), "contact-name", "cn",
65+
"The name of the person responsible for contact.", true, true, false
66+
);
67+
68+
private static final StringOption CONTACT_EMAIL_OPTION = new StringOption(
69+
Arrays.asList(OptionCategoryEnum.CUSTOM.getCategory()), "contact-email", "ce",
70+
"The E-mail of the person responsible for contact.", true, true, false
71+
);
72+
73+
private static final EnumOption<UbuntuCodeNameEnum> UBUNTU_CODE_NAME_OPTION = new EnumOption<>(
74+
Arrays.asList(OptionCategoryEnum.CUSTOM.getCategory()), "ubuntu-code-name", "ucn",
75+
"The first word of the Ubuntu version code name.", UbuntuCodeNameEnum.class, "jammy", true, true, false
76+
);
77+
78+
private static final StringOption LICENSE_OPTION = new StringOption(
79+
Arrays.asList(OptionCategoryEnum.CUSTOM.getCategory()), "licence", "l",
80+
"The name of the licence of the application.", true, true, false
81+
);
82+
83+
private static final StringOption KEY_OPTION = new StringOption(
84+
Arrays.asList(OptionCategoryEnum.SIGN.getCategory()), "key", "k",
85+
"The GPG secret key ID for package signing.", true, true, false
86+
);
87+
88+
private static final StringOption PPA_USERNAME_OPTION = new StringOption(
89+
Arrays.asList(OptionCategoryEnum.PUBLISH.getCategory()), "ppa-username", "pu",
90+
"The Launchpad username of the PPA repository owner.", true, true, false
91+
);
92+
93+
private static final StringOption PPA_NAME_OPTION = new StringOption(
94+
Arrays.asList(OptionCategoryEnum.PUBLISH.getCategory()), "ppa-name", "pn",
95+
"The name of the PPA repository.", true, true, false
96+
);
97+
98+
/**
99+
* Gets the command name.
100+
*
101+
* @return the command name as a {@code String}.
102+
*
103+
*/
104+
@Override
105+
public String getName() {
106+
return "generate-ppa-distributable";
107+
}
108+
109+
/**
110+
* Gets the command descriptive name.
111+
*
112+
* @return the command descriptive name as a {@code String}.
113+
*
114+
*/
115+
@Override
116+
public String getDescriptiveName() {
117+
return "Generate GNU/Linux Debian source packages from Java for PPA (Personal Package Archives)";
118+
}
119+
120+
/**
121+
* Gets the command description.
122+
*
123+
* @return the command description as a {@code String}.
124+
*
125+
*/
126+
@Override
127+
public String getDescription() {
128+
return "Generates the corresponding GNU/Linux Debian source packages from a set of Java sources for publishing in a PPA (Personal Package Archives) repository.";
129+
}
130+
131+
@Override
132+
protected List<Option<?>> createDistributableOptions() {
133+
final List<Option<?>> options = new ArrayList<>();
134+
135+
options.add(MAINTAINER_OPTION);
136+
options.add(CONTACT_NAME_OPTION);
137+
options.add(CONTACT_EMAIL_OPTION);
138+
options.add(UBUNTU_CODE_NAME_OPTION);
139+
options.add(LICENSE_OPTION);
140+
options.add(KEY_OPTION);
141+
options.add(PPA_USERNAME_OPTION);
142+
options.add(PPA_NAME_OPTION);
143+
144+
return options;
145+
}
146+
147+
@Override
148+
protected OutputGenerator getOutputGenerator(File output, AppInfo info, Map<String, Boolean> options) {
149+
AppOutputGenerator gen = new PPAAppOutputGenerator(info, output);
150+
for (String option : options.keySet()) {
151+
switch (option.toUpperCase()) {
152+
case "SIGN":
153+
if (options.get(option) == true)
154+
gen = new PPASignerAppOutputGenerator(gen);
155+
break;
156+
case "PUBLISH":
157+
if (options.get(option) == true)
158+
gen = new PPAPublisherAppOutputGenerator(gen);
159+
break;
160+
default:
161+
LOGGER.warn("Option: " + option + " not supported.");
162+
break;
163+
}
164+
}
165+
return gen;
166+
}
167+
168+
/**
169+
* Gets and returns the command {@code Logger}.
170+
*
171+
* @return the command {@code Logger}
172+
*
173+
*/
174+
@Override
175+
protected Logger getLogger() {
176+
return LoggerFactory.getLogger(GeneratePPADistributableCommand.class);
177+
}
178+
179+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* #%L
3+
* Java to distributable
4+
* %%
5+
* Copyright (C) 2023 - 2024 Miguel Jose Da Silva Araujo, Daniel Glez-Peña,
6+
* Hugo López-Fernández, and Miguel Reboiro-Jato
7+
* %%
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public
19+
* License along with this program. If not, see
20+
* <http://www.gnu.org/licenses/gpl-3.0.html>.
21+
* #L%
22+
*/
23+
/**
24+
*
25+
*/
26+
package es.uvigo.esei.sing.java_to_distributable.enums;
27+
28+
/**
29+
* Enumeration representing different versions of Ubuntu. Each enum value
30+
* represents a specific version by its code name.
31+
*
32+
* @author Miguel José Da Silva Araujo
33+
*
34+
*/
35+
public enum UbuntuCodeNameEnum {
36+
37+
/**
38+
* Represents the 20.04 version of Ubuntu "Focal Fossa".
39+
*/
40+
focal("focal"),
41+
42+
/**
43+
* Represents the 22.04 version of Ubuntu "Jammy Jellyfish".
44+
*/
45+
jammy("jammy"),
46+
47+
/**
48+
* Represents the 24.04 version of Ubuntu "Noble Numbat".
49+
*/
50+
noble("noble");
51+
52+
private String codeName;
53+
54+
private UbuntuCodeNameEnum(String codeName) {
55+
this.codeName = codeName;
56+
}
57+
58+
/**
59+
* Gets the Ubuntu code name.
60+
*
61+
* @return the {@code String} representation of the Ubuntu code name.
62+
*
63+
*/
64+
public String getCodeName() {
65+
return this.codeName;
66+
}
67+
68+
}

0 commit comments

Comments
 (0)