From 6ef4cc854d1df46b719de5d66b45537b0aa11f92 Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Sun, 28 Jul 2019 02:32:20 +0100 Subject: Single wrapper instead of old ./configure, Makefile and ./for-group Until now, to work on a project, it was necessary to `./configure' it and build the software. Then we had to run `.local/bin/make' to run the project and do the analysis every time. If the project was a shared project between many users on a large server, it was necessary to call the `./for-group' script. This way of managing the project had a major problem: since the user directly called the lower-level `./configure' or `.local/bin/make' it was not possible to provide high-level control (for example limiting the environment variables). This was especially noticed recently with a bug that was related to environment variables (bug #56682). With this commit, this problem is solved using a single script called `project' in the top directory. To configure and build the project, users can now run these commands: $ ./project configure $ ./project make To work on the project with other users in a group these commands can be used: $ ./project configure --group=GROUPNAME $ ./project make --group=GROUPNAME The old options to both configure and make the project are still valid. Run `./project --help' to see a list. For example: $ ./project configure -e --host-cc $ ./project make -j8 The old `configure' script has been moved to `reproduce/software/bash/configure.sh' and is called by the new `./project' script. The `./project' script now just manages the options, then passes control to the `configure.sh' script. For the "make" step, it also reads the options, then calls Make. So in the lower-level nothing has changed. Only the `./project' script is now the single/direct user interface of the project. On a parallel note: as part of bug #56682, we also found out that on some macOS systems, the `DYLD_LIBRARY_PATH' environment variable has to be set to blank. This is no problem because RPATH is automatically set in macOS and the executables and libraries contain the absolute address of the libraries they should link with. But having `DYLD_LIBRARY_PATH' can conflict with some low-level system libraries and cause very hard to debug linking errors (like that reported in the bug report). This fixes bug #56682. --- project | 291 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100755 project (limited to 'project') diff --git a/project b/project new file mode 100755 index 0000000..b366e00 --- /dev/null +++ b/project @@ -0,0 +1,291 @@ +#!/bin/bash +# +# High-level script to manage the project. +# Run `./project --help' for a description of how to use it. +# +# Copyright (C) 2019 Mohammad Akhlaghi +# +# This script is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This script 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 General +# Public License for more details. See . + + +# Basic settings +# -------------- +# Stop the script if there are any errors. +set -e + +# Default option values +jobs=0 # 0 is for the default for the `configure.sh' script. +group= +debug= +host_cc=0 +operation= +build_dir= +input_dir= +make_targets= +software_dir= +existing_conf=0 +scriptname="./project" +minmapsize=10000000000 + + + + + +# Parse the options +# ----------------- +# +# Separate command-line arguments from options. Then put the option value +# 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 +# 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. +# +# 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 +# between them, and finally one where the value is immediately after the +# short-format. This exact order is important. Otherwise, there will be a +# conflict between them. + +print_help() { + # Print the output. + cat < /dev/null" &> /dev/null; 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" +fi + + + + + +# Do requested operation +# ---------------------- +perms="u+r,u+w,g+r,g+w,o-r,o-w,o-x" +configscript=./reproduce/software/bash/configure.sh +case $operation in + + # Build the project's software. + configure) + + # Variables to pass to the configuration script. + export jobs=$jobs + export host_cc=$host_cc + export build_dir=$build_dir + export input_dir=$input_dir + export scriptname=$scriptname + export minmapsize=$minmapsize + export software_dir=$software_dir + export existing_conf=$existing_conf + export reproducible_paper_group_name=$group + + # Run the configuration script + if [ x"$group" = x ]; then + $configscript + else + # Set the group and permission flags. + sg "$group" "umask $perms && $configscript" + + # 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 + # 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. + echo "Enabling group writing permission on all installed software..." + .local/bin/chmod -R g+w .local/; + fi + ;; + + # Run the project + make) + + # Make sure the configure script has been completed properly + # (`configuration-done.txt' exists). + if ! [ -f .build/software/configuration-done.txt ]; then + cat <