utils/*: delete common.sh and inline $ELIXIR_THREADS fallback

$ELIXIR_THREADS fallback to nproc is straight forward code, much more
than the incantation to find the path to the Elixir install path.
Remove the incantation and replace by simple code:

    if test -z "$ELIXIR_THREADS"; then
        ELIXIR_THREADS="$(nproc)"
    fi

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
This commit is contained in:
Théo Lebrun 2024-11-08 10:41:15 +01:00
parent 9d90b07201
commit a58e8b55bd
4 changed files with 11 additions and 32 deletions

View file

@ -1,24 +0,0 @@
#!/bin/bash
# This file is part of Elixir, a source code cross-referencer.
#
# Copyright (C) 2019--2023 Michael Opdenacker and contributors
#
# Elixir is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Elixir is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Elixir. If not, see <http://www.gnu.org/licenses/>.
if [ "$ELIXIR_THREADS" = "" ]
then
# Set number of threads to the number of CPU cores
# available to the current process
export ELIXIR_THREADS=`nproc`
fi

View file

@ -21,6 +21,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with Elixir. If not, see <http://www.gnu.org/licenses/>.
if test -z "$ELIXIR_THREADS"; then
ELIXIR_THREADS="$(nproc)"
fi
index() {
project=$1
master=$2
@ -62,9 +66,6 @@ index() {
./update.py $ELIXIR_THREADS
}
export ELIXIR_INSTALL=$(dirname $(dirname $(readlink -f "$0")))
. $ELIXIR_INSTALL/utils/common.sh
if [ "$ELIXIR_ROOT" = "" ]
then
echo "Error: ELIXIR_ROOT environment variable not set"

View file

@ -5,9 +5,6 @@ if [ "$#" -lt 2 ]; then
exit 1
fi
export ELIXIR_INSTALL=$(dirname $(dirname $(readlink -f "$0")))
. $ELIXIR_INSTALL/utils/common.sh
dir=/srv/elixir-data/$1
mkdir -p $dir/data $dir/repo
@ -40,6 +37,10 @@ done
$git fetch --all --tags -j4
if test -z "$ELIXIR_THREADS"; then
ELIXIR_THREADS="$(nproc)"
fi
export LXR_REPO_DIR=$dir/repo
export LXR_DATA_DIR=$dir/data
python3 /usr/local/elixir/update.py $ELIXIR_THREADS

View file

@ -17,8 +17,9 @@
# You should have received a copy of the GNU Affero General Public License
# along with Elixir. If not, see <http://www.gnu.org/licenses/>.
export ELIXIR_INSTALL=$(dirname $(dirname $(readlink -f "$0")))
. $ELIXIR_INSTALL/utils/common.sh
if test -z "$ELIXIR_THREADS"; then
ELIXIR_THREADS="$(nproc)"
fi
if [ -z "$LXR_PROJ_DIR" ]; then
echo "ERROR: LXR_PROJ_DIR environment variable not set"