scripts/package/builddeb

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

File Facts

System
Linux kernel
Corpus path
scripts/package/builddeb
Extension
[no extension]
Size
5969 bytes
Lines
177
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

#!/bin/sh
#
# builddeb 1.3
# Copyright 2003 Wichert Akkerman <wichert@wiggy.net>
#
# Simple script to generate a deb package for a Linux kernel. All the
# complexity of what to do with a kernel after it is installed or removed
# is left to other scripts and packages. Scripts can be placed into the
# preinst, postinst, prerm and postrm directories in /etc/kernel or
# /usr/share/kernel. A different list of search directories can be given
# via KDEB_HOOKDIR. Scripts in directories earlier in the list will
# override scripts of the same name in later directories.  The script will
# be called on package installation and removal.

set -eu

is_enabled() {
	grep -q "^$1=y" include/config/auto.conf
}

if_enabled_echo() {
	if is_enabled "$1"; then
		echo -n "$2"
	elif [ $# -ge 3 ]; then
		echo -n "$3"
	fi
}

install_linux_image () {
	pname=$1
	pdir=debian/$1

	# Only some architectures with OF support have this target
	if is_enabled CONFIG_OF_EARLY_FLATTREE && [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then
		${MAKE} -f ${srctree}/Makefile INSTALL_DTBS_PATH="${pdir}/usr/lib/linux-image-${KERNELRELEASE}" dtbs_install
	fi

	${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" INSTALL_MOD_STRIP=1 modules_install
	rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build"

	# Install the kernel
	if [ "${ARCH}" = um ] ; then
		mkdir -p "${pdir}/usr/lib/uml/modules"
		mv "${pdir}/lib/modules/${KERNELRELEASE}" "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}"
		mkdir -p "${pdir}/usr/bin" "${pdir}/usr/share/doc/${pname}"
		cp System.map "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}/System.map"
		cp ${KCONFIG_CONFIG} "${pdir}/usr/share/doc/${pname}/config"
		gzip "${pdir}/usr/share/doc/${pname}/config"
	else
		mkdir -p "${pdir}/boot"
		cp System.map "${pdir}/boot/System.map-${KERNELRELEASE}"
		cp ${KCONFIG_CONFIG} "${pdir}/boot/config-${KERNELRELEASE}"
	fi

	# Not all arches have the same installed path in debian
	# XXX: have each arch Makefile export a variable of the canonical image install
	# path instead
	case "${SRCARCH}" in
	um)
		installed_image_path="usr/bin/linux-${KERNELRELEASE}";;
	parisc|mips|powerpc)
		installed_image_path="boot/vmlinux-${KERNELRELEASE}";;
	*)
		installed_image_path="boot/vmlinuz-${KERNELRELEASE}";;
	esac
	cp "$(${MAKE} -s -f ${srctree}/Makefile image_name)" "${pdir}/${installed_image_path}"

	if [ "${ARCH}" != um ]; then
		install_maint_scripts "${pdir}"
	fi

Annotation

Implementation Notes