Skip to content
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

Merged
merged 28 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
866dfae
Minor pinned build script README changes
kj4ezj Mar 21, 2023
df36855
Pull note about sudo into its own quote block
kj4ezj Mar 21, 2023
7f27916
Cardinal objects should be in a numbered list
kj4ezj Mar 17, 2023
8fc769e
Restore markdown formatting erroneously deleted in commit 06c9e253277…
kj4ezj Mar 17, 2023
f3aab2c
Merge pull request #849 from AntelopeIO/zach-readme
kj4ezj Mar 21, 2023
f67e598
Roll scripts/install_deps.sh into scripts/pinned_build.sh with a guard
kj4ezj Mar 17, 2023
dd2d53d
Add a warning for OSes that do not have aptitude
kj4ezj Mar 17, 2023
3ed298c
Add a print statement at the beginning and end of package deps instal…
kj4ezj Mar 17, 2023
8c0465a
Use try() for apt-get commands
kj4ezj Mar 17, 2023
fcb5437
Use sudo for apt-get commands if we are not root
kj4ezj Mar 17, 2023
8b25083
Write code to by-pass invocation of apt-get (and sudo) if dependencie…
kj4ezj Mar 20, 2023
1deeab7
Use "dpkg -s" instead of "dpkg -l"
kj4ezj Mar 20, 2023
75c5f3b
SC2086 - note: Double quote to prevent globbing and word splitting
kj4ezj Mar 20, 2023
ddfedd4
SC2207 - warning: Prefer mapfile or read -a to split command output (…
kj4ezj Mar 20, 2023
c7545f2
Remove unnecessary MISSING_DEPS var
kj4ezj Mar 21, 2023
41e34c4
Remove hard-coded timezone
kj4ezj Mar 21, 2023
71fe27c
Remove the "-y" flag from "apt-get install"
kj4ezj Mar 21, 2023
68bf7fe
Remove scripts/install_deps.sh from the README.md
kj4ezj Mar 17, 2023
0fcb2a1
Add a note about the pinned build script asking for a password
kj4ezj Mar 17, 2023
a0a7338
Add a pinned build example where the [Y/n] prompts from aptitude are …
kj4ezj Mar 21, 2023
c21e563
Make it easier to debug by printing significant commands before runni…
kj4ezj Mar 21, 2023
fcdbe4c
Do not hide exit status in try()
kj4ezj Mar 21, 2023
429e6e7
A comment
kj4ezj Mar 21, 2023
624864f
Apparently the software suite including `apt-get` is called APT, not …
kj4ezj Mar 21, 2023
9f523ed
You pass "y", not "-y", lol
kj4ezj Mar 21, 2023
4381229
Guard against sudo being missing
kj4ezj Mar 21, 2023
229de5a
Fix spurious commit
kj4ezj Mar 21, 2023
3f76a2e
Merge branch 'release/4.0' into zach-install-deps
kj4ezj Apr 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,23 @@ When building C/C++ software, often the build is performed in parallel via a com
If you are in an Ubuntu docker container, omit `sudo` from all commands because you run as `root` by default. Most other docker containers also exclude `sudo`, especially Debian-family containers. If your shell prompt is a hash tag (`#`), omit `sudo`.

#### Pinned Build
Make sure you are in the root of the `leap` repo, then run the `install_depts.sh` script to install dependencies:
```bash
sudo scripts/install_deps.sh
```

Next, run the pinned build script. You have to give it three arguments in the following order:
Make sure you are in the root of the `leap` repo, then run the pinned build script. You have to give it three arguments in the following order:
1. A temporary folder, for all dependencies that need to be built from source.
1. A build folder, where the binaries you need to install will be built to.
1. The number of jobs or CPU cores/threads to use (note the [jobs flag](#step-3---build) warning above).

> 🔒 You do not need to run this script with `sudo` or as root.
> 🔒 You do not need to run this script with `sudo` or as root. On Debian-family operating systems such as Ubuntu, the script will determine if all package dependencies are installed and only invoke `apt-get` if you are missing packages. In that case, you may be prompted for your password if `apt-get` needs additional permissions from `sudo`. You should not run this script with `sudo` or as root because you do not need to.

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)"
```
All other script behavior remains unchanged.

Now you can optionally [test](#step-4---test) your build, or [install](#step-5---install) the `*.deb` binary packages, which will be in the root of your build directory.

#### Unpinned Build
Expand Down
27 changes: 0 additions & 27 deletions scripts/install_deps.sh

This file was deleted.

38 changes: 37 additions & 1 deletion scripts/pinned_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,47 @@ popdir() {
}

try(){
echo "$ $*"
"$@"
res=$?
if [[ ${res} -ne 0 ]]; then
exit 255
exit $res
fi
}

install_dependencies() {
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
if dpkg -s sudo &>/dev/null; then # guard against sudo not being installed
SUDO_CMD='sudo'
else
printf '\033[1;31mERROR: This script must be run as root or sudo must be installed!\n\033[0m'
exit 2
fi
else
unset SUDO_CMD
fi
DEPENDENCIES=()
while IFS='' read -r LINE; do
DEPENDENCIES+=("$LINE");
done < <(cat "$SCRIPT_DIR/pinned_deps.txt")
echo 'Checking for missing package dependencies.'
if dpkg -s "${DEPENDENCIES[@]}" &> /dev/null; then
echo 'All package dependencies are already installed.'
else
echo 'Some package dependencies are missing, installing...'
try $SUDO_CMD apt-get update
try $SUDO_CMD apt-get update --fix-missing
export DEBIAN_FRONTEND='noninteractive'
try $SUDO_CMD apt-get install "${DEPENDENCIES[@]}"
fi
else
printf '\033[1;33mWARNING: Skipping package manager dependency installations because this is not a Debian-family operating system!\nWe currently only support Ubuntu.\033[0m\n'
fi
echo 'Done installing package dependencies.'
}

install_clang() {
CLANG_DIR="$1"
if [ ! -d "${CLANG_DIR}" ]; then
Expand Down Expand Up @@ -118,6 +152,8 @@ install_boost() {
export BOOST_DIR="${BOOST_DIR}"
}

install_dependencies

pushdir "${DEP_DIR}"

install_clang "${DEP_DIR}/clang-${CLANG_VER}"
Expand Down
21 changes: 21 additions & 0 deletions scripts/pinned_deps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
build-essential
bzip2
cmake
curl
file
git
libbz2-dev
libcurl4-openssl-dev
libgmp-dev
libncurses5
libssl-dev
libtinfo-dev
libzstd-dev
python3
python3-numpy
time
tzdata
unzip
wget
zip
zlib1g-dev