Re: Publicizing MacPorts [installation]

2021-05-23 Thread Marius Schamschula
A script that’ll download the installer pkg and then run the installer cli 
command

i.e. something like

cd ~/Downloads
curl -OL /url/of/installer.pkg
sudo installer -pkg installer.pkg -target /


> On May 23, 2021, at 12:58 PM, Joshua Root  > wrote:
> 
> On 2021-5-23 20:40 , Artem Loenko via macports-dev wrote:
>> If you ask me, `curl | sh` is a better option than `sudo make install`.
>> Even if we compare them both as anti-patterns.
> 
> If you haven't done any verification of the integrity of what you're 
> installing, 'make install' is certainly also a bad idea. But at least you had 
> the opportunity to verify the gpg signature or whatever of the tarball you 
> downloaded before running that. (And sure, a lot of people don't, hence the 
> preference of the pkg installer for general use, which will refuse to install 
> if the signature can't be verified.)
> 
>> Plus, `make` requires a few dependencies. But when you install a package,
>> all the logic/doctor checks can be implemented on the `ports` binary level.
>> Install CLT, Xcode, check the environment, etc. Simple is better.
> 
> Sure.
> 
> - Josh



Marius
--
Marius Schamschula






Re: Publicizing MacPorts [installation]

2021-05-23 Thread Joshua Root

On 2021-5-23 20:40 , Artem Loenko via macports-dev wrote:

If you ask me, `curl | sh` is a better option than `sudo make install`.
Even if we compare them both as anti-patterns.


If you haven't done any verification of the integrity of what you're 
installing, 'make install' is certainly also a bad idea. But at least 
you had the opportunity to verify the gpg signature or whatever of the 
tarball you downloaded before running that. (And sure, a lot of people 
don't, hence the preference of the pkg installer for general use, which 
will refuse to install if the signature can't be verified.)



Plus, `make` requires a few dependencies. But when you install a package,
all the logic/doctor checks can be implemented on the `ports` binary level.
Install CLT, Xcode, check the environment, etc. Simple is better.


Sure.

- Josh


Re: Publicizing MacPorts [installation]

2021-05-23 Thread Artem Loenko via macports-dev
> On Sat, May 22, 2021 at 1:35 PM Ken Cunningham 
>  wrote:
>
> cd /tmp
> git clone -b release-2.7 https://github.com/macports/macports-base.git
> cd macports-base
> ./configure && make && sudo make install
>
> and then add to the $PATH as usual

If you ask me, `curl | sh` is a better option than `sudo make install`. 
Even if we compare them both as anti-patterns. 
Plus, `make` requires a few dependencies. But when you install a package, 
all the logic/doctor checks can be implemented on the `ports` binary level. 
Install CLT, Xcode, check the environment, etc. Simple is better.

On Sat, May 22, 2021 at 2:31 PM Joshua Root http://macports.org/> wrote:
>
> I think the best thing we could do to facilitate one-liner command
> line installation is set up a redirect so you can download the latest
> binary installer for your OS version without having to construct
> its not-so-easy-to-derive name yourself. It would then be simple to
> download the .pkg and feed it to installer(8).
>

Yes, this is the idea. And it seems manageable to implement. 
Proper short links, a few lines to produce/validate them in release scripts, 
profit.

P.S. I have started to build a simple version of such a script[1] based on the 
advice from the discussion.
Please, join if you desire to improve the script and propose it as a source for 
the one-liner we are talking about.

Regards,
Artem

[1] https://gist.github.com/dive/c4a51179aa96d229a32dd3492e5fdc2d

> On 22 May 2021, at 19:55, Jason Liu  wrote:
> 
> 
> On Sat, May 22, 2021 at 1:35 PM Ken Cunningham 
> mailto:ken.cunningham.web...@gmail.com>> 
> wrote:
> Yes, thanks for the tips! I am pretty sure that it is possible to automate it 
> one way or another. But my point is that it would be helpful to have a 
> one-liner to install MacPorts and maintain it as a part of the main 
> repository. 
> 
> This was of course suggested years ago as well, when homebrew first did it, 
> but at that time was that it was both not needed and not a useful addition to 
> MacPorts, if I recall the full email exchange correctly, so we let the idea 
> die.
> 
> I feel like having a one-liner to install MacPorts, similar to Homebrew, 
> would be incredibly useful, especially for people who are not tech savvy. It 
> seems that many of us on the mailing list, including myself, already have our 
> own home-grown scripts to automate installing MacPorts. One thing that I 
> particularly like about the Homebrew installer is that it automatically 
> installs the CLT... I've been doing something similar in my own MacPorts 
> install script for around a decade.
> 
> My script even automatically accepts the Xcode license by using a small chunk 
> of expect. I realize that from the perspective of the MacPorts developers, we 
> might not want to be taking over control of this step from the user. But from 
> personal experience as a sysadmin, even this seemingly minor step can be a 
> fairly high hurdle for people who are not tech savvy.
> 
> Another thing that my script tries to automate is to add /opt/local to 
> everyone's $PATH if the script detects that SIP is disabled.
> 
> On Sat, May 22, 2021 at 2:31 PM Joshua Root  > wrote:
> 
> I think the best thing we could do to facilitate one-liner command line 
> installation is set up a redirect so you can download the latest binary 
> installer for your OS version without having to construct its 
> not-so-easy-to-derive name yourself. It would then be simple to download the 
> .pkg and feed it to installer(8).
> 
> This would be incredibly useful, and would allow me to cut out around 40-50 
> lines of code from my MacPorts install script (which is currently 
> constructing the not-so-easy-to-derive name myself). A single permalink 
> redirect would also allow the installation instructions to be simplified on 
> the MacPorts website, instead of what's currently there:
> 
> 3. Install MacPorts for your version of the operating system:
> * macOS Big Sur v11 
> 
> * macOS Cataline v10.15 
> 
> * macOS Mojave v10.14 
> 
> * Older OS? See here. 
> -- 
> Jason Liu
> 
> 



Re: Publicizing MacPorts [installation]

2021-05-22 Thread Bjarne D Mathiesen
Joshua Root wrote:
> I think the best thing we could do to facilitate one-liner command line
> installation is set up a redirect so you can download the latest binary
> installer for your OS version without having to construct its
> not-so-easy-to-derive name yourself. It would then be simple to download
> the .pkg and feed it to installer(8).

so ... do we want to have a HomeBrew like instaler option ?

And if so : what type ? My solution installs directly from source & thus
by-passes the problem of finding the correct .pkg.

My complete script furthermore establishes a basis for maintainance (it
needs more --help options, but that can be fixed)

-- 
Bjarne D Mathiesen
Korsør ; Danmark ; Europa
---
denne besked er skrevet i et totalt M$-frit miljø
OpenCore + macOS 10.15.7 Catalina
MacPro 2010 ; 2 x 3,46 GHz 6-Core Intel Xeon ; 256 GB 1333 MHz DDR3 ECC
ATI Radeon RX 590 8 GB


Re: Publicizing MacPorts [installation]

2021-05-22 Thread Bjarne D Mathiesen



Joshua Root wrote:
> On 2021-5-23 03:12 , Bjarne D Mathiesen wrote:
>>
>>
>> Artem Loenko wrote:
>>> Yes, thanks for the tips! I am pretty sure that it is possible to
>>> automate it one way or another. But my point is that it would be
>>> helpful to have a one-liner to install MacPorts and maintain it as a
>>> part of the main repository.
>>>
>>
>> I'm 90% there there with this :
>> /usr/bin/env bash -c $( curl -fsSL --url
>> 'https://trac.macports.org/raw-attachment/wiki/howto/AdvancedDailyAdm/macports.bash'
>>
>> ) install
>>
>> When I'm running this as my normal un-privileged user,
>> it executes 邏 (and fails because it's un-privileged)
>>
>> !!! but !!! if I try this as my admin user, nothing happens 樂邏
>> There's some obscure security setting I presently can't fathom, because
>> I can run the script locally (without curl) without any issues. And it
>> does download - it just doesn't execute 樂邏樂
> 
> That's probably Gatekeeper and/or the Quarantine attribute doing its
> thing and stopping you from running arbitrary code straight from the
> web. curl | sh or the equivalent should be considered an antipattern

And yet HomeBrew uses it.

Now, how do I go about solving my original problem / finding the root
cause ?!?

-- 
Bjarne D Mathiesen
Korsør ; Danmark ; Europa
---
denne besked er skrevet i et totalt M$-frit miljø
OpenCore + macOS 10.15.7 Catalina
MacPro 2010 ; 2 x 3,46 GHz 6-Core Intel Xeon ; 256 GB 1333 MHz DDR3 ECC
ATI Radeon RX 590 8 GB


Re: Publicizing MacPorts [installation]

2021-05-22 Thread Jason Liu
On Sat, May 22, 2021 at 1:35 PM Ken Cunningham <
ken.cunningham.web...@gmail.com> wrote:
>
> Yes, thanks for the tips! I am pretty sure that it is possible to automate
>> it one way or another. But my point is that it would be helpful to have a
>> one-liner to install MacPorts and maintain it as a part of the main
>> repository.
>
>
> This was of course suggested years ago as well, when homebrew first did
> it, but at that time was that it was both not needed and not a useful
> addition to MacPorts, if I recall the full email exchange correctly, so we
> let the idea die.
>

I feel like having a one-liner to install MacPorts, similar to Homebrew,
would be incredibly useful, especially for people who are not tech savvy.
It seems that many of us on the mailing list, including myself, already
have our own home-grown scripts to automate installing MacPorts. One thing
that I particularly like about the Homebrew installer is that it
automatically installs the CLT... I've been doing something similar in my
own MacPorts install script for around a decade.

My script even automatically accepts the Xcode license by using a small
chunk of expect. I realize that from the perspective of the MacPorts
developers, we might not want to be taking over control of this step from
the user. But from personal experience as a sysadmin, even this seemingly
minor step can be a fairly high hurdle for people who are not tech savvy.

Another thing that my script tries to automate is to add /opt/local to
everyone's $PATH if the script detects that SIP is disabled.

On Sat, May 22, 2021 at 2:31 PM Joshua Root  wrote:

>
> I think the best thing we could do to facilitate one-liner command
> line installation is set up a redirect so you can download the latest
> binary installer for your OS version without having to construct
> its not-so-easy-to-derive name yourself. It would then be simple to
> download the .pkg and feed it to installer(8).
>

This would be incredibly useful, and would allow me to cut out around 40-50
lines of code from my MacPorts install script (which is currently
constructing the not-so-easy-to-derive name myself). A single permalink
redirect would also allow the installation instructions to be simplified on
the MacPorts website, instead of what's currently there:

3. Install MacPorts for your version of the operating system:
* macOS Big Sur v11

* macOS Cataline v10.15

* macOS Mojave v10.14

* Older OS? See here. 

-- 
Jason Liu


On Sat, May 22, 2021 at 1:35 PM Ken Cunningham <
ken.cunningham.web...@gmail.com> wrote:

> > Yes, thanks for the tips! I am pretty sure that it is possible to
> automate it one way or another. But my point is that it would be helpful to
> have a one-liner to install MacPorts and maintain it as a part of the main
> repository.
>
> This was of course suggested years ago as well, when homebrew first did
> it, but at that time was that it was both not needed and not a useful
> addition to MacPorts, if I recall the full email exchange correctly, so we
> let the idea die.
>
> I wrote up a MacPorts install script for Jeremy’s Xquartz project here <
> https://github.com/XQuartz/XQuartz/blob/master/install-or-update-macports.sh>
> that adds a bit more trickery he needed, but the basic guts was extremely
> simple and what I recommend to people who complain that MacPorts is
> extremely difficult to get installed and they claim to have spent hours and
> hours and hours trying to make it work:
>
> ==
>
> cd /tmp
> git clone -b release-2.7 https://github.com/macports/macports-base.git
> cd macports-base
> ./configure && make && sudo make install
>
>
> and then add to the $PATH as usual
>
> ==


Re: Publicizing MacPorts [installation]

2021-05-22 Thread Joshua Root

On 2021-5-23 03:12 , Bjarne D Mathiesen wrote:



Artem Loenko wrote:

Yes, thanks for the tips! I am pretty sure that it is possible to automate it 
one way or another. But my point is that it would be helpful to have a 
one-liner to install MacPorts and maintain it as a part of the main repository.



I'm 90% there there with this :
/usr/bin/env bash -c $( curl -fsSL --url
'https://trac.macports.org/raw-attachment/wiki/howto/AdvancedDailyAdm/macports.bash'
) install

When I'm running this as my normal un-privileged user,
it executes 邏 (and fails because it's un-privileged)

!!! but !!! if I try this as my admin user, nothing happens 樂邏
There's some obscure security setting I presently can't fathom, because
I can run the script locally (without curl) without any issues. And it
does download - it just doesn't execute 樂邏樂


That's probably Gatekeeper and/or the Quarantine attribute doing its 
thing and stopping you from running arbitrary code straight from the 
web. curl | sh or the equivalent should be considered an antipattern (at 
one point there was even a tumblr hall of shame for it.)


I think the best thing we could do to facilitate one-liner command line 
installation is set up a redirect so you can download the latest binary 
installer for your OS version without having to construct its 
not-so-easy-to-derive name yourself. It would then be simple to download 
the .pkg and feed it to installer(8).


- Josh


Re: Publicizing MacPorts [installation]

2021-05-22 Thread Ken Cunningham
> Yes, thanks for the tips! I am pretty sure that it is possible to automate it 
> one way or another. But my point is that it would be helpful to have a 
> one-liner to install MacPorts and maintain it as a part of the main 
> repository. 

This was of course suggested years ago as well, when homebrew first did it, but 
at that time was that it was both not needed and not a useful addition to 
MacPorts, if I recall the full email exchange correctly, so we let the idea die.

I wrote up a MacPorts install script for Jeremy’s Xquartz project here 
 
that adds a bit more trickery he needed, but the basic guts was extremely 
simple and what I recommend to people who complain that MacPorts is extremely 
difficult to get installed and they claim to have spent hours and hours and 
hours trying to make it work:

==

cd /tmp
git clone -b release-2.7 https://github.com/macports/macports-base.git
cd macports-base
./configure && make && sudo make install


and then add to the $PATH as usual

==

Re: Publicizing MacPorts [installation]

2021-05-22 Thread Bjarne D Mathiesen



Artem Loenko wrote:
> Yes, thanks for the tips! I am pretty sure that it is possible to automate it 
> one way or another. But my point is that it would be helpful to have a 
> one-liner to install MacPorts and maintain it as a part of the main 
> repository.
> 

I'm 90% there there with this :
/usr/bin/env bash -c $( curl -fsSL --url
'https://trac.macports.org/raw-attachment/wiki/howto/AdvancedDailyAdm/macports.bash'
) install

When I'm running this as my normal un-privileged user,
it executes 邏 (and fails because it's un-privileged)

!!! but !!! if I try this as my admin user, nothing happens 樂邏
There's some obscure security setting I presently can't fathom, because
I can run the script locally (without curl) without any issues. And it
does download - it just doesn't execute 樂邏樂

but the following is presently a more complete solution, that also
provides the script for further use.

#!/usr/bin/env bash

declare
baseURL='https://trac.macports.org/raw-attachment/wiki/howto/AdvancedDailyAdm'

mkdir -p MacPorts
cd MacPorts
curl -O --url "${baseURL}/portDefaults"
curl -O --url "${baseURL}/macports.bash"
chmod +x *.bash
sudo macports.bash setpaths
sudo macports.bash install
macports.bash --help


-- 
Bjarne D Mathiesen
Korsør ; Danmark ; Europa
---
denne besked er skrevet i et totalt M$-frit miljø
OpenCore + macOS 10.15.7 Catalina
MacPro 2010 ; 2 x 3,46 GHz 6-Core Intel Xeon ; 256 GB 1333 MHz DDR3 ECC
ATI Radeon RX 590 8 GB


Re: Publicizing MacPorts [installation]

2021-05-22 Thread Artem Loenko via macports-dev
Yes, thanks for the tips! I am pretty sure that it is possible to automate it 
one way or another. But my point is that it would be helpful to have a 
one-liner to install MacPorts and maintain it as a part of the main repository.

Regards,
Artem

> On 22 May 2021, at 15:01, Bjarne D Mathiesen  wrote:
> 
> 
> 
> Joshua Root wrote:
>> On 2021-5-22 23:17 , Bjarne D Mathiesen wrote:
>>> 
>>> My own installation script looks something like this :
>>> 
>>> #!/usr/bin/env bash
>>> 
>>> prefix=$(1:-'/opt/local')
>>> version=${2:-'2.7.0'}
>> 
>> I you want to automatically use the latest version, it can be found in
>> .
>> 
>> - Josh
>> 
> 
> so something like this :
> declare version=$( curl --url
> 'https://raw.githubusercontent.com/macports/macports-base/master/config/RELEASE_URL'
> )
> version=${version##*/v}
> 
> 
> -- 
> Bjarne D Mathiesen
> Korsør ; Danmark ; Europa
> ---
> denne besked er skrevet i et totalt M$-frit miljø
> OpenCore + macOS 10.15.7 Catalina
> MacPro 2010 ; 2 x 3,46 GHz 6-Core Intel Xeon ; 256 GB 1333 MHz DDR3 ECC
> ATI Radeon RX 590 8 GB



Re: Publicizing MacPorts [installation]

2021-05-22 Thread Bjarne D Mathiesen



Joshua Root wrote:
> On 2021-5-22 23:17 , Bjarne D Mathiesen wrote:
>>
>> My own installation script looks something like this :
>>
>> #!/usr/bin/env bash
>>
>> prefix=$(1:-'/opt/local')
>> version=${2:-'2.7.0'}
> 
> I you want to automatically use the latest version, it can be found in
> .
> 
> - Josh
> 

so something like this :
declare version=$( curl --url
'https://raw.githubusercontent.com/macports/macports-base/master/config/RELEASE_URL'
)
version=${version##*/v}


-- 
Bjarne D Mathiesen
Korsør ; Danmark ; Europa
---
denne besked er skrevet i et totalt M$-frit miljø
OpenCore + macOS 10.15.7 Catalina
MacPro 2010 ; 2 x 3,46 GHz 6-Core Intel Xeon ; 256 GB 1333 MHz DDR3 ECC
ATI Radeon RX 590 8 GB


Re: Publicizing MacPorts [installation]

2021-05-22 Thread Joshua Root

On 2021-5-22 23:17 , Bjarne D Mathiesen wrote:


My own installation script looks something like this :

#!/usr/bin/env bash

prefix=$(1:-'/opt/local')
version=${2:-'2.7.0'}


I you want to automatically use the latest version, it can be found in 
.


- Josh


Re: Publicizing MacPorts [installation]

2021-05-22 Thread Bjarne D Mathiesen



Artem Loenko via macports-dev wrote:
> INSTALLATION
> 
> The current process is described well[1], but it is almost impossible to
> automate it. For a tool that supposes to be a CLI to manage everything,
> this is a disadvantage for me. Yes, I can install MacPorts from the
> command-line with something like this in my Makefile:
> 
...

My own installation script looks something like this :

#!/usr/bin/env bash

prefix=$(1:-'/opt/local')
version=${2:-'2.7.0'}

if [ ! -e MacPorts-${version}.tar.gz ]
then
curl -L -O --url
"https://github.com/macports/macports-base/releases/download/v${version}/MacPorts-${version}.tar.gz;
fi

rm  -rf  ./MacPorts-${version}
tar -zxf   MacPorts-${version}.tar.gz 2>/dev/null \
|| { echo "error expanding MacPorts-${version}.tar.gz" ; exit }

cd MacPorts-${version}
CC=/usr/bin/cc ./configure \
 --prefix=/opt/local \
 --with-install-user=root \
 --with-install-group=admin \
 --with-directory-mode=0755 \
 --enable-readline \
&& make SELFUPDATING=1 \
&& make install SELFUPDATING=1 \
|| { echo "error compiling MacPorts-${version}" ; exit }

# update MacPorts itself
${prefix}/bin/port -dN selfupdate

# let's get bash, zsh & nano
${prefix}/bin/port -N install bash  && echo "${prefix}/bin/bash" >>
/etc/shells
${prefix}/bin/port -N install zsh   && echo "${prefix}/bin/zsh"  >>
/etc/shells
${prefix}/bin/port -N install nano

# cleanup
cd ..
rm  -rf  ./MacPorts-${version}

(this is actuallly part of a bigger script system I (desperately) try to
maintain at https://trac.macports.org/wiki/howto/AdvancedDailyAdm )

-- 
Bjarne D Mathiesen
Korsør ; Danmark ; Europa
---
denne besked er skrevet i et totalt M$-frit miljø
OpenCore + macOS 10.15.7 Catalina
MacPro 2010 ; 2 x 3,46 GHz 6-Core Intel Xeon ; 256 GB 1333 MHz DDR3 ECC
ATI Radeon RX 590 8 GB