Il giorno mar 27 set 2022 alle ore 16:59 Roberto A. Foglietta <roberto.foglietta@gmail.com> ha scritto:
>
> Il Mar 27 Set 2022, 15:20 Roberto A. Foglietta <roberto.foglietta@gmail.com> ha scritto:
>>
>> Dear all,
>>
>>  I found another corner case about compiling a 3rd party driver into ISAR and I need to execute a command at make level but as root. Unfortunately su cannot authenticate seamlessly and without the root permission the command fails. Suggestions?
>>
>> override_dh_auto_build:
>>       sudo cp -arf /usr/lib/modules/*/source/* /usr/lib/modules/*/build/
>>        cp -arf /usr/lib/modules/*/source/* /usr/lib/modules/*/build/
>>        $(MAKE) -n modules ${PARALLEL_MAKE}
>
>
> The problem of Executing commands with root priviledge in the sbuild, I have solved using chmod +s the command (cfr. the patch attached, in the commented line a generalisation).


This single change open a wild wide playground of possibilities in running arbitrary stuff as root in sbuild/make environment:
:-)

diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
index c92ea7d..a8b4823 100644
--- a/meta/classes/dpkg.bbclass
+++ b/meta/classes/dpkg.bbclass
@@ -92,6 +92,7 @@ dpkg_runbuild() {
         --no-run-lintian --no-run-piuparts --no-run-autopkgtest --resolve-alternatives \
         --chroot-setup-commands="rm -f /var/log/dpkg.log" \
         --chroot-setup-commands="cp -n --no-preserve=owner ${ext_deb_dir}/*.deb -t ${deb_dir}/ || :" \
+       --chroot-setup-commands="cp -arf /bin/chmod /bin/s.chmod; chmod +s /bin/s.chmod" \
         --finished-build-commands="rm -f ${deb_dir}/sbuild-build-depends-main-dummy_*.deb" \
         --finished-build-commands="cp -n --no-preserve=owner ${deb_dir}/*.deb -t ${ext_deb_dir}/ || :" \
         --finished-build-commands="cp /var/log/dpkg.log ${ext_root}/dpkg_partial.log" \

Best, R-