#!/usr/bin/env v // a package written as a V script: the spec is a struct, the phases are // functions, and vsh_entry turns it into a makepkg package import vmakepkg import os fn spec() !vmakepkg.Spec { return vmakepkg.Spec{ pkgname: 'vshsmoke' pkgver: '1.4' pkgrel: 1 pkgdesc: 'a smoke test that a PKGBUILD.vsh builds end to end' arch: ['any'] url: 'https://example.org/vshsmoke' license: 'MIT' depends: ['bash'] source: ['vshsmoke.sh', 'readme.txt'] b2sums: [ '5395122afa0a2a2f169f4dbf6da935531a81c968adfc2e284f8cdeb36db10bd6966f679e5b6f768c1962b507dd1fe5973a0fe18ce77affc1064a0f8a8e4eca8b', '1645d573e1441b363804b7f6e1bbd71b87ee87027d0110be97bc8de7e2682d391ae0812770de7c218d0018ee3f4ad6607039019ed7b3c814963ecae80b12f77d', ] hooks: ['post-install'] } } fn build() ! { // the cwd is the sources makepkg unpacked; run shells out with makepkg's // own spellings of its state restored vmakepkg.run('install -m755 vshsmoke.sh vsh')! println('vshsmoke: build finished') } fn package() ! { pd := vmakepkg.pkgdir()! mut docs := []string{} // the binary is the package whether or not a doc came beside it vmakepkg.run('install -Dm755 vsh ${vmakepkg.shell_quote(pd)}/usr/bin/vshsmoke')! for doc in vmakepkg.glob('*.txt')! { name := os.base(doc) vmakepkg.run('install -Dm644 ${vmakepkg.shell_quote(doc)} ${vmakepkg.shell_quote(pd)}/usr/share/doc/vshsmoke/${vmakepkg.shell_quote(name)}')! docs << doc } println('vshsmoke: package finished (${docs.len} docs unpacked alongside)') } fn post_install(_ []string) ! { println('vshsmoke: installed, run vshsmoke for a hello') } vmakepkg.vsh_entry( spec: spec build: build package: package hooks: { 'post-install': post_install } ) or { eprintln(err) exit(1) }