Re: Help with zef Portfile

2023-11-26 Thread raf via macports-users
On Mon, Nov 27, 2023 at 06:08:00AM +1100, Joshua Root  wrote:

> raf wrote:
> 
> > I tried just putting "system" before the command but it didn't work.
> > I couldn't find the documentation for tcl's system,
> 
> System isn't a standard Tcl thing, it's provided by MacPorts. It's closely
> analogous to system(3). It takes a single string which is passed to 'sh -c'.

Thanks. I was effectively giving it multiple strings instead of one.

> It's documented in the portfile man page at least. If it's missing
> elsewhere, that's one more thing for the list of documentation improvements
> that are needed.

I looked for it at 
https://guide.macports.org/chunked/reference.tcl-extensions.html
Thanks for the pointer to the portfile manpage.

> >:info:destroot Failed to create directory 
> > '/opt/local/share/perl6/site/short' with mode '0o777': Failed to mkdir: 
> > Operation not permitted
> That path is outside the work path, so it's not permitted to write to it
> except in the activate phase, but apparently something in the port is trying
> to create it during the destroot phase.
> 
> - Josh

Yes. I thought it was odd but assumed it must have been part of
the activation phase (even though it says destroot in the message).

Perhaps it's rakudo itself doing that. But how did I manage to get it
to work at all (before trying install with -vst)? Maybe I had installed
zef earlier manually and the directories were there? Not sure. But I
think I remember seeing that directory in the past but it's gone now.

I'll try to create any missing directories in ${destroot} as part of
post-destroot and see if that helps. Or maybe I can ask on a rakudo
mailing list about what creates these directories.

cheers,
raf



Re: Help with zef Portfile

2023-11-26 Thread Joshua Root

raf wrote:


I tried just putting "system" before the command but it didn't work.
I couldn't find the documentation for tcl's system,


System isn't a standard Tcl thing, it's provided by MacPorts. It's 
closely analogous to system(3). It takes a single string which is passed 
to 'sh -c'.


It's documented in the portfile man page at least. If it's missing 
elsewhere, that's one more thing for the list of documentation 
improvements that are needed.



   :info:destroot Failed to create directory 
'/opt/local/share/perl6/site/short' with mode '0o777': Failed to mkdir: 
Operation not permitted
That path is outside the work path, so it's not permitted to write to it 
except in the activate phase, but apparently something in the port is 
trying to create it during the destroot phase.


- Josh



Re: Help with zef Portfile

2023-11-26 Thread raf via macports-users
On Sat, Nov 25, 2023 at 05:45:35PM +0100, Rainer Müller  
wrote:

> On 25.11.23 16:07, Joshua Root wrote:
> > The default destroot phase builds a string to pass to 'system' by
> > combining destroot.cmd, destroot.args, etc. In this case, it might be
> > easiest to use those for the rakudo command, and create the symlinks in
> > a post-destroot block?
> 
> Also note that all files have to be put into ${destroot} during the
> destroot phase. The files will afterwards be put into an archive from
> this ${destroot} and will only later be moved to the real ${prefix}
> when activating the port.
> 
> When moving these symlink commands to a post-destroot phase, these should 
> look like this:
> 
> post-destroot {
> ln -s "${prefix}/share/perl6/site/bin/zef"   
> "${destroot}${prefix}/bin/zef"
> ln -s "${prefix}/share/perl6/site/bin/zef-m" 
> "${destroot}${prefix}/bin/zef-m"
> }
> 
> Rainer

Thanks. I spotted that mistake too.

cheers,
raf



Re: Help with zef Portfile

2023-11-26 Thread raf via macports-users
On Sun, Nov 26, 2023 at 02:07:39AM +1100, Joshua Root  wrote:

> raf wrote:
> 
> > The destroot part looks like this:
> > 
> >destroot {
> >"${prefix}/bin/rakudo" -I"${worksrcpath}" bin/zef \
> >--to="inst#${destroot}${prefix}/share/perl6/site" \
> >install "${worksrcpath}"
> > 
> >ln -s "${prefix}/share/perl6/site/bin/zef"   "${prefix}/bin/zef"
> >ln -s "${prefix}/share/perl6/site/bin/zef-m" "${prefix}/bin/zef-m"
> >}
> > 
> > Which results in this error:
> > 
> >:error:destroot Failed to destroot raku-zef: invalid command name 
> > "/opt/local/bin/rakudo"
> >:debug:destroot Error code: NONE
> >:debug:destroot Backtrace: invalid command name "/opt/local/bin/rakudo"
> >:debug:destroot while executing
> >:debug:destroot "$procedure $targetname"
> > 
> > As "${prefix}/bin/rakudo" is valid in test.cmd,
> > why isn't it valid during destroot?
> > And how do I help destroot find it?
> 
> This is really a macports-dev question, so cross-posting this there.
> 
> When you override (e.g. destroot { ... }) or augment (e.g. post-build { ...
> }) a port phase, the code you provide is executed in the Tcl interpreter.
> '${prefix}/bin/rakudo' is indeed not a valid Tcl command. It happens that we
> do define an 'ln' Tcl command that takes args very much like ln(1). If you
> want to execute something in the shell, you have to use the 'system' command
> (or sometimes 'exec' if you want to capture the output.)
> 
> The default destroot phase builds a string to pass to 'system' by combining
> destroot.cmd, destroot.args, etc. In this case, it might be easiest to use
> those for the rakudo command, and create the symlinks in a post-destroot
> block?
> 
> - Josh

Thanks! That's super helpful.

I tried just putting "system" before the command but it didn't work.
I couldn't find the documentation for tcl's system, so I tried using
destroot.cmd "${prefix}/bin/rakudo" ... instead, but it added extra
arguments: install DESTROOT=... which break the command. But erasing
destroot's args, pre_args, and post_args fixed the build.

Then the problem was activating it. It said:

  Error: Failed to activate raku-zef: Image error:
  /opt/local/share/perl6/site/version is being used by the active rakudo port.
  Please deactivate this port first, or use 'port -f activate raku-zef' to
  force the activation.

So I added the removal of that file to post-destroot and now it works!
It installs and avtivates...

However, when I now test with "sudo port install -vst raku-zef", and add the
missing dependencies (curl, git, wget), I get this error:

  :info:destroot Failed to create directory '/opt/local/share/perl6/site/short' 
with mode '0o777': Failed to mkdir: Operation not permitted
  :info:destroot Command failed:  cd 
"/opt/local/var/macports/build/_Users_raf_macports_ports_lang_raku-zef/raku-zef/work/zef-0.21.1"
 && /opt/local/bin/rakudo 
-I"/opt/local/var/macports/build/_Users_raf_macports_ports_lang_raku-zef/raku-zef/work/zef-0.21.1"
 bin/zef 
--to="inst#/opt/local/var/macports/build/_Users_raf_macports_ports_lang_raku-zef/raku-zef/work/destroot/opt/local/share/perl6/site"
 install 
/opt/local/var/macports/build/_Users_raf_macports_ports_lang_raku-zef/raku-zef/work/zef-0.21.1
 
  :info:destroot Exit code: 1

And now, I get the same error without -vst. Wierd, that did work before trying 
-vst.
And port test isn't working anymore either with teh same error.

  $ ls -lasp /opt/local/share/perl6/site
  0 drwxr-xr-x  3 root  wheel   96 26 Nov 11:58 ./
  0 drwxr-xr-x  7 root  admin  224 26 Nov 11:58 ../
  0 -rw-r--r--  1 root  wheel  1 26 Nov 11:57 version

Any idea what's happening? Or what to try next?

I tried uninstalling and reinstalling rakudo just in case it might
help, but it didn't. My current attempt is
https://github.com/macportsraf/raku-zef-portfile

cheers,
raf



Re: Help with zef Portfile

2023-11-25 Thread Rainer Müller

On 25.11.23 16:07, Joshua Root wrote:
The default destroot phase builds a string to pass to 'system' by 
combining destroot.cmd, destroot.args, etc. In this case, it might be 
easiest to use those for the rakudo command, and create the symlinks in 
a post-destroot block?


Also note that all files have to be put into ${destroot} during the destroot 
phase. The files will afterwards be put into an archive from this ${destroot} 
and will only later be moved to the real ${prefix} when activating the port.

When moving these symlink commands to a post-destroot phase, these should look 
like this:

post-destroot {
ln -s "${prefix}/share/perl6/site/bin/zef"   "${destroot}${prefix}/bin/zef"
ln -s "${prefix}/share/perl6/site/bin/zef-m" 
"${destroot}${prefix}/bin/zef-m"
}

Rainer


Re: Help with zef Portfile

2023-11-25 Thread Joshua Root

raf wrote:


The destroot part looks like this:

   destroot {
   "${prefix}/bin/rakudo" -I"${worksrcpath}" bin/zef \
   --to="inst#${destroot}${prefix}/share/perl6/site" \
   install "${worksrcpath}"

   ln -s "${prefix}/share/perl6/site/bin/zef"   "${prefix}/bin/zef"
   ln -s "${prefix}/share/perl6/site/bin/zef-m" "${prefix}/bin/zef-m"
   }

Which results in this error:

   :error:destroot Failed to destroot raku-zef: invalid command name 
"/opt/local/bin/rakudo"
   :debug:destroot Error code: NONE
   :debug:destroot Backtrace: invalid command name "/opt/local/bin/rakudo"
   :debug:destroot while executing
   :debug:destroot "$procedure $targetname"

As "${prefix}/bin/rakudo" is valid in test.cmd,
why isn't it valid during destroot?
And how do I help destroot find it?


This is really a macports-dev question, so cross-posting this there.

When you override (e.g. destroot { ... }) or augment (e.g. post-build { 
... }) a port phase, the code you provide is executed in the Tcl 
interpreter. '${prefix}/bin/rakudo' is indeed not a valid Tcl command. 
It happens that we do define an 'ln' Tcl command that takes args very 
much like ln(1). If you want to execute something in the shell, you have 
to use the 'system' command (or sometimes 'exec' if you want to capture 
the output.)


The default destroot phase builds a string to pass to 'system' by 
combining destroot.cmd, destroot.args, etc. In this case, it might be 
easiest to use those for the rakudo command, and create the symlinks in 
a post-destroot block?


- Josh



Help with zef Portfile

2023-11-24 Thread raf via macports-users
Hi,

I'm writing a Portfile for raku's module manager, zef (port named raku-zef),
and I'm getting a destroot error I don't understand.

The test part looks like this:

  test.runyes
  test.cmd"${prefix}/bin/rakudo" -I"${worksrcpath}" bin/zef test 
"${worksrcpath}"
  test.target

And it works and the tests pass (Yay!).

The destroot part looks like this:

  destroot {
  "${prefix}/bin/rakudo" -I"${worksrcpath}" bin/zef \
  --to="inst#${destroot}${prefix}/share/perl6/site" \
  install "${worksrcpath}"

  ln -s "${prefix}/share/perl6/site/bin/zef"   "${prefix}/bin/zef"
  ln -s "${prefix}/share/perl6/site/bin/zef-m" "${prefix}/bin/zef-m"
  }

Which results in this error:

  :error:destroot Failed to destroot raku-zef: invalid command name 
"/opt/local/bin/rakudo"
  :debug:destroot Error code: NONE
  :debug:destroot Backtrace: invalid command name "/opt/local/bin/rakudo"
  :debug:destroot while executing
  :debug:destroot "$procedure $targetname"

As "${prefix}/bin/rakudo" is valid in test.cmd,
why isn't it valid during destroot?
And how do I help destroot find it?

If you need to see the whole Portfile, it's at:

  
https://github.com/macportsraf/raku-zef-portfile/blob/main/lang/raku-zef/Portfile

cheers,
raf