Score:1

Linux, do I need if, else, or statements to accomplish automation of compiling programs from source

gu flag

I am wondering what would be the best way to write a bash script to install packages from source, would it even be needed to go in depth with how to automate the task?

For example let's say I want to compile apache

cd /path/httpd
./configure -arguments here -augment here -blah blah
make
make install

This process would be completely automated, no human interaction. Would it be fine to simply pass the arguments like shown above or do you think it should be more in depth with else statements and so forth?

Thank you for your time.

Score:2
cn flag

If you know by advance that you have the prerequisite, you can do this.

This is how works PKGBUILDs.

You can use CI-CD in your gitlab/github to test that the compilation is successful.

If you are unsure, then you need to add some conditions:

trap 'echo >&2 "Encountered an error"; exit 1' ERR
cd /path/httpd
./configure -arguments here -augment here -blah blah
make
make install

or

set -e
cd /path/httpd 
./configure -arguments here -augment here -blah blah
make
make install

or using boolean logic:

cd /path/httpd && 
./configure -arguments here -augment here -blah blah &&
make &&
make install

each command need to be successful to run the next one.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.