aboutsummaryrefslogtreecommitdiffstats
path: root/main/linux-firmware/APKBUILD
blob: 585a9f429e3ad6c88567909161b5fc5f44ec7eca (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
# Contributor: 
# Contributor: Oliver Smith <ollieparanoid@bitmessage.ch>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=linux-firmware
pkgver=20190322
pkgrel=0
pkgdesc="firmware files for linux"
#url="https://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git;a=summary"
url="http://git.kernel.org/?p=linux/kernel/git/firmware/linux-firmware.git;a=summary"
arch="all"
license="custom:multiple"
makedepends=
install=""
provides="linux-firmware-any"
provider_priority=1
options="!strip !check !archcheck !tracedeps !spdx"

_rpi_bt=96eefffcccc725425fd83be5e0704a5c32b79e54

source="https://dev.alpinelinux.org/archive/$pkgname/$pkgname-${pkgver}.tar.gz
	https://community.cypress.com/servlet/JiveServlet/download/15932-1-39799/cypress-fmac-v4.14.52-2018_0928.zip
	BCM43430A1.hcd.${_rpi_bt::8}::https://github.com/RPi-Distro/bluez-firmware/raw/$_rpi_bt/broadcom/BCM43430A1.hcd
	BCM4345C0.hcd.${_rpi_bt::8}::https://github.com/RPi-Distro/bluez-firmware/raw/$_rpi_bt/broadcom/BCM4345C0.hcd
	"

_giturl="git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git"
_upload=dev.alpinelinux.org:/archive/$pkgname/

_builddir="$srcdir"/$pkgname-$pkgver

# Put /lib/firmware/* folders in subpackages
_folders="3com acenic adaptec advansys amd amd-ucode amdgpu ar3k ath10k ath6k
	ath9k_htc atmel atusb av7110 bnx2 bnx2x brcm cadence cavium cis
	cpia2 cxgb3 cxgb4 dabusb dpaa2 dsp56k e100 edgeport emi26 emi62 ene-ub6250 ess
	go7007 i915 imx intel isci kaweth keyspan keyspan_pda korg libertas liquidio
	matrox mediatek mellanox microchip moxa mrvl mwl8k mwlwifi myricom netronome
	nvidia ositech qca qcom qed qlogic r128 radeon rockchip rsi rtl8192e rtl_bt
	rtl_nic rtlwifi rtw88 sb16 slicoss sun sxg tehuti ti-connectivity ti-keystone
	tigon ttusb-budget ueagle-atm vicam vxge yam yamaha"

subpackages="$pkgname-other::noarch $pkgname-none::noarch"
depends="linux-firmware-other=$pkgver-r$pkgrel"
for i in $_folders; do
	subpackages="$pkgname-$i:_folder:noarch $subpackages"
	depends="$pkgname-$i=$pkgver-r$pkgrel $depends"
done

snapshot() {
	local _date=$(date +%Y%m%d)
	local _pkg=$pkgname-$_date.tar.gz
	mkdir -p "$srcdir"
	cd "$srcdir"
	rm -rf "$pkgname"
	git clone --depth=1 --bare $_giturl
	git --git-dir ${_giturl##*/} archive -o $_pkg \
		--prefix=$pkgname-$_date/ HEAD
	msg "New snapshot: $_pkg"
	if [ -n "$_upload" ]; then
		msg "Uploading to $_upload"
		scp $_pkg $_upload && abump $pkgname-$_date
	fi
}

package() {
	cd "${_builddir}"
	make DESTDIR="${pkgdir}" FIRMWAREDIR="/lib/firmware" install

	# add compat links for pre-5.0 kernel
	ln -s brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt "$pkgdir"/lib/firmware/brcm/brcmfmac43455-sdio.txt
	ln -s brcmfmac43430-sdio.raspberrypi,3-model-b.txt      "$pkgdir"/lib/firmware/brcm/brcmfmac43430-sdio.txt

	local fw; for fw in $source; do
		local _f=${fw%::*}
		case $_f in
		*.hcd*)
			install -Dm 644 $srcdir/$_f \
				"$pkgdir"/lib/firmware/brcm/"${_f%.*}"
			;;
		*.zip)
			unzip -p $srcdir/${fw##*/} "cypress-firmware-*.tar.gz" | \
				tar xzv -C "$pkgdir"/lib/firmware/brcm/ \
					--wildcards --strip-components=1 \
					"*.bin" "*.clm_blob"
			;;
		esac
	done

	rm -f "${pkgdir}/usr/lib/firmware/{Makefile,README,configure,GPL-3}"

	rm -r "${pkgdir}/lib/firmware/carl9170fw/"
	find "${pkgdir}" \( -name '*.S' -or -name '*.asm' -or \
		-name '*.c' -or -name '*.h' -or -name '*.pl' -or \
                -name 'Makefile' \) -exec rm -- {} \;
}

_folder() {
	local folder=${subpkgname##linux-firmware-}
	pkgdesc="firmware files for linux ($folder folder)"
	depends=""
	provides="linux-firmware-any"
	provider_priority=

	# Move /lib/firmware/$folder (case insensitive)
	mkdir -p "$subpkgdir/lib/firmware"
	mv "$(find "$pkgdir/lib/firmware" -iname "$folder" -type d)" \
		"$subpkgdir/lib/firmware"
}

other() {
	# Requires subfolders to be split in subpackages
	local leftover=""
	local i
	for i in "$pkgdir"/lib/firmware/*; do
		[ -d "$i" ] && leftover="$leftover $(basename $i)"
	done
	if [ "$leftover" != "" ]; then
		local fixed
		error "Not all subfolders have been moved to subpackages!"
		error "Fix this by adjusting _folders as follows:"
		fixed="$(echo $_folders$leftover | tr " " "\n" | tr '[A-Z]' '[a-z]' | sort)"
		echo "_folders=\"$(printf "$fixed" | tr "\n" " ")\"" | fold -s
		return 1
	fi

	# Move /lib/firmware (which doesn't have subfolders now)
	pkgdesc="firmware files for linux (uncategorized)"
	depends=""
	provides="linux-firmware-any"
	provider_priority=
	mkdir -p "$subpkgdir"/
	mv "$pkgdir"/lib "$subpkgdir"/
}

none() {
	# dummy package with no firmware
	pkgdesc="Empty linux firwmare package for those who does not need any firmware"
	provider_priority=
	provides="linux-firmware-any"
	depends=
	mkdir -p "$subpkgdir"
}


sha512sums="d88837cf6d5674294cc78b946f97b9ecdf2a1beae00d6e9df0a60573ac720814240643c729ae9672591263bf796e966824239c5c93a29a606511c48352b83a3f  linux-firmware-20190322.tar.gz
cc423a6b1ca2fab5a05577d98a732668d1e30fd39ce65e3b12692bc8bda26295249944e44081e6a476fb4d695ebe65afd6fb0fe90fc5f2a00a21d7e0d9b9962c  cypress-fmac-v4.14.52-2018_0928.zip
a7b37bce092367125e390017bb0329c3b7f8fa891cf30d422ee73ce53d0592d4ff0fc2e2a94a87eefb641d5dd8631fae1cc46664224dea987ca04b68a8af8519  BCM43430A1.hcd.96eefffc
83015026e740cbe14a3991bf751eb7aba6aeaab1835c0252c449376b2700d87f8d24e1f4dd2317fbb333665907ba5760db9d858ac06e2d357e1add944e1dbc2d  BCM4345C0.hcd.96eefffc"