diff options
Diffstat (limited to 'project')
-rwxr-xr-x | project | 87 |
1 files changed, 49 insertions, 38 deletions
@@ -1,9 +1,10 @@ #!/bin/sh # # High-level script to manage the project. -# Run `./project --help' for a description of how to use it. +# Run './project --help' for a description of how to use it. # -# Copyright (C) 2019-2021 Mohammad Akhlaghi <mohammad@akhlaghi.org> +# Copyright (C) 2019-2023 Mohammad Akhlaghi <mohammad@akhlaghi.org> +# Copyright (C) 2021-2023 Raul Infante-Sainz <infantesainz@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,7 +30,7 @@ set -e # Default option values -jobs=0 # 0 is for the default for the `configure.sh' script. +jobs=0 # 0 is for the default for the 'configure.sh' script. group= debug= host_cc=0 @@ -46,7 +47,6 @@ all_highlevel=0 existing_conf=0 highlightnotes=0 scriptname="./project" -minmapsize=10000000000 @@ -59,9 +59,9 @@ minmapsize=10000000000 # into the respective variable. # # Each option has two lines because we want to process both these formats: -# `--name=value' and `--name value'. The former (with `=') is a single +# '--name=value' and '--name value'. The former (with '=') is a single # command-line argument, so we just need to shift the counter by one. The -# latter (without `=') is two arguments, so we'll need two shifts. +# latter (without '=') is two arguments, so we'll need two shifts. # # Note on the case strings: for every option, we need three lines: one when # the option name and value are separate. Another when there is an equal @@ -108,7 +108,6 @@ Configure options: -e, --existing-conf Use (possibly existing) local configuration. --host-cc Use host system's C compiler, don't build GCC. -i, --input-dir=STR Directory containing input datasets (optional). - -m, --minmapsize=INT [Gnuastro] Minimum number of bytes to use RAM. -s, --software-dir=STR Directory containing necessary software tarballs. --check-config During configuration, show what is being built. --clean-texdir Remove possibly existing build-time subdirectories @@ -117,15 +116,17 @@ Configure options: --all-highlevel Build all high-level software (for development). Configure and Make options: + -d, --debug[=FLAGS] In configure: use -j1, no -k, and no Zenodo check. + In make: 'FLAGS' will be directly passed to 'make'. -g, --group=STR Build and run with write permissions for a group. -j, --jobs=INT Number of threads to build/run the software. -?, --help Print this help list. Make (analysis) options: - -d, --debug=FLAGS Print various types of debugging information. -p, --prepare-redo Re-do preparation (only done automatically once). Make (final PDF) options: + --refresh-bib Force refresh the bibliography. --highlight-new Highlight '\new' parts of text as green. --highlight-notes Show '\tonote' regions as red text in PDF. @@ -172,7 +173,6 @@ do make) func_operation_set $1; shift;; shell) func_operation_set $1; shift;; - # Configure options: -b|--build-dir) build_dir="$2"; check_v "$1" "$build_dir"; shift;shift;; -b=*|--build-dir=*) build_dir="${1#*=}"; check_v "$1" "$build_dir"; shift;; @@ -184,9 +184,6 @@ do -i|--input-dir) input_dir="$2"; check_v "$1" "$input_dir"; shift;shift;; -i=*|--input-dir=*) input_dir="${1#*=}"; check_v "$1" "$input_dir"; shift;; -i*) input_dir=$(echo "$1" | sed -e's/-i//'); check_v "$1" "$input_dir"; shift;; - -m|--minmapsize) minmapsize="$2"; check_v "$1" "$minmapsize"; shift;shift;; - -m=*|--minmapsize=*) minmapsize="${1#*=}"; check_v "$1" "$minmapsize"; shift;; - -m*) minmapsize=$(echo "$1" | sed -e's/-m//'); check_v "$1" "$minmapsize"; shift;; -s|--software-dir) software_dir="$2"; check_v "$1" "$software_dir"; shift;shift;; -s=*|--software-dir=*) software_dir="${1#*=}"; check_v "$1" "$software_dir"; shift;; -s*) software_dir=$(echo "$1" | sed -e's/-s//'); check_v "$1" "$software_dir"; shift;; @@ -210,14 +207,22 @@ do # Make options # ------------ # - # Note that Make's `debug' can take values, but when called without any - # value, it is like giving it a value of `a'): + # Note that Make's 'debug' can take values, but when called without any + # value, it is like giving it a value of 'a'): + --refresh-bib) [ -f tex/src/references.tex ] && touch tex/src/references.tex; shift;; --highlight-new) highlightnew=1; shift;; --highlight-new=*) on_off_option_error --highlight-new;; --highlight-notes) highlightnotes=1; shift;; --highlight-notes=*) on_off_option_error --highlight-notes;; - -d|--debug) if [ x"$2" = x ]; then debug=a; shift; - else debug="$2"; check_v debug "$debug"; shift;shift; fi;; + -d|--debug) if [ x$operation = x ]; then + echo "Please set the operation before calling '--debug'"; exit 1 + elif [ x$operation = xconfigure ]; then debug=a; shift; + elif [ x$operation = xmake ]; then + if [ x"$2" = x ]; then echo "In make-mode, '--debug' needs a value"; exit 1 + else debug="$2"; check_v debug "$debug"; shift;shift; fi + else + echo "Operation '$operation' not recognized, please use 'configure' or 'make'" + fi;; -d=*|--debug=*) debug="${1#*=}"; check_v debug "$debug"; shift;; -d*) debug=$(echo "$1" | sed -e's/-d//'); check_v debug "$debug"; shift;; -p|--prepare-redo) prepare_redo=1; shift;; @@ -238,8 +243,8 @@ done # Check configuration status # -------------------------- if ! [ x$check_config = x ]; then - # Find the color option to pass to `ls'. Note that `--color' (for GNU - # Coreutils `ls') should be checked first because it also has `-G', but + # Find the color option to pass to 'ls'. Note that '--color' (for GNU + # Coreutils 'ls') should be checked first because it also has '-G', but # for something else. if ls --color 2> /dev/null > /dev/null; then coloropt="--color=auto" elif ls -G 2> /dev/null > /dev/null; then coloropt="-G" @@ -285,7 +290,7 @@ EOF check=$(ls .local/version-info/python/) if ! [ "x$check" = x ]; then printresults=1 - ln -s .local/version-info/python/* $checkdir/ + ln -s "$(pwd)"/.local/version-info/python/* $checkdir/ fi check=$(ls .local/version-info/proglib/) if ! [ "x$check" = x ]; then @@ -299,7 +304,7 @@ EOF # Then sort all the links based on the most recent dates of the # files they link to (with '-L'). - ls -Llt $checkdir \ + ls -Llt $checkdir \ | awk '/^-/ && c++<5 {printf "[at %s] %s\n", $(NF-1), $NF}' fi else @@ -329,14 +334,14 @@ fi if ! [ x$group = x ]; then # Check if group is usable. - if ! sg "$group" "echo test &> /dev/null" &> /dev/null; then + if ! sg "$group" "echo Group \'$group\' exists"; then echo "$scriptname: '$group' is not a usable group name on this system."; echo "(TIP: you can use the 'groups' command to see your groups)" exit 1 fi # Set the group option for running Make. - gopt="reproducible_paper_group_name=$group" + gopt="maneage_group_name=$group" fi @@ -375,10 +380,11 @@ EOF # Run operations in controlled environment # ---------------------------------------- controlled_env() { + # Get the full address of the build directory: bdir=`.local/bin/realpath .build` - # Remove all existing environment variables (with `env -i') and only + # Remove all existing environment variables (with 'env -i') and only # use some pre-defined environment variables, then build the project. envmake=".local/bin/env -i HOME=$bdir sys_rm=$(which rm) $gopt" envmake="$envmake highlightnew=$highlightnew" @@ -386,7 +392,7 @@ controlled_env() { envmake="$envmake --no-builtin-rules --no-builtin-variables -f $1" if ! [ x"$debug" = x ]; then envmake="$envmake --debug=$debug"; fi - # Set the number of jobs. Note that for the `configure.sh' script the + # Set the number of jobs. Note that for the 'configure.sh' script the # default value has to be 0, so the default is the maximum number of # threads. But here, the default value is 1. if ! [ x"$jobs" = x0 ]; then envmake="$envmake -j$jobs"; fi @@ -418,7 +424,7 @@ case $operation in # # In some scenarios (for example when using a tarball from arXiv), # it may happen that the host server has removed the executable - # flags of all the files. In `README.md' we instruct the readers on + # flags of all the files. In 'README.md' we instruct the readers on # setting the executable flag of this script. But we don't want the # user to have to worry about any other file that needs an # executable flag. @@ -439,15 +445,15 @@ case $operation in # Variables to pass to the configuration script. export jobs=$jobs + export debug=$debug export host_cc=$host_cc export build_dir=$build_dir export input_dir=$input_dir export scriptname=$scriptname - export minmapsize=$minmapsize + export maneage_group_name=$group export software_dir=$software_dir export existing_conf=$existing_conf export all_highlevel=$all_highlevel - export reproducible_paper_group_name=$group # Run the configuration script if [ x"$group" = x ]; then @@ -459,7 +465,7 @@ case $operation in # Set the group writing permission for everything in the # installed software directory. The common build process sets # the writing permissions of the installed programs/libraries - # to `755'. So group members can't write over a file. This + # to '755'. So group members can't write over a file. This # creates problems when another group member wants to update # the software for example. We thus need to manually add the # group writing flag to all installed software files. @@ -476,17 +482,17 @@ case $operation in make) # Make sure the configure script has been completed properly - # (`configuration-done.txt' exists). + # ('configuration-done.txt' exists). if ! [ -f .build/software/configuration-done.txt ]; then configuration_necessary fi # Run data preparation phase (optionally build Makefiles with - # special values for optimizing the main `top-make.mk'). But note + # special values for optimizing the main 'top-make.mk'). But note # that data preparation is only done automatically the first time - # the project is built (when `.build/software/preparation-done.mk' + # the project is built (when '.build/software/preparation-done.mk' # doesn't yet exist). After that, if the user wants to re-do the - # preparation they have to use the `--prepare-redo' option. + # preparation they have to use the '--prepare-redo' option. if ! [ -f .build/software/preparation-done.mk ] \ || [ x"$prepare_redo" = x1 ]; then controlled_env reproduce/analysis/make/top-prepare.mk @@ -500,7 +506,7 @@ case $operation in shell) # Make sure the configure script has been completed properly - # (`configuration-done.txt' exists). + # ('configuration-done.txt' exists). if ! [ -f .build/software/configuration-done.txt ]; then configuration_necessary fi @@ -510,20 +516,25 @@ case $operation in # tools like some text editors. bdir=`.local/bin/realpath .build` instdir="$bdir"/software/installed + bindir="$bdir"/software/installed/bin + rcfile=$(pwd)/reproduce/software/shell/bashrc.sh .local/bin/env -i \ HOME="$bdir" \ TERM="$TERM" \ + PATH="$bindir" \ CCACHE_DISABLE=1 \ - PATH="$instdir"/bin \ + PROJECT_STATUS=shell \ + SHELL="$bindir"/bash \ + COLORTERM="$COLORTERM" \ + PROJECT_RCFILE="$rcfile" \ LDFLAGS=-L"$instdir"/lib \ - SHELL="$instdir"/bin/bash \ CPPFLAGS=-I"$instdir"/include \ LD_LIBRARY_PATH="$instdir"/lib \ OMPI_MCA_plm_rsh_agent=/bin/false \ PYTHONPATH="$instdir"/lib/python/site-packages \ PYTHONPATH3="$instdir"/lib/python/site-packages \ - PS1="[\[\033[32m\](maneage)\[\033[00m\] \u@\h \W]$ " \ - "$instdir"/bin/bash + PS1="[\[\033[01;35m\]maneage@\h \W\[\033[32m\]\[\033[00m\]]$ " \ + "$bindir"/bash --noprofile --rcfile "$rcfile" ;; @@ -538,5 +549,5 @@ Please run with '--help' for more information. EOF exit 1 - ;; + ;; esac |