summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 78d2a5cec1a8b02dcd7713fea84f74fe6f8e7713 (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
# Maintainer: watasuke <watasuke102@gmail.com>
_pkgname=openplc-editor
pkgname="${_pkgname}-git"
pkgver=r479.5e4f443
pkgrel=4
pkgdesc="OpenPLC editor"
arch=("x86_64")
url="https://github.com/thiagoralves/OpenPLC_Editor"
source=("git+${url}.git")
license=("GPL2")
md5sums=("SKIP")
makedepends=("git")
depends=("python39")

pkgver() {
  cd "${srcdir}/OpenPLC_Editor"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cd "${srcdir}/OpenPLC_Editor"
  git submodule update --init --recursive
  cd matiec
  autoreconf -i
  ./configure --prefix="${pkgdir}" CXXFLAGS="-std=c++03"
  make -s
  cp ./iec2c ../editor/arduino/bin/
}

prepare() {
  mkdir -p "${srcdir}/OpenPLC_Editor/.venv"
  python3.9 -m venv "${srcdir}/OpenPLC_Editor/.venv"
  "${srcdir}/OpenPLC_Editor/.venv/bin/python" -m pip install --upgrade pip
  "${srcdir}/OpenPLC_Editor/.venv/bin/python" -m pip install wheel jinja2 lxml==4.6.2 future matplotlib zeroconf pyserial pypubsub pyro5 attrdict3
  "${srcdir}/OpenPLC_Editor/.venv/bin/python" -m pip install wxPython==4.2.0

  cat << END > OpenPLC_Editor.desktop
[Desktop Entry]
Name=OpenPLC Editor
Categories=Development;
Exec="/opt/OpenPLC_Editor/openplc_editor.sh"
Icon=/opt/OpenPLC_Editor/editor/images/brz.png
Type=Application
Terminal=false
END

  cd "${srcdir}/OpenPLC_Editor"
  cat << END > openplc_editor.sh
#!/bin/bash
cd "/opt/OpenPLC_Editor"
if [ -d "./new_editor" ]; then
    rm -Rf editor
    rm -Rf ./matiec/lib
    mv ./new_editor ./editor
    mv ./new_lib ./matiec/lib
fi
source ".venv/bin/activate"
export GDK_BACKEND=x11
./.venv/bin/python3 ./editor/Beremiz.py
END
  chmod +x openplc_editor.sh
}

package() {
  install -dm755 "$pkgdir/opt"
  cp -r "${srcdir}/OpenPLC_Editor" "$pkgdir/opt/OpenPLC_Editor"
  install -Dm644 "OpenPLC_Editor.desktop" "${pkgdir}/usr/share/applications/OpenPLC_Editor.desktop"
}