使用env2,从shell脚本制作module文件

克隆代码

(py38) $ REMOTE_GIT_FILE=git://git.code.sf.net/p/env2/code \
LOCAL_GIT_FILE=$HOME/github/env2.git \
time -p bash -c 'git clone --bare $REMOTE_GIT_FILE $LOCAL_GIT_FILE'

检查git branches和tags,选一个看着顺眼的版本,只有FETCH_HEAD

(py38) $ GIT_DIR=$HOME/github/env2.git \
time -p bash -c '
git --bare --git-dir=$GIT_DIR fetch --all --prune; 
git --bare --git-dir=$GIT_DIR describe --all --long;
git --bare --git-dir=$GIT_DIR branch --list --all; 
git --bare --git-dir=$GIT_DIR tag;'

签出FETCH_HEAD代码

(py38) $ GIT_DIR=$HOME/github/env2.git \
USER_CODE_DIR=$HOME/code \
CODE_GIT_TAG=FETCH_HEAD \
GIT_WORK_TREE=$USER_CODE_DIR/env2-$CODE_GIT_TAG \
time -p bash -c '
git --bare --git-dir=$GIT_DIR --work-tree=$USER_CODE_DIR reset --soft $CODE_GIT_TAG;
git --bare --git-dir=$GIT_DIR --work-tree=$GIT_WORK_TREE clean -fxd;
git --bare --git-dir=$GIT_DIR --work-tree=$USER_CODE_DIR checkout-index --force --all --prefix=$GIT_WORK_TREE/;
git --bare --git-dir=$GIT_DIR --work-tree=$GIT_WORK_TREE describe --all --long;'

添加一个可执行链接

USER_CODE_DIR=$HOME/code \
CODE_GIT_TAG=FETCH_HEAD \
GIT_WORK_TREE=$USER_CODE_DIR/env2-$CODE_GIT_TAG \
time -p bash -c '
ln -s $USER_CODE_DIR/env2-$CODE_GIT_TAG/env2 $HOME/bin/'

制作module files

从shell脚本制作module file

(py38) $ env2 -from sh -to modulecmd "$HOME/application/compiler/setenv_AOCC-2.0.0.sh" -o output && mv env2.modulecmd /tmp/aocc-compiler-2.0.0-tmp
(py38) $ env2 -from sh -to modulecmd "$HOME/application/compiler/setenv_AOCC-2.1.0.sh" -o output && mv env2.modulecmd /tmp/aocc-compiler-2.1.0-tmp
(py38) $ module purge
(py38) $ module load /tmp/aocc-compiler-2.0.0-tmp
(py38) $ env2 -from sh -to modulecmd "$HOME/application/compiler/setenv_AOCC-2.1.0.sh" -o output && mv env2.modulecmd 2.1.0
(py38) $ module purge
(py38) $ module load /tmp/aocc-compiler-2.1.0-tmp
(py38) $ env2 -from sh -to modulecmd "$HOME/application/compiler/setenv_AOCC-2.0.0.sh" -o output && mv env2.modulecmd 2.0.0
(py38) $ mv 2.0.0 2.1.0 $HOME/ascii/modulefiles/aocc

检视制作好的module file,添加注释

(py38) $ cat $HOME/ascii/modulefiles/aocc/2.1.0 
#%Module1.0###################################################################
append-path CPLUS_INCLUDE_PATH {/lustre/application/compiler/aocc-compiler-2.1.0/include};
prepend-path PATH {/lustre/application/compiler/aocc-compiler-2.1.0/bin};
append-path C_INCLUDE_PATH {/lustre/application/compiler/aocc-compiler-2.1.0/include};
prepend-path LD_LIBRARY_PATH {/lustre/application/compiler/aocc-compiler-2.1.0/lib32};
prepend-path LD_LIBRARY_PATH {/lustre/application/compiler/aocc-compiler-2.1.0/lib};
prepend-path LD_LIBRARY_PATH {/usr/lib};
prepend-path LD_LIBRARY_PATH {/usr/lib64};
prepend-path LIBRARY_PATH {/lustre/application/compiler/aocc-compiler-2.1.0/lib32};
prepend-path LIBRARY_PATH {/lustre/application/compiler/aocc-compiler-2.1.0/lib};
prepend-path LIBRARY_PATH {/usr/lib};
prepend-path LIBRARY_PATH {/usr/lib64};
#eof env2.modulecmd

用其它软件制作管理module file

brightcomputing有这样的脚本,可能要收费

(py38) $ rpm -qi env-modules-slave
Name        : env-modules-slave            Relocations: (not relocatable)
Version     : 3.2.10                            Vendor: modules project
Release     : 86_cm7.1                      Build Date: Mon 20 Apr 2015 03:52:16 AM +08
Install Date: Tue 15 Sep 2015 10:19:54 AM +08      Build Host: rhel6-buildhost64-nonvm.brightcomputing.com
Group       : Utilities/Shell               Source RPM: env-modules-3.2.10-86_cm7.1.src.rpm
Size        : 206201                           License: GPL
Signature   : (none)
Packager    : Martijn de Vries 
URL         : http://modules.sourceforge.net
Summary     : Environment Modules initialization scripts
Description :
The Modules package provides for the dynamic modification of a user's
environment via modulefiles.

你可能感兴趣的:(使用env2,从shell脚本制作module文件)