summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8d7d729226d0765d1917a890cb749adb36f97568 (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
# Maintainer: ava1ar <mail(at)ava1ar(dot)me>
# Maintainer: Corey Hinshaw <coreyhinshaw(at)gmail(dot)com>

pkgname=system76-driver
pkgver=17.10.23
pkgrel=1
pkgdesc="System76 Driver provides drivers, restore, and regression support for System76 computers"
arch=('any')
url="https://github.com/pop-os/system76-driver"
license=('GPL')
install="${pkgname}.install"
depends=(
	'python>=3.6'
	'python-cffi'
	'python-dbus'
	'python-evdev'
	'python-gobject'
	'python-pynacl'
	'python-xlib'
	'dmidecode')
makepdepends=(
	'python-pyflakes')
optdepends=(
	'pm-utils: For power management features'
	'gtk3: To launch System76 driver and firmware GUI'
	'grub: To apply kernel boot time parameters'
	'polkit: Run System76 Driver GUI from application menu'
	'pulseaudio: To apply microphone fix'
	'xorg-xbacklight: To use the backlight service')
source=(
	"https://github.com/pop-os/${pkgname}/archive/${pkgver}.tar.gz"
	'galu1.patch'
	'gtk.patch'
	'cli.patch'
	'hidpi.patch')
sha1sums=('a35a853892d0d61c636d4816b6375bf6880e28ca'
          'ea8d53a80a26eb05b367f27996c8ce715aafba1e'
          'bf0c37a6226858c768e8ce2c9c3c3801aef14c0e'
          '92f0de2acea6ac69c36378c7139fb84a7eaf7842'
          'acbcc10d4b4fc94bc33e9956fb0f4f335136beab')


package() {
	cd ${srcdir}/${pkgname}-${pkgver}

	###########
	# Install #
	###########

	# Build and install base package
	python setup.py install --prefix=/usr --root=${pkgdir} --optimize=1

	# Install daemons and executables
	install -m755 -D system76-daemon ${pkgdir}/usr/lib/${pkgname}/system76-daemon
	install -m755 -D system76-backlight-daemon ${pkgdir}/usr/lib/${pkgname}/system76-backlight-daemon
	install -m755 -D system76-hidpi-daemon ${pkgdir}/usr/lib/${pkgname}/system76-hidpi-daemon
	install -m755 -D system76-hidpi-notification ${pkgdir}/usr/lib/${pkgname}/system76-hidpi-notification
	install -m755 -D system76-firmware-dialog ${pkgdir}/usr/lib/${pkgname}/system76-firmware-dialog
	install -m755 -D system76-driver-pkexec ${pkgdir}/usr/bin/system76-driver-pkexec
	install -m755 -D system76-firmware-pkexec ${pkgdir}/usr/bin/system76-firmware-pkexec
	install -m755 -D system76-firmware ${pkgdir}/usr/bin/system76-firmware

	# Install systemd unit files
	# Note: system76-driver* service files shortened to system76*
	install -m644 -D debian/system76-driver.service ${pkgdir}/usr/lib/systemd/system/system76.service
	install -m644 -D debian/system76-firmware.service ${pkgdir}/usr/lib/systemd/system/system76-firmware.service
	install -m644 -D debian/system76-driver-backlight.service ${pkgdir}/usr/lib/systemd/user/system76-backlight.service
	install -m644 -D debian/system76-driver-hidpi.service ${pkgdir}/usr/lib/systemd/user/system76-hidpi.service

	# Install scripts and configuration
	install -m755 -D system76-nm-restart ${pkgdir}/usr/lib/${pkgname}/system76-nm-restart
	install -m644 -D com.system76.pkexec.system76-driver.policy ${pkgdir}/usr/share/polkit-1/actions/com.system76.pkexec.system76-driver.policy
	install -m644 -D com.system76.pkexec.system76-firmware.policy ${pkgdir}/usr/share/polkit-1/actions/com.system76.pkexec.system76-firmware.policy

	# Install desktop shortcuts
	install -m644 -D system76-driver-backlight.desktop ${pkgdir}/usr/share/applications/system76-backlight.desktop
	install -m644 -D system76-driver-hidpi.desktop ${pkgdir}/usr/share/applications/system76-hidpi.desktop
	install -m644 -D system76-firmware.desktop ${pkgdir}/usr/share/applications/system76-firmware.desktop

	# Install certificates and keys
	install -m644 -D pinned/ssl/certs/firmware.system76.com.cert ${pkgdir}/usr/share/system76-driver/ssl/certs/firmware.system76.com.cert
	install -m644 -D pinned/keys/verify ${pkgdir}/usr/share/system76-driver/keys/verify

	# Create /var/lib/system76-driver directory for brightness settings saving
	install -m755 -d ${pkgdir}/var/lib/${pkgname}

	# Clean up
	rm -rf ${pkgdir}/usr/lib/python*/site-packages/system76driver/{__pycache__,tests}

	#################
	# Apply patches #
	#################

	cd ${pkgdir}

	# patch for cli version - enable override vendor/model via /etc/system76-daemon.json
	patch --no-backup-if-mismatch -Np1 -i ${srcdir}/cli.patch

	# galu1 model-specific patch
	patch --no-backup-if-mismatch -Np1 -i ${srcdir}/galu1.patch

	# enabling "Restore System" button if all changes applied
	patch --no-backup-if-mismatch -Np1 -i ${srcdir}/gtk.patch

	# Remove Ubuntu-specific service target
	patch --no-backup-if-mismatch -Np1 -i ${srcdir}/hidpi.patch
}