And use it in what way though? This is an executable
This is basically what I mean:
swift package install --url https://somewhere.tld/some/package
swift package install --id some.package
swift package install --path /Users/Someone/Development/some/package
All of the plumbing for it should already be there.
I see! I’ll integrate —path sometime but how would —id work?
I am basically mirroring these from the manifest.
All you would be doing is asking SwiftPM’s existing fetch code to put it in tmp or wherever you are working instead of inside .build.
Any versioning analysis you would need is likewise already implemented for the sake of resolution (including security checksums).
@stackotter @SDGGiesbrecht local support, added and tested, here.
I can already see this being so useful for distributing Swift tools. At the moment I'm using Mint and it's a bit cumbersome when overriding installed versions with local development builds. Also, not everyone has Mint installed, so having the functionality built into SwiftPM will make installing tools even simpler.
I still think that the install command should support local git-less packages, they could be versioned using sha checksums. It would be slower than commit hashes, but at least it would be able to avoid unnecessarily rebuilding local packages when updating them from a script or something.
@stackotter @SDGGiesbrecht Update: Local support for gitless repos added: Add install-package support for gitless repos, add --force flag to up… · SerenaKit/swift-package-manager@62cb55b · GitHub
Oh, and another update, pr opened at Add Subcommands to install, update, and remove packages. by SerenaKit · Pull Request #5591 · apple/swift-package-manager · GitHub
This is cool.
A possible enhancement:
Once you've fetched the package you're going to build & install, run swift package plugin --list on it, and look for command plugins with known names, such as pre-install, post-install. If they are found, invoke them.
This would provide a clean mechanism for pre/post-install hooks and other more complicated installation stuff. There is a security trade-off, of course, but then that's already inherent in installing an open-source tool in the first place, since you're presumably going to run it once you've installed it.
(I confess that I've not looked at the code, so maybe you're doing something like this already, in which case I will shut up...!)
Part of the motivation for that suggestion is that I built something here which acts a kind of general-purpose package manager that I use to install things on my machines, but also to configure things.
So for example I might install things like my "xcode support" package, which adds a bunch of scripts and aliases into known locations, but also sets up some symbolic links for stuff like my standard Xcode templates.
I built my tool on top of SPM, and it leverages SPM to handle versions and dependencies. That works, but I still have to do a bootstrap installation of my tool. Having the same abilities built in to SPM would be one step closer to nirvana! For that to work though I need to not just install my "Xcode support" package, but then invoke it to perform the rest of the setup. Likewise when uninstalling, I need to be able to invoke something to clean up.