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

Put it on package managers #12

Closed
Keats opened this Issue Mar 24, 2017 · 35 comments

Comments

Projects
None yet
10 participants
@Keats
Copy link
Collaborator

Keats commented Mar 24, 2017

Once 0.1 is reached

I think brew is used on mac? Any mac user around?

@Keats Keats changed the title Put it on AUR Put it on package managers Apr 6, 2017

@rushmorem

This comment has been minimized.

Copy link

rushmorem commented May 17, 2017

If no one beats me to it, I will create a Nix package for it.

@saghm

This comment has been minimized.

Copy link

saghm commented Sep 12, 2017

Is the AUR package blocked on anything? I'd be happy to submit/maintain an AUR package if someone is needed.

@Keats

This comment has been minimized.

Copy link
Collaborator Author

Keats commented Sep 12, 2017

@saghm Nothing, I just didn't find the time for it yet

@saghm

This comment has been minimized.

Copy link

saghm commented Sep 12, 2017

I wrote up a PKGBUILD file (minus the checksum, which is liable to change); feel free to use it!

pkgname=gutenberg-git
pkgver=0.1.3
pkgrel=1
_file="${pkgname}-v${pkgver}-x86_64-unknown-linux-gnu.tar.gz"
pkgdesc="An opinionated static site generator written in Rust"
arch=('any')
url="${_file}::https://github.com/Keats/gutenberg"
license=('MIT')
depends=('oniguruma')
makedepends=('rust')
source=($url/archive/v$pkgver.tar.gz)
sha512sums=('..')

build() {
  cd "$srcdir/gutenberg-$pkgver"
  cargo build --release
}

package() {
  cd "$srcdir/gutenberg-$pkgver"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm755 target/release/gutenberg "$pkgdir/usr/bin/gutenberg"
}
@Keats

This comment has been minimized.

Copy link
Collaborator Author

Keats commented Sep 13, 2017

I'm not sure that would work, the sass library for example requires at least git as well and if you want to build from source you'll need rust/cargo too. Is there a way to test the PKGBUILD in a container or something?
Also the source links to the already built package so you don't need to cargo build

@saghm

This comment has been minimized.

Copy link

saghm commented Sep 14, 2017

I'm not sure that would work, the sass library for example requires at least git as well

I don't think it should be necessary, but if you'd prefer, you can add git in the makedepends section.

if you want to build from source you'll need rust/cargo too

Yep, that's what the makedepends=('rust') line is for.

Also the source links to the already built package so you don't need to cargo build.

From downloading and inspecting this, it doesn't seem to be the case. Either way, it's generally preferable to build from source whenever possible (e.g. when installing a proprietary package) since that's what will be expected if the package is ever accepted in the main repos. For things that take an extraordinary long time to build, it's not uncommon to provide a separate <pkgname>-bin package for users who don't want to build from source. See for example [exa](https://aur.archlinux.org/packages/exa-git/

Is there a way to test the PKGBUILD in a container or something?

Sure! Here's a Dockerfile that installs the package:

FROM base/archlinux

RUN pacman -Syu --noconfirm 
RUN pacman -S --noconfirm --needed base-devel 

# Setup non-root user to run makepkg
RUN useradd -m -G wheel nonroot
RUN echo "nonroot ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/nonroot && \
    chmod 0440 /etc/sudoers.d/nonroot

WORKDIR /home/nonroot
COPY PKGBUILD .

USER nonroot

CMD makepkg -si --noconfirm && gutenberg --version
@Keats

This comment has been minimized.

Copy link
Collaborator Author

Keats commented Oct 4, 2017

@saghm Sorry for the delay, only got around to testing it!

I have tried the following:

pkgname=gutenberg-git
pkgver=0.2.0
pkgrel=1
pkgdesc="An opinionated static site generator written in Rust"
arch=('any')
url="https://github.com/Keats/gutenberg"
license=('MIT')
makedepends=('oniguruma' 'rust' 'git')
source=('git+https://github.com/Keats/gutenberg.git')
sha512sums=('SKIP')
conflicts=('gutenberg')
provides=('gutenberg')

build() {
  cd "$srcdir/gutenberg"
  cargo build --release
}

package() {
  cd "$srcdir/gutenberg"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm755 target/release/gutenberg "$pkgdir/usr/bin/gutenberg"
}

and the Dockerfile:

FROM base/archlinux

RUN pacman -Syu --noconfirm
RUN pacman -S --noconfirm --needed base-devel git rust

# Setup non-root user to run makepkg
RUN useradd -m -G wheel nonroot
RUN echo "nonroot ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/nonroot && \
    chmod 0440 /etc/sudoers.d/nonroot

WORKDIR /home/nonroot
COPY PKGBUILD .

USER nonroot

CMD makepkg -si --noconfirm && gutenberg --version && git clone https://gitlab.com/Keats/vincent.is && cd vincent.is && gutenberg build && ls public/ && cat public/app.css

And that seems to work! The main change is putting oniguruma as build dep as it will be linked statically by Gutenberg so we don't need it after.

I want to write the PKGBUILD for gutenberg-bin next as I wouldn't really recommend using gutenberg master branch, it might be buggy sometimes.

@Keats

This comment has been minimized.

Copy link
Collaborator Author

Keats commented Oct 5, 2017

And

pkgname=gutenberg-bin
pkgver=0.2.0
pkgrel=1
pkgdesc="An opinionated static site generator - Precompiled binary from official repository"
arch=('any')
url="https://github.com/Keats/gutenberg"
license=('MIT')
provides=('gutenberg')
conflicts=('gutenberg')

source=("https://github.com/Keats/gutenberg/releases/download/v${pkgver}/${pkgname/-bin}-v${pkgver}-x86_64-unknown-linux-gnu.tar.gz")
sha256sums=('e41e65cd182dfce0aa77afe77c88f162839b9dfb527274476e2f9de3256bcc40')

package() {
  install -Dm755 "${srcdir}/${pkgname/-bin}" "${pkgdir}/usr/bin/${pkgname/-bin}"
}

does the job for a gutenberg-bin.

@rushmorem any chance you can make a nix derivation for 0.2.0 that was just released?

@rushmorem

This comment has been minimized.

Copy link

rushmorem commented Oct 6, 2017

@Keats Will be happy to. Will try to make time for that.

@saghm

This comment has been minimized.

Copy link

saghm commented Oct 7, 2017

@Keats Awesome, I'm glad it's working! Looking forward to being able to install it through the AUR

@Keats

This comment has been minimized.

Copy link
Collaborator Author

Keats commented Oct 13, 2017

I uploaded https://aur.archlinux.org/packages/gutenberg-bin/ but I don't think i'll upload a git version myself though

@saghm

This comment has been minimized.

Copy link

saghm commented Oct 14, 2017

Awesome! I don't plan on using anything but the releases, so the binary version works for me.

@BrendanBuono

This comment has been minimized.

Copy link

BrendanBuono commented Oct 19, 2017

https://chocolatey.org/ is generally the best package manager for Windows. I haven't actually uploaded a package there before, but I can take a look over the weekend if no one else has time

@danieleggert

This comment has been minimized.

Copy link

danieleggert commented Oct 19, 2017

For macOS, it’d be great to provide an installer .pkg.

@Keats

This comment has been minimized.

Copy link
Collaborator Author

Keats commented Oct 19, 2017

@danieleggert is it possible to generate one on Travis? If so, any guide/article on how to do so?

@perryprog

This comment has been minimized.

Copy link

perryprog commented Oct 19, 2017

Mac user here! I don't know anything about making homebrew packages, but here's ripgrep's formula.

I would recommend against .pkg installs. They're pains in the butt, and it's uncommon to find any programer without homebrew installed.

EDIT: Fixed formula link.

EDIT 2: Homebrew's docs on creating formula.

@Larusso

This comment has been minimized.

Copy link

Larusso commented Oct 19, 2017

I created a few brew Formulars and brew cask Formulars as well. Depends if you want to build it on the machines or just install the packed binaries. I am happy to help out.

@danieleggert

This comment has been minimized.

Copy link

danieleggert commented Oct 19, 2017

@Keats Yes, you can do it on Travis. As opposed to @perryprog I’d strongly prefer .pkg. I think it’s very much as question of preference. Some people have homebrew others don't.

@perryprog

This comment has been minimized.

Copy link

perryprog commented Oct 19, 2017

Fair enough, why not do both?

@Keats

This comment has been minimized.

Copy link
Collaborator Author

Keats commented Oct 19, 2017

@Larusso thanks! I think installing the packed binaries is the easiest way as a cargo build --release is going to take a long time.

Is there some kind of convention in Brew like in AUR? In AUR, you can have several packages like $NAME-bin means for the precompiled binary, $NAME-git for building from source from git master and $NAME would be building building from a tagged commit I guess.

@danieleggert @perryprog Agreed, if we can do both, let's do both!

@perryprog

This comment has been minimized.

Copy link

perryprog commented Oct 19, 2017

@Keats I don't think so — brew isn't like that too much, https://docs.brew.sh/Formula-Cookbook.html describes how most of the Formulas work and look.

In case you're wondering, installing something using homebrew looks something like this:

brew install ripgrep
brew install vim --without-python2
brew install emacs --with-cocoa
@Keats

This comment has been minimized.

Copy link
Collaborator Author

Keats commented Oct 19, 2017

I see. Looking at https://github.com/Homebrew/homebrew-core/blob/master/Formula/ripgrep.rb it seems that it's building from source so maybe we can do that as well if people don't mind a long compilation time.

@bfontaine

This comment has been minimized.

Copy link
Contributor

bfontaine commented Oct 19, 2017

Experienced Homebrew-formula writer here—I just started writing a formula after seeing Gutenberg on HN. Is someone already on it? Otherwise if I don’t hit any issue it should be ready tonight.

@Larusso

This comment has been minimized.

Copy link

Larusso commented Oct 19, 2017

@Keats There is a difference between brew and brew cask to start with. Brew Formulars build from Source. But you can provide prebuild binaries so called bottles. Cask on the other hand is for binary packages only. It allows you to execute an install script which can download an app package pkg or whatever. You can even symlink tools for command line use. This is helpfully for apps that also allow command line execution. The Formulars have a different DSL. If you want to build from source you also need to install all the dependencies. I don’t know if this is still the case but MacPorts was way saver when also quite verbose when it comes to compiler dependencies. Brew just falls back to system libraries. The Formular file can get quite complicated when you need to support older versions of Mac OS. With MacPorts you have the complete toolchain under control.

@bfontaine

This comment has been minimized.

Copy link
Contributor

bfontaine commented Oct 19, 2017

I just submitted a PR to the core repository: Homebrew/homebrew-core#19650

@Calinou

This comment has been minimized.

Copy link

Calinou commented Oct 20, 2017

Scoop can be interesting to package for; it's a simple Windows package manager targeted at CLI applications.

I can work on adding Gutenberg to it.

Edit: I submitted a pull request to Scoop. Providing 32-bit binaries (possibly using the GNU ABI) may have to be done, I'm not sure.

@danieleggert

This comment has been minimized.

Copy link

danieleggert commented Oct 20, 2017

@Keats I’m a bit at loss wrt. Travis. But you’d want to run something like this

#!/bin/sh
#
# Package into a product archive for the macOS installer
#

VERSION=1
IDENTIFIER=is.vincent.gutenberg
TOOL_PATH=${HOME}/Downloads/gb
TEMP=.
OUTPUT_PATH=.

ROOT=${TEMP}/gutenberg.dst
BIN=usr/local/bin

mkdir -p ${ROOT}/${BIN}
for x in gutenberg; do
    xcrun ditto ${TOOL_PATH}/${x} ${ROOT}/${BIN}/${x}
done

componentpkg=gutenberg-component.pkg

xcrun pkgbuild \
	--root ${ROOT} \
	--identifier ${IDENTIFIER}.component \
	--version ${VERSION} \
	--ownership recommended \
	${OUTPUT_PATH}/${componentpkg}

xcrun productbuild \
	--product gutenberg-requirements.plist \
	--package ${componentpkg} \
	--identifier ${IDENTIFIER} \
	--version ${VERSION} \
	${OUTPUT_PATH}/gutenberg.pkg

And the resulting ${OUTPUT_PATH}/gutenberg.pkg would then be what you’d distribute.
I’m not sure if you need to clear out $TMP on Travis or not. And you obviously need to fix the paths in this script to point to where things are on Travis.

This doesn’t sign the package, but it’d be a good start.

@Calinou

This comment has been minimized.

Copy link

Calinou commented Oct 20, 2017

A follow-up to the Scoop packaging: the pull request has been merged. 😄

@r15ch13

This comment has been minimized.

Copy link

r15ch13 commented Oct 20, 2017

gutenberg is now available for Windows via scoop. New GitHub releases will be added automagically 😄

$ scoop install gutenberg
@danieleggert

This comment has been minimized.

Copy link

danieleggert commented Oct 20, 2017

@Keats How would I go about adding the above script for macOS to the Travis configuration?

@Keats

This comment has been minimized.

Copy link
Collaborator Author

Keats commented Oct 21, 2017

@Calinou @r15ch13 thanks! I've added it to the docs in 7cf120d

Can you install a specific version or will it always get the latest?

@Keats

This comment has been minimized.

Copy link
Collaborator Author

Keats commented Oct 21, 2017

@danieleggert I'm not entirely sure to be honest. I am using https://github.com/japaric/trust for the cross-compilation CI and I believe in that case it would need to change https://github.com/Keats/gutenberg/blob/master/ci/before_deploy.sh

However, if .pkg is something Mac users want, it would make sense to do an issue/PR on trust so it will happen for way more Rust binaries than just Gutenberg but I don't know whether @japaric is interested in that.

@Calinou

This comment has been minimized.

Copy link

Calinou commented Oct 21, 2017

Can you install a specific version or will it always get the latest?

Scoop doesn't support this, only the latest version can be installed (the version number cannot be specified upon installing), see Chocolatey Comparison for details.

@r15ch13

This comment has been minimized.

Copy link

r15ch13 commented Oct 21, 2017

@Calinou @Keats it's possible to install other versions like so:

$ scoop install gutenberg@0.2.0

But it creates a new manifest file and doesn't validate the hash values. It creates a manifest on the fly.

@bfontaine

This comment has been minimized.

Copy link
Contributor

bfontaine commented Oct 27, 2017

FYI the Homebrew PR has been merged; so one can now install Gutenberg on macOS using:

brew install gutenberg

@Keats Keats closed this Nov 26, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.