Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call losetup -f to make sure loop device exists #6576

Merged
merged 2 commits into from
May 20, 2024

Conversation

JohnTheCoolingFan
Copy link
Contributor

@JohnTheCoolingFan JohnTheCoolingFan commented May 11, 2024

Description

  1. Added a call to losetup -f which would make sure that there is a loop device that exists and available for use. See Fail at check_loop_device: device node doesn't exist and LOOP= in cycle 1 #6568
  2. Added doas support to is_root_or_sudo_prefix function. I will understand if this change would be asked to be removed, added just because I use doas.

Jira reference number AR-2132

How Has This Been Tested?

Building using the command ./compile.sh BOARD=orangepi5 BRANCH=legacy BUILD_DESKTOP=no BUILD_MINIMAL=no KERNEL_CONFIGURE=no KERNEL_GIT=shallow RELEASE=bookworm on my machine.

Checklist:

Please delete options that are not relevant.

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

@JohnTheCoolingFan JohnTheCoolingFan requested a review from a team as a code owner May 11, 2024 14:22
@github-actions github-actions bot added the size/small PR with less then 50 lines label May 11, 2024
@JohnTheCoolingFan JohnTheCoolingFan marked this pull request as draft May 11, 2024 14:22
@JohnTheCoolingFan
Copy link
Contributor Author

As outlined in the "How Has This Been Tested?", there is currently a problem with the fix, which is why I'm making this PR a draft.

@igorpecovnik
Copy link
Member

For some reason fails on the first try, creating the device and not finding it, but the second run succeeds.

Try to keep this function in host_prepare part. But on the other hand this is only needed for compiling images.

@igorpecovnik igorpecovnik added Work in progress Unfinished / work in progress 08 Milestone: Third quarter release labels May 11, 2024
@JohnTheCoolingFan
Copy link
Contributor Author

Ok, I've moved the call to the command way earlier, but currently I'm not sure where its place really is.

I've fixed the issue of having to run it 2 times by moving the call to losetup to host (before docker), put it in entrypoint... But I feel like that would mess with usage of ./compile.sh with other commands, which is why I would like to move it to docker and build, with the latter having an if check for running inside of docker. Although I'm not sure whether that's necessary. And I'm unsure what the call chain is in the case of ./compile.sh <settings with no command>

doas is not compatible with sudo flags. The codebase was checked for
sudo-specific uses of this function, but none were found, all cases were
in the form of `sudo <command>`. Replacing it with `doas <command>`
yields the same result.
@JohnTheCoolingFan
Copy link
Contributor Author

Rebased on main properly and squashed the moving around, removed the issue from the PR root comment and I think this is ready for review.

@igorpecovnik igorpecovnik added Needs review Seeking for review 05 Milestone: Second quarter release and removed Work in progress Unfinished / work in progress labels May 17, 2024
Copy link
Member

@igorpecovnik igorpecovnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks ok, it works

@igorpecovnik igorpecovnik added Ready to merge Reviewed, tested and ready for merge and removed Needs review Seeking for review labels May 20, 2024
@igorpecovnik igorpecovnik merged commit b3d9a17 into armbian:main May 20, 2024
7 checks passed
@rpardini
Copy link
Member

Complete and general breakage due to this.
@igorpecovnik Have reverted on my fork

@igorpecovnik
Copy link
Member

I check if it breaks. It didn't ... so I merge as there was no other complains.

@igorpecovnik
Copy link
Member

This is an attempt to enable build framework execution on Gentoo. Which I don't mind if it doesn't harm us. Where is the problem?

@rpardini
Copy link
Member

Dunno, seems it tries to use sudo even in the docker case.

@viraniac
Copy link
Collaborator

Yes, it breaks build on MacOS. The ensure_loop_exists must only run when ARMBIAN_RELAUNCHED is set to yes

@viraniac
Copy link
Collaborator

Also I don't see a point why ensure_loop_exists needs to be added to cli-docker.sh.

@JohnTheCoolingFan
Copy link
Contributor Author

JohnTheCoolingFan commented May 20, 2024

The issue on my machine was that there were no loop devices created by default unless I try to find one using losetup -f, which also requires root privileges. And even though it can be called inside docker and would output a valid loop device, the script didn't find it (presumably because it wasn't available in the docker container). But if it's called before the docker container is launched, everything works. I am using Gentoo with a distribution kernel which is not configured to create a number of free loop devices by default, only when needed. It depends on the kernel configuration and kernel command line. Technically, it's not specific to Gentoo, it just happens to be that Gentoo's distribution kernel config has such values by default.

The PR breaking builds on MacOS is a major issue, which would justify the revert of the merge, if possible. This PR only provides a dirty quickfix to go around a problem in the part of the script that finds a free loop device. The problem is that it sets the result to an empty string and "succeeds" on the first try, breaking because of the edge case that there are no /dev/loopX loop devices at all

@JohnTheCoolingFan
Copy link
Contributor Author

Also I don't see a point why ensure_loop_exists needs to be added to cli-docker.sh.

As I've explained, calling losetup -f inside docker will output a free loop device path, but the script fails to find it.

@viraniac
Copy link
Collaborator

viraniac commented May 20, 2024

As I've explained, calling losetup -f inside docker will output a free loop device path, but the script fails to find it.

Yes, got that from the previous post. It was just that we both commented at almost the same time. There was no need to explain it twice.

May I suggest a workaround? Create a file in userpatches/extensions with the following content

function add_host_dependencies__losetup(){
	local sudo_prefix="" && is_root_or_sudo_prefix sudo_prefix
	${sudo_prefix} losetup -f
}

If that works for you, we can probably revert this change until a better version is proposed.

@JohnTheCoolingFan
Copy link
Contributor Author

Yes, that works, although I still need to add the doas support for it to run on my machine.

@igorpecovnik
Copy link
Member

@JohnTheCoolingFan OK, make revert PR and once this is better tested, new one. This would be IMO best path from current situation.

@JohnTheCoolingFan
Copy link
Contributor Author

I'll also put the doas support into a separate PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
05 Milestone: Second quarter release 08 Milestone: Third quarter release Ready to merge Reviewed, tested and ready for merge size/small PR with less then 50 lines
Development

Successfully merging this pull request may close these issues.

None yet

4 participants