App-perlbrew icon indicating copy to clipboard operation
App-perlbrew copied to clipboard

Custom cygwin package

Open drbean opened this issue 1 year ago • 3 comments

After much trial and error, I think I have an App-perlbrew custom cygwin package which I can not recommend, but at least show, as proof that it can be done.

I put it on a custom cygwin server, http://drbean.sdf.org/cygwin, where it is the only package. If it is your first download of cygwin packages, you will need to download perl and other packages from a real cygwin mirror beforehand.

It is unsigned by the project so you have to invoke the cygwin installer from the command line, as /cygdrive/c/Users/$USER/Downloads/setup-x86_64.exe --no-verify.

As a proof of concept, I decided to just install perlbrew in /usr/bin, but with tweaks, like

export PERL_MB_OPT="--install_base ${HOME}/perl5/perlbrew
	--install_path share=${HOME}/perl5/perlbrew/share"

I was able to install at least man and lib in perl5/perlbrew, but not README, etc. I couldn't find where the App::Perlbrew::* modules were when I installed perlbrew in /usr, and /usr/local.

Not being a system package it should at most be in /usr/local, not /usr.

The real work appears to be done in the postinstall script, which at the moment is just

    curl -L https://install.perlbrew.pl | bash

So it doesn't add any value over installing it that way.

Because the whole install is done with elevated Administrator privileges, the files end up with Administrator permissions, which is not wanted in ~/perl5/perlbrew.

I don't know how to change that. Perhaps it is as simple as chowning them after they're created.

I'm open to suggestions as the best place for perlbrew installed by a cygwin package, although I don't intend to promote use of packages to install perlbrew on cygwin, or even to maintain this one. It was more an exercise in learning about cygwin packaging.

https://cygwin.org/packages.html https://cygwin.github.io/cygport/toc_index.html

drbean avatar Mar 12 '25 13:03 drbean

I set up a github repo at

https://github.com/drbean/cygwin-perlbrew

with the perlbrew.cygport file that creates the package and the postinstall.sh file that actually installs perlbrew.

Also there is setup.ini, on the server, which cygwin uses downloading packages, and custom_installer.sh you can use to install the package,

In postinstall.sh,

export PERLBREW_SYSTEM_PERL=/usr/bin/perl
export PERLBREW_ROOT=/usr
curl -L https://install.perlbrew.pl | bash

The package installs the perlbrew perl file in /usr/bin/perlbrew as perl PERLBREW_ROOT, but the shebang line, which should be

usr/bin/perl

is empty, with and without the export of PERLBREW_SYSTEM_PERL.

I should investigate, but instead I'm going to try to make the package put perlbrew in HOME/perl5.

drbean avatar Mar 18 '25 13:03 drbean

The package has no information about the user's HOME and the cygwin install doesn't allow for user input, and typically installs with Administrators permissions.

Installing perlbrew in /home/Administrator/perl5 seems to be the answer.

'Administrator' is apparently the first account on Windows but needs to be made available with

net user Administrator /active:yes

using Administrators permissions. Windows also has other ways of doing this.

A password may need to be set too.

Then after the successful install, the user with Administrators permissions needs to move it to their USER_ACCOUNT:

mv /home/{Administrator,USER_ACCOUNT}/perl5
chown -R USER_ACCOUNT:197121 ~USER_ACCOUNT/perl5/

I'm getting a National Language Support version for the right group. This group may be a cygwin-generated one. The numeric gid works for me.

Then grepping for 'Administrator' in perlbrew only shows it in the perlbrew packlist and bashrc's

export PERLBREW_ROOT=/home/Administrator/perl5/perlbrew

where it is easily changed.

So, this is achieved with the perl-App-perlbrew-1.01-1 package, that can be built with the perlbrew.cygport and postinstall.sh file in https://github.com/drbean/cygwin-perlbrew, along with setup.ini, the file making the package hostable on a custom cygwin server.

I'm hosting it at http://drbean.sdf.org/cygwin.

I think this is the best solution to this cygwin install question.

There is probably only one developer on any Windows machine, and if they have 2 accounts using perlbrew they probably want to keep the 2 separate.

If not, they can mv perlbrew from /home/Administrator/perl5 to an appropriate path like /opt/perl5 and set appropriate permissions.

Finally, this was just an exercise in cygwin packaging for me. Installing with the package does not have any advantage over

curl -L https://install.perlbrew.pl | bash

drbean avatar Mar 22 '25 01:03 drbean

I updated my custom package to App-perlbrew-1.02, installable from http://drbean.sdf.org/cygwin/

Following my instructions above, users already with a ~/perl5 directory will find moving perlbrew from the Administrator account places it in a second perl5 subdirectory below ~/perl5, which you don't want, so you need to change that line.

drbean avatar Aug 05 '25 00:08 drbean