( originally https://github.com/MicrosoftDocs/PowerShell-Docs/issues/5601 )
It would be great to have a document (or a build script) outlining how to build PowerShell without a self-hosted copy available. Maintaining the AUR package becomes more difficult for me every time the build system changes between versions with no document or script explaining the changes. All of the current documentation assumes a previously installed version of PowerShell.
I've got a working Arch Linux PKGBUILD (essentially a bash script) for 6.2.4 but have been having some trouble getting 7.0 to successfully build and run.
If there was a build script that didn't depend on PowerShell in the repository, packages could just delegate to that.
Why can you not use existing PowerShell package to build new one? It is very difficult for us to support standalone build scripts.
@kylesferrazza Just to clarify the request, would a build.sh entry point that checks for a local pwsh install, installs it if necessary and then invokes the current build script be sufficient? Or are you asking for a build script that doesn't touch PowerShell at all?
I was asking about a build script that doesn't touch PowerShell at all, similar to how I build 6.2.4 here (see the build() function):
https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=powershell
I suppose I could just rewrite the PKGBUILD to use a binary PowerShell to call Start-PSBuild from build.psm1, but I was thinking that users would want to be able to build PowerShell from source without needing to trust/install a pre-packaged binary PowerShell.
It seems to still work on 7.0, but I get the following error on running the built pwsh:
Error:
An assembly specified in the application dependencies manifest (pwsh.deps.json) was not found:
package: 'runtimepack.Microsoft.NETCore.App.Runtime.linux-x64', version: '3.1.2'
path: 'System.IO.Compression.Native.a'
On further digging, it looks like after my build script runs, ./src/powershell-unix/bin/Debug/netcoreapp3.1/linux-x64/publish/pwsh works fine, but the above error shows up after copying publish/ to /opt and then trying to run pwsh within /opt.
Are additional packaging steps required besides copying the contents of the publish directory to /opt and then symlinking pwsh into /usr/bin?
Oh that's not anywhere near as long as I pictured.
@SteveL-MSFT It might be worth officially supporting a script like this to make this process easier for community package maintainers. Or at the very least a bit of someone's time to troubleshoot the issue above.
strace revealed powershell trying to open a .a. Adding options=(!strip) to the PKGBUILD seems to have fixed the issue.
[kyle@37bb2b2d8d53 app]$ strace pwsh -Command exit 2>&1 | grep '\.a'
stat("/opt/microsoft/powershell/7/System.IO.Compression.Native.a", {st_mode=S_IFREG|0744, st_size=2837182, ...}) = 0
stat("/opt/microsoft/powershell/7/System.Native.a", {st_mode=S_IFREG|0744, st_size=419888, ...}) = 0
stat("/opt/microsoft/powershell/7/System.Net.Http.Native.a", {st_mode=S_IFREG|0744, st_size=79868, ...}) = 0
stat("/opt/microsoft/powershell/7/System.Net.Security.Native.a", {st_mode=S_IFREG|0744, st_size=36266, ...}) = 0
stat("/opt/microsoft/powershell/7/System.Security.Cryptography.Native.OpenSsl.a", {st_mode=S_IFREG|0744, st_size=993712, ...}) = 0
I see that dotNet 3.0 SDK for FreeBSD has been hacked together.
https://github.com/jasonpugsley/core-sdk/wiki/.Net-Core-3.0.0-for-FreeBSD
But it's chicken/egg to build Powershell for FreeBSD right?
GitHub
.NET Core SDK Setup. Contribute to jasonpugsley/core-sdk development by creating an account on GitHub.
Most helpful comment
stracerevealed powershell trying to open a.a. Addingoptions=(!strip)to the PKGBUILD seems to have fixed the issue.