Skip to content

Commit

Permalink
[macports] support additional distribution types. Resolves #615
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Dec 22, 2021
1 parent 0ba0e1b commit 5048d01
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 18 deletions.
Expand Up @@ -124,13 +124,16 @@ public RepositoryTap getRepositoryTap() {

@Override
public boolean supportsPlatform(String platform) {
return isBlank(platform) || PlatformUtils.isMac(platform);
return isBlank(platform) ||
(PlatformUtils.isMac(platform) && PlatformUtils.isIntel(platform));
}

@Override
public boolean supportsDistribution(Distribution distribution) {
return distribution.getType() == Distribution.DistributionType.JAVA_BINARY ||
distribution.getType() == Distribution.DistributionType.NATIVE_IMAGE;
distribution.getType() == Distribution.DistributionType.JLINK ||
distribution.getType() == Distribution.DistributionType.NATIVE_IMAGE ||
distribution.getType() == Distribution.DistributionType.BINARY;
}

public static class MacportsRepository extends AbstractRepositoryTap {
Expand Down
Expand Up @@ -17,6 +17,8 @@
*/
package org.jreleaser.model.validation;

import org.jreleaser.bundle.RB;
import org.jreleaser.model.Active;
import org.jreleaser.model.Artifact;
import org.jreleaser.model.Distribution;
import org.jreleaser.model.GitService;
Expand All @@ -27,8 +29,10 @@
import org.jreleaser.util.Errors;

import java.util.Collections;
import java.util.List;
import java.util.Set;

import static java.util.stream.Collectors.toList;
import static org.jreleaser.model.validation.DistributionsValidator.validateArtifactPlatforms;
import static org.jreleaser.model.validation.ExtraPropertiesValidator.mergeExtraProperties;
import static org.jreleaser.model.validation.TemplateValidator.validateTemplate;
Expand Down Expand Up @@ -91,14 +95,21 @@ public static void validateMacports(JReleaserContext context, Distribution distr
}
}

// activate rmd160 checksum
Set<String> fileExtensions = tool.getSupportedExtensions();
long count = distribution.getArtifacts().stream()
List<Artifact> candidateArtifacts = distribution.getArtifacts().stream()
.filter(Artifact::isActive)
.filter(artifact -> fileExtensions.stream().anyMatch(ext -> artifact.getPath().endsWith(ext)))
.filter(artifact -> tool.supportsPlatform(artifact.getPlatform()))
.count();
if (count > 0) {
.collect(toList());

if (candidateArtifacts.size() == 0) {
tool.setActive(Active.NEVER);
tool.disable();
} else if(candidateArtifacts.size()> 1) {
errors.configuration(RB.$("validation_tool_multiple_artifacts", "distribution." + distribution.getName() + ".macports"));
tool.disable();
} else {
// activate rmd160 checksum
context.getModel().getChecksum().getAlgorithms().add(Algorithm.RMD160);
}
}
Expand Down
Expand Up @@ -41,11 +41,13 @@ java-binary.chocolatey=binary.nuspec.tpl,tools/chocolateyinstall.ps1.tpl,tools/c
binary.docker=Dockerfile.tpl,Dockerfile-remote.tpl
binary.scoop=README.md.tpl,manifest.json.tpl
binary.brew=formula-multi.rb.tpl,cask.rb.tpl,README.md.tpl,formula.rb.tpl
binary.macports=Portfile.tpl
binary.snap=README.md.tpl,snap/snapcraft.yaml.tpl
native-package.brew=cask.rb.tpl,README.md.tpl
jlink.docker=Dockerfile.tpl,Dockerfile-remote.tpl
jlink.scoop=README.md.tpl,manifest.json.tpl
jlink.brew=formula-multi.rb.tpl,cask.rb.tpl,README.md.tpl,formula.rb.tpl
jlink.macports=Portfile.tpl
jlink.snap=README.md.tpl,/snap/snapcraft.yaml.tpl
jlink.spec=app.spec.tpl
jlink.chocolatey=binary.nuspec.tpl,tools/chocolateyinstall.ps1.tpl,tools/chocolateyuninstall.ps1.tpl
Expand Down
@@ -0,0 +1,47 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# [JRELEASER_VERSION]

PortSystem 1.0

name {{macportsPackageName}}
version {{projectVersion}}
revision {{macportsRevision}}

categories {{macportsCategories}}
license {{projectLicense}}
maintainers {{macportsMaintainers}}
platforms darwin
supported_archs x86_64

description {{projectDescription}}
long_description {{projectLongDescription}}

homepage {{projectWebsite}}

master_sites {{macportsDistributionUrl}}
distname {{macportsDistname}}
use_zip yes

checksums rmd160 {{distributionChecksumRmd160}} \
sha256 {{distributionChecksumSha256}} \
size {{distributionSize}}

use_configure no

build {}

destroot {
set target ${destroot}${prefix}/share/${name}

# Create the target directory
xinstall -m 755 -d ${target}

# Copy over the needed elements of our directory tree
foreach f [glob -dir ${worksrcpath} *] {
copy ${f} ${target}
}

ln -s ../share/${name}/bin/{{distributionExecutable}} ${destroot}${prefix}/bin/{{distributionExecutable}}
}

livecheck.type none
Expand Up @@ -34,22 +34,22 @@ use_configure no
build {}

destroot {
set target ${destroot}${prefix}/share/java/${name}
set target ${destroot}${prefix}/share/${name}

# Create the target java directory
# Create the target directory
xinstall -m 755 -d ${target}

# Copy over the needed elements of our directory tree
foreach d { bin lib } {
copy ${worksrcpath}/${d} ${target}
foreach f [glob -dir ${worksrcpath} *] {
copy ${f} ${target}
}

# Remove extraneous files
foreach f [glob -directory ${target}/bin *.{{distributionExecutableExtension}}] {
delete ${f}
}

ln -s ../share/java/${name}/bin/{{distributionExecutable}} ${destroot}${prefix}/bin/{{distributionExecutable}}
ln -s ../share/${name}/bin/{{distributionExecutable}} ${destroot}${prefix}/bin/{{distributionExecutable}}
}

livecheck.type none
@@ -0,0 +1,47 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# [JRELEASER_VERSION]

PortSystem 1.0

name {{macportsPackageName}}
version {{projectVersion}}
revision {{macportsRevision}}

categories {{macportsCategories}}
license {{projectLicense}}
maintainers {{macportsMaintainers}}
platforms darwin
supported_archs x86_64

description {{projectDescription}}
long_description {{projectLongDescription}}

homepage {{projectWebsite}}

master_sites {{macportsDistributionUrl}}
distname {{macportsDistname}}
use_zip yes

checksums rmd160 {{distributionChecksumRmd160}} \
sha256 {{distributionChecksumSha256}} \
size {{distributionSize}}

use_configure no

build {}

destroot {
set target ${destroot}${prefix}/share/${name}

# Create the target directory
xinstall -m 755 -d ${target}

# Copy over the needed elements of our directory tree
foreach f [glob -dir ${worksrcpath} *] {
copy ${f} ${target}
}

ln -s ../share/${name}/bin/{{distributionExecutable}} ${destroot}${prefix}/bin/{{distributionExecutable}}
}

livecheck.type none
Expand Up @@ -37,8 +37,8 @@ destroot {
xinstall -m 755 -d ${target}

# Copy over the needed elements of our directory tree
foreach d { bin } {
copy ${worksrcpath}/${d} ${target}
foreach f [glob -dir ${worksrcpath} *] {
copy ${f} ${target}
}

ln -s ../share/${name}/bin/{{distributionExecutable}} ${destroot}${prefix}/bin/{{distributionExecutable}}
Expand Down
2 changes: 2 additions & 0 deletions jreleaser.yml
Expand Up @@ -206,6 +206,8 @@ distributions:
artifacts:
- path: apps/{{distributionName}}/build/distributions/{{distributionName}}-{{projectVersion}}.zip
transform: '{{distributionName}}/{{distributionName}}-{{projectEffectiveVersion}}.zip'
extraProperties:
skipSpec: true
- path: apps/{{distributionName}}/build/distributions/{{distributionName}}-{{projectVersion}}.tar
transform: '{{distributionName}}/{{distributionName}}-{{projectEffectiveVersion}}.tar'

Expand Down
10 changes: 5 additions & 5 deletions src/jreleaser/distributions/jreleaser/macports/Portfile.tpl
Expand Up @@ -33,22 +33,22 @@ use_configure no
build {}

destroot {
set target ${destroot}${prefix}/share/java/${name}
set target ${destroot}${prefix}/share/${name}

# Create the target java directory
# Create the target directory
xinstall -m 755 -d ${target}

# Copy over the needed elements of our directory tree
foreach d { bin lib } {
copy ${worksrcpath}/${d} ${target}
foreach f [glob -dir ${worksrcpath} *] {
copy ${f} ${target}
}

# Remove extraneous files
foreach f [glob -directory ${target}/bin *.{{distributionExecutableExtension}}] {
delete ${f}
}

ln -s ../share/java/${name}/bin/{{distributionExecutable}} ${destroot}${prefix}/bin/{{distributionExecutable}}
ln -s ../share/${name}/bin/{{distributionExecutable}} ${destroot}${prefix}/bin/{{distributionExecutable}}
}

livecheck.type regex
Expand Down

0 comments on commit 5048d01

Please sign in to comment.