summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 696a0402b836261bdf86822f6c43546a4b6eba0b (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Maintainer: dreieck (https://aur.archlinux.org/account/dreieck)
# Contributor: jzbor (https://aur.archlinux.org/account/jzbor)

_pkgname=sdiff-gtk
pkgname="${_pkgname}-git"
pkgver=0.1.1+0.r20.20230905.689cba6
pkgrel=1
pkgdesc="GTK+ frontend for Stable Diffusion. Latest git checkout."
arch=(
  'any'
)
url="https://github.com/jzbor/${_pkgname}"
license=(
  'MIT'
)
groups=()
depends=(
  gtk3
  'python>=3'
  python-gobject
  python-diffusers
  python-pillow
  python-pytorch
  python-transformers
  python-accelerate
)
makedepends=(
  git
  python-poetry
  python-installer
)
checkdepends=()
optdepends=()
provides=(
  "${_pkgname}=${pkgver}"
)
conflicts=(
  "${_pkgname}"
)
replaces=()
backup=()
options=()
source=(
  "${_pkgname}::git+${url}.git"
  "${_pkgname}.sh.in"
  "${_pkgname}.desktop"
)
noextract=()
sha256sums=(
  'SKIP'
  'c50bb6462ac2e0258361138115b832cdd276b2104ac070a4cdad94138367b744'
  'bdcad0987423cdda32c0fe687d3689f1ae4b92fb769debc146ea1389607ef9c9'
)
validpgpkeys=()

prepare() {
  cd "${srcdir}/${_pkgname}"

  git log > "${srcdir}/git.log"
}

pkgver() {
  cd "${srcdir}/${_pkgname}"

  _ver="$(git describe --long --tags | sed -E -e 's|^[vV]||' -e 's|\-g[0-9a-f]*$||' | tr '-' '+')"
  _rev="$(git rev-list --count HEAD)"
  _date="$(git log -1 --date=format:"%Y%m%d" --format="%ad")"
  _hash="$(git rev-parse --short HEAD)"

  if [ -z "${_ver}" ]; then
    error "Could not determine version."
    return 1
  else
    printf '%s' "${_ver}.r${_rev}.${_date}.${_hash}"
  fi

}

build() {
  cd "${srcdir}/${_pkgname}"

  poetry build

  local site_packges_escaped="$(python -c 'import site; print(site.getsitepackages()[0])' | sed 's/\//\\\//g')"
  sed "s/%%PYTHON_SITEPACKAGES%%/${site_packges_escaped}/g" "${srcdir}/${_pkgname}.sh.in" > "${srcdir}/${_pkgname}.sh"
}

package() {
  cd "${srcdir}/${_pkgname}"

  # Install launcher script
  install -D -v -m755 "${srcdir}/${_pkgname}.sh" "${pkgdir}/usr/bin/${_pkgname}"

  # Install desktop file
  install -D -v -m644 "${srcdir}/${_pkgname}.desktop" "${pkgdir}/usr/share/applications/${_pkgname}.desktop"

  # Install actual python wheel
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Install documentation
  for _docfile in README.md "${srcdir}/git.log"; do
    install -D -v -m644 "${_docfile}" "${pkgdir}/usr/share/doc/${_pkgname}/$(basename "${_docfile}")"
  done
}