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

[FHS bundles] Proposal #1392

Merged
merged 2 commits into from Jan 19, 2018
Merged

[FHS bundles] Proposal #1392

merged 2 commits into from Jan 19, 2018

Conversation

millenomi
Copy link
Contributor

Please leave comments here or at the thread I'm about to start on the swift-corelibs-dev list.

@millenomi
Copy link
Contributor Author

As a formality:

@swift-ci Please test.


Function | Path returned
---|---
`CFBundleCopyBundleURL` | `…/MyFramework.resources`
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be sure: does ... mean the parent directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It meant 'the same directory as … in the other entries', but I see how it can be confusing. I will clarify this.


### Bundle Paths

The bundle's `.resources` directory contains resources much like an iOS-style flat bundle. Unlike on iOS, however, executables are not contained directly inside this directory. Instead, given that the bundle exists in `share/MyFramework.resources`, then an installed bundle will source from the following additional paths within the prefix the bundle is installed in (the parent directory of the `share` directory):
Copy link
Member

Choose a reason for hiding this comment

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

Can you include reference to some document which explains iOS-style flat bundle? I see many references to the iOS bundle in this proposal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Perfect, thanks!

@ianpartridge
Copy link
Collaborator

Hi @millenomi - from my reading of FHS /usr/local/share is intended for architecture-independent data. Do you intend for installed bundles to only contain architecture-independent data?

As Foundation runs on platforms including Linux on z Systems (LinuxONE) and Linux on POWER it's important that we have a cross-architecture approach. Just checking that this has been considered in your thinking. Perhaps you could elaborate how this would work. Thanks!

@millenomi
Copy link
Contributor Author

The idea is that bundle resources, which are for all bundles we intend to ship this way architecture-independent, will live under share; architecture-dependent parts will live in bin, sbin, lib<suffix>, lib (for the main executable) and libexec (for auxiliary executables and embedded frameworks.) So, no, not all bundle content will live in share.

@ianpartridge
Copy link
Collaborator

Thanks @millenomi that sounds good.

One other thing. I imagine that in future we intend to ship bundles containing Foundation resources as part of the Linux toolchains from swift.org (for things like localization content), so we'd have a /usr/local/share/Foundation.resources directory?

How would this work when a user wants to have multiple versions of Swift installed on their Linux machine, which would ship with different bundle content?

@millenomi
Copy link
Contributor Author

millenomi commented Jan 17, 2018

I'm going to circle back to you about that shortly, but the preliminary thought is that right now no two released versions of Swift are able to coinhabit the same --prefix. However, we do want to have a proposal for when that can occur, but we may postpone the details if it turns out we can do it in a purely additive way.

@millenomi
Copy link
Contributor Author

Perfunctorily,

@swift-ci Please test.

Copy link
Member

@ddunbar ddunbar left a comment

Choose a reason for hiding this comment

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

Awesome, I'm very glad to see a proposal here!

An installed bundle exists if there is:

- A directory with the `.resources` extension;
- contained in a directory named `share`.
Copy link
Member

Choose a reason for hiding this comment

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

Is this complete? I found myself wondering "anywhere?". I presume this is limited to /usr, /usr/local, etc? Also, do any relative paths to a process working directory come into play?

Copy link
Member

Choose a reason for hiding this comment

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

Would it be conceptually constant for /usr/lib/libfoo.so to also be a "bundle"? The reason I ask is that it seems a little anomalous that it would be a library for a bundle only if there is also a .resources present. I could imagine that lifting this restriction might allow client code to be more consistent.

This isn't a well formed idea, please disregard if it doesn't make sense to consider.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is complete. As long as the CFBundle code finds that its client is trying to create a bundle at $PREFIX/share/$NAME.resources, we treat it as a FHS installed bundle. This is to support installing bundles in any --prefix=$PREFIX.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also briefly considered using the library as the lynchpin of an installed bundle, to allow for resource-less bundles. This hits an issue I'd like to avoid: it means that at least for some bundles, their location would not be a directory URL, which is not quite part of the contract but it is something I gather people would be severely surprised by.

Since the point here is to allow finally shipping resources, I would feel personally OK with restricting this proposal to only work with bundles that do have a resources path.

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense, thanks!

- Executable bundles will search `bin`, then `sbin`, for an executable with the same base name as the resources folder, plus any platform prefix or suffix for executables. e.g.: `bin/MyApp`.
- Framework bundles will search the appropriate `lib…` directories for a library of the same name, adding appropriate platform prefixes or suffixes for shared library file (falling back to just `lib` otherwise). e.g.: `lib/libMyFramework.so`.
- Auxiliary executables and libraries will be in, or in subdirectories of, `libexec/MyFramework.executables`;
- For framework bundles, `include/MyFramework` will contain headers, though this directory does affect the return values of the runtime API.
Copy link
Member

Choose a reason for hiding this comment

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

Will we also support a Modules directory like we do for frameworks? One reason this distinction is important is that a framework module map is written differently (framework module) than one for flat headers, and there may be something we want to do to reconcile this (presumably Clang itself isn't going to start understanding this convention).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. I'll circle back to you on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So.

This document does affect the discussion you mention, but right now we're a little more interested in the runtime aspect of this. The compile-time aspect is additive, and we can set that up with the clang team as a follow-up from implementing this — there's no runtime API that is affected by the presence (or absence) of the headers or of the module file, as far as I can tell.

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense. I don't see any issues with tackling that later.

@millenomi millenomi changed the title Add a proposal for a new installed bundle structure on Linux and other UNIX-like systems. [FHS bundles] Proposal Jan 18, 2018
@millenomi
Copy link
Contributor Author

We seem to have reached some consensus. I will write SRs for the remaining tasks, and we can continue discussion on the forums if needed once they're up.

@swift-ci Please test and merge.

@millenomi
Copy link
Contributor Author

Ahem.

@swift-ci Please test and merge.

@millenomi
Copy link
Contributor Author

Looks like there was a transient issue.

I'll just force-merge this, since it has no code changes.

@millenomi millenomi merged commit 7fc7463 into apple:master Jan 19, 2018
@millenomi millenomi deleted the pr/installed-bundles branch January 19, 2018 21:32
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.

None yet

5 participants