#!/usr/bin/env v // a package written as a V script: the spec is a struct, the phases are // functions, and vsh_entry dispatches the compiled recipe 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: [os.uname().machine] url: 'https://example.org/vshsmoke' license: 'MIT' makedepends: ['gcc'] source: ['vshsmoke.c', 'readme.txt'] b2sums: [ '61e646216ee8f398f9fcc605a573954e5f5e9fafc0dfd583352203eed7081c8540127f7e879079f71a654b3efef6f79b1604fec7ea28056363c8a7a899a6fa8a', '1645d573e1441b363804b7f6e1bbd71b87ee87027d0110be97bc8de7e2682d391ae0812770de7c218d0018ee3f4ad6607039019ed7b3c814963ecae80b12f77d', ] hooks: ['post-install'] } } fn build() ! { vmakepkg.run(['cc', '-o', 'vshsmoke', 'vshsmoke.c'])! 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', 'vshsmoke', os.join_path(pd, 'usr/bin/vshsmoke')])! for doc in vmakepkg.glob('*.txt')! { name := os.base(doc) vmakepkg.run(['install', '-Dm644', doc, os.join_path(pd, 'usr/share/doc/vshsmoke', 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) }