vpac / pkgs / vshsmoke / PKGBUILD.vsh
61 lines · 55 sloc · 1.74 KB · 3609dfbd82867dc1034a443f8f9ced529ddbbedd
Raw
1#!/usr/bin/env v
2
3// a package written as a V script: the spec is a struct, the phases are
4// functions, and vsh_entry turns it into a makepkg package
5import vmakepkg
6import os
7
8fn spec() !vmakepkg.Spec {
9 return vmakepkg.Spec{
10 pkgname: 'vshsmoke'
11 pkgver: '1.4'
12 pkgrel: 1
13 pkgdesc: 'a smoke test that a PKGBUILD.vsh builds end to end'
14 arch: ['any']
15 url: 'https://example.org/vshsmoke'
16 license: 'MIT'
17 depends: ['bash']
18 source: ['vshsmoke.sh', 'readme.txt']
19 b2sums: [
20 '5395122afa0a2a2f169f4dbf6da935531a81c968adfc2e284f8cdeb36db10bd6966f679e5b6f768c1962b507dd1fe5973a0fe18ce77affc1064a0f8a8e4eca8b',
21 '1645d573e1441b363804b7f6e1bbd71b87ee87027d0110be97bc8de7e2682d391ae0812770de7c218d0018ee3f4ad6607039019ed7b3c814963ecae80b12f77d',
22 ]
23 hooks: ['post-install']
24 }
25}
26
27fn build() ! {
28 // the cwd is the sources makepkg unpacked; run shells out with makepkg's
29 // own spellings of its state restored
30 vmakepkg.run('install -m755 vshsmoke.sh vsh')!
31 println('vshsmoke: build finished')
32}
33
34fn package() ! {
35 pd := vmakepkg.pkgdir()!
36 mut docs := []string{}
37 // the binary is the package whether or not a doc came beside it
38 vmakepkg.run('install -Dm755 vsh ${vmakepkg.shell_quote(pd)}/usr/bin/vshsmoke')!
39 for doc in vmakepkg.glob('*.txt')! {
40 name := os.base(doc)
41 vmakepkg.run('install -Dm644 ${vmakepkg.shell_quote(doc)} ${vmakepkg.shell_quote(pd)}/usr/share/doc/vshsmoke/${vmakepkg.shell_quote(name)}')!
42 docs << doc
43 }
44 println('vshsmoke: package finished (${docs.len} docs unpacked alongside)')
45}
46
47fn post_install(_ []string) ! {
48 println('vshsmoke: installed, run vshsmoke for a hello')
49}
50
51vmakepkg.vsh_entry(
52 spec: spec
53 build: build
54 package: package
55 hooks: {
56 'post-install': post_install
57 }
58) or {
59 eprintln(err)
60 exit(1)
61}
62