Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hut: new port, CLI for SourceHut API #18306

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

woolsweater
Copy link
Contributor

Description

Add hut, a CLI for the SourceHut.org API, to the MacPorts tree.

Type(s)
  • bugfix
  • enhancement
  • security fix
Tested on

macOS 12.6.3 21G419 arm64
Xcode 13.3.1 13E500a

Verification

Have you

@woolsweater
Copy link
Contributor Author

Still pretty new to working with Portfiles, so please let me know if there's anything that can be improved.

@woolsweater
Copy link
Contributor Author

The project doesn't include shell completion files directly, but the tool, once built, can generate them. Is there a good way to incorporate that into the Portfile's installation process?

@herbygillot
Copy link
Member

herbygillot commented Apr 18, 2023

Thanks for this contribution @woolsweater.

Here's a Portfile for hut that addresses installing completions, as well as some other things:

# -*- 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

PortSystem          1.0
PortGroup           golang 1.0

go.setup            git.sr.ht/~emersion/hut 0.3.0 v
revision            0

description         A CLI tool for sr.ht.

long_description    ${name} lets you interact with the SourceHut API from the \
                    command line. See the man page for a full list of \
                    available commands.

categories          devel
installs_libs       no
license             AGPL-3
maintainers         {woolsweater.net:macports @woolsweater} \
                    openmaintainer

checksums           rmd160  6d031cf9704c4645e0f1036989000126ae78d482 \
                    sha256  ca191d663be81000c8ac0e952cd1b95fbded8c1d918d6d89ff08adbcd3d75289 \
                    size    116316

depends_build-append \
                    port:scdoc

# Tarball contents name conflicts with the default work dir name
worksrcdir          ${name}-${version}-${epoch}

# Allow Go to fetch dependencies at build time
build.env-delete    GO111MODULE=off GOPROXY=off

build.cmd           \
    ${build.cmd} -ldflags \" \
        -X main.version=v${version} -X main.builtBy=macports \
    \" \&\& \
    make completions doc/${name}.1

destroot {
    # install binary:
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/

    # install man page:
    xinstall -m 0644 \
        ${worksrcpath}/doc/${name}.1 \
        ${destroot}${prefix}/share/man/man1/${name}.1

    # install shell completions:
    # bash:
    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    file copy ${worksrcpath}/${name}.bash \
        ${destroot}${prefix}/share/bash-completion/completions/${name}

    # zsh:
    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    file copy ${worksrcpath}/${name}.zsh \
        ${destroot}${prefix}/share/zsh/site-functions/_${name}

    # fish:
    xinstall -d ${destroot}${prefix}/share/fish/vendor_completions.d
    file copy ${worksrcpath}/${name}.fish \
        ${destroot}${prefix}/share/fish/vendor_completions.d/${name}.fish
}

Some points:

  1. The golang portgroup knows how to support the git.sr.ht domain. You do not need to import the sourcehut portgroup, and you do not need to specify sourcehut.setup.
  2. The .scd file is actually a source file meant to generate the manpage. This is done using the scdoc utility. Calling make doc/hut.1 will do this as part of the build process. We add scdoc as a build dependency and call this make target at the same time that we call make completions.
  3. We add the actions that copy each completion file into the correct location within the destroot block.

@woolsweater
Copy link
Contributor Author

That's awesome @herbygillot, thank you for the information and the changes. I've applied your version to the branch.

@herbygillot herbygillot merged commit 13c50f2 into macports:master Apr 20, 2023
2 checks passed
@herbygillot
Copy link
Member

Merged. Thanks for your contribution, @woolsweater.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants