Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rednoah/ant-spk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.6
Choose a base ref
...
head repository: rednoah/ant-spk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 11 commits
  • 22 files changed
  • 3 contributors

Commits on Jun 23, 2018

  1. Remove WTF code

    rednoah committed Jun 23, 2018
    Copy the full SHA
    e57667b View commit details

Commits on Apr 6, 2020

  1. Fix broken links

    rednoah authored Apr 6, 2020
    Copy the full SHA
    c418d30 View commit details
  2. Fix broken links

    rednoah authored Apr 6, 2020
    Copy the full SHA
    f23b36f View commit details

Commits on Dec 18, 2020

  1. Copy the full SHA
    d7f6e90 View commit details

Commits on Jun 15, 2021

  1. Fix for Gradle 6.9

    rednoah committed Jun 15, 2021
    Copy the full SHA
    1081ee7 View commit details
  2. Copy the full SHA
    f889c06 View commit details
  3. brew install gradle@6

    rednoah committed Jun 15, 2021
    Copy the full SHA
    4473021 View commit details

Commits on Jun 16, 2021

  1. Update dependencies

    rednoah committed Jun 16, 2021
    Copy the full SHA
    23fd5eb View commit details

Commits on Jul 6, 2021

  1. Update README.md

    rednoah authored Jul 6, 2021
    Copy the full SHA
    6a6bba8 View commit details

Commits on Dec 17, 2021

  1. Requires Gradle 6.9

    rednoah committed Dec 17, 2021
    Copy the full SHA
    b27ef15 View commit details
  2. Copy the full SHA
    c45566e View commit details
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ __Ant SPK Task__
* Much more easy to use than whats in the official Synology SDK docs & tools
* Automatically create and sign your SPK packages in your automated Ant build
* Works on Windows, Mac and Linux (including Synology DSM) and any other device that can run Java 8
* Supports passphrase protected GPG keychains

Have a quick look at the [Synology DSM 3rd Party Apps Developer Guide](https://global.download.synology.com/download/Document/DeveloperGuide/DSM_Developer_Guide.pdf) and read the **Package Structure** section to learn more on how SPK packages work.

@@ -31,16 +30,14 @@ Have a quick look at the [Synology DSM 3rd Party Apps Developer Guide](https://
<info name="dsmappname" value="org.example.HelloWorld" />
<info name="dsmuidir" value="dsm" />

<icon size="72" file="app/dsm/images/icon_72.png" />
<icon file="app/dsm/images/icon_64.png" />
<icon size="256" file="app/dsm/images/icon_256.png" />

<wizard dir="spk/wizard" />
<scripts dir="spk/scripts" filemode="755" />

<package dir="app" includes="**/*.sh" filemode="755" />
<package dir="app" excludes="**/*.sh" />

<codesign keyid="D545C93D" secring="gpg/secring.gpg" password="" />
</syno:spk>

</target>
@@ -49,13 +46,13 @@ Have a quick look at the [Synology DSM 3rd Party Apps Developer Guide](https://
```

## Downloads
[ant-spk](https://github.com/rednoah/ant-spk) is available on available on [Maven Central](https://mvnrepository.com/artifact/net.filebot/ant-spk). Use [Apache Ivy](http://ant.apache.org/ivy/) to retrieve all the dependencies:
[ant-spk](https://github.com/rednoah/ant-spk) is available on [Maven Central](https://mvnrepository.com/artifact/net.filebot/ant-spk). Use [Apache Ivy](http://ant.apache.org/ivy/) to retrieve all the dependencies:
```xml
<dependency org="net.filebot" name="ant-spk" rev="latest.release" />
<dependency org="net.filebot" name="ant-spk" rev="0.7.1" />
```

## Build
[ant-spk](https://github.com/rednoah/ant-spk) uses the [Gradle](https://gradle.org/gradle-download/) build tool. Call `gradle example` to fetch all dependencies and build the example project.
[ant-spk](https://github.com/rednoah/ant-spk) uses the [Gradle 6.9](https://gradle.org/gradle-download/) build tool. Call `gradle example` to fetch all dependencies and build the example project.

## Real World Examples
[ant-spk](https://github.com/rednoah/ant-spk) is used to automatically build `.spk` packages for the [FileBot](http://www.filebot.net/) project, so check out [filebot](http://www.filebot.net/) [build.xml](https://github.com/filebot/filebot/blob/master/build.xml) or [filebot-node](https://github.com/filebot/filebot-node) [build.xml](https://github.com/filebot/filebot-node/blob/master/build.xml) or [java-installer](https://github.com/rednoah/java-installer) [build.xml](https://github.com/rednoah/java-installer/blob/master/build.xml) or [ant-installer](https://github.com/rednoah/ant-installer) [build.xml](https://github.com/rednoah/ant-installer/blob/master/build.xml) for a set of more comprehensive examples. 🚀
[ant-spk](https://github.com/rednoah/ant-spk) is used to automatically build `.spk` packages for the [FileBot](http://www.filebot.net/) project, so check out [filebot-node](https://github.com/filebot/filebot-node) [build.xml](https://github.com/filebot/filebot-node/blob/master/build.xml) or [java-installer](https://github.com/rednoah/java-installer) [build.xml](https://github.com/rednoah/java-installer/blob/master/build.xml) for a set of more comprehensive examples. 🚀
21 changes: 13 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -7,10 +7,15 @@ apply plugin: 'signing'

group = 'net.filebot'
archivesBaseName = 'ant-spk'
version = '0.6'
version = '0.7.1'



compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
@@ -38,13 +43,13 @@ repositories {
}

dependencies {
compileOnly 'org.apache.ant:ant:1.10.1'
compile 'org.bouncycastle:bcprov-jdk15on:1.56'
compile 'org.bouncycastle:bcpg-jdk15on:1.56'
compile 'org.apache.httpcomponents:httpcore:4.4.6'
compile 'org.apache.httpcomponents:httpmime:4.5.2'
compile 'org.apache.httpcomponents:httpclient:4.5.2'
compile 'org.glassfish:javax.json:1.0.4'
compileOnly 'org.apache.ant:ant:1.10.10'
compile 'org.bouncycastle:bcprov-jdk15on:1.69'
compile 'org.bouncycastle:bcpg-jdk15on:1.69'
compile 'org.apache.httpcomponents:httpcore:4.4.14'
compile 'org.apache.httpcomponents:httpmime:4.5.13'
compile 'org.apache.httpcomponents:httpclient:4.5.13'
compile 'org.glassfish:javax.json:1.1.4'
}


2 changes: 0 additions & 2 deletions build.sh

This file was deleted.

2 changes: 0 additions & 2 deletions deploy.sh

This file was deleted.

Binary file modified examples/helloworld/app/dsm/images/icon_256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/helloworld/app/dsm/images/icon_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed examples/helloworld/app/dsm/images/icon_72.png
Binary file not shown.
2 changes: 0 additions & 2 deletions examples/helloworld/build.sh

This file was deleted.

13 changes: 5 additions & 8 deletions examples/helloworld/build.xml
Original file line number Diff line number Diff line change
@@ -15,24 +15,21 @@
<info name="dsmappname" value="org.example.HelloWorld" />
<info name="dsmuidir" value="dsm" />

<icon size="72" file="app/dsm/images/icon_72.png" />
<icon file="app/dsm/images/icon_64.png" />
<icon size="256" file="app/dsm/images/icon_256.png" />

<wizard dir="spk/wizard" />
<scripts dir="spk/scripts" filemode="755" />

<package dir="app" includes="**/*.sh" filemode="755" />
<package dir="app" excludes="**/*.sh" />

<codesign keyid="D545C93D" secring="gpg/secring.gpg" password="" />
</syno:spk>

<syno:package-source file="dist/spksrc.json">
<keyring file="gpg/alice.pub" />
<syno:package-source file="dist/syno.json">
<spk file="dist/${package}-${version}-noarch.spk">
<info name="link" value="http://packages.example.org/${package}-${version}-noarch.spk" />
<thumbnail url="http://images.example.org/${package}/thumbnail.png" />
<snapshot url="http://images.example.org/${package}/screenshot.png" />
<info name="link" value="https://packages.example.org/${package}-${version}-noarch.spk" />
<thumbnail url="https://images.example.org/${package}/thumbnail.png" />
<snapshot url="https://images.example.org/${package}/screenshot.png" />
</spk>
</syno:package-source>
</target>
30 changes: 0 additions & 30 deletions examples/helloworld/gpg/alice.pub

This file was deleted.

Binary file removed examples/helloworld/gpg/pubring.gpg
Binary file not shown.
Binary file removed examples/helloworld/gpg/secring.gpg
Binary file not shown.
5 changes: 5 additions & 0 deletions examples/helloworld/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ANT := ant -lib lib

build:
$(ANT) retrieve
$(ANT) spk
19 changes: 19 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
GRADLE := docker run --rm -v "$(PWD)":/ant-spk -w /ant-spk gradle:6-jdk11 gradle

jar:
$(GRADLE) clean build

example:
cd "$(PWD)/examples/helloworld" && ant -lib "$(PWD)/build/libs" -lib "lib"

deploy:
$(GRADLE) clean uploadArchives
# open "https://oss.sonatype.org/#stagingRepositories"

eclipse:
$(GRADLE) cleanEclipse eclipse

clean:
git reset --hard
git pull
git --no-pager log -1
2 changes: 1 addition & 1 deletion src/main/java/net/filebot/ant/spk/CodeSignTask.java
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
import org.apache.tools.ant.types.Resource;
import org.bouncycastle.openpgp.PGPException;

import net.filebot.ant.spk.openpgp.OpenPGPSignature;
import net.filebot.ant.spk.pgp.OpenPGPSignature;

public class CodeSignTask extends Task {

12 changes: 10 additions & 2 deletions src/main/java/net/filebot/ant/spk/Icon.java
Original file line number Diff line number Diff line change
@@ -4,15 +4,23 @@

public class Icon {

IconSize size;
Integer size;
File file;

public void setSize(IconSize size) {
public void setSize(Integer size) {
this.size = size;
}

public void setFile(File file) {
this.file = file;
}

public String getPackageName() {
if (size == null || size.equals(64) || size.equals(72)) {
return "PACKAGE_ICON.PNG";
} else {
return "PACKAGE_ICON_" + size + ".PNG";
}
}

}
20 changes: 0 additions & 20 deletions src/main/java/net/filebot/ant/spk/IconSize.java

This file was deleted.

15 changes: 7 additions & 8 deletions src/main/java/net/filebot/ant/spk/PackageTask.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package net.filebot.ant.spk;

import static java.nio.charset.StandardCharsets.*;
import static net.filebot.ant.spk.Info.*;
import static net.filebot.ant.spk.util.Digest.*;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
@@ -81,7 +80,7 @@ public void addConfiguredConf(TarFileSet files) {

public void addConfiguredIcon(Icon icon) {
TarFileSet files = new TarFileSet();
files.setFullpath(icon.size.getFileName());
files.setFullpath(icon.getPackageName());
files.setFile(icon.file);
spkFiles.add(files);
}
@@ -162,15 +161,15 @@ private void preparePackage(File tempDirectory) {

private void prepareInfo(File tempDirectory) {
StringBuilder infoText = new StringBuilder();
for (Entry<String, String> it : infoList.entrySet()) {
infoText.append(it.getKey()).append('=').append('"').append(it.getValue()).append('"').append('\n');
}
infoList.forEach((k, v) -> {
infoText.append(k).append('=').append('"').append(v).append('"').append('\n');
});

File infoFile = new File(tempDirectory, INFO);
log("Generating INFO: " + infoFile);
try {
Files.write(infoFile.toPath(), infoText.toString().getBytes("UTF-8"));
} catch (IOException e) {
Files.write(infoFile.toPath(), infoText.toString().getBytes(UTF_8));
} catch (Exception e) {
throw new BuildException("Failed to write INFO", e);
}

46 changes: 25 additions & 21 deletions src/main/java/net/filebot/ant/spk/RepositoryTask.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package net.filebot.ant.spk;

import static java.nio.charset.StandardCharsets.*;
import static java.util.Collections.*;
import static net.filebot.ant.spk.PackageTask.*;
import static net.filebot.ant.spk.util.Digest.*;

import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -114,42 +113,49 @@ public void execute() throws BuildException {
for (URLResource source : sources) {
try (JsonReader reader = Json.createReader(source.getInputStream())) {
JsonObject json = reader.readObject();
for (JsonValue k : json.getJsonArray(KEYRINGS)) {
log("Import keyring: " + source);
keyrings.add(normalizeKey(((JsonString) k).getString()));

if (json.getJsonArray(KEYRINGS) != null) {
for (JsonValue k : json.getJsonArray(KEYRINGS)) {
log("Import keyring: " + source);
keyrings.add(normalizeKey(((JsonString) k).getString()));
}
}
for (JsonValue p : json.getJsonArray(PACKAGES)) {
log("Import package: " + (((JsonString) ((JsonObject) p).get(PACKAGE))).getString());
jsonPackages.add(p);

if (json.getJsonArray(PACKAGES) != null) {
for (JsonValue p : json.getJsonArray(PACKAGES)) {
log("Import package: " + (((JsonString) ((JsonObject) p).get(PACKAGE))).getString());
jsonPackages.add(p);
}
}
} catch (Exception e) {
throw new BuildException(e);
}
}

JsonArrayBuilder jsonKeyrings = Json.createArrayBuilder();
keyrings.forEach(jsonKeyrings::add);

JsonObjectBuilder jsonRoot = Json.createObjectBuilder();
jsonRoot.add(KEYRINGS, jsonKeyrings);
if (keyrings.size() > 0) {
JsonArrayBuilder jsonKeyrings = Json.createArrayBuilder();
keyrings.forEach(jsonKeyrings::add);
jsonRoot.add(KEYRINGS, jsonKeyrings);
}
jsonRoot.add(PACKAGES, jsonPackages);

log("Write Package Source: " + index);
StringWriter json = new StringWriter();
try (JsonWriter writer = Json.createWriterFactory(singletonMap(JsonGenerator.PRETTY_PRINTING, true)).createWriter(json)) {
writer.writeObject(jsonRoot.build());
}
Files.write(index.toPath(), json.toString().trim().getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
Files.write(index.toPath(), json.toString().trim().getBytes(UTF_8));
} catch (Exception e) {
throw new BuildException(e);
}
}

public List<String> getKeyRings() throws IOException {
public List<String> getKeyRings() throws Exception {
List<String> keys = new ArrayList<String>();
for (Resource resource : keyrings) {
log("Include keyring: " + resource.getName());
String key = FileUtils.readFully(new InputStreamReader(resource.getInputStream(), StandardCharsets.US_ASCII));
String key = FileUtils.readFully(new InputStreamReader(resource.getInputStream(), US_ASCII));
if (key != null) {
keys.add(normalizeKey(key)); // make sure to normalize line endings
}
@@ -174,7 +180,7 @@ private String normalizeKey(String key) {
public static final String THUMBNAIL = "thumbnail";
public static final String SNAPSHOT = "snapshot";

public List<Map<String, Object>> getPackages() throws IOException {
public List<Map<String, Object>> getPackages() throws Exception {
List<Map<String, Object>> packages = new ArrayList<Map<String, Object>>();

for (SPK spk : spks) {
@@ -186,9 +192,6 @@ public List<Map<String, Object>> getPackages() throws IOException {
if (!spk.file.exists()) {
spk.file.getParentFile().mkdirs();
}
if (spk.url == null) {
spk.url = spk.url;
}
Get get = new Get();
get.bindToOwner(this);
get.setQuiet(true);
@@ -209,7 +212,7 @@ public List<Map<String, Object>> getPackages() throws IOException {
tar.setIncludes(INFO);
for (Resource resource : tar) {
if (INFO.equals(resource.getName())) {
String text = FileUtils.readFully(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8));
String text = FileUtils.readFully(new InputStreamReader(resource.getInputStream(), UTF_8));
for (String line : NEWLINE.split(text)) {
String[] s = line.split("=", 2);
if (s.length == 2) {
@@ -272,6 +275,7 @@ public void importSpkInfo(Map<String, Object> info, String key, String value) {
info.put("depsers", value);
break;
case "startable":
case "ctl_stop":
info.put("start", Project.toBoolean(value));
info.put("qstart", Project.toBoolean(value));
break;
Loading