| 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 dispatches the compiled recipe |
| 5 | import vmakepkg |
| 6 | import os |
| 7 | |
| 8 | fn 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: [os.uname().machine] |
| 15 | url: 'https://example.org/vshsmoke' |
| 16 | license: 'MIT' |
| 17 | makedepends: ['gcc'] |
| 18 | source: ['vshsmoke.c', 'readme.txt'] |
| 19 | b2sums: [ |
| 20 | '61e646216ee8f398f9fcc605a573954e5f5e9fafc0dfd583352203eed7081c8540127f7e879079f71a654b3efef6f79b1604fec7ea28056363c8a7a899a6fa8a', |
| 21 | '1645d573e1441b363804b7f6e1bbd71b87ee87027d0110be97bc8de7e2682d391ae0812770de7c218d0018ee3f4ad6607039019ed7b3c814963ecae80b12f77d', |
| 22 | ] |
| 23 | hooks: ['post-install'] |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | fn build() ! { |
| 28 | vmakepkg.run(['cc', '-o', 'vshsmoke', 'vshsmoke.c'])! |
| 29 | println('vshsmoke: build finished') |
| 30 | } |
| 31 | |
| 32 | fn package() ! { |
| 33 | pd := vmakepkg.pkgdir()! |
| 34 | mut docs := []string{} |
| 35 | // the binary is the package whether or not a doc came beside it |
| 36 | vmakepkg.run(['install', '-Dm755', 'vshsmoke', os.join_path(pd, 'usr/bin/vshsmoke')])! |
| 37 | for doc in vmakepkg.glob('*.txt')! { |
| 38 | name := os.base(doc) |
| 39 | vmakepkg.run(['install', '-Dm644', doc, os.join_path(pd, 'usr/share/doc/vshsmoke', name)])! |
| 40 | docs << doc |
| 41 | } |
| 42 | println('vshsmoke: package finished (${docs.len} docs unpacked alongside)') |
| 43 | } |
| 44 | |
| 45 | fn post_install(_ []string) ! { |
| 46 | println('vshsmoke: installed, run vshsmoke for a hello') |
| 47 | } |
| 48 | |
| 49 | vmakepkg.vsh_entry( |
| 50 | spec: spec |
| 51 | build: build |
| 52 | package: package |
| 53 | hooks: { |
| 54 | 'post-install': post_install |
| 55 | } |
| 56 | ) or { |
| 57 | eprintln(err) |
| 58 | exit(1) |
| 59 | } |
| 60 | |