-
Notifications
You must be signed in to change notification settings - Fork 1
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
Rewrite autowrap #5
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There were a few tweaks to work better with `brioche-ld` as well
Each file in the search path will be a candidate, and will be checked by both filname and by the `DT_SONAME` field
This fixes a regression seen when building `as` from `binutils`. Here's what went wrong: 1. `as` was built and linked against `libbfd-2.41.so` 2. `libbfd-2.41.so` was passed as an input directly via a symlink called `libbfd.so` 3. Because the library has a `DT_SONAME` field, the resulting binary has a `NEEDED` field for `libbfd-2.41.so` 4. Since we were using the direct filename from the input rather than the library name, `libbfd.so` was added as a resource to the packed binary 5. When ran, `as` was looking for `libbfd-2.41.so` instead of `libbfd.so`, so it failed to run The issue is in step (4). Now, the library is added by whatever's in the `NEEDED` list instead of what the input filename happened to be
This was referenced Jul 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a massive overhaul to the autowrap functionality in this repo.
From a high level, the main difference is in the
brioche-packer autowrap
subcommand. Previously, this took a lot of command-line flags to control autowrapping. This has been changed to take the config as a JSON object, along with variable values to set paths (the variables are important as to avoid issues that could come up when interpolating paths in the JSON config).There are also some new capabilities, like autowrapping shebang scripts, using separate options for wrapping dynamic binaries and libraries, and rewrapping already-wrapped programs.
Here's an example invocation:
The positional argument (
RECIPE_PATH
) specifies the root path to wrap (this is used for resolving some relative paths and is the base path used for glob patterns). Each variable takes the format--var [name]=[type]:[value]
, with the only type beingpath
currently. Passing--schema
will also print the JSON schema of the config (although currently this doesn't include documentation for each option).paths
: Set to a list of paths to wrap explicitly. This will fail if any path cannot be wrapped. Mutually exclusive withglobs
globs
: Set to a list of glob patterns to try to wrap. If any matched file cannot be wrapped, it will be ignored. Mutually exclusive withpaths
linkDependencies
: A list of paths to link against. This is used for finding dynamic libraries, the dynamic interpreter, and programs from shebang scriptsselfDependency
: Include the recipe itself in the list oflinkDependencies
. This is useful if a package includes libraries that are referenced by its own binariesdynamicBinary
: Config used when wrapping a dynamic binary. If unset, dynamic binaries will be skippedpackedExecutable
(required): Path to the packed executable to use when wrapping the binary. This will usually be the path to thebrioche-packed-userland-exec
executable from this crateextraRuntimeLibraryPaths
: Extra paths to search for libraries at runtime when the executable is run. Paths are relative to the recipe dirlibraryPaths
: Extra paths to search for libraries at link timeskipLibraries
: A list of library names to not link if if included in theDT_NEEDED
sectionextraLibraries
: A list of library names to link even if not included in theDT_NEEDED
sectionskipUnknownLibraries
: When set to true, skip any libraries that could not be found instead of erroring outsharedLibrary
: Config used when wrapping a shared library. If unset, shared libraries will be skippedlibraryPaths
: Extra paths to search for libraries at link timeskipLibraries
: A list of library names to not link if if included in theDT_NEEDED
sectionextraLibraries
: A list of library names to link even if not included in theDT_NEEDED
sectionskipUnknownLibraries
: When set to true, skip any libraries that could not be found instead of erroring outscript
: Config used when wrapping a shebang script. If unset, shebang scripts will be skippedpackedExecutable
(required): Path to the packed executable to use when wrapping the script. This will usually be the path to thebrioche-packed-plain-exec
executable from this crateenv
: An object representing env vars to change when the script gets run. Each key is an env var name, and each value with one of the following types:clear
: Clear the env var even if it is already setinherit
: Inherit the env var even ifclearEnv
is enabledset
: Set the env var to the provided valuefallback
: Set the env var if is emptyprepend
: Prepend to the current env var (separated with the provided separator). If the env var is empty, the separator will not be includedappend
: Append to the current env var (separated with the provided separator). If the env var is empty, the separator will not be includedclearEnv
: Start the process without any env vars set, except those explicitly set inenv
rewrap
: Config used when encountering a dynamic binary, shared library, or script that was already wrapped. If unset, already-wrapped things will be left as-is