diff mbox series

[6/9] UBUNTU: [Packaging] convert to direct ancillaries

Message ID 20220914135455.2685644-7-apw@canonical.com
State New
Headers show
Series [1/9] UBUNTU: [Packaging] fix our dh_clean override | expand

Commit Message

Andy Whitcroft Sept. 14, 2022, 1:54 p.m. UTC
Convert the rather opaque "sed the changelog" ancillaries into direct
ancillaries in debian/ancillary.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 .../debian/rules.in}                          |   0
 .../debian/scripts/gen-rules}                 |   2 +-
 .../debian/rules.in}                          |   0
 .../debian/scripts/gen-rules}                 |   2 +-
 .../download-signed                           |   0
 debian/scripts/gen-rules                      | 267 +++++++++++++++++-
 debian/scripts/gen-rules.lrm                  | 266 -----------------
 7 files changed, 263 insertions(+), 274 deletions(-)
 rename debian/{rules.lrg => ancillary/linux-restricted-generate/debian/rules.in} (100%)
 rename debian/{scripts/gen-rules.lrg => ancillary/linux-restricted-generate/debian/scripts/gen-rules} (98%)
 rename debian/{rules.lrs => ancillary/linux-restricted-signatures/debian/rules.in} (100%)
 rename debian/{scripts/gen-rules.lrs => ancillary/linux-restricted-signatures/debian/scripts/gen-rules} (98%)
 rename download-signed => debian/ancillary/linux-restricted-signatures/download-signed (100%)
 delete mode 100755 debian/scripts/gen-rules.lrm

Comments

Stefan Bader Sept. 23, 2022, 1:38 p.m. UTC | #1
On 14.09.22 15:54, Andy Whitcroft wrote:
> Convert the rather opaque "sed the changelog" ancillaries into direct
> ancillaries in debian/ancillary.
> 
> Signed-off-by: Andy Whitcroft <apw@canonical.com>
> ---
>   .../debian/rules.in}                          |   0
>   .../debian/scripts/gen-rules}                 |   2 +-
>   .../debian/rules.in}                          |   0
>   .../debian/scripts/gen-rules}                 |   2 +-
>   .../download-signed                           |   0
>   debian/scripts/gen-rules                      | 267 +++++++++++++++++-
>   debian/scripts/gen-rules.lrm                  | 266 -----------------
>   7 files changed, 263 insertions(+), 274 deletions(-)
>   rename debian/{rules.lrg => ancillary/linux-restricted-generate/debian/rules.in} (100%)
>   rename debian/{scripts/gen-rules.lrg => ancillary/linux-restricted-generate/debian/scripts/gen-rules} (98%)
>   rename debian/{rules.lrs => ancillary/linux-restricted-signatures/debian/rules.in} (100%)
>   rename debian/{scripts/gen-rules.lrs => ancillary/linux-restricted-signatures/debian/scripts/gen-rules} (98%)
>   rename download-signed => debian/ancillary/linux-restricted-signatures/download-signed (100%)
>   delete mode 100755 debian/scripts/gen-rules.lrm
> 
> diff --git a/debian/rules.lrg b/debian/ancillary/linux-restricted-generate/debian/rules.in
> similarity index 100%
> rename from debian/rules.lrg
> rename to debian/ancillary/linux-restricted-generate/debian/rules.in
> diff --git a/debian/scripts/gen-rules.lrg b/debian/ancillary/linux-restricted-generate/debian/scripts/gen-rules
> similarity index 98%
> rename from debian/scripts/gen-rules.lrg
> rename to debian/ancillary/linux-restricted-generate/debian/scripts/gen-rules
> index d1e528a..27c79c4 100755
> --- a/debian/scripts/gen-rules.lrg
> +++ b/debian/ancillary/linux-restricted-generate/debian/scripts/gen-rules
> @@ -30,7 +30,7 @@ src_main_version=$(echo ${src_version} | sed -e 's/+[0-9][0-9\.]*$//')
>   src_lrm_package=$(echo "${src_package}" | sed -e 's/-restricted-generate/-restricted-modules/')
>   src_lrm_version=${src_version}
>   
> -cat - "debian/rules.lrg" >"debian/rules.gen" <<EOL
> +cat - "debian/rules.in" >"debian/rules.gen" <<EOL
>   #! /usr/bin/make -f
>   
>   src_package := ${src_package}
> diff --git a/debian/rules.lrs b/debian/ancillary/linux-restricted-signatures/debian/rules.in
> similarity index 100%
> rename from debian/rules.lrs
> rename to debian/ancillary/linux-restricted-signatures/debian/rules.in
> diff --git a/debian/scripts/gen-rules.lrs b/debian/ancillary/linux-restricted-signatures/debian/scripts/gen-rules
> similarity index 98%
> rename from debian/scripts/gen-rules.lrs
> rename to debian/ancillary/linux-restricted-signatures/debian/scripts/gen-rules
> index f7f7648..ed74d70 100755
> --- a/debian/scripts/gen-rules.lrs
> +++ b/debian/ancillary/linux-restricted-signatures/debian/scripts/gen-rules
> @@ -30,7 +30,7 @@ src_genr_version=${src_version}
>   
>   # linux-restricted-modules/5.8.0-41.46[+1]
>   
> -cat - "debian/rules.lrs" >"debian/rules.gen" <<EOL
> +cat - "debian/rules.in" >"debian/rules.gen" <<EOL
>   #! /usr/bin/make -f
>   
>   src_package := ${src_package}
> diff --git a/download-signed b/debian/ancillary/linux-restricted-signatures/download-signed
> similarity index 100%
> rename from download-signed
> rename to debian/ancillary/linux-restricted-signatures/download-signed
> diff --git a/debian/scripts/gen-rules b/debian/scripts/gen-rules
> index c5c36a6..f9f5eca 100755
> --- a/debian/scripts/gen-rules
> +++ b/debian/scripts/gen-rules
> @@ -1,11 +1,266 @@
>   #!/bin/bash
>   set -e
>   
> +validate_unique()
> +{
> +	[ "$#" = "2" ]

Maybe cleverly short but hard to read...

> +	local duplicates=$(echo $2 | tr " " "\n" | sort | uniq -d)
> +	if [ "$duplicates" ]; then
> +		echo "EE: duplicate values in $1" 1>&2
> +		exit 1

Both tests _are_ supposed to abort any execution, right? First exit would be silent.

> +	fi
> +}
> +
> +# Pick out relevant version and package information including our predecessor
> +# packages: linux -> linux-restricted-modules-signatures -> linux-restricted-modules
>   src_package=$(LC_ALL=C dpkg-parsechangelog -SSource)
> -case "$src_package" in
> -linux-restricted-generate*)	pkg='lrg' ;;
> -linux-restricted-signature*)	pkg='lrs' ;;
> -linux-restricted-modules*)	pkg='lrm' ;;
> -esac
> +src_version=$(LC_ALL=C dpkg-parsechangelog -SVersion)
> +src_abi=$(echo "${src_version}" | sed -ne 's/\([0-9]*\.[0-9]*\.[0-9]*\-[0-9]*\)\..*/\1/p')
> +src_series=$(LC_ALL=C dpkg-parsechangelog -SDistribution | sed -e 's/-\(security\|updates\|proposed\)$//')
> +
> +# linux/5.8.0-41.46
> +src_main_package=$(echo "${src_package}" | sed -e 's/-restricted-modules//')
> +src_main_version=$(echo ${src_version} | sed -e 's/+[0-9][0-9\.]*$//')
> +
> +# linux-restricted-generate/5.8.0-41.46[+1]
> +src_genr_package=$(echo "${src_package}" | sed -e 's/-restricted-modules/-restricted-generate/')
> +src_genr_version=${src_version}
> +
> +# linux-restricted-signatures/5.8.0-41.46[+1]
> +src_sigs_package=$(echo "${src_package}" | sed -e 's/-restricted-modules/-restricted-signatures/')
> +src_sigs_version=${src_version}
> +
> +# linux-restricted-modules/5.8.0-41.46[+1]
> +
> +mkdir -p "debian/control.d"
> +: >"debian/control.interlock-up"
> +: >"debian/control.d/meta-nvidia"
> +: >"debian/control.d/nvidia"
> +: >"debian/control.d/migrate-nvidia"
> +: >"debian/control.d/transitionals-local"
> +: >"debian/control.d/signatures"

Likewise maybe valid syntax but cryptic like heck...

Below, a bit too much to consume on a theoretical level...

> +
> +cat - "debian/rules.in" >"debian/rules.gen" <<EOL
> +#! /usr/bin/make -f
> +
> +src_package := ${src_package}
> +src_version = ${src_version}
> +src_abi = ${src_abi}
> +src_series = ${src_series}
> +src_main_package = ${src_main_package}
> +src_main_version = ${src_main_version}
> +src_genr_package = ${src_genr_package}
> +src_genr_version = ${src_genr_version}
> +src_sigs_package = ${src_sigs_package}
> +src_sigs_version = ${src_sigs_version}
> +
> +EOL
> +
> +dkms_build_new=$(grep -c 'shift 7' debian/scripts/dkms-build)
> +if [ "$dkms_build_new" -eq 0 ]; then
> +	sed -i -e '/debian\/scripts\/dkms-build/s/ $(4)//' debian/rules.gen
> +fi
> +
> +nvidia_desktop=
> +nvidia_server=
> +nvidia_ignore=
> +while read command arg
> +do
> +	case "$command" in
> +	option)		;;
> +	suppress)		nvidia_ignore="$nvidia_ignore $arg"; continue ;;
> +	*)		continue ;;
> +	esac
> +
> +	case "$arg" in
> +	desktop)	nvidia_desktop=y ;;
> +	server)		nvidia_server=y ;;
> +	esac
> +done <"debian/package.config"
> +
> +while read command flavour archs
> +do
> +	case "$command" in
> +	build)		;;
> +	*)		continue ;;
> +	esac
> +
> +	validate_unique "archs" "$archs"
> +	cat - >>"debian/control.interlock-up" <<EOL
> + linux-headers-${src_abi}-${flavour} (>= @VERSION@) [${archs}],
> +EOL
> +
> +	while read package version extra
> +	do
> +		case "$package" in
> +		nvidia-graphics-drivers-*-server)
> +			[ -z "$nvidia_server" ] && continue
> +			;;
> +		nvidia-graphics-drivers-*)
> +			[ -z "$nvidia_desktop" ] && continue
> +			;;
> +		*) continue ;;
> +		esac
> +		case " $nvidia_ignore " in
> +		*\ $package\ *)		continue ;;
> +		esac
> +
> +		case " $extra " in
> +		*\ signonly\ *)		continue ;;
> +		esac
> +
> +		# If package specifies arch= keys, only build it on
> +		# the intersection of kernel flavour arches & the
> +		# package arches, otherwise build for all kernel
> +		# flavour arches.
> +		pkg_archs=
> +		for cmd in $extra
> +		do
> +			case "$cmd" in
> +			arch=*)		pkg_archs="$pkg_archs ${cmd#arch=}" ;;
> +			esac
> +		done
> +		# No package arches set, build for everything
> +		if [ -z "$pkg_archs" ]; then
> +			pkg_archs=$archs
> +		else
> +			# Package arches set, build for intersection
> +			validate_unique "pkg_archs" "$pkg_archs"
> +			pkg_archs=$(sort <(echo $archs | tr " " "\n") <(echo $pkg_archs | tr " " "\n") | uniq -d | tr "\n" " ")
> +			# No intersection, skip
> +			if [ -z "$pkg_archs" ]; then
> +				continue
> +			fi
> +		fi
> +
> +		targets=$(echo "$pkg_archs" | sed -e 's/\</nvidia-/g')
> +		suffix_minus=$(echo "$package" | sed -e 's/nvidia-graphics-drivers-//')
> +		suffix_under=$(echo "$suffix_minus" | sed -e 's/-/_/g')
> +		suffix_short=$(echo "$suffix_minus" | sed -e 's/-server/srv/g')
> +
> +		echo "II: build $package for $flavour $pkg_archs"
> +
> +		# debian/rules.gen
> +		cat - >>"debian/rules.gen" <<EOL
> +
> +# $package $version $suffix_minus $suffix_under
> +dkms_nvidia_${suffix_under}_version="$version"
> +nvidia_${suffix_under}_upstream_version=\$(shell echo "\$(dkms_nvidia_${suffix_under}_version)" | cut -d '-' -f 1)
> +gencontrol_flags += -Vdkms:nvidia-${suffix_minus}-modules="nvidia-dkms-${suffix_minus} (= \$(dkms_nvidia_${suffix_under}_version))"
> +gencontrol_flags += -Vnvk:nvidia-${suffix_minus}="nvidia-kernel-common-${suffix_minus} (<= \$(nvidia_${suffix_under}_upstream_version)-1), nvidia-kernel-common-${suffix_minus} (>= \$(nvidia_${suffix_under}_upstream_version))"
> +test::
> +	@echo $package $version $suffix_minus $suffix_under $suffix_short $targets
> +$targets::
> +	rm -rf \$(dkms_dir)/build \$(dkms_dir)/source
> +	mkdir -p \$(dkms_dir)/build \$(dkms_dir)/source
> +	install -d debian/linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour}
> +	install -d debian/linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour}/usr/lib/linux/triggers
> +	\$(call install_control,linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour},${flavour},nvidia,${suffix_short},postinst postrm prerm config templates)
> +	install -d debian/linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}
> +	\$(call build_dkms, \$(src_abi)-${flavour}, linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}, \$(CURDIR)/debian/linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}/lib/modules/\$(src_abi)-${flavour}/kernel, "", nvidia-${suffix_short}, pool/restricted/n/nvidia-graphics-drivers-${suffix_minus}/nvidia-kernel-source-${suffix_minus}_\$(dkms_nvidia_${suffix_under}_version)_\$(arch).deb pool/restricted/n/nvidia-graphics-drivers-${suffix_minus}/nvidia-dkms-${suffix_minus}_\$(dkms_nvidia_${suffix_under}_version)_\$(arch).deb)
> +EOL
> +
> +		# debian/control.d/meta-nvidia
> +		cat - >>"debian/control.d/meta-nvidia" <<EOL
> +
> +Package: linux-modules-nvidia-${suffix_minus}-${flavour}\${variant:suffix}
> +Build-Profiles: <!stage1>
> +Architecture: ${pkg_archs}
> +Section: kernel
> +Provides: \${dkms:nvidia-${suffix_minus}-modules}, nvidia-prebuilt-kernel
> +Depends:
> + \${misc:Depends},
> + linux-modules-nvidia-${suffix_minus}-${src_abi}-${flavour} (= \${binary:Version}),
> + \${nvk:nvidia-${suffix_minus}},
> +Description: Extra drivers for nvidia-${suffix_minus} for the ${flavour}\${variant:suffix} flavour
> + Install extra signed nvidia-${suffix_minus} modules compatible with the ${flavour}\${variant:suffix} flavour.
> +EOL
> +
> +		# debian/control.d/nvidia
> +		cat - >>"debian/control.d/nvidia" <<EOL
> +
> +Package: linux-objects-nvidia-${suffix_minus}-${src_abi}-${flavour}
> +Build-Profiles: <!stage1>
> +Architecture: ${pkg_archs}
> +Section: kernel
> +Priority: optional
> +Built-Using: \${linux:BuiltUsing}
> +Depends:
> + \${misc:Depends},
> + \${shlibs:Depends},
> + binutils,
> +Description: Linux kernel nvidia modules for version ${src_abi} (objects)
> + This package contains the Linux kernel nvidia modules for version ${src_abi}.
> + .
> + You likely do not want to install this package directly. Instead, install the
> + one of the linux-modules-nvidia-${suffix_minus}-${flavour}* meta-packages,
> + which will ensure that upgrades work correctly, and that supporting packages are
> + also installed.
> +
> +Package: linux-modules-nvidia-${suffix_minus}-${src_abi}-${flavour}
> +Build-Profiles: <!stage1>
> +Architecture: ${pkg_archs}
> +Section: kernel
> +Priority: optional
> +Built-Using: \${linux:BuiltUsing}
> +Depends:
> + \${misc:Depends},
> + \${shlibs:Depends},
> + linux-image-${src_abi}-${flavour} | linux-image-unsigned-${src_abi}-${flavour},
> + linux-signatures-nvidia-${src_abi}-${flavour} (= ${src_sigs_version}),
> + linux-objects-nvidia-${suffix_minus}-${src_abi}-${flavour} (= \${binary:Version}),
> + \${nvk:nvidia-${suffix_minus}},
> +Description: Linux kernel nvidia modules for version ${src_abi}
> + This package pulls together the Linux kernel nvidia modules for
> + version ${src_abi} with the appropriate signatures.
> + .
> + You likely do not want to install this package directly. Instead, install the
> + one of the linux-modules-nvidia-${suffix_minus}-${flavour}* meta-packages,
> + which will ensure that upgrades work correctly, and that supporting packages are
> + also installed.
> +EOL
> +		# debian/control.d/migrate-nvidia
> +		for cmd in $extra
> +		do
> +			case "$cmd" in
> +			transition=*)
> +				from="${cmd#transition=}"
> +				from_minus=$(echo "$from" | sed -e 's/nvidia-graphics-drivers-//')
> +				echo "II: general transition $from -> $package ($from_minus -> $suffix_minus) $pkg_archs"
> +				cat - >>"debian/control.d/migrate-nvidia" <<EOL
> +
> +Package: linux-modules-nvidia-${from_minus}-${flavour}\${variant:suffix}
> +Architecture: ${pkg_archs}
> +Section: oldlibs
> +Depends: linux-modules-nvidia-${suffix_minus}-${flavour}\${variant:suffix}
> +Description: Extra drivers for nvidia-${from_minus} for the ${flavour} flavour (dummy transitional package)
> + Transitional package for upgrades of -${from_minus} to -${suffix_minus}.
> +EOL
> +				;;
> +			esac
> +				#suffix_minus=$(echo "$package" | sed -e 's/nvidia-graphics-drivers-//')
> +				#suffix_under=$(echo "$suffix_minus" | sed -e 's/-/_/g')
> +				#suffix_short=$(echo "$suffix_minus" | sed -e 's/-server/srv/g')
> +		done
> +	done <"debian/dkms-versions"
> +done <"debian/package.config"
> +
> +while read command from to archs
> +do
> +	case "$command" in
> +	transitional)	;;
> +	*)		continue ;;
> +	esac
> +
> +	# debian/control.d/transitionals-local
> +	echo "II: manual transition linux-modules-nvidia-$from -> linux-modules-nvidia-$to $archs"
> +	cat - >>"debian/control.d/transitionals-local" <<EOL
>   
> -exec "$0.$pkg" "$@"
> +Package: linux-modules-nvidia-${from}
> +Architecture: ${archs}
> +Section: oldlibs
> +Depends: linux-modules-nvidia-${to}
> +Description: Extra drivers for nvidia-${from} (dummy transitional package)
> + Transitional package for upgrades of ${from} to ${to}.
> +EOL
> +done <"debian/package.config"
> diff --git a/debian/scripts/gen-rules.lrm b/debian/scripts/gen-rules.lrm
> deleted file mode 100755
> index f9f5eca..0000000
> --- a/debian/scripts/gen-rules.lrm
> +++ /dev/null
> @@ -1,266 +0,0 @@
> -#!/bin/bash
> -set -e
> -
> -validate_unique()
> -{
> -	[ "$#" = "2" ]
> -	local duplicates=$(echo $2 | tr " " "\n" | sort | uniq -d)
> -	if [ "$duplicates" ]; then
> -		echo "EE: duplicate values in $1" 1>&2
> -		exit 1
> -	fi
> -}
> -
> -# Pick out relevant version and package information including our predecessor
> -# packages: linux -> linux-restricted-modules-signatures -> linux-restricted-modules
> -src_package=$(LC_ALL=C dpkg-parsechangelog -SSource)
> -src_version=$(LC_ALL=C dpkg-parsechangelog -SVersion)
> -src_abi=$(echo "${src_version}" | sed -ne 's/\([0-9]*\.[0-9]*\.[0-9]*\-[0-9]*\)\..*/\1/p')
> -src_series=$(LC_ALL=C dpkg-parsechangelog -SDistribution | sed -e 's/-\(security\|updates\|proposed\)$//')
> -
> -# linux/5.8.0-41.46
> -src_main_package=$(echo "${src_package}" | sed -e 's/-restricted-modules//')
> -src_main_version=$(echo ${src_version} | sed -e 's/+[0-9][0-9\.]*$//')
> -
> -# linux-restricted-generate/5.8.0-41.46[+1]
> -src_genr_package=$(echo "${src_package}" | sed -e 's/-restricted-modules/-restricted-generate/')
> -src_genr_version=${src_version}
> -
> -# linux-restricted-signatures/5.8.0-41.46[+1]
> -src_sigs_package=$(echo "${src_package}" | sed -e 's/-restricted-modules/-restricted-signatures/')
> -src_sigs_version=${src_version}
> -
> -# linux-restricted-modules/5.8.0-41.46[+1]
> -
> -mkdir -p "debian/control.d"
> -: >"debian/control.interlock-up"
> -: >"debian/control.d/meta-nvidia"
> -: >"debian/control.d/nvidia"
> -: >"debian/control.d/migrate-nvidia"
> -: >"debian/control.d/transitionals-local"
> -: >"debian/control.d/signatures"
> -
> -cat - "debian/rules.in" >"debian/rules.gen" <<EOL
> -#! /usr/bin/make -f
> -
> -src_package := ${src_package}
> -src_version = ${src_version}
> -src_abi = ${src_abi}
> -src_series = ${src_series}
> -src_main_package = ${src_main_package}
> -src_main_version = ${src_main_version}
> -src_genr_package = ${src_genr_package}
> -src_genr_version = ${src_genr_version}
> -src_sigs_package = ${src_sigs_package}
> -src_sigs_version = ${src_sigs_version}
> -
> -EOL
> -
> -dkms_build_new=$(grep -c 'shift 7' debian/scripts/dkms-build)
> -if [ "$dkms_build_new" -eq 0 ]; then
> -	sed -i -e '/debian\/scripts\/dkms-build/s/ $(4)//' debian/rules.gen
> -fi
> -
> -nvidia_desktop=
> -nvidia_server=
> -nvidia_ignore=
> -while read command arg
> -do
> -	case "$command" in
> -	option)		;;
> -	suppress)		nvidia_ignore="$nvidia_ignore $arg"; continue ;;
> -	*)		continue ;;
> -	esac
> -
> -	case "$arg" in
> -	desktop)	nvidia_desktop=y ;;
> -	server)		nvidia_server=y ;;
> -	esac
> -done <"debian/package.config"
> -
> -while read command flavour archs
> -do
> -	case "$command" in
> -	build)		;;
> -	*)		continue ;;
> -	esac
> -
> -	validate_unique "archs" "$archs"
> -	cat - >>"debian/control.interlock-up" <<EOL
> - linux-headers-${src_abi}-${flavour} (>= @VERSION@) [${archs}],
> -EOL
> -
> -	while read package version extra
> -	do
> -		case "$package" in
> -		nvidia-graphics-drivers-*-server)
> -			[ -z "$nvidia_server" ] && continue
> -			;;
> -		nvidia-graphics-drivers-*)
> -			[ -z "$nvidia_desktop" ] && continue
> -			;;
> -		*) continue ;;
> -		esac
> -		case " $nvidia_ignore " in
> -		*\ $package\ *)		continue ;;
> -		esac
> -
> -		case " $extra " in
> -		*\ signonly\ *)		continue ;;
> -		esac
> -
> -		# If package specifies arch= keys, only build it on
> -		# the intersection of kernel flavour arches & the
> -		# package arches, otherwise build for all kernel
> -		# flavour arches.
> -		pkg_archs=
> -		for cmd in $extra
> -		do
> -			case "$cmd" in
> -			arch=*)		pkg_archs="$pkg_archs ${cmd#arch=}" ;;
> -			esac
> -		done
> -		# No package arches set, build for everything
> -		if [ -z "$pkg_archs" ]; then
> -			pkg_archs=$archs
> -		else
> -			# Package arches set, build for intersection
> -			validate_unique "pkg_archs" "$pkg_archs"
> -			pkg_archs=$(sort <(echo $archs | tr " " "\n") <(echo $pkg_archs | tr " " "\n") | uniq -d | tr "\n" " ")
> -			# No intersection, skip
> -			if [ -z "$pkg_archs" ]; then
> -				continue
> -			fi
> -		fi
> -
> -		targets=$(echo "$pkg_archs" | sed -e 's/\</nvidia-/g')
> -		suffix_minus=$(echo "$package" | sed -e 's/nvidia-graphics-drivers-//')
> -		suffix_under=$(echo "$suffix_minus" | sed -e 's/-/_/g')
> -		suffix_short=$(echo "$suffix_minus" | sed -e 's/-server/srv/g')
> -
> -		echo "II: build $package for $flavour $pkg_archs"
> -
> -		# debian/rules.gen
> -		cat - >>"debian/rules.gen" <<EOL
> -
> -# $package $version $suffix_minus $suffix_under
> -dkms_nvidia_${suffix_under}_version="$version"
> -nvidia_${suffix_under}_upstream_version=\$(shell echo "\$(dkms_nvidia_${suffix_under}_version)" | cut -d '-' -f 1)
> -gencontrol_flags += -Vdkms:nvidia-${suffix_minus}-modules="nvidia-dkms-${suffix_minus} (= \$(dkms_nvidia_${suffix_under}_version))"
> -gencontrol_flags += -Vnvk:nvidia-${suffix_minus}="nvidia-kernel-common-${suffix_minus} (<= \$(nvidia_${suffix_under}_upstream_version)-1), nvidia-kernel-common-${suffix_minus} (>= \$(nvidia_${suffix_under}_upstream_version))"
> -test::
> -	@echo $package $version $suffix_minus $suffix_under $suffix_short $targets
> -$targets::
> -	rm -rf \$(dkms_dir)/build \$(dkms_dir)/source
> -	mkdir -p \$(dkms_dir)/build \$(dkms_dir)/source
> -	install -d debian/linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour}
> -	install -d debian/linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour}/usr/lib/linux/triggers
> -	\$(call install_control,linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour},${flavour},nvidia,${suffix_short},postinst postrm prerm config templates)
> -	install -d debian/linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}
> -	\$(call build_dkms, \$(src_abi)-${flavour}, linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}, \$(CURDIR)/debian/linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}/lib/modules/\$(src_abi)-${flavour}/kernel, "", nvidia-${suffix_short}, pool/restricted/n/nvidia-graphics-drivers-${suffix_minus}/nvidia-kernel-source-${suffix_minus}_\$(dkms_nvidia_${suffix_under}_version)_\$(arch).deb pool/restricted/n/nvidia-graphics-drivers-${suffix_minus}/nvidia-dkms-${suffix_minus}_\$(dkms_nvidia_${suffix_under}_version)_\$(arch).deb)
> -EOL
> -
> -		# debian/control.d/meta-nvidia
> -		cat - >>"debian/control.d/meta-nvidia" <<EOL
> -
> -Package: linux-modules-nvidia-${suffix_minus}-${flavour}\${variant:suffix}
> -Build-Profiles: <!stage1>
> -Architecture: ${pkg_archs}
> -Section: kernel
> -Provides: \${dkms:nvidia-${suffix_minus}-modules}, nvidia-prebuilt-kernel
> -Depends:
> - \${misc:Depends},
> - linux-modules-nvidia-${suffix_minus}-${src_abi}-${flavour} (= \${binary:Version}),
> - \${nvk:nvidia-${suffix_minus}},
> -Description: Extra drivers for nvidia-${suffix_minus} for the ${flavour}\${variant:suffix} flavour
> - Install extra signed nvidia-${suffix_minus} modules compatible with the ${flavour}\${variant:suffix} flavour.
> -EOL
> -
> -		# debian/control.d/nvidia
> -		cat - >>"debian/control.d/nvidia" <<EOL
> -
> -Package: linux-objects-nvidia-${suffix_minus}-${src_abi}-${flavour}
> -Build-Profiles: <!stage1>
> -Architecture: ${pkg_archs}
> -Section: kernel
> -Priority: optional
> -Built-Using: \${linux:BuiltUsing}
> -Depends:
> - \${misc:Depends},
> - \${shlibs:Depends},
> - binutils,
> -Description: Linux kernel nvidia modules for version ${src_abi} (objects)
> - This package contains the Linux kernel nvidia modules for version ${src_abi}.
> - .
> - You likely do not want to install this package directly. Instead, install the
> - one of the linux-modules-nvidia-${suffix_minus}-${flavour}* meta-packages,
> - which will ensure that upgrades work correctly, and that supporting packages are
> - also installed.
> -
> -Package: linux-modules-nvidia-${suffix_minus}-${src_abi}-${flavour}
> -Build-Profiles: <!stage1>
> -Architecture: ${pkg_archs}
> -Section: kernel
> -Priority: optional
> -Built-Using: \${linux:BuiltUsing}
> -Depends:
> - \${misc:Depends},
> - \${shlibs:Depends},
> - linux-image-${src_abi}-${flavour} | linux-image-unsigned-${src_abi}-${flavour},
> - linux-signatures-nvidia-${src_abi}-${flavour} (= ${src_sigs_version}),
> - linux-objects-nvidia-${suffix_minus}-${src_abi}-${flavour} (= \${binary:Version}),
> - \${nvk:nvidia-${suffix_minus}},
> -Description: Linux kernel nvidia modules for version ${src_abi}
> - This package pulls together the Linux kernel nvidia modules for
> - version ${src_abi} with the appropriate signatures.
> - .
> - You likely do not want to install this package directly. Instead, install the
> - one of the linux-modules-nvidia-${suffix_minus}-${flavour}* meta-packages,
> - which will ensure that upgrades work correctly, and that supporting packages are
> - also installed.
> -EOL
> -		# debian/control.d/migrate-nvidia
> -		for cmd in $extra
> -		do
> -			case "$cmd" in
> -			transition=*)
> -				from="${cmd#transition=}"
> -				from_minus=$(echo "$from" | sed -e 's/nvidia-graphics-drivers-//')
> -				echo "II: general transition $from -> $package ($from_minus -> $suffix_minus) $pkg_archs"
> -				cat - >>"debian/control.d/migrate-nvidia" <<EOL
> -
> -Package: linux-modules-nvidia-${from_minus}-${flavour}\${variant:suffix}
> -Architecture: ${pkg_archs}
> -Section: oldlibs
> -Depends: linux-modules-nvidia-${suffix_minus}-${flavour}\${variant:suffix}
> -Description: Extra drivers for nvidia-${from_minus} for the ${flavour} flavour (dummy transitional package)
> - Transitional package for upgrades of -${from_minus} to -${suffix_minus}.
> -EOL
> -				;;
> -			esac
> -				#suffix_minus=$(echo "$package" | sed -e 's/nvidia-graphics-drivers-//')
> -				#suffix_under=$(echo "$suffix_minus" | sed -e 's/-/_/g')
> -				#suffix_short=$(echo "$suffix_minus" | sed -e 's/-server/srv/g')
> -		done
> -	done <"debian/dkms-versions"
> -done <"debian/package.config"
> -
> -while read command from to archs
> -do
> -	case "$command" in
> -	transitional)	;;
> -	*)		continue ;;
> -	esac
> -
> -	# debian/control.d/transitionals-local
> -	echo "II: manual transition linux-modules-nvidia-$from -> linux-modules-nvidia-$to $archs"
> -	cat - >>"debian/control.d/transitionals-local" <<EOL
> -
> -Package: linux-modules-nvidia-${from}
> -Architecture: ${archs}
> -Section: oldlibs
> -Depends: linux-modules-nvidia-${to}
> -Description: Extra drivers for nvidia-${from} (dummy transitional package)
> - Transitional package for upgrades of ${from} to ${to}.
> -EOL
> -done <"debian/package.config"
Andy Whitcroft Sept. 23, 2022, 1:45 p.m. UTC | #2
On Fri, Sep 23, 2022 at 2:39 PM Stefan Bader <stefan.bader@canonical.com> wrote:
> > +validate_unique()
> > +{
> > +     [ "$#" = "2" ]
>
> Maybe cleverly short but hard to read...
>
> > +     local duplicates=$(echo $2 | tr " " "\n" | sort | uniq -d)
> > +     if [ "$duplicates" ]; then
> > +             echo "EE: duplicate values in $1" 1>&2
> > +             exit 1
>
> Both tests _are_ supposed to abort any execution, right? First exit would be silent.
>
> > +     fi
> > +}

Yeah all valid complaints.  None of this code is new however, you are
only seeing it because git has made a poor choice when this file was
renamed.  Basically I rename two files, and replace one of the
originals, doing that makes git do the wong things for this file.  It
is most annoying.

-apw
diff mbox series

Patch

diff --git a/debian/rules.lrg b/debian/ancillary/linux-restricted-generate/debian/rules.in
similarity index 100%
rename from debian/rules.lrg
rename to debian/ancillary/linux-restricted-generate/debian/rules.in
diff --git a/debian/scripts/gen-rules.lrg b/debian/ancillary/linux-restricted-generate/debian/scripts/gen-rules
similarity index 98%
rename from debian/scripts/gen-rules.lrg
rename to debian/ancillary/linux-restricted-generate/debian/scripts/gen-rules
index d1e528a..27c79c4 100755
--- a/debian/scripts/gen-rules.lrg
+++ b/debian/ancillary/linux-restricted-generate/debian/scripts/gen-rules
@@ -30,7 +30,7 @@  src_main_version=$(echo ${src_version} | sed -e 's/+[0-9][0-9\.]*$//')
 src_lrm_package=$(echo "${src_package}" | sed -e 's/-restricted-generate/-restricted-modules/')
 src_lrm_version=${src_version}
 
-cat - "debian/rules.lrg" >"debian/rules.gen" <<EOL
+cat - "debian/rules.in" >"debian/rules.gen" <<EOL
 #! /usr/bin/make -f
 
 src_package := ${src_package}
diff --git a/debian/rules.lrs b/debian/ancillary/linux-restricted-signatures/debian/rules.in
similarity index 100%
rename from debian/rules.lrs
rename to debian/ancillary/linux-restricted-signatures/debian/rules.in
diff --git a/debian/scripts/gen-rules.lrs b/debian/ancillary/linux-restricted-signatures/debian/scripts/gen-rules
similarity index 98%
rename from debian/scripts/gen-rules.lrs
rename to debian/ancillary/linux-restricted-signatures/debian/scripts/gen-rules
index f7f7648..ed74d70 100755
--- a/debian/scripts/gen-rules.lrs
+++ b/debian/ancillary/linux-restricted-signatures/debian/scripts/gen-rules
@@ -30,7 +30,7 @@  src_genr_version=${src_version}
 
 # linux-restricted-modules/5.8.0-41.46[+1]
 
-cat - "debian/rules.lrs" >"debian/rules.gen" <<EOL
+cat - "debian/rules.in" >"debian/rules.gen" <<EOL
 #! /usr/bin/make -f
 
 src_package := ${src_package}
diff --git a/download-signed b/debian/ancillary/linux-restricted-signatures/download-signed
similarity index 100%
rename from download-signed
rename to debian/ancillary/linux-restricted-signatures/download-signed
diff --git a/debian/scripts/gen-rules b/debian/scripts/gen-rules
index c5c36a6..f9f5eca 100755
--- a/debian/scripts/gen-rules
+++ b/debian/scripts/gen-rules
@@ -1,11 +1,266 @@ 
 #!/bin/bash
 set -e
 
+validate_unique()
+{
+	[ "$#" = "2" ]
+	local duplicates=$(echo $2 | tr " " "\n" | sort | uniq -d)
+	if [ "$duplicates" ]; then
+		echo "EE: duplicate values in $1" 1>&2
+		exit 1
+	fi
+}
+
+# Pick out relevant version and package information including our predecessor
+# packages: linux -> linux-restricted-modules-signatures -> linux-restricted-modules
 src_package=$(LC_ALL=C dpkg-parsechangelog -SSource)
-case "$src_package" in
-linux-restricted-generate*)	pkg='lrg' ;;
-linux-restricted-signature*)	pkg='lrs' ;;
-linux-restricted-modules*)	pkg='lrm' ;;
-esac
+src_version=$(LC_ALL=C dpkg-parsechangelog -SVersion)
+src_abi=$(echo "${src_version}" | sed -ne 's/\([0-9]*\.[0-9]*\.[0-9]*\-[0-9]*\)\..*/\1/p')
+src_series=$(LC_ALL=C dpkg-parsechangelog -SDistribution | sed -e 's/-\(security\|updates\|proposed\)$//')
+
+# linux/5.8.0-41.46
+src_main_package=$(echo "${src_package}" | sed -e 's/-restricted-modules//')
+src_main_version=$(echo ${src_version} | sed -e 's/+[0-9][0-9\.]*$//')
+
+# linux-restricted-generate/5.8.0-41.46[+1]
+src_genr_package=$(echo "${src_package}" | sed -e 's/-restricted-modules/-restricted-generate/')
+src_genr_version=${src_version}
+
+# linux-restricted-signatures/5.8.0-41.46[+1]
+src_sigs_package=$(echo "${src_package}" | sed -e 's/-restricted-modules/-restricted-signatures/')
+src_sigs_version=${src_version}
+
+# linux-restricted-modules/5.8.0-41.46[+1]
+
+mkdir -p "debian/control.d"
+: >"debian/control.interlock-up"
+: >"debian/control.d/meta-nvidia"
+: >"debian/control.d/nvidia"
+: >"debian/control.d/migrate-nvidia"
+: >"debian/control.d/transitionals-local"
+: >"debian/control.d/signatures"
+
+cat - "debian/rules.in" >"debian/rules.gen" <<EOL
+#! /usr/bin/make -f
+
+src_package := ${src_package}
+src_version = ${src_version}
+src_abi = ${src_abi}
+src_series = ${src_series}
+src_main_package = ${src_main_package}
+src_main_version = ${src_main_version}
+src_genr_package = ${src_genr_package}
+src_genr_version = ${src_genr_version}
+src_sigs_package = ${src_sigs_package}
+src_sigs_version = ${src_sigs_version}
+
+EOL
+
+dkms_build_new=$(grep -c 'shift 7' debian/scripts/dkms-build)
+if [ "$dkms_build_new" -eq 0 ]; then
+	sed -i -e '/debian\/scripts\/dkms-build/s/ $(4)//' debian/rules.gen
+fi
+
+nvidia_desktop=
+nvidia_server=
+nvidia_ignore=
+while read command arg
+do
+	case "$command" in
+	option)		;;
+	suppress)		nvidia_ignore="$nvidia_ignore $arg"; continue ;;
+	*)		continue ;;
+	esac
+
+	case "$arg" in
+	desktop)	nvidia_desktop=y ;;
+	server)		nvidia_server=y ;;
+	esac
+done <"debian/package.config"
+
+while read command flavour archs
+do
+	case "$command" in
+	build)		;;
+	*)		continue ;;
+	esac
+
+	validate_unique "archs" "$archs"
+	cat - >>"debian/control.interlock-up" <<EOL
+ linux-headers-${src_abi}-${flavour} (>= @VERSION@) [${archs}],
+EOL
+
+	while read package version extra
+	do
+		case "$package" in
+		nvidia-graphics-drivers-*-server)
+			[ -z "$nvidia_server" ] && continue
+			;;
+		nvidia-graphics-drivers-*)
+			[ -z "$nvidia_desktop" ] && continue
+			;;
+		*) continue ;;
+		esac
+		case " $nvidia_ignore " in
+		*\ $package\ *)		continue ;;
+		esac
+
+		case " $extra " in
+		*\ signonly\ *)		continue ;;
+		esac
+
+		# If package specifies arch= keys, only build it on
+		# the intersection of kernel flavour arches & the
+		# package arches, otherwise build for all kernel
+		# flavour arches.
+		pkg_archs=
+		for cmd in $extra
+		do
+			case "$cmd" in
+			arch=*)		pkg_archs="$pkg_archs ${cmd#arch=}" ;;
+			esac
+		done
+		# No package arches set, build for everything
+		if [ -z "$pkg_archs" ]; then
+			pkg_archs=$archs
+		else
+			# Package arches set, build for intersection
+			validate_unique "pkg_archs" "$pkg_archs"
+			pkg_archs=$(sort <(echo $archs | tr " " "\n") <(echo $pkg_archs | tr " " "\n") | uniq -d | tr "\n" " ")
+			# No intersection, skip
+			if [ -z "$pkg_archs" ]; then
+				continue
+			fi
+		fi
+
+		targets=$(echo "$pkg_archs" | sed -e 's/\</nvidia-/g')
+		suffix_minus=$(echo "$package" | sed -e 's/nvidia-graphics-drivers-//')
+		suffix_under=$(echo "$suffix_minus" | sed -e 's/-/_/g')
+		suffix_short=$(echo "$suffix_minus" | sed -e 's/-server/srv/g')
+
+		echo "II: build $package for $flavour $pkg_archs"
+
+		# debian/rules.gen
+		cat - >>"debian/rules.gen" <<EOL
+
+# $package $version $suffix_minus $suffix_under
+dkms_nvidia_${suffix_under}_version="$version"
+nvidia_${suffix_under}_upstream_version=\$(shell echo "\$(dkms_nvidia_${suffix_under}_version)" | cut -d '-' -f 1)
+gencontrol_flags += -Vdkms:nvidia-${suffix_minus}-modules="nvidia-dkms-${suffix_minus} (= \$(dkms_nvidia_${suffix_under}_version))"
+gencontrol_flags += -Vnvk:nvidia-${suffix_minus}="nvidia-kernel-common-${suffix_minus} (<= \$(nvidia_${suffix_under}_upstream_version)-1), nvidia-kernel-common-${suffix_minus} (>= \$(nvidia_${suffix_under}_upstream_version))"
+test::
+	@echo $package $version $suffix_minus $suffix_under $suffix_short $targets
+$targets::
+	rm -rf \$(dkms_dir)/build \$(dkms_dir)/source
+	mkdir -p \$(dkms_dir)/build \$(dkms_dir)/source
+	install -d debian/linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour}
+	install -d debian/linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour}/usr/lib/linux/triggers
+	\$(call install_control,linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour},${flavour},nvidia,${suffix_short},postinst postrm prerm config templates)
+	install -d debian/linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}
+	\$(call build_dkms, \$(src_abi)-${flavour}, linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}, \$(CURDIR)/debian/linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}/lib/modules/\$(src_abi)-${flavour}/kernel, "", nvidia-${suffix_short}, pool/restricted/n/nvidia-graphics-drivers-${suffix_minus}/nvidia-kernel-source-${suffix_minus}_\$(dkms_nvidia_${suffix_under}_version)_\$(arch).deb pool/restricted/n/nvidia-graphics-drivers-${suffix_minus}/nvidia-dkms-${suffix_minus}_\$(dkms_nvidia_${suffix_under}_version)_\$(arch).deb)
+EOL
+
+		# debian/control.d/meta-nvidia
+		cat - >>"debian/control.d/meta-nvidia" <<EOL
+
+Package: linux-modules-nvidia-${suffix_minus}-${flavour}\${variant:suffix}
+Build-Profiles: <!stage1>
+Architecture: ${pkg_archs}
+Section: kernel
+Provides: \${dkms:nvidia-${suffix_minus}-modules}, nvidia-prebuilt-kernel
+Depends:
+ \${misc:Depends},
+ linux-modules-nvidia-${suffix_minus}-${src_abi}-${flavour} (= \${binary:Version}),
+ \${nvk:nvidia-${suffix_minus}},
+Description: Extra drivers for nvidia-${suffix_minus} for the ${flavour}\${variant:suffix} flavour
+ Install extra signed nvidia-${suffix_minus} modules compatible with the ${flavour}\${variant:suffix} flavour.
+EOL
+
+		# debian/control.d/nvidia
+		cat - >>"debian/control.d/nvidia" <<EOL
+
+Package: linux-objects-nvidia-${suffix_minus}-${src_abi}-${flavour}
+Build-Profiles: <!stage1>
+Architecture: ${pkg_archs}
+Section: kernel
+Priority: optional
+Built-Using: \${linux:BuiltUsing}
+Depends:
+ \${misc:Depends},
+ \${shlibs:Depends},
+ binutils,
+Description: Linux kernel nvidia modules for version ${src_abi} (objects)
+ This package contains the Linux kernel nvidia modules for version ${src_abi}.
+ .
+ You likely do not want to install this package directly. Instead, install the
+ one of the linux-modules-nvidia-${suffix_minus}-${flavour}* meta-packages,
+ which will ensure that upgrades work correctly, and that supporting packages are
+ also installed.
+
+Package: linux-modules-nvidia-${suffix_minus}-${src_abi}-${flavour}
+Build-Profiles: <!stage1>
+Architecture: ${pkg_archs}
+Section: kernel
+Priority: optional
+Built-Using: \${linux:BuiltUsing}
+Depends:
+ \${misc:Depends},
+ \${shlibs:Depends},
+ linux-image-${src_abi}-${flavour} | linux-image-unsigned-${src_abi}-${flavour},
+ linux-signatures-nvidia-${src_abi}-${flavour} (= ${src_sigs_version}),
+ linux-objects-nvidia-${suffix_minus}-${src_abi}-${flavour} (= \${binary:Version}),
+ \${nvk:nvidia-${suffix_minus}},
+Description: Linux kernel nvidia modules for version ${src_abi}
+ This package pulls together the Linux kernel nvidia modules for
+ version ${src_abi} with the appropriate signatures.
+ .
+ You likely do not want to install this package directly. Instead, install the
+ one of the linux-modules-nvidia-${suffix_minus}-${flavour}* meta-packages,
+ which will ensure that upgrades work correctly, and that supporting packages are
+ also installed.
+EOL
+		# debian/control.d/migrate-nvidia
+		for cmd in $extra
+		do
+			case "$cmd" in
+			transition=*)
+				from="${cmd#transition=}"
+				from_minus=$(echo "$from" | sed -e 's/nvidia-graphics-drivers-//')
+				echo "II: general transition $from -> $package ($from_minus -> $suffix_minus) $pkg_archs"
+				cat - >>"debian/control.d/migrate-nvidia" <<EOL
+
+Package: linux-modules-nvidia-${from_minus}-${flavour}\${variant:suffix}
+Architecture: ${pkg_archs}
+Section: oldlibs
+Depends: linux-modules-nvidia-${suffix_minus}-${flavour}\${variant:suffix}
+Description: Extra drivers for nvidia-${from_minus} for the ${flavour} flavour (dummy transitional package)
+ Transitional package for upgrades of -${from_minus} to -${suffix_minus}.
+EOL
+				;;
+			esac
+				#suffix_minus=$(echo "$package" | sed -e 's/nvidia-graphics-drivers-//')
+				#suffix_under=$(echo "$suffix_minus" | sed -e 's/-/_/g')
+				#suffix_short=$(echo "$suffix_minus" | sed -e 's/-server/srv/g')
+		done
+	done <"debian/dkms-versions"
+done <"debian/package.config"
+
+while read command from to archs
+do
+	case "$command" in
+	transitional)	;;
+	*)		continue ;;
+	esac
+
+	# debian/control.d/transitionals-local
+	echo "II: manual transition linux-modules-nvidia-$from -> linux-modules-nvidia-$to $archs"
+	cat - >>"debian/control.d/transitionals-local" <<EOL
 
-exec "$0.$pkg" "$@"
+Package: linux-modules-nvidia-${from}
+Architecture: ${archs}
+Section: oldlibs
+Depends: linux-modules-nvidia-${to}
+Description: Extra drivers for nvidia-${from} (dummy transitional package)
+ Transitional package for upgrades of ${from} to ${to}.
+EOL
+done <"debian/package.config"
diff --git a/debian/scripts/gen-rules.lrm b/debian/scripts/gen-rules.lrm
deleted file mode 100755
index f9f5eca..0000000
--- a/debian/scripts/gen-rules.lrm
+++ /dev/null
@@ -1,266 +0,0 @@ 
-#!/bin/bash
-set -e
-
-validate_unique()
-{
-	[ "$#" = "2" ]
-	local duplicates=$(echo $2 | tr " " "\n" | sort | uniq -d)
-	if [ "$duplicates" ]; then
-		echo "EE: duplicate values in $1" 1>&2
-		exit 1
-	fi
-}
-
-# Pick out relevant version and package information including our predecessor
-# packages: linux -> linux-restricted-modules-signatures -> linux-restricted-modules
-src_package=$(LC_ALL=C dpkg-parsechangelog -SSource)
-src_version=$(LC_ALL=C dpkg-parsechangelog -SVersion)
-src_abi=$(echo "${src_version}" | sed -ne 's/\([0-9]*\.[0-9]*\.[0-9]*\-[0-9]*\)\..*/\1/p')
-src_series=$(LC_ALL=C dpkg-parsechangelog -SDistribution | sed -e 's/-\(security\|updates\|proposed\)$//')
-
-# linux/5.8.0-41.46
-src_main_package=$(echo "${src_package}" | sed -e 's/-restricted-modules//')
-src_main_version=$(echo ${src_version} | sed -e 's/+[0-9][0-9\.]*$//')
-
-# linux-restricted-generate/5.8.0-41.46[+1]
-src_genr_package=$(echo "${src_package}" | sed -e 's/-restricted-modules/-restricted-generate/')
-src_genr_version=${src_version}
-
-# linux-restricted-signatures/5.8.0-41.46[+1]
-src_sigs_package=$(echo "${src_package}" | sed -e 's/-restricted-modules/-restricted-signatures/')
-src_sigs_version=${src_version}
-
-# linux-restricted-modules/5.8.0-41.46[+1]
-
-mkdir -p "debian/control.d"
-: >"debian/control.interlock-up"
-: >"debian/control.d/meta-nvidia"
-: >"debian/control.d/nvidia"
-: >"debian/control.d/migrate-nvidia"
-: >"debian/control.d/transitionals-local"
-: >"debian/control.d/signatures"
-
-cat - "debian/rules.in" >"debian/rules.gen" <<EOL
-#! /usr/bin/make -f
-
-src_package := ${src_package}
-src_version = ${src_version}
-src_abi = ${src_abi}
-src_series = ${src_series}
-src_main_package = ${src_main_package}
-src_main_version = ${src_main_version}
-src_genr_package = ${src_genr_package}
-src_genr_version = ${src_genr_version}
-src_sigs_package = ${src_sigs_package}
-src_sigs_version = ${src_sigs_version}
-
-EOL
-
-dkms_build_new=$(grep -c 'shift 7' debian/scripts/dkms-build)
-if [ "$dkms_build_new" -eq 0 ]; then
-	sed -i -e '/debian\/scripts\/dkms-build/s/ $(4)//' debian/rules.gen
-fi
-
-nvidia_desktop=
-nvidia_server=
-nvidia_ignore=
-while read command arg
-do
-	case "$command" in
-	option)		;;
-	suppress)		nvidia_ignore="$nvidia_ignore $arg"; continue ;;
-	*)		continue ;;
-	esac
-
-	case "$arg" in
-	desktop)	nvidia_desktop=y ;;
-	server)		nvidia_server=y ;;
-	esac
-done <"debian/package.config"
-
-while read command flavour archs
-do
-	case "$command" in
-	build)		;;
-	*)		continue ;;
-	esac
-
-	validate_unique "archs" "$archs"
-	cat - >>"debian/control.interlock-up" <<EOL
- linux-headers-${src_abi}-${flavour} (>= @VERSION@) [${archs}],
-EOL
-
-	while read package version extra
-	do
-		case "$package" in
-		nvidia-graphics-drivers-*-server)
-			[ -z "$nvidia_server" ] && continue
-			;;
-		nvidia-graphics-drivers-*)
-			[ -z "$nvidia_desktop" ] && continue
-			;;
-		*) continue ;;
-		esac
-		case " $nvidia_ignore " in
-		*\ $package\ *)		continue ;;
-		esac
-
-		case " $extra " in
-		*\ signonly\ *)		continue ;;
-		esac
-
-		# If package specifies arch= keys, only build it on
-		# the intersection of kernel flavour arches & the
-		# package arches, otherwise build for all kernel
-		# flavour arches.
-		pkg_archs=
-		for cmd in $extra
-		do
-			case "$cmd" in
-			arch=*)		pkg_archs="$pkg_archs ${cmd#arch=}" ;;
-			esac
-		done
-		# No package arches set, build for everything
-		if [ -z "$pkg_archs" ]; then
-			pkg_archs=$archs
-		else
-			# Package arches set, build for intersection
-			validate_unique "pkg_archs" "$pkg_archs"
-			pkg_archs=$(sort <(echo $archs | tr " " "\n") <(echo $pkg_archs | tr " " "\n") | uniq -d | tr "\n" " ")
-			# No intersection, skip
-			if [ -z "$pkg_archs" ]; then
-				continue
-			fi
-		fi
-
-		targets=$(echo "$pkg_archs" | sed -e 's/\</nvidia-/g')
-		suffix_minus=$(echo "$package" | sed -e 's/nvidia-graphics-drivers-//')
-		suffix_under=$(echo "$suffix_minus" | sed -e 's/-/_/g')
-		suffix_short=$(echo "$suffix_minus" | sed -e 's/-server/srv/g')
-
-		echo "II: build $package for $flavour $pkg_archs"
-
-		# debian/rules.gen
-		cat - >>"debian/rules.gen" <<EOL
-
-# $package $version $suffix_minus $suffix_under
-dkms_nvidia_${suffix_under}_version="$version"
-nvidia_${suffix_under}_upstream_version=\$(shell echo "\$(dkms_nvidia_${suffix_under}_version)" | cut -d '-' -f 1)
-gencontrol_flags += -Vdkms:nvidia-${suffix_minus}-modules="nvidia-dkms-${suffix_minus} (= \$(dkms_nvidia_${suffix_under}_version))"
-gencontrol_flags += -Vnvk:nvidia-${suffix_minus}="nvidia-kernel-common-${suffix_minus} (<= \$(nvidia_${suffix_under}_upstream_version)-1), nvidia-kernel-common-${suffix_minus} (>= \$(nvidia_${suffix_under}_upstream_version))"
-test::
-	@echo $package $version $suffix_minus $suffix_under $suffix_short $targets
-$targets::
-	rm -rf \$(dkms_dir)/build \$(dkms_dir)/source
-	mkdir -p \$(dkms_dir)/build \$(dkms_dir)/source
-	install -d debian/linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour}
-	install -d debian/linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour}/usr/lib/linux/triggers
-	\$(call install_control,linux-modules-nvidia-${suffix_minus}-\$(src_abi)-${flavour},${flavour},nvidia,${suffix_short},postinst postrm prerm config templates)
-	install -d debian/linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}
-	\$(call build_dkms, \$(src_abi)-${flavour}, linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}, \$(CURDIR)/debian/linux-objects-nvidia-${suffix_minus}-\$(src_abi)-${flavour}/lib/modules/\$(src_abi)-${flavour}/kernel, "", nvidia-${suffix_short}, pool/restricted/n/nvidia-graphics-drivers-${suffix_minus}/nvidia-kernel-source-${suffix_minus}_\$(dkms_nvidia_${suffix_under}_version)_\$(arch).deb pool/restricted/n/nvidia-graphics-drivers-${suffix_minus}/nvidia-dkms-${suffix_minus}_\$(dkms_nvidia_${suffix_under}_version)_\$(arch).deb)
-EOL
-
-		# debian/control.d/meta-nvidia
-		cat - >>"debian/control.d/meta-nvidia" <<EOL
-
-Package: linux-modules-nvidia-${suffix_minus}-${flavour}\${variant:suffix}
-Build-Profiles: <!stage1>
-Architecture: ${pkg_archs}
-Section: kernel
-Provides: \${dkms:nvidia-${suffix_minus}-modules}, nvidia-prebuilt-kernel
-Depends:
- \${misc:Depends},
- linux-modules-nvidia-${suffix_minus}-${src_abi}-${flavour} (= \${binary:Version}),
- \${nvk:nvidia-${suffix_minus}},
-Description: Extra drivers for nvidia-${suffix_minus} for the ${flavour}\${variant:suffix} flavour
- Install extra signed nvidia-${suffix_minus} modules compatible with the ${flavour}\${variant:suffix} flavour.
-EOL
-
-		# debian/control.d/nvidia
-		cat - >>"debian/control.d/nvidia" <<EOL
-
-Package: linux-objects-nvidia-${suffix_minus}-${src_abi}-${flavour}
-Build-Profiles: <!stage1>
-Architecture: ${pkg_archs}
-Section: kernel
-Priority: optional
-Built-Using: \${linux:BuiltUsing}
-Depends:
- \${misc:Depends},
- \${shlibs:Depends},
- binutils,
-Description: Linux kernel nvidia modules for version ${src_abi} (objects)
- This package contains the Linux kernel nvidia modules for version ${src_abi}.
- .
- You likely do not want to install this package directly. Instead, install the
- one of the linux-modules-nvidia-${suffix_minus}-${flavour}* meta-packages,
- which will ensure that upgrades work correctly, and that supporting packages are
- also installed.
-
-Package: linux-modules-nvidia-${suffix_minus}-${src_abi}-${flavour}
-Build-Profiles: <!stage1>
-Architecture: ${pkg_archs}
-Section: kernel
-Priority: optional
-Built-Using: \${linux:BuiltUsing}
-Depends:
- \${misc:Depends},
- \${shlibs:Depends},
- linux-image-${src_abi}-${flavour} | linux-image-unsigned-${src_abi}-${flavour},
- linux-signatures-nvidia-${src_abi}-${flavour} (= ${src_sigs_version}),
- linux-objects-nvidia-${suffix_minus}-${src_abi}-${flavour} (= \${binary:Version}),
- \${nvk:nvidia-${suffix_minus}},
-Description: Linux kernel nvidia modules for version ${src_abi}
- This package pulls together the Linux kernel nvidia modules for
- version ${src_abi} with the appropriate signatures.
- .
- You likely do not want to install this package directly. Instead, install the
- one of the linux-modules-nvidia-${suffix_minus}-${flavour}* meta-packages,
- which will ensure that upgrades work correctly, and that supporting packages are
- also installed.
-EOL
-		# debian/control.d/migrate-nvidia
-		for cmd in $extra
-		do
-			case "$cmd" in
-			transition=*)
-				from="${cmd#transition=}"
-				from_minus=$(echo "$from" | sed -e 's/nvidia-graphics-drivers-//')
-				echo "II: general transition $from -> $package ($from_minus -> $suffix_minus) $pkg_archs"
-				cat - >>"debian/control.d/migrate-nvidia" <<EOL
-
-Package: linux-modules-nvidia-${from_minus}-${flavour}\${variant:suffix}
-Architecture: ${pkg_archs}
-Section: oldlibs
-Depends: linux-modules-nvidia-${suffix_minus}-${flavour}\${variant:suffix}
-Description: Extra drivers for nvidia-${from_minus} for the ${flavour} flavour (dummy transitional package)
- Transitional package for upgrades of -${from_minus} to -${suffix_minus}.
-EOL
-				;;
-			esac
-				#suffix_minus=$(echo "$package" | sed -e 's/nvidia-graphics-drivers-//')
-				#suffix_under=$(echo "$suffix_minus" | sed -e 's/-/_/g')
-				#suffix_short=$(echo "$suffix_minus" | sed -e 's/-server/srv/g')
-		done
-	done <"debian/dkms-versions"
-done <"debian/package.config"
-
-while read command from to archs
-do
-	case "$command" in
-	transitional)	;;
-	*)		continue ;;
-	esac
-
-	# debian/control.d/transitionals-local
-	echo "II: manual transition linux-modules-nvidia-$from -> linux-modules-nvidia-$to $archs"
-	cat - >>"debian/control.d/transitionals-local" <<EOL
-
-Package: linux-modules-nvidia-${from}
-Architecture: ${archs}
-Section: oldlibs
-Depends: linux-modules-nvidia-${to}
-Description: Extra drivers for nvidia-${from} (dummy transitional package)
- Transitional package for upgrades of ${from} to ${to}.
-EOL
-done <"debian/package.config"