summaryrefslogtreecommitdiff
path: root/pcr/libreboot-utils/PKGBUILD
blob: cc343c67dd43a0e4f01e2ce23b9c732e0a75cb7a (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Copyright (C) 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
# Copyright (C) 2022 Wael Karram <wael@waelk.tech>
# SPDX-License-Identifier: CC0-1.0
# Maintainers: Parabola hackers <dev@lists.parabola.nu>

pkgname=libreboot-utils
pkgrel=12
_upstream_ver=20211122
pkgver=4.15.libreboot${_upstream_ver}
pkgdesc="Misc. Coreboot/Libreboot utils (bucts, cbfstool, ECtool, nvramtool, superiotool)"
url="https://libreboot.org/"
arch=('x86_64' 'i686' 'armv7h')
license=('GPL2')
makedepends=('pciutils' 'python3')

_mirror="https://mirrors.mit.edu/libreboot" # use a mirror per libreboot's request
source=("${_mirror}/testing/${_upstream_ver}/libreboot-${_upstream_ver}_src.tar.xz"{,.sig}
        "0001-cbfstool-enable-to-disable-Werror-in-standalone-buil.patch")
sha256sums=('e8a610e51e668c34627a6d9c048c554592fd2c2ab4dbcad83c85c06d132e5ad1'
            '4442fc225383e1edf8f45e1aecba81868ae43db19978f15c17828389364c0434'
            'SKIP')
sha512sums=('3eac75b33bc6d2874c3ca1ad2392db7287992cf91d37879bb3244dbd6716bc7ffa3f8d31e15d821899e91a55b6fe665d918bea4e9da92e5e98345e9bcbe1bb95'
            '3a532ecef550ef27b723845544e91ff6b13ed6f2f1188d40fdeb7b3c416be619ff58103c3b01cd52ff88c28df6d419d2113b92d0b8ba36d1a74cfc16f70e0e63'
            'SKIP')
validpgpkeys=('98CCDDF8E56047F475C044BDD0C62464FA8B4856') # Leah Rowe

prepare() {
	cd "$srcdir/libreboot-${_upstream_ver}_src/coreboot/default/"
	patch \
	    -Np1 -i \
	    "${srcdir}/0001-cbfstool-enable-to-disable-Werror-in-standalone-buil.patch"

	# Replace sbin with bin in the makefiles.
	cd "$srcdir/libreboot-${_upstream_ver}_src/coreboot/default/util/bucts/"
	sed 's#/sbin#/bin#' -i Makefile
	cd "$srcdir/libreboot-${_upstream_ver}_src/coreboot/default/util/cbfstool/"
	sed 's#/sbin#/bin#' -i Makefile
	cd "$srcdir/libreboot-${_upstream_ver}_src/coreboot/default/util/cbmem/"
	sed 's#/sbin#/bin#' -i Makefile
	cd "$srcdir/libreboot-${_upstream_ver}_src/coreboot/default/util/ectool/"
	sed 's#/sbin#/bin#' -i Makefile
	cd "$srcdir/libreboot-${_upstream_ver}_src/coreboot/default/util/inteltool/"
	sed 's#/sbin#/bin#' -i Makefile
	cd "$srcdir/libreboot-${_upstream_ver}_src/coreboot/default/util/nvramtool/"
	sed 's#/sbin#/bin#' -i Makefile
	cd "$srcdir/libreboot-${_upstream_ver}_src/coreboot/default/util/superiotool/"
	sed 's#/sbin#/bin#' -i Makefile

	# Remove uneeded files.
	cd "$srcdir/libreboot-${_upstream_ver}_src/coreboot/default/"
	rm -rf tests
	rm -rf spd
	rm -rf payloads
	rm -rf Documentation
}

build() {
	# Get to the directory.
	cd "$srcdir/libreboot-${_upstream_ver}_src/coreboot/default/util/"

	# These tools uses port-mapped I/O which doesn't exist on armv7h,
	# so they fails to compile when including sys/io.h. They also need
	# port-mapped I/O to work so it's pointless to try to build them
	# on armv7h.
	if [ "${CARCH}" = "i686" -o "${CARCH}" = "x86_64" ] ; then
		# Build bucts.
		make -C bucts

		# Build ECtool.
		make -C ectool

		# Build inteltool.
		make -C inteltool

		# Build superiotool.
		make -C superiotool
	fi

	# Build bincfg.
	make -C bincfg WERROR=""

	# Build cbfstool.
	make -C cbfstool WERROR=''

	# Build cbmem.
	make -C cbmem

	# Build ifdtool
	make -C ifdtool

	# Build me_cleaner.
	cd me_cleaner
	python3 setup.py build
	cd ..

	# Build nvramtool.
	make -C nvramtool

	# Build spkmodem_recv.
	make -C spkmodem_recv
}

package() {
	# Get to the directory.
	cd "$srcdir/libreboot-${_upstream_ver}_src/coreboot/default/util/"

	# Set directories up.
	install -d "${pkgdir}"/usr/bin "${pkgdir}"/usr/share/man/man8

	# These tools uses port-mapped I/O which doesn't exist on armv7h,
	# so they fails to compile when including sys/io.h. So we also need
	# to skip their installation.
	if [ "${CARCH}" = "i686" -o "${CARCH}" = "x86_64" ] ; then
		# Install bucts.
		install -Dm755 bucts/bucts "${pkgdir}"/usr/bin/bucts

		# Install ECtool.
		make -C superiotool install DESTDIR="${pkgdir}" PREFIX=/usr

		# Install inteltool.
		make -C inteltool install DESTDIR="${pkgdir}" PREFIX=/usr

		# Install superiotool.
		make -C superiotool install DESTDIR="${pkgdir}" PREFIX=/usr
	fi

	# Install bincfg.
	install -Dm755 bincfg/bincfg "${pkgdir}"/usr/bin/bincfg

	install -d "${pkgdir}"/usr/share/bincfg
	for _file in ddr3_unregistered_spd_128.spec \
		    ddr3_unregistered_spd_256.spec \
		    ddr4_registered_spd_512.spec \
		    ddr4_unbuffered_spd_512.spec \
		    gbe-82579LM.set \
		    gbe-82579LM.spec \
		    gbe-ich9m.set \
		    gbe-ich9m.spec \
		    ifd-x200.set \
		    ifd-x200.spec \
		    it8718f-ec.spec ; do
		install -Dm644 bincfg/"${_file}" "${pkgdir}"/usr/share/bincfg/"${_file}"
	done

	# Install cbfstool.
	make -C cbfstool install DESTDIR="${pkgdir}" PREFIX=/usr

	# Install cbmem.
	make -C cbmem install DESTDIR="${pkgdir}" PREFIX=/usr

	# Install ifdtool.
	make -C ifdtool install DESTDIR="${pkgdir}" PREFIX=/usr

	# Install me_cleaner.
	cd me_cleaner
	python3 setup.py install --root="$pkgdir/" --optimize=1
	cd ..

	# Install nvramtool.
	make -C nvramtool install DESTDIR="${pkgdir}" PREFIX=/usr

	# Install spkmodem_recv.
	make -C spkmodem_recv install PREFIX="${pkgdir}/usr"
}