You are not logged in.

#1 2016-03-11 21:18:03

Dragavnir
Member
From: Brest, France
Registered: 2015-01-07
Posts: 6
Website

read in install script

Hi,

During an install script for a package I'm working on, I need the user to input some data and retrieve it with the read utility. As I need the user to input something else than just <CR>, i put it in a while loop:

while [ -z $COZY_DOMAIN ]; do
    echo "Domain name of your Cozy [cozy.example.tld]: "
    read COZY_DOMAIN
done

It worked fine until recently. Now I have an infinite loop asking a domain name (needless to say I don't have the time to input anything). In the same time, the code shown above works perfectly when running as a normal shell script.
I wondered if it wouldn't come from the read instruction, supposed to pause the script, waiting for user input. Here's what I get when running this code:

echo "Say something: "
read something

as the only instructions in my pre_install function, and here's the output:

Say something: 
error: command failed to execute correctly

I'm not the only one experiencing this issue. I've already witnessed it on Docker containers (running an Archlinux image), on a test VPS, and I've received issues on the package's GitHub repo describing the same thing.

I know that install scripts are run within a special environment, but can anyone explain to me how it can affect the read utility this way?

Offline

#2 2016-03-11 21:30:48

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,868
Website

Re: read in install script

Why on earth would you make an installation scriptlet interactive in the first place?

Print the instructions that the user needs to follow to get the package working if you really must, but don't try to be clever and automagically set up the program for the user. Pacman is a package manager, not a configuration manager.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#3 2016-03-11 21:34:37

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,534
Website

Re: read in install script

I just looked at the full install script.  You also should should not do all that downloading and installing in the post_install script.  That all needs to be moved to the PKGBUILD.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2016-03-11 21:52:35

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,395
Website

Re: read in install script

pacman closes stdin so install scripts can not be interactive.

Offline

#5 2016-03-11 21:59:14

Dragavnir
Member
From: Brest, France
Registered: 2015-01-07
Posts: 6
Website

Re: read in install script

Allan wrote:

pacman closes stdin so install scripts can not be interactive.

Oh, I see.

TBH, it's an install script I've quickly written a few months ago (when I was far less familiar with Arch's philosophy regarding packages) mimicking the install functions of Cozy's Debian package. I'm more and more thinking about reorganizing it all, to be more accurate to Arch's pilosophy, as you guys advised.

Offline

Board footer

Powered by FluxBB