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

[4.0] Revert "Simplify Pinned Build Scripts" #1193

Merged
merged 1 commit into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,22 @@ 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 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 `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:
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. 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.
> 🔒 You do not need to run this script with `sudo` or as root.

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: 27 additions & 0 deletions scripts/install_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
apt-get update
apt-get update --fix-missing
export DEBIAN_FRONTEND='noninteractive'
export TZ='Etc/UTC'
apt-get install -y \
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
38 changes: 1 addition & 37 deletions scripts/pinned_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,47 +57,13 @@ popdir() {
}

try(){
echo "$ $*"
"$@"
res=$?
if [[ ${res} -ne 0 ]]; then
exit $res
exit 255
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 @@ -152,8 +118,6 @@ install_boost() {
export BOOST_DIR="${BOOST_DIR}"
}

install_dependencies

pushdir "${DEP_DIR}"

install_clang "${DEP_DIR}/clang-${CLANG_VER}"
Expand Down
21 changes: 0 additions & 21 deletions scripts/pinned_deps.txt

This file was deleted.