summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a51227c847ceaba44c41d89559cdd671060a9090 (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
105
106
107
108
109
110
111
112
113
# Maintainer: Mehad <mehad605@example.com>
pkgname=dev-type
pkgver=1.0.2
pkgrel=1
pkgdesc="Master touch typing while coding"
arch=('x86_64')
url="https://github.com/mehad605/dev_type"
license=('CC-BY-NC-SA-4.0')

depends=('glibc' 'gcc-libs')
# uv is in Arch's extra repo; only needed at build time, not runtime.
# python-pyinstaller is needed to bundle the app.
# execstack is needed to clear the executable-stack flag from bundled .so files.
makedepends=('uv' 'python' 'execstack')
provides=('dev-type')
conflicts=('dev-type-bin' 'dev-type-git')
options=('!strip')

source=(
  "${pkgname}-${pkgver}.tar.gz::https://github.com/mehad605/dev_type/archive/refs/tags/v${pkgver}.tar.gz"
)
sha256sums=('38ba1088dc3b4159af0467069204d9f014c936940149bfa2736ed51d93b3bfd1')

build() {
  cd "dev_type-${pkgver}"

  # Install all Python dependencies (into an isolated .venv managed by uv)
  uv sync

  # Run PyInstaller in onedir mode so that bundled .so files are real files
  # on disk (not embedded in a single blob) — required for execstack patching.
  uv run pyinstaller \
    --name=dev_type \
    --onedir \
    --icon=assets/icon.png \
    --add-data="assets/icon.svg:assets" \
    --add-data="assets/icon.png:assets" \
    --add-data="assets/sounds:assets/sounds" \
    --add-data="assets/icon-theme.zip:assets" \
    --hidden-import=PySide6.QtSvg \
    --hidden-import=PySide6.QtSvgWidgets \
    --hidden-import=PySide6.QtMultimedia \
    --hidden-import=app.portable_data \
    --hidden-import=app.ghost_manager \
    --hidden-import=app.stats_db \
    --hidden-import=app.settings \
    --hidden-import=app.themes \
    --hidden-import=app.typing_engine \
    --hidden-import=app.typing_area \
    --hidden-import=app.sound_manager \
    --hidden-import=app.sound_profile_editor \
    --hidden-import=app.sound_volume_widget \
    --hidden-import=app.icon_manager \
    --hidden-import=app.language_cache \
    --hidden-import=app.file_scanner \
    --hidden-import=app.file_tree \
    --hidden-import=app.editor_tab \
    --hidden-import=app.history_tab \
    --hidden-import=app.languages_tab \
    --hidden-import=app.session_result_dialog \
    --hidden-import=app.ghost_replay_widget \
    --hidden-import=app.stats_display \
    --hidden-import=app.progress_bar_widget \
    --hidden-import=app.instant_splash \
    --hidden-import=_tkinter \
    --hidden-import=tkinter \
    --hidden-import=tkinter.font \
    --hidden-import=tkinter.ttk \
    --noupx \
    --clean \
    main.py

  # Clear the executable-stack flag from all bundled ELF files.
  # libpython and several Qt .so files are compiled with this flag set, which
  # modern kernels refuse to load. execstack -c clears it safely.
  find dist/dev_type -type f -exec execstack -c {} \; 2>/dev/null || true
}

package() {
  cd "dev_type-${pkgver}"

  # Install the onedir bundle into /usr/lib/dev_type/
  # (binary + _internal/ with all bundled .so files)
  install -d "${pkgdir}/usr/lib/dev_type"
  cp -a dist/dev_type/. "${pkgdir}/usr/lib/dev_type/"
  chmod 755 "${pkgdir}/usr/lib/dev_type/dev_type"

  # Launcher wrapper in /usr/bin
  install -Dm755 /dev/stdin "${pkgdir}/usr/bin/dev_type" << 'EOF'
#!/bin/sh
exec /usr/lib/dev_type/dev_type "$@"
EOF

  # Icon
  install -Dm644 assets/icon.png \
    "${pkgdir}/usr/share/icons/hicolor/256x256/apps/dev_type.png"

  # Desktop entry (inlined — packaging/ files may not exist in older tags)
  install -Dm644 /dev/stdin "${pkgdir}/usr/share/applications/dev_type.desktop" << 'EOF'
[Desktop Entry]
Name=Dev Type
Exec=dev_type
Icon=dev_type
Type=Application
Categories=Education;
Comment=Master touch typing while coding
Terminal=false
EOF

  # License
  install -Dm644 LICENSE \
    "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}