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

How to fix destroot for zef? #516

Open
barracuda156 opened this issue May 7, 2023 · 12 comments
Open

How to fix destroot for zef? #516

barracuda156 opened this issue May 7, 2023 · 12 comments

Comments

@barracuda156
Copy link

I am writing a portfile for zef. It should first install itself into ${destroot}${prefix}, and then Macports moves everything in place in ${prefix}. However, zef ignores passed agrs and tries to directly write into /opt/local, which obviously fails:

Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_zef/zef/work/zef-0.18.2" && /opt/local/bin/rakudo -I. bin/zef install --install-to=/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_zef/zef/work/destroot/opt/local DESTDIR=/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_zef/zef/work/destroot 
Failed to create directory '/opt/local/share/perl6/site/short' with mode '0o777': Failed to mkdir: Operation not permitted
Command failed:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_zef/zef/work/zef-0.18.2" && /opt/local/bin/rakudo -I. bin/zef install --install-to=/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_zef/zef/work/destroot/opt/local DESTDIR=/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_zef/zef/work/destroot

How to pass the target dir correctly, what should I add after bin/zef install? I can create a directory in destroot as needed, it should just go there and not try to creep into /opt/local/ directly.

@Dave-Allured
Copy link

Try prefixing ${destroot} with "inst#". See "Custom installation locations" within README.md.

@macportsraf
Copy link

Thanks. That's great. It looks like it needs --to="inst#${destroot}${prefix}/share/perl6/site". I'm running into other problems, but the macports folk can help with that.

@Dave-Allured
Copy link

Good. BTW I AM one of those Macports folk. Never even heard of zef until today. However I like a good puzzle, and I DO know how to read the docs once in a while. ;-)

I can't guarantee that the usual trick of moving ${destroot}${prefix} into ${prefix} will work in this case, but it's the obvious thing to try.

@barracuda156
Copy link
Author

@Dave-Allured Ah, I should complete this one finally, but will probably do it in a couple of weeks, since I am on a journey and therefore away from my PPC hardware (and Intel as well, only M1 with me).

@raforg
Copy link

raforg commented Nov 26, 2023

I've made a lot of progress. I actually got it to successfully test and install and activate. Briefly. But then I tried sudo port install -vst raku-zef, and now somehow it's all broken (fails to create a directory). And install no longer works without even without -vst. Very odd.

@barracuda156 I started another attempt at https://github.com/macportsraf/raku-zef-portfile/blob/main/lang/raku-zef/Portfile which might be of some use to you. I'll keep trying to get it working with the help of the macports mailing lists and see how it goes.

@ugexe
Copy link
Owner

ugexe commented Nov 30, 2023

If the site directory doesn't exist then rakudo will create it at runtime. This can occur without using zef at all. I think you could test this by running raku -e 'say CompUnit::RepositoryRegistry.repository-for-name("site").can-install()' which will attempt to mkdir that site directory if it doesn't exist (although looking at the code I wouldn't expect it to error, just return false)

@macportsraf
Copy link

macportsraf commented Nov 30, 2023

The site directory did already exist (I think). Rakudo is creating another directory underneath it. The error is due to permissions. The user that is used to build the package in "destroot" does not have permission to write to that directory, or perhaps it's a artificial protection ceated by macports to maintain control of what ports are doing.

Is there a list of all the items underneath the site directory that rakudo will create, or better still, is there a command that I could add to rakudo's macports portfile that would get it to create everything that it would end up creating, so that it doesn't get in the way of any other raku-related ports?

I've asked on the rakudo mailing list but haven't had a response yet.

@niner
Copy link
Collaborator

niner commented Dec 1, 2023

make install during Rakudo's build should already create all required directories.

@macportsraf
Copy link

Thanks, but unfortunately, it's isn't doing so. If it were, there wouldn't be a subsequent attempt to create them under /opt/local when trying to install zef to the destroot area.

@barracuda156 How is raku being installed? The Portfile doesn't mention install/destroot specifically, so I assume that it's doing a default make install under the hood. Is that the case?

It would be very helpful if someone knew the list of directories/files that make install for raku should create, so we can force them to be created when raku is installed.

Perhaps I need to work them out one at a time using the error messages as feedback.

@macportsraf
Copy link

macportsraf commented Dec 3, 2023

I think I might know what's going wrong. Macports has a wierd assumption that empty directories created in the destroot area aren't necessary, so it deletes them by default (or just doesn't copy them to the installation location). The Portfile needs to explicitly declare that they are needed, and macports puts a file in them to retain them. That's not happening.

So maybe raku is creating empty directories and macports is discarding them.

I'll see what raku's Makefile is creating during install to get a list of directories to explicitly retain. Hopefully, the extra file that macports insists on having won't cause problems for raku.

@ugexe
Copy link
Owner

ugexe commented Dec 3, 2023

See: https://github.com/rakudo/rakudo/blob/d2f8bb6fe0c21857007629d3be7e3330c36aa9aa/src/core.c/CompUnit/Repository/Installation.rakumod#L126-L142

$ raku -e 'say CompUnit::RepositoryRegistry.repository-for-name("site").prefix.absolute'
/Users/nlogan/.rakubrew/versions/moar-blead/install/share/perl6/site

$ rm -rf /Users/nlogan/.rakubrew/versions/moar-blead/install/share/perl6/site

$ ls /Users/nlogan/.rakubrew/versions/moar-blead/install/share/perl6/site
ls: /Users/nlogan/.rakubrew/versions/moar-blead/install/share/perl6/site: No such file or directory

$ raku -e 'use Test;'

$ ls /Users/nlogan/.rakubrew/versions/moar-blead/install/share/perl6/site
short

$ rakubrew build zef
HEAD is now at cb8e045 Bump version 0.21.2
Already on 'main'
Your branch is up to date with 'origin/main'.
===> Testing: zef:ver<0.21.2>:auth<github:ugexe>:api<0>
===> Testing [OK] for zef:ver<0.21.2>:auth<github:ugexe>:api<0>
===> Staging zef:ver<0.21.2>:auth<github:ugexe>:api<0>
===> Staging [OK] for zef:ver<0.21.2>:auth<github:ugexe>:api<0>
===> Installing: zef:ver<0.21.2>:auth<github:ugexe>:api<0>

1 bin/ script [zef] installed to:
/Users/nlogan/.rakubrew/versions/moar-blead/install/share/perl6/site/bin
Done, built zef for moar-blead

$ ls /Users/nlogan/.rakubrew/versions/moar-blead/install/share/perl6/site
bin             dist            precomp         resources       short           sources

@macportsraf
Copy link

Thanks. When I try raku -e 'use Test;' I get the same permissions error seen when installing zef to the destroot area which is great.

===SORRY!=== Error while compiling -e
Failed to create directory '/opt/local/share/perl6/site/short' with mode '0o777': Failed to mkdir: Permission denied
at -e:1

This will be a quick way to see all the directories that are needed and fix raku's Portfile. When that's merged, the zef Portfile will have a much better chance of working.

Many thanks.

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

No branches or pull requests

6 participants