build icon indicating copy to clipboard operation
build copied to clipboard

[Bug]: `BUILD_KSRC` switch gone

Open EvilOlaf opened this issue 7 months ago • 10 comments

What happened?

With the update to the new framework the BUILD_KSRC has been removed it seems. No clue if that was by mistake or intentionally removed due to reasons. From time to time folks asking for a kernel source package for their board. Seemed handy.

The function to create the config used to look something like this:

#!/usr/bin/env bash
create_linux-source_package() {
	ts=$(date +%s)
	local sources_pkg_dir tmp_src_dir
	tmp_src_dir=$(mktemp -d)
	trap "ret=\$?; rm -rf \"${tmp_src_dir}\" ; exit \$ret" 0 1 2 3 15
	sources_pkg_dir=${tmp_src_dir}/${CHOSEN_KSRC}_${REVISION}_all
	mkdir -p "${sources_pkg_dir}"/usr/src/ \
		"${sources_pkg_dir}"/usr/share/doc/linux-source-${version}-${LINUXFAMILY} \
		"${sources_pkg_dir}"/DEBIAN

	cp "${SRC}/config/kernel/${LINUXCONFIG}.config" "default_${LINUXCONFIG}.config"
	xz < .config > "${sources_pkg_dir}/usr/src/${LINUXCONFIG}_${version}_${REVISION}_config.xz"

	display_alert "Compressing sources for the linux-source package"
	tar cp --directory="$kerneldir" --exclude='.git' --owner=root . |
		pv -p -b -r -s "$(du -sb "$kerneldir" --exclude=='.git' | cut -f1)" |
		pixz -4 > "${sources_pkg_dir}/usr/src/linux-source-${version}-${LINUXFAMILY}.tar.xz"
	cp COPYING "${sources_pkg_dir}/usr/share/doc/linux-source-${version}-${LINUXFAMILY}/LICENSE"

	cat <<- EOF > "${sources_pkg_dir}"/DEBIAN/control
		Package: linux-source-${version}-${BRANCH}-${LINUXFAMILY}
		Version: ${version}-${BRANCH}-${LINUXFAMILY}+${REVISION}
		Architecture: all
		Maintainer: $MAINTAINER <$MAINTAINERMAIL>
		Section: kernel
		Priority: optional
		Depends: binutils, coreutils, linux-base
		Provides: linux-source, linux-source-${version}-${LINUXFAMILY}
		Recommends: gcc, make
		Description: This package provides the source code for the Linux kernel $version
	EOF

	fakeroot dpkg-deb -b -Z${DEB_COMPRESS} -z0 "${sources_pkg_dir}" "${sources_pkg_dir}.deb"
	rsync --remove-source-files -rq "${sources_pkg_dir}.deb" "${DEB_STORAGE}/"

	te=$(date +%s)
	display_alert "Make the linux-source package" "$(($te - $ts)) sec." "info"
	rm -rf "${tmp_src_dir}"
}

How to reproduce?

Branch

main (main development branch)

On which host OS are you running the build script and observing this problem?

Ubuntu 24.04 Noble

Are you building on Windows WSL2?

  • [ ] Yes, my Ubuntu/Debian/OtherOS is running on WSL2

Relevant log URL

No response

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

EvilOlaf avatar May 06 '25 04:05 EvilOlaf

Jira ticket: AR-2673

github-actions[bot] avatar May 06 '25 04:05 github-actions[bot]

I don't recall. @rpardini

igorpecovnik avatar May 06 '25 05:05 igorpecovnik

Building a source package makes very little sense -- the packaging is done in armbian/build for some 3 years now. Yes, one could export a .deb containing a flat tarball (thus losing all patch information) of sources after patching, but building that would result in absolutely nothing usable. Developers in-the-know enough could use rewrite-kernel-patches PUSH_<xxx> to get a git tree that is patched the same way as our packages.

rpardini avatar May 06 '25 07:05 rpardini

Sometimes user demands don't necessarily make sense ;)

EvilOlaf avatar May 06 '25 11:05 EvilOlaf

Building a source package makes very little sense

Oh ho ho. Then why do all self-respecting distributions provide source packages for their binary packages?

This is not even a matter for discussion.

The-going avatar May 06 '25 13:05 The-going

armbian/build does not create source packages for any of the "binary" packages it produces. bsp-cli? no. desktop stuff? no. u-boot? no. kernel? no.

The old stuff shipped a (different and also "binary") package called kernel-sources with a tarball inside. Go ahead and bring it back if you need it, but understand building it produces different .debs than what armbian/build produces.

nb that after 6.12 the upstream Kbuild now knows how to package cross-compiled headers. And since it "always knew" how to produce a source package that builds itself, armbian/build simply disappears kernel-wise. 6.1 is LTS until 2028 so it will take a while.

rpardini avatar May 06 '25 21:05 rpardini

Very poorly made adaption as extension:

function extension_prepare_config__linux_source_package_extension() {
	display_alert "Packaging kernel source enabled. This will enforce ARTIFACT_IGNORE_CACHE=yes in order to prepare the source code." "${EXTENSION}" "info"
	declare -g ARTIFACT_IGNORE_CACHE=yes	# enforce building from scratch
	declare -g KERNEL_GIT=shallow			# download necessary branch only
}

function add_host_dependencies__add_fakeroot() {
	display_alert "Adding packages to host dependencies" "${EXTENSION}" "info"
	EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} fakeroot"
}

function armbian_kernel_config__create_ksrc_package() {
	if [[ -f .config ]]; then

		#( set -o posix ; set )
		echo ${kernel_version_family}

		display_alert "Packaging kernel source..." "${EXTENSION}" "info"
		declare kernel_work_dir="${SRC}/cache/sources/${LINUXSOURCEDIR}"
		declare CHOSEN_KSRC=linux-source-${BRANCH}-${LINUXFAMILY}

		ts=$(date +%s)
		local sources_pkg_dir tmp_src_dir
		tmp_src_dir=$(mktemp -d)
		trap "ret=\$?; rm -rf \"${tmp_src_dir}\" ; exit \$ret" 0 1 2 3 15
		sources_pkg_dir=${tmp_src_dir}/${CHOSEN_KSRC}_${REVISION}_all
		mkdir -p "${sources_pkg_dir}"/usr/src/ \
			"${sources_pkg_dir}"/usr/share/doc/linux-source-${version}-${LINUXFAMILY} \
			"${sources_pkg_dir}"/DEBIAN

		cp "${SRC}/config/kernel/${LINUXCONFIG}.config" "default_${LINUXCONFIG}.config"
		xz < ${kernel_work_dir}/.config > "${sources_pkg_dir}/usr/src/${LINUXCONFIG}_${version}_${REVISION}_config.xz"

		display_alert "Compressing sources for the linux-source package" "${EXTENSION}" "info"
		tar cp --directory="$kernel_work_dir" --exclude='.git' --owner=root . |
			pv -p -b -r -s "$(du -sb "$kernel_work_dir" --exclude=='.git' | cut -f1)" |
			xz -T0 -1 > "${sources_pkg_dir}/usr/src/linux-source-${version}-${LINUXFAMILY}.tar.xz"
		cp ${kernel_work_dir}/COPYING "${sources_pkg_dir}/usr/share/doc/linux-source-${version}-${LINUXFAMILY}/LICENSE"

		cat <<- EOF > "${sources_pkg_dir}"/DEBIAN/control
			Package: linux-source-${version}-${BRANCH}-${LINUXFAMILY}
			Version: ${version}-${BRANCH}-${LINUXFAMILY}+${REVISION}
			Architecture: all
			Maintainer: $MAINTAINER <$MAINTAINERMAIL>
			Section: kernel
			Priority: optional
			Depends: binutils, coreutils, linux-base
			Provides: linux-source, linux-source-${REVISION}-${LINUXFAMILY}
			Recommends: gcc, make
			Description: This package provides the source code for the Linux kernel $REVISION
		EOF

		fakeroot dpkg-deb -b -z0 "${sources_pkg_dir}" "${sources_pkg_dir}.deb"
		rsync --remove-source-files -rq "${sources_pkg_dir}.deb" "${DEB_STORAGE}/"

		te=$(date +%s)
		display_alert "Make the linux-source package" "$(($te - $ts)) sec." "info"
		rm -rf "${tmp_src_dir}"
	fi
}

EvilOlaf avatar May 13 '25 09:05 EvilOlaf

Not sure if the source package should contain either the Linux version or the hash or both...couldn't manage to get it to work either way. For some reason ${version} is empty seems empty when used but when read the variable has contents...I don't get it.

EvilOlaf avatar May 14 '25 03:05 EvilOlaf

I'd like to suggest this as wontfix if we are not going to address it.

leggewie avatar Nov 19 '25 09:11 leggewie

fwiw I recently saw a similar request on IRC/Discrord for a uboot src-pkg. As to why, I expect some ppl expect it as part of GPL compliance, in that it is how, 20-30 years ago, it was done [and as @The-going noted, many distros still do]. OTOH, as long as there is enough info in our git to reproduce the same trees, it doesn't feel essential.

tabrisnet avatar Nov 19 '25 10:11 tabrisnet