* rules.tmpl how to exec a cmd as root [not found] <AM0PR10MB20205FF67C22F88DC3BE525BAA559@AM0PR10MB2020.EURPRD10.PROD.OUTLOOK.COM> @ 2022-09-27 13:20 ` Roberto A. Foglietta 2022-09-27 14:59 ` Roberto A. Foglietta 2022-09-28 9:37 ` Henning Schild 0 siblings, 2 replies; 6+ messages in thread From: Roberto A. Foglietta @ 2022-09-27 13:20 UTC (permalink / raw) To: isar-users [-- Attachment #1: Type: text/plain, Size: 478 bytes --] 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} Thanks, R- [-- Attachment #2: Type: text/html, Size: 712 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: rules.tmpl how to exec a cmd as root 2022-09-27 13:20 ` rules.tmpl how to exec a cmd as root Roberto A. Foglietta @ 2022-09-27 14:59 ` Roberto A. Foglietta 2022-09-27 21:13 ` Roberto A. Foglietta 2022-09-28 9:37 ` Henning Schild 1 sibling, 1 reply; 6+ messages in thread From: Roberto A. Foglietta @ 2022-09-27 14:59 UTC (permalink / raw) To: isar-users [-- Attachment #1.1: Type: text/plain, Size: 952 bytes --] 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). About the module compile, I should have checked what's wrong in the makefile & Co. but at the moment the approach is not pointing the finger on the lacks of others but manage it. Cheers, R- > [-- Attachment #1.2: Type: text/html, Size: 1794 bytes --] [-- Attachment #2: isar.patch --] [-- Type: text/x-diff, Size: 1181 bytes --] diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass index c92ea7d..6fb53bb 100644 --- a/meta/classes/dpkg.bbclass +++ b/meta/classes/dpkg.bbclass @@ -87,11 +87,14 @@ dpkg_runbuild() { sh -c "cd ${WORKDIR}; dpkg-source -q -b ${PPS}" DSC_FILE=$(find ${WORKDIR} -name "${DEB_SOURCE_NAME}*.dsc" -print) + # --chroot-setup-commands="chmod +s /bin/cp /bin/mv /bin/ln /bin/ls /bin/chmod /bin/chown" \ + # sbuild -A -n -c ${SBUILD_CHROOT} --extra-repository="${ISAR_APT_REPO}" \ --host=${PACKAGE_ARCH} --build=${SBUILD_HOST_ARCH} ${profiles} \ --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="chmod +s /bin/cp" \ --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" \ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: rules.tmpl how to exec a cmd as root 2022-09-27 14:59 ` Roberto A. Foglietta @ 2022-09-27 21:13 ` Roberto A. Foglietta 2022-09-27 22:03 ` Roberto A. Foglietta 0 siblings, 1 reply; 6+ messages in thread From: Roberto A. Foglietta @ 2022-09-27 21:13 UTC (permalink / raw) To: isar-users [-- Attachment #1: Type: text/plain, Size: 1850 bytes --] 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- [-- Attachment #2: Type: text/html, Size: 2254 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: rules.tmpl how to exec a cmd as root 2022-09-27 21:13 ` Roberto A. Foglietta @ 2022-09-27 22:03 ` Roberto A. Foglietta 0 siblings, 0 replies; 6+ messages in thread From: Roberto A. Foglietta @ 2022-09-27 22:03 UTC (permalink / raw) To: isar-users [-- Attachment #1: Type: text/plain, Size: 2383 bytes --] Il giorno mar 27 set 2022 alle ore 23:13 Roberto A. Foglietta < roberto.foglietta@gmail.com> ha scritto: > 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: > :-) > Also a ldconfig is appreciated. In fact, trying to use "su" - which is not configured to be used without password - a lacks of ldconfig emerges diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass index c92ea7d..8aad4fb 100644 --- a/meta/classes/dpkg.bbclass +++ b/meta/classes/dpkg.bbclass @@ -90,8 +90,9 @@ dpkg_runbuild() { sbuild -A -n -c ${SBUILD_CHROOT} --extra-repository="${ISAR_APT_REPO}" \ --host=${PACKAGE_ARCH} --build=${SBUILD_HOST_ARCH} ${profiles} \ --no-run-lintian --no-run-piuparts --no-run-autopkgtest --resolve-alternatives \ - --chroot-setup-commands="rm -f /var/log/dpkg.log" \ + --chroot-setup-commands="ldconfig; 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 -paf /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" \ Cheers, R- [-- Attachment #2: Type: text/html, Size: 3194 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: rules.tmpl how to exec a cmd as root 2022-09-27 13:20 ` rules.tmpl how to exec a cmd as root Roberto A. Foglietta 2022-09-27 14:59 ` Roberto A. Foglietta @ 2022-09-28 9:37 ` Henning Schild 2022-09-28 14:45 ` Roberto A. Foglietta 1 sibling, 1 reply; 6+ messages in thread From: Henning Schild @ 2022-09-28 9:37 UTC (permalink / raw) To: Roberto A. Foglietta; +Cc: isar-users Hi, i recently was in the same situation that i had to install additional files. You sure to not need sudo there. The permissions and ownership will be set and controlled by the package manager. You want to make sure the Makefile of your modules installs everything with "make install" or "make modules_install" and then override the rules template to call the modules Makefile directly ... not the default. my_module_0.1.bb: ... SRC_URI += "file://debian/my_rules.tmpl" ... do_my_rules() { mv ${WORKDIR}/debian/my_rules.tmpl ${WORKDIR}/debian/rules.tmpl } addtask my_rules after do_unpack before do_transform_template ... --- isar/meta/recipes-kernel/linux-module/files/debian/rules.tmpl +++ my_module/files/debian/my_rules.tmpl @@ -48,13 +48,14 @@ endif override_dh_auto_clean: - $(MAKE) -C $(KDIR) M=$(PWD) clean + $(MAKE) KDIR=$(KDIR) clean override_dh_auto_build: - $(MAKE) -C $(KDIR) M=$(PWD) modules + $(MAKE) KDIR=$(KDIR) modules override_dh_auto_install: - $(MAKE) -C $(KDIR) M=$(PWD) INSTALL_MOD_PATH=$(PWD)/debian/${PN} modules_install + $(MAKE) KDIR=$(KDIR) INSTALL_MOD_PATH=$(PWD)/debian/${PN} modules_install + $(MAKE) KDIR=$(KDIR) INSTALL_MOD_PATH=$(PWD)/debian/${PN} install See this discussion and patches https://groups.google.com/g/isar-users/c/nHMhNJtX5FM/m/K4QsqjKDAQAJ With this the Makefile of the out-of-tree module can now do all sorts of fun stuff in "modules_install" and "install". And you patch the sources of that module to contain a Makefile that does what you want. Henning Am Tue, 27 Sep 2022 15:20:57 +0200 schrieb "Roberto A. Foglietta" <roberto.foglietta@gmail.com>: > 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} > > Thanks, R- > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: rules.tmpl how to exec a cmd as root 2022-09-28 9:37 ` Henning Schild @ 2022-09-28 14:45 ` Roberto A. Foglietta 0 siblings, 0 replies; 6+ messages in thread From: Roberto A. Foglietta @ 2022-09-28 14:45 UTC (permalink / raw) To: Henning Schild; +Cc: isar-users [-- Attachment #1: Type: text/plain, Size: 878 bytes --] Il Mer 28 Set 2022, 11:37 Henning Schild <henning.schild@siemens.com> ha scritto: > > With this the Makefile of the out-of-tree module can now do all sorts > of fun stuff in "modules_install" and "install". And you patch the > sources of that module to contain a Makefile that does what you want. > > > Am Tue, 27 Sep 2022 15:20:57 +0200 > schrieb "Roberto A. Foglietta" <roberto.foglietta@gmail.com>: > > > 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. > Dear Henning, thanks for the reply. I confirm you that this approach do NOT work for the 3rd party modules I have to compile in ISAR against a standard debian kernel. I accept to be a newbie in ISAR but the only approach that demonstrated being working with this stuff is exorcism as root! LOL Best, R- > [-- Attachment #2: Type: text/html, Size: 1680 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-09-28 14:46 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <AM0PR10MB20205FF67C22F88DC3BE525BAA559@AM0PR10MB2020.EURPRD10.PROD.OUTLOOK.COM> 2022-09-27 13:20 ` rules.tmpl how to exec a cmd as root Roberto A. Foglietta 2022-09-27 14:59 ` Roberto A. Foglietta 2022-09-27 21:13 ` Roberto A. Foglietta 2022-09-27 22:03 ` Roberto A. Foglietta 2022-09-28 9:37 ` Henning Schild 2022-09-28 14:45 ` Roberto A. Foglietta
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox