summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorlukelabrie2023-10-10 18:13:27 +0200
committerlukelabrie2023-10-10 18:13:27 +0200
commiteafc2ecd6e374920e9ad9bbbbe3330bc81ec8f1c (patch)
treef42b1e451feca39a98ac7bc43483bb0a027a7ede
parent99a02b0052a8204acd5712048ce01e6df37f86e7 (diff)
downloadaur-eafc2ecd6e374920e9ad9bbbbe3330bc81ec8f1c.tar.gz
refactor of path handling
-rwxr-xr-xPKGBUILD10
-rw-r--r--set_paths.sh33
-rw-r--r--test_install.sh8
3 files changed, 42 insertions, 9 deletions
diff --git a/PKGBUILD b/PKGBUILD
index ac12480f96d5..a705ef70f072 100755
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -55,7 +55,7 @@ build() {
-DDAGMC_ROOT=/opt/DAGMC \
-DOPENMC_USE_MPI=ON \
-DHDF5_PREFER_PARALLEL=ON \
- -DCMAKE_INSTALL_PREFIX=/opt/openmc
+ -DCMAKE_INSTALL_PREFIX=/opt/openmc
_ccores=`cat /proc/cpuinfo |grep CPU|wc -l`
if [ "x$1" != "x" ]; then
_ccores=$1
@@ -67,5 +67,11 @@ package() {
cd $srcdir/${pkgname}/build
make DESTDIR="$pkgdir/" install
pip install --break-system-packages ../
- mv $srcdir/${pkgname} $pkgdir/opt/openmc
+ cp -r $srcdir/${pkgname} $pkgdir/opt/openmc
+
+ # installed to opt, inform user how to set paths
+ _path_msg="$'\n'INFO: OpenMC and its dependencies were installed to the
+ non-standard location /opt. Run bash
+ ~/.cache/yay/openmc-git/set_paths.sh before attempting to
+ use openmc$'\n'"
}
diff --git a/set_paths.sh b/set_paths.sh
new file mode 100644
index 000000000000..da0799ae29bd
--- /dev/null
+++ b/set_paths.sh
@@ -0,0 +1,33 @@
+# get variables
+arch=$(uname -m)
+python_version=$(python -V 2>&1 | cut -d' ' -f2 | cut -d'.' -f1-2)
+var=`echo /opt/nuclear-data/*hdf5 | head -n1`
+
+# Define the paths
+export_path="export PATH=\$PATH:/opt/openmc/bin"
+export_pythonpath="export PYTHONPATH=\$PYTHONPATH:/opt/MOAB/lib/python$python_version/site-packages"
+export_ld_library_path="export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/MOAB/lib"
+export_openmc_cross_sections="export OPENMC_CROSS_SECTIONS=$var/cross_sections.xml"
+
+# set non-standard paths in current session
+eval $export_path
+eval $export_pythonpath
+eval $export_ld_library_path
+eval $export_openmc_cross_sections
+
+# Check and add to bashrc if not exists
+if ! grep -qF "$export_path" ~/.bashrc; then
+ echo "$export_path" >> ~/.bashrc
+fi
+
+if ! grep -qF "$export_pythonpath" ~/.bashrc; then
+ echo "$export_pythonpath" >> ~/.bashrc
+fi
+
+if ! grep -qF "$export_ld_library_path" ~/.bashrc; then
+ echo "$export_ld_library_path" >> ~/.bashrc
+fi
+
+if ! grep -qF "$export_openmc_cross_sections" ~/.bashrc; then
+ echo "$export_openmc_cross_sections" >> ~/.bashrc
+fi \ No newline at end of file
diff --git a/test_install.sh b/test_install.sh
index cb6424a125f6..d7ed296b9e6c 100644
--- a/test_install.sh
+++ b/test_install.sh
@@ -1,11 +1,5 @@
# set non-standard paths
-arch=$(uname -m)
-python_version=$(python -V 2>&1 | cut -d' ' -f2 | cut -d'.' -f1-2)
-export PATH=$PATH:/opt/openmc/bin:$HOME/.local/lib/python$python_version/site-packages
-export PYTHONPATH=$PYTHONPATH:/opt/MOAB/lib/python$python_version/site-packages
-export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/MOAB/lib
-var=`echo /opt/nuclear-data/*hdf5 | head -n1`
-export OPENMC_CROSS_SECTIONS=$var/cross_sections.xml
+bash set_paths.sh
# test geometry build
python ~/.cache/yay/openmc-git/step_to_h5m.py