add feature to transparently fetch external potential files when a package is installed
This commit is contained in:
40
src/Fetch.sh
Executable file
40
src/Fetch.sh
Executable file
@ -0,0 +1,40 @@
|
||||
# transparently fetch external files for a given package
|
||||
|
||||
fetch_potentials() {
|
||||
pdir="$1"
|
||||
shift
|
||||
|
||||
type curl > /dev/null 2>&1 && have_curl=1 || have_curl=0
|
||||
type wget > /dev/null 2>&1 && have_wget=1 || have_wget=0
|
||||
if [ $have_curl -ne 1 ] && [ $have_wget -ne 1 ]
|
||||
then \
|
||||
echo "Need 'curl' or 'wget' to fetch external potential files"
|
||||
return
|
||||
fi
|
||||
|
||||
while [ $# -gt 1 ]
|
||||
do \
|
||||
file=$1; sum=$2
|
||||
shift; shift
|
||||
|
||||
echo ${sum} ${pdir}/${file} | md5sum -c - > /dev/null 2>&1 \
|
||||
&& need_fetch=0 || need_fetch=1
|
||||
if [ ${need_fetch} -eq 1 ]
|
||||
then \
|
||||
url="https://download.lammps.org/potentials/${file}.${sum}"
|
||||
echo "Fetching external potential file ${file} from ${url}"
|
||||
if [ ${have_curl} ]
|
||||
then \
|
||||
curl -L -o ${pdir}/${file} ${url}
|
||||
elif [ ${have_wget} ]
|
||||
then \
|
||||
wget -O ${pdir}/${file} ${url}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ -f "$1/potentials.txt" ]
|
||||
then
|
||||
fetch_potentials "$1/../../potentials" `sed -e 's/#.*$//' "$1/potentials.txt"`
|
||||
fi
|
||||
@ -280,7 +280,7 @@ install-python:
|
||||
tar:
|
||||
@cd STUBS; $(MAKE) clean
|
||||
@cd ..; tar cvzf src/$(ROOT)_src.tar.gz \
|
||||
src/Make* src/Package.sh src/Depend.sh src/Install.sh \
|
||||
src/Make* src/Package.sh src/Depend.sh src/Install.sh src/Fetch.sh \
|
||||
src/MAKE src/DEPEND src/*.cpp src/*.h src/STUBS \
|
||||
$(patsubst %,src/%,$(PACKAGEUC)) $(patsubst %,src/%,$(PACKUSERUC)) \
|
||||
--exclude=*/.svn
|
||||
@ -369,6 +369,7 @@ yes-%:
|
||||
cd $(YESDIR); $(SHELL) ../Install.sh 1; cd ..; \
|
||||
$(SHELL) Depend.sh $(YESDIR) 1; \
|
||||
fi;
|
||||
@$(SHELL) Fetch.sh $(YESDIR)
|
||||
|
||||
no-%:
|
||||
@if [ ! -e $(NODIR) ]; then \
|
||||
|
||||
3
src/USER-MISC/potentials.txt
Normal file
3
src/USER-MISC/potentials.txt
Normal file
@ -0,0 +1,3 @@
|
||||
# list of potential files to be fetched when this package is installed
|
||||
# potential file md5sum
|
||||
C_10_10.mesocnt 028de73ec828b7830d762702eda571c1
|
||||
Reference in New Issue
Block a user