summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 51fc0dae734e5c7325081a3be5d05667d25991bb (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
114
115
116
117
118
119
120
121
122
123
124
125
# Maintainer:
# Contributor: Mark Wagie <mark dot wagie at proton dot me>

## links
# https://github.com/barry-ran/QtScrcpy
# https://github.com/barry-ran/QtScrcpyCore

## options
: ${_install_path:=opt}
: ${_commit=8abdc5c389169ee060d55aacbb4a7c03b946d939} # 2.2.1

# basic info
_pkgname=qtscrcpy
pkgname="$_pkgname"
pkgver=2.2.1
pkgrel=5
pkgdesc="Android real-time screencast control tool"
url="https://github.com/barry-ran/QtScrcpy"
license=('Apache-2.0')
arch=('x86_64' 'aarch64')

depends=(
  'android-tools'
  'qt5-multimedia'
  'qt5-x11extras'
)
makedepends=(
  'chrpath'
  'cmake'
  'git'
  'qt5-tools'
)

conflicts=('qtscrcpy-docs')

backup=("etc/$_pkgname/config.ini")

_pkgsrc="$_pkgname"
_pkgsrc_core="qtscrcpycore"
source=(
  "$_pkgname"::"git+$url.git#commit=$_commit"
  "$_pkgsrc_core"::"git+https://github.com/barry-ran/QtScrcpyCore.git"
  "path-fix.patch"
)
sha256sums=(
  'SKIP'
  'SKIP'
  '16c9470136d4ab84af22b9689e5767b38e7be4eaa41b069546480a44a2776c36'
)

prepare() {
  cd "$_pkgsrc_core"
  git remote set-url origin https://github.com/barry-ran/QtScrcpyCore.git
  git fetch origin 769943161f99dbc7b0c55f7f769e32729ab06693

  cd "$srcdir/$_pkgsrc"
  git submodule init
  git config submodule.QtScrcpy/QtScrcpyCore.url "$srcdir/qtscrcpycore"
  git -c protocol.file.allow=always submodule update

  patch -Np1 -F100 -i "$srcdir/path-fix.patch"

  sed -E -e 's&\bQt6 Qt5\b&Qt5&g' \
    -i QtScrcpy/res/i18n/CMakeLists.txt \
    QtScrcpy/CMakeLists.txt
}

build() {
  local _cmake_options=(
    -B build
    -S "$_pkgsrc"
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX='/usr'
    -DQT_VERSION_MAJOR=5
    -Wno-dev
  )

  cmake "${_cmake_options[@]}"
  cmake --build build

  cd "$_pkgsrc"

  # Remove insecure RPATH
  chrpath --delete output/x64/None/QtScrcpy
}

package() {
  cd "$_pkgsrc"
  install -Dm755 output/x64/None/QtScrcpy -t "$pkgdir/$_install_path/$_pkgname/"
  install -Dm644 output/x64/None/scrcpy-server -t "$pkgdir/$_install_path/$_pkgname/"
  install -Dm644 output/x64/None/sndcpy.apk "$pkgdir/$_install_path/$_pkgname/"
  install -Dm755 output/x64/None/sndcpy.sh "$pkgdir/$_install_path/$_pkgname/"

  install -Dm644 backup/logo.png "$pkgdir/usr/share/pixmaps/$_pkgname.png"
  install -Dm644 config/config.ini -t "$pkgdir/etc/$_pkgname/"

  cp -r keymap "$pkgdir/$_install_path/$_pkgname/"

  install -dm755 "$pkgdir/usr/bin"
  ln -s "/$_install_path/$_pkgname/sndcpy.sh" "$pkgdir/usr/bin/"

  install -dm755 "$pkgdir/usr/share/doc/$_pkgname"
  cp -r docs/* "$pkgdir/usr/share/doc/$_pkgname/"

  install -Dm755 /dev/stdin "$pkgdir/usr/bin/$_pkgname" << END
#!/usr/bin/env sh
exec /$_install_path/qtscrcpy/QtScrcpy "\$@"
END

  install -Dm644 /dev/stdin "$pkgdir/usr/share/applications/$_pkgname.desktop" << END
[Desktop Entry]
Type=Application
Name=QtScrcpy
Comment=Android real-time screencast control tool
Exec=$_pkgname %u
Icon=$_pkgname
Terminal=false
StartupNotify=true
Categories=Development;Utility;
MimeType=application/epub+zip;
END

  # fix permissions
  chmod -R u+rwX,go+rX,go-w "$pkgdir/"
}