Message ID | 20210311120632.2456390-5-apw@canonical.com |
---|---|
State | Accepted |
Headers | show |
On 11.03.21 13:06, Andy Whitcroft wrote: > dkms-build and particularly dkms-build--nvidia-N are consumed in all > derivative linux-restricted-modules packages. Each gets its local > independant copy from its main kernel package, and that is common to all > kernels based on a particular top-level kernel. Sync the latest updated > versions of these back into the kernel. > > BugLink: https://bugs.launchpad.net/bugs/1918134 > Signed-off-by: Andy Whitcroft <apw@canonical.com> > --- Applied to focal:linux-oem-5.6/oem-5.6-next. Thanks. -Stefan > debian/scripts/dkms-build | 2 +- > debian/scripts/dkms-build--nvidia-N | 62 +++++++++++++++-------------- > 2 files changed, 33 insertions(+), 31 deletions(-) > > diff --git a/debian/scripts/dkms-build b/debian/scripts/dkms-build > index 638b3122a05d..c1751ffaa016 100755 > --- a/debian/scripts/dkms-build > +++ b/debian/scripts/dkms-build > @@ -234,7 +234,7 @@ done > # as squirreled away, and the log in case it is useful. Finally pass a formed > # signing command line in case we need to do that. > dkms_build_specific="$srcdir/$0--$package" > -dkms_build_generic=$(echo "$dkms_build_specific" | sed -n -e 's/-[0-9][0-9]*$/-N/p') > +dkms_build_generic=$(echo "$dkms_build_specific" | sed -n -e 's/-[0-9][0-9]*[a-z]*$/-N/p') > for dkms_build in "$dkms_build_specific" "$dkms_build_generic" > do > if [ -z "$dkms_build" -o ! -e "$dkms_build" ]; then > diff --git a/debian/scripts/dkms-build--nvidia-N b/debian/scripts/dkms-build--nvidia-N > index bdec78233b43..310d63b5edda 100755 > --- a/debian/scripts/dkms-build--nvidia-N > +++ b/debian/scripts/dkms-build--nvidia-N > @@ -35,51 +35,53 @@ mkdir -p "$pkgdir/bits/scripts" > ) > > # Install the support files we need. > -cp "$srcdir/scripts/module-common.lds" "$pkgdir/bits/scripts" > -grep /usr/bin/ld.bfd "$log" | sed -e "s@$build/@@g" >"$pkgdir/bits/BUILD" > -grep /usr/bin/ld.bfd "$log" | sed -e "s@$build/@@g" \ > - -e 's/.*-o *\([^ ]*\) .*/rm -f \1/g' >"$pkgdir/bits/CLEAN" > +echo "II: copying support files ..." > +for lds_src in \ > + "$dkms_dir/headers/linux-headers-$abi_flavour/scripts/module.lds" \ > + "/usr/src/linux-headers-$abi_flavour/scripts/module.lds" \ > + "$dkms_dir/headers/linux-headers-$abi_flavour/scripts/module-common.lds" \ > + "/usr/src/linux-headers-$abi_flavour/scripts/module-common.lds" > +do > + [ ! -f "$lds_src" ] && continue > + echo "II: copying support files ... found $lds_src" > + cp "$lds_src" "$pkgdir/bits/scripts" > + break > +done > + > +# Build helper scripts. > +cat - <<'EOL' >"$pkgdir/bits/BUILD" > +[ "$1" = "unsigned" ] && signed_only=: > +EOL > +grep /usr/bin/ld.bfd "$log" | grep -v scripts/genksyms/genksyms | sed -e "s@$build/@@g" >>"$pkgdir/bits/BUILD" > +sed -e 's/.*-o *\([^ ]*\) .*/rm -f \1/g' <"$pkgdir/bits/BUILD" >"$pkgdir/bits/CLEAN" > > # As the builds contain the absolute filenames as used. Use RECONSTRUCT to > # rebuild the .ko's, sign them, pull off the signatures and then finally clean > # up again. > ( > cd "$pkgdir/bits" || exit 1 > - sh ./CLEAN > - sh ./BUILD > - for ko in *.ko > + > + # Add .ko handling to the CLEAN/BUILD dance. > + for ko in "$pkgdir"/*.ko > do > - echo "cat '$ko' '$ko.sig' >'../$ko'" >>"$pkgdir/bits/BUILD" > - echo "rm -f '$ko'" >>"$pkgdir/bits/BUILD" > + ko=$(basename "$ko") > + echo "\$signed_only cat '$ko' '$ko.sig' >'../$ko'" >>"$pkgdir/bits/BUILD" > + echo "\$signed_only rm -f '$ko'" >>"$pkgdir/bits/BUILD" > echo "rm -f '../$ko'" >>"$pkgdir/bits/CLEAN" > done > > + # Clear out anything we are not going to distribute and build unsigned .kos. > + sh ./CLEAN > + sh ./BUILD unsigned > + > if [ "$sign" = "--custom" ]; then > # We are building for and archive custom signing upload. Keep everything. > : > elif [ "$sign" = "--lrm" ]; then > - # We are in LRM build the package a copy in any signatures we can > - # find for them. These will be added after linking. > - base="/usr/lib/linux/$abi_flavour" > - > - # Check the GCC version we are using against that used in the kernel > - # NOTE: that we treat this as only a warning, as if the binaries did come > - # out differently then we will actually > - echo "II: checking gcc version ..." > - cat "$base/compiler" > - gcc --version > - gcc_was=$(cat "$base/compiler" | sed -e 's/^GCC:/gcc/') > - gcc_is=$(gcc --version | head -1) > - if [ "$gcc_was" != "$gcc_is" ]; then > - echo "WW: gcc version missmatch between linux and linux-restricted-modules" > - echo "WW: was: $gcc_was is: $gcc_is" > - fi > - > - # Apply any local signatures. > - echo "II: adding signatures from $base ..." > - cp "$base/signatures/$package/"*".ko.sig" "$pkgdir/bits" > - sha256sum -c "$base/signatures/$package/SHA256SUMS" || exit 1 > + # We are in the LRM build; grab sha256 checksums and clean up. > + sha256sum -b *.ko >"SHA256SUMS" > sh ./CLEAN > + > else > # We are in the main kernel, put the .kos together as we will > # on the users machine, sign them, and keep just the signature. >
diff --git a/debian/scripts/dkms-build b/debian/scripts/dkms-build index 638b3122a05d..c1751ffaa016 100755 --- a/debian/scripts/dkms-build +++ b/debian/scripts/dkms-build @@ -234,7 +234,7 @@ done # as squirreled away, and the log in case it is useful. Finally pass a formed # signing command line in case we need to do that. dkms_build_specific="$srcdir/$0--$package" -dkms_build_generic=$(echo "$dkms_build_specific" | sed -n -e 's/-[0-9][0-9]*$/-N/p') +dkms_build_generic=$(echo "$dkms_build_specific" | sed -n -e 's/-[0-9][0-9]*[a-z]*$/-N/p') for dkms_build in "$dkms_build_specific" "$dkms_build_generic" do if [ -z "$dkms_build" -o ! -e "$dkms_build" ]; then diff --git a/debian/scripts/dkms-build--nvidia-N b/debian/scripts/dkms-build--nvidia-N index bdec78233b43..310d63b5edda 100755 --- a/debian/scripts/dkms-build--nvidia-N +++ b/debian/scripts/dkms-build--nvidia-N @@ -35,51 +35,53 @@ mkdir -p "$pkgdir/bits/scripts" ) # Install the support files we need. -cp "$srcdir/scripts/module-common.lds" "$pkgdir/bits/scripts" -grep /usr/bin/ld.bfd "$log" | sed -e "s@$build/@@g" >"$pkgdir/bits/BUILD" -grep /usr/bin/ld.bfd "$log" | sed -e "s@$build/@@g" \ - -e 's/.*-o *\([^ ]*\) .*/rm -f \1/g' >"$pkgdir/bits/CLEAN" +echo "II: copying support files ..." +for lds_src in \ + "$dkms_dir/headers/linux-headers-$abi_flavour/scripts/module.lds" \ + "/usr/src/linux-headers-$abi_flavour/scripts/module.lds" \ + "$dkms_dir/headers/linux-headers-$abi_flavour/scripts/module-common.lds" \ + "/usr/src/linux-headers-$abi_flavour/scripts/module-common.lds" +do + [ ! -f "$lds_src" ] && continue + echo "II: copying support files ... found $lds_src" + cp "$lds_src" "$pkgdir/bits/scripts" + break +done + +# Build helper scripts. +cat - <<'EOL' >"$pkgdir/bits/BUILD" +[ "$1" = "unsigned" ] && signed_only=: +EOL +grep /usr/bin/ld.bfd "$log" | grep -v scripts/genksyms/genksyms | sed -e "s@$build/@@g" >>"$pkgdir/bits/BUILD" +sed -e 's/.*-o *\([^ ]*\) .*/rm -f \1/g' <"$pkgdir/bits/BUILD" >"$pkgdir/bits/CLEAN" # As the builds contain the absolute filenames as used. Use RECONSTRUCT to # rebuild the .ko's, sign them, pull off the signatures and then finally clean # up again. ( cd "$pkgdir/bits" || exit 1 - sh ./CLEAN - sh ./BUILD - for ko in *.ko + + # Add .ko handling to the CLEAN/BUILD dance. + for ko in "$pkgdir"/*.ko do - echo "cat '$ko' '$ko.sig' >'../$ko'" >>"$pkgdir/bits/BUILD" - echo "rm -f '$ko'" >>"$pkgdir/bits/BUILD" + ko=$(basename "$ko") + echo "\$signed_only cat '$ko' '$ko.sig' >'../$ko'" >>"$pkgdir/bits/BUILD" + echo "\$signed_only rm -f '$ko'" >>"$pkgdir/bits/BUILD" echo "rm -f '../$ko'" >>"$pkgdir/bits/CLEAN" done + # Clear out anything we are not going to distribute and build unsigned .kos. + sh ./CLEAN + sh ./BUILD unsigned + if [ "$sign" = "--custom" ]; then # We are building for and archive custom signing upload. Keep everything. : elif [ "$sign" = "--lrm" ]; then - # We are in LRM build the package a copy in any signatures we can - # find for them. These will be added after linking. - base="/usr/lib/linux/$abi_flavour" - - # Check the GCC version we are using against that used in the kernel - # NOTE: that we treat this as only a warning, as if the binaries did come - # out differently then we will actually - echo "II: checking gcc version ..." - cat "$base/compiler" - gcc --version - gcc_was=$(cat "$base/compiler" | sed -e 's/^GCC:/gcc/') - gcc_is=$(gcc --version | head -1) - if [ "$gcc_was" != "$gcc_is" ]; then - echo "WW: gcc version missmatch between linux and linux-restricted-modules" - echo "WW: was: $gcc_was is: $gcc_is" - fi - - # Apply any local signatures. - echo "II: adding signatures from $base ..." - cp "$base/signatures/$package/"*".ko.sig" "$pkgdir/bits" - sha256sum -c "$base/signatures/$package/SHA256SUMS" || exit 1 + # We are in the LRM build; grab sha256 checksums and clean up. + sha256sum -b *.ko >"SHA256SUMS" sh ./CLEAN + else # We are in the main kernel, put the .kos together as we will # on the users machine, sign them, and keep just the signature.
dkms-build and particularly dkms-build--nvidia-N are consumed in all derivative linux-restricted-modules packages. Each gets its local independant copy from its main kernel package, and that is common to all kernels based on a particular top-level kernel. Sync the latest updated versions of these back into the kernel. BugLink: https://bugs.launchpad.net/bugs/1918134 Signed-off-by: Andy Whitcroft <apw@canonical.com> --- debian/scripts/dkms-build | 2 +- debian/scripts/dkms-build--nvidia-N | 62 +++++++++++++++-------------- 2 files changed, 33 insertions(+), 31 deletions(-)