aboutsummarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 112edb2423c3247dc9ea43f2cf84e8309c08ce45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Maintainer: Trevor Facer <trevordf@protonmail.com>

pkgname=docker-model-plugin
pkgver=1.2.6
pkgrel=1
pkgdesc='Docker CLI plugin for Model Runner - manage and run AI models in containers'
arch=('x86_64')
url='https://github.com/docker/model-runner'
license=('Apache-2.0')
depends=('glibc')
makedepends=('go>=2:1.25')
optdepends=('docker: for Docker Engine container operations')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/docker/model-runner/archive/v${pkgver}.tar.gz")
sha256sums=('b6d8d327728e5d0443c6d31346eeee41b0e955ab9f52f3112a1b8d6bedeba8c4')

prepare() {
  cd "model-runner-${pkgver}"

  # Download Go module dependencies for both modules
  export GOPATH="${srcdir}/gopath"
  export GOFLAGS="-modcacherw"

  # Download root module dependencies (required by cmd/cli)
  go mod download -x

  # Download CLI module dependencies
  cd cmd/cli
  go mod download -x
}

build() {
  cd "model-runner-${pkgver}/cmd/cli"

  # Set Go build flags per Arch guidelines
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
  export GOPATH="${srcdir}/gopath"

  # Build the binary with version information
  # Upstream ldflags format: -X github.com/docker/model-runner/cmd/cli/desktop.Version
  go build -o docker-model \
    -ldflags "-linkmode=external -X github.com/docker/model-runner/cmd/cli/desktop.Version=${pkgver}" \
    .
}

check() {
  cd "model-runner-${pkgver}/cmd/cli"

  # Verify binary was built correctly
  ./docker-model --help > /dev/null

  # Run unit tests
  go test -short -v ./... || warning "Some tests failed - may require Docker runtime"
}

package() {
  cd "model-runner-${pkgver}"

  # Install CLI plugin to system-wide Docker plugin directory
  install -Dm755 cmd/cli/docker-model "${pkgdir}/usr/lib/docker/cli-plugins/docker-model"

  # Install license
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  # Install documentation
  install -Dm644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md"
}