-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify Pinned Build Scripts #857
Conversation
Fix README.md Formatting
for Debian-family OSes
…s are already installed
…or quote to avoid splitting) Note: This implementation is backwards-compatible with BASH 3.x for macOS
tzdata defaults to UTC anyways, lol
To suppress the prompts from aptitude, run: echo 'y' | ./scripts/pinned_build.sh /leap/deps /leap/build "$(nproc)"
This pull request contains part of the changes I tried to introduce in pull request 832. I believe I have addressed everyone's concerns from that pull request. I will lay out the concerns I read there and explain how I have addressed each and every one individually to try to head-off contention and to speed up peer review. See More
|
README.md
Outdated
|
||
For example, the following command runs the `pinned_build.sh` script, specifies a `deps` and `build` folder in the root of the Leap repo for the first two arguments, then builds the packages using all of your computer's CPU threads: | ||
```bash | ||
scripts/pinned_build.sh deps build "$(nproc)" | ||
``` | ||
If you want to by-pass the `[Y/n]` prompt from aptidue, you can pass `-y` to the script like this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to by-pass the `[Y/n]` prompt from aptidue, you can pass `-y` to the script like this. | |
If you want to by-pass the `[Y/n]` prompt from apt-get, you can pass `-y` to the script like this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aptitude != apt-get
Otherwise, lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
README.md
Outdated
|
||
For example, the following command runs the `pinned_build.sh` script, specifies a `deps` and `build` folder in the root of the Leap repo for the first two arguments, then builds the packages using all of your computer's CPU threads: | ||
```bash | ||
scripts/pinned_build.sh deps build "$(nproc)" | ||
``` | ||
If you want to by-pass the `[Y/n]` prompt from `apt-get install`, you can pass `-y` to the script like this. | ||
```bash | ||
echo '-y' | scripts/pinned_build.sh deps build "$(nproc)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how that works. sudo
doesn't consume from stdin? I don't think -y
is correct here anyways, from this test
echo -y | apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
base-files libgmp10 libgnutls30 libpam-modules libpam-modules-bin libpam-runtime libpam0g libpcre2-8-0
libsystemd0 libudev1 login passwd perl-base tar zlib1g
15 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 4893 kB of archives.
After this operation, 14.3 kB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
It seems like you may want to allow the user to pass -y
as a script argument, and then forward that through to apt-get
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, -y
was not correct! I have amended it to just y
. I tested this on Ubuntu 22.04 without sudo
.
As for sudo
passing STDIN
to apt-get
, it worked for me.
From ChatGPT:
When you run
echo 'y' | sudo cmd
, theecho
command sends the charactery
to its standard output (stdout), which is then piped to the standard input (stdin) of thesudo
command. Thesudo
command then runscmd
with its stdin connected to the pipe.For example, if
cmd
is theapt-get
command, and you runecho 'y' | sudo apt-get install package
, theapt-get
command will read they
character from its stdin and assume "yes" as the answer to any prompts.
I had considered (and would prefer) the pattern of passing -y
as an argument to the BASH script, but it doesn't seem user-friendly to require the -y
argument to be, say, argument 4 and only argument 4 because most tools do not work that way. I could've written code to parse the arguments no matter where the -y
flag is in the argv
, but other peer reviewers were already complaining about code complexity so I went with the simplest implementation.
scripts/pinned_build.sh
Outdated
echo 'Installing package dependencies.' | ||
if [[ "$(uname)" == 'Linux' && -f /etc/debian_version ]]; then | ||
if [[ "$(id -u)" != '0' ]]; then # if not root, use sudo for the package manager | ||
SUDO_CMD='sudo' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik sudo is not guaranteed to be installed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik sudo is not guaranteed to be installed
Truth. And not everyone likes sudo
, either. It might be appropriate to test for sudo
and report an error if it's missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I'd prefer to avoid adding additional complexity to build scripts (and, really, the existence of build scripts at all); I'm deferring to others on this particular one. |
Resolve README.md conflict that GitHub thinks is a conflict but really wasn't...
From issue 735, this pull request simplifies the process of performing a pinned build by merging
scripts/install_deps.sh
intoscripts/pinned_build.sh
.This is simpler for our customers because now they only have to run a single command that calls a single BASH script to perform the entire pinned build process. This is simpler for our team to maintain because all of the code is in one place, we no longer need to maintain multiple scripts, and it is unambiguous how the pieces fit together.
The aptitude code only runs on Debian-family operating systems, it only runs if package dependencies are missing, it only invokes
sudo
if it is not running asroot
already, and it prints bold yellow warnings to the terminal for unsupported non-Debian-family users so they know this step is being skipped, in addition to the print statements already at the top of the script. This is all documented in theREADME.md
.This code has been checked with multiple BASH linters.
I believe I have addressed all of the concerns my fellow engineers and community members brought up during my previous attempt.
See Also
Pull Request 832 - Rollinstall_deps.sh
intopinned_build.sh
libcurl4-openssl-dev
README.md
Formatting