scripts/package/PKGBUILD

Source file repositories/reference/linux-study-clean/scripts/package/PKGBUILD

File Facts

System
Linux kernel
Corpus path
scripts/package/PKGBUILD
Extension
[no extension]
Size
3475 bytes
Lines
135
Domain
Support Tooling And Documentation
Bucket
scripts
Inferred role
Support Tooling And Documentation: scripts
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

# SPDX-License-Identifier: GPL-2.0-only
# Maintainer: Thomas Weißschuh <linux@weissschuh.net>
# Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgbase=${PACMAN_PKGBASE:-linux-upstream}
pkgname=("${pkgbase}")

_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers debug}
for pkg in $_extrapackages; do
	pkgname+=("${pkgbase}-${pkg}")
done

pkgver="$(echo "${KERNELRELEASE}" | sed 's/-\(rc[0-9]\+\)/\1/;s/-/_/g')"
# The PKGBUILD is evaluated multiple times.
# Running scripts/build-version from here would introduce inconsistencies.
pkgrel="${KBUILD_REVISION}"
pkgdesc='Upstream Linux'
url='https://www.kernel.org/'
# Enable flexible cross-compilation
arch=(${CARCH})
license=(GPL-2.0-only)
makedepends=(
	bc
	bison
	flex
	gettext
	kmod
	libelf
	openssl
	pahole
	perl
	python
	rsync
	tar
)
options=(!debug !strip !buildflags !makeflags)

_prologue() {
	# MAKEFLAGS from makepkg.conf override the ones inherited from kbuild.
	# Bypass this override with a custom variable.
	export MAKEFLAGS="${KBUILD_MAKEFLAGS}"

	# Kbuild works in the output directory, where this PKGBUILD is located.
	cd "$(dirname "${BASH_SOURCE[0]}")"
}

build() {
	_prologue

	${MAKE} KERNELRELEASE="${KERNELRELEASE}" KBUILD_BUILD_VERSION="${pkgrel}"
}

_package() {
	pkgdesc="The ${pkgdesc} kernel and modules"

	local modulesdir="${pkgdir}/usr/lib/modules/${KERNELRELEASE}"

	_prologue

	echo "Installing boot image..."
	# systemd expects to find the kernel here to allow hibernation
	# https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
	install -Dm644 "$(${MAKE} -s image_name)" "${modulesdir}/vmlinuz"

	# Used by mkinitcpio to name the kernel
	echo "${pkgbase}" > "${modulesdir}/pkgbase"

	echo "Installing modules..."
	${MAKE} INSTALL_MOD_PATH="${pkgdir}/usr" INSTALL_MOD_STRIP=1 \
		DEPMOD=true modules_install

Annotation

Implementation Notes