mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-11-23 11:15:34 +08:00
optimize deps installation
- add `-packages_skip` - able run without root
This commit is contained in:
parent
846fd6815e
commit
5708cbdc72
@ -106,7 +106,8 @@ This will:
|
||||
Additional arguments you can pass to this script:
|
||||
* `-j <n>`: build with `<n>` parallel jobs, by default 70% of the available threads
|
||||
* `-verbose`: output compiler/linker commands used by `CMAKE`
|
||||
* `-packages_only`: install the required Linux packages via `apt isntall` and exit (don't rebuild)
|
||||
* `-packages_skip`: skip package installation via `apt install` and continue build
|
||||
* `-packages_only`: install the required Linux packages via `apt install` and exit (don't rebuild)
|
||||
|
||||
---
|
||||
|
||||
|
@ -12,12 +12,6 @@
|
||||
# https://linux.die.net/man/1/nm
|
||||
#nm -D --defined-only libsteam.so | grep " T "
|
||||
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Please run as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# common stuff
|
||||
script_dir=$( cd -- "$( dirname -- "${0}" )" &> /dev/null && pwd )
|
||||
deps_dir="$script_dir/build/deps/linux"
|
||||
@ -38,6 +32,7 @@ deps_archives=(
|
||||
# < 0: deduce, > 1: force
|
||||
PARALLEL_THREADS_OVERRIDE=-1
|
||||
VERBOSITY=''
|
||||
INSTALL_PACKAGES=1
|
||||
INSTALL_PACKAGES_ONLY=0
|
||||
|
||||
for (( i=1; i<=$#; i++ )); do
|
||||
@ -52,6 +47,8 @@ for (( i=1; i<=$#; i++ )); do
|
||||
#echo "[?] Overriding parralel build jobs count with $PARALLEL_THREADS_OVERRIDE"
|
||||
elif [[ "$var" = "-verbose" ]]; then
|
||||
VERBOSITY='-v'
|
||||
elif [[ "$var" = "-packages_skip" ]]; then
|
||||
INSTALL_PACKAGES=0
|
||||
elif [[ "$var" = "-packages_only" ]]; then
|
||||
INSTALL_PACKAGES_ONLY=1
|
||||
else
|
||||
@ -66,17 +63,10 @@ last_code=0
|
||||
|
||||
############## required packages ##############
|
||||
echo // installing required packages
|
||||
apt update -y
|
||||
last_code=$((last_code + $?))
|
||||
|
||||
apt install "coreutils" -y # echo, printf, etc...
|
||||
last_code=$((last_code + $?))
|
||||
apt install "tar" -y # we need to extract packages
|
||||
last_code=$((last_code + $?))
|
||||
apt install "binutils" -y # (optional) contains the tool 'readelf' mainly, and other usefull binary stuff
|
||||
#apt install cmake git wget unzip -y
|
||||
|
||||
all_packages=(
|
||||
"coreutils" # echo, printf, etc...
|
||||
"tar" # we need to extract packages
|
||||
"build-essential"
|
||||
"gcc-multilib" # needed for 32-bit builds
|
||||
"g++-multilib"
|
||||
@ -86,13 +76,33 @@ all_packages=(
|
||||
"binutils" # (optional) contains the tool 'readelf' mainly, and other usefull binary stuff
|
||||
)
|
||||
|
||||
if [[ "$INSTALL_PACKAGES" -ne 0 ]]; then
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
# if sudo exist, use sudo.
|
||||
if type sudo > /dev/null 2>&1; then
|
||||
apt_run() { sudo apt "$@" -y || exit $? ; }
|
||||
else
|
||||
echo "Please run as root, install sudo or pass '-packages_skip' argument." >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
apt_run() { apt "$@" -y || exit $? ; }
|
||||
fi
|
||||
|
||||
apt_run update
|
||||
last_code=$((last_code + $?))
|
||||
|
||||
for dep in "${all_packages[@]}"; do
|
||||
apt install "$dep" -y
|
||||
apt_run install "$dep"
|
||||
last_code=$((last_code + $?))
|
||||
done
|
||||
|
||||
# exit early if we should install packages only, used by CI mainly
|
||||
[[ "$INSTALL_PACKAGES_ONLY" -ne 0 ]] && exit $last_code
|
||||
else
|
||||
echo "Package installation skipped, please be sure the follow packages correspond to your distro is installed."
|
||||
echo "${all_packages[*]}"
|
||||
fi
|
||||
|
||||
echo; echo;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user