agent: Add pre-inst-env script

The agent requires Jami's bindings to correctly run scenario.  This
can only be done if Guile can find the correct scripts.  Thus, the
pre-inst-env script can be used to setup the correct environment for
running the agent before its installation.

Change-Id: I474ef204bb33fd2098eee44b5b99c00f120c4536
This commit is contained in:
Olivier Dion
2022-05-20 14:02:19 -04:00
committed by Sébastien Blin
parent 75d76949d7
commit 15460298ab
4 changed files with 51 additions and 4 deletions

View File

@ -1,4 +1,5 @@
agent
pre-inst-env
*.yml
*.txt
*.log

View File

@ -0,0 +1,46 @@
#!/bin/sh
# Copyright © 2012, 2013, 2014, 2015, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2017 Eric Bavier <bavier@cray.com>
#
# Modified and adapted for Jami's agent.
# Copyright © 2022 Savoir-faire Liux Inc.
#
# 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
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Usage: ./pre-inst-env COMMAND ARG...
#
# Run COMMAND in a pre-installation environment. Typical use is
# "./pre-inst-env agent"
# By default we may end up with absolute directory names that contain '..',
# which get into $GUILE_LOAD_PATH, leading to '..' in the module file names
# recorded by Guile. To avoid that, make sure we get a real absolute directory
# name. Additionally, use '-P' to get the canonical directory name so that
# Guile's 'relative' %file-port-name-canonicalization can actually work (see
# <http://bugs.gnu.org/17935>.)
abs_top_srcdir="`cd "@abs_top_srcdir@" > /dev/null; pwd -P`"
abs_top_builddir="`cd "@abs_top_builddir@" > /dev/null; pwd -P`"
GUILE_LOAD_COMPILED_PATH="$abs_top_builddir/test/agent${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
GUILE_LOAD_PATH="$abs_top_builddir:$abs_top_srcdir/test/agent${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH"
GUILE_AUTO_COMPILE="0"
export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH GUILE_AUTO_COMPILE
# Define $PATH so that `guile' and friends are easily found.
PATH="$abs_top_srcdir/test/agent:$abs_top_srcdir/contrib/x86_64-unknown-linux-gnu/bin:$PATH"
export PATH
exec "$@"

View File

@ -81,9 +81,6 @@ main(int argc, char* argv[])
{
struct args args = { argc, argv };
setenv("GUILE_LOAD_PATH", ".", 1);
setenv("GUILE_LOAD_COMPILED_PATH", ".", 1);
if (argc > 1 && streq(argv[1], "compile")) {
scm_with_guile(compile_in_guile, (void*)&args);
} else {