Skip to content

feat: implement binary prefix detection behavior in packaging #1658

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

zelosleone
Copy link
Collaborator

@zelosleone zelosleone commented May 14, 2025

closes #1507 #1681

I’ve tried to change the usage of bool types to Option Type as well, just because it looked cleaner. I think it is a little bit better for our usage case as well since we will now default to error. I also used proper types instead of bool types for our usage case, just in case we will introduce more types in the future. On windows, binaries aren’t a problem, so I limited the test to UNIX.

@wolfv
Copy link
Member

wolfv commented May 14, 2025

The idea is good but we cannot easily change the schema at this point, unfortunately. It would destroy backward compatibility, sadly. For now, IMO the only thing we can do is add a CLI flag, and later create a v2 schema where we allow the new value(s).

Or we could add a third value (true/false/error) but even that is a "breaking" schema change.

@zelosleone
Copy link
Collaborator Author

The idea is good but we cannot easily change the schema at this point, unfortunately. It would destroy backward compatibility, sadly. For now, IMO the only thing we can do is add a CLI flag, and later create a v2 schema where we allow the new value(s).

Or we could add a third value (true/false/error) but even that is a "breaking" schema change.

Gotcha! I will revert the changes on option type then

@zelosleone zelosleone requested a review from wolfv May 15, 2025 15:29
@zelosleone
Copy link
Collaborator Author

I think i fixed the bugs now that i spent 3 hours to get into pop os :D (lost my usb stick while moving) and i also manage to apply However 2 runners are failing because of chocolatey extract action, i don't think that should be in our repos but i think its more related to chocolatey @wolfv

@wolfv
Copy link
Member

wolfv commented May 20, 2025

I think there is some misunderstanding going on.

What we want to introduce is a sanity check to error the package build if any files contain a binary prefix. This should be implemented as an additional CLI flag.

Actually, I think we can just do these checks in a post-processing stage and then let the package fail if the flag is activated.
We can use the same method to check (on Windows) if the final package contains any symlinks (#1681).

@zelosleone
Copy link
Collaborator Author

I think there is some misunderstanding going on.

What we want to introduce is a sanity check to error the package build if any files contain a binary prefix. This should be implemented as an additional CLI flag.

Actually, I think we can just do these checks in a post-processing stage and then let the package fail if the flag is activated.
We can use the same method to check (on Windows) if the final package contains any symlinks (#1681).

I am switching to windows ATM and can only reply on mobile but yeah I might have misunderstood the issue, I will try to include the fix for the symlink issue as well today or tomorrow (I will let you know about it too) and will let you know about the progress

@zelosleone zelosleone requested a review from wolfv May 22, 2025 15:41
@@ -605,7 +700,7 @@ def check_path(p, t):
elif path == "force_text/file_without_prefix":
check_path(p, None)
elif path == "force_binary/file_with_prefix":
check_path(p, "binary")
Copy link
Member

Choose a reason for hiding this comment

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

why was this changed?

@zelosleone zelosleone force-pushed the erroringhostprefix branch from 207fbb6 to 5845966 Compare May 27, 2025 15:16
@wolfv
Copy link
Member

wolfv commented May 27, 2025

Looks good and clean :)

@zelosleone
Copy link
Collaborator Author

Looks good and clean :)

But i gotta fix the windows issue now, I will work on this today xD

@zelosleone
Copy link
Collaborator Author

@wolfv There were too many problems with symlink tests on windows due to symlinks being broken on creation for packaging (only on windows) (both with windows native commands and python commands, i also activated developer mode and edited the key on regedit to no end) so i switched the symlink test to linux for now.

}
#[cfg(windows)]
{
let res = if metadata.file_type().is_dir() {
Copy link
Member

Choose a reason for hiding this comment

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

the metadata is the symlink_metadata - is that correct, and will it ever evaluate is_dir() == true?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just checked and i think we can use symlink_dir as well alongside with symlink_metadata to check if first if the target is a directory or not, will add this too now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support erroring (possibly by default) when detecting the host prefix in the binary
2 participants