Commit 8d96e513 by Maarten L. Hekkelman

rename update script

parent cdefd063
......@@ -6,7 +6,7 @@ tools/symop-map-generator
test/unit-test
test/pdb2cif-test
test/rename-compound-test
tools/update-dictionary-script
tools/update-libcifpp-data
data/components.cif*
CMakeSettings.json
msvc/
......
......@@ -287,16 +287,17 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_link_options(cifpp PRIVATE -undefined dynamic_lookup)
endif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# download the components.cif file from CCD
set(COMPONENTS_CIF ${PROJECT_SOURCE_DIR}/data/components.cif)
option(DOWNLOAD_CCD "Download the CCD file components.cif during installation" OFF)
if(DOWNLOAD_CCD)
# download the components.cif file from CCD
set(COMPONENTS_CIF ${PROJECT_SOURCE_DIR}/data/components.cif)
if (NOT EXISTS ${COMPONENTS_CIF})
if (NOT EXISTS ${COMPONENTS_CIF})
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/data)
file(MAKE_DIRECTORY ${PROJECT_SOURCE_DIR}/data/)
endif()
# if(${CMAKE_VERSION} VERSION_LESS "3.19.0")
find_program(GUNZIP gunzip)
if(GUNZIP)
......@@ -309,16 +310,10 @@ if (NOT EXISTS ${COMPONENTS_CIF})
file(DOWNLOAD ftp://ftp.wwpdb.org/pub/pdb/data/monomers/components.cif ${COMPONENTS_CIF}
SHOW_PROGRESS)
endif()
# else()
# file(DOWNLOAD ftp://ftp.wwpdb.org/pub/pdb/data/monomers/components.cif.gz ${COMPONENTS_CIF}.gz
# SHOW_PROGRESS)
# file(ARCHIVE_EXTRACT INPUT ${COMPONENTS_CIF}.gz
# DESTINATION ${CMAKE_SOURCE_DIR}/data/
# VERBOSE)
# endif()
endif()
endif()
add_custom_target(COMPONENTS ALL DEPENDS ${COMPONENTS_CIF})
add_custom_target(COMPONENTS ALL DEPENDS ${COMPONENTS_CIF})
endif()
if(UNIX)
option(INSTALL_UPDATE_SCRIPT "Install the script to update CCD and dictionary files" OFF)
......@@ -471,9 +466,9 @@ message("Will install in ${CMAKE_INSTALL_PREFIX}")
if(INSTALL_UPDATE_SCRIPT)
set(CIFPP_CRON_DIR "$ENV{DESTDIR}/etc/cron.weekly")
configure_file(${CMAKE_SOURCE_DIR}/tools/update-dictionary-script.in update-dictionary-script @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/tools/update-libcifpp-data.in update-libcifpp-data @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/update-dictionary-script
FILES ${CMAKE_CURRENT_BINARY_DIR}/update-libcifpp-data
DESTINATION ${CIFPP_CRON_DIR}
PERMISSIONS OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
)
......@@ -482,13 +477,14 @@ if(INSTALL_UPDATE_SCRIPT)
install(DIRECTORY DESTINATION "$ENV{DESTDIR}/etc/libcifpp/cache-update.d")
# a config to, to make it complete
if(NOT EXISTS "$ENV{DESTDIR}/etc/libcifpp.conf")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libcifpp.conf [[# Uncomment the next line to enable automatic updates
# update=true
]])
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcifpp.conf DESTINATION "$ENV{DESTDIR}/etc")
install(CODE "message(\"A configuration file has been written to $ENV{DESTDIR}/etc/libcifpp.conf, please edit this file to enable automatic updates\")")
endif()
target_compile_definitions(cifpp PUBLIC CACHE_DIR="${CIFPP_CACHE_DIR}")
install(CODE "message(\"A configuration file has been written to $ENV{DESTDIR}/etc/libcifpp.conf, please edit this file to enable automatic updates\")")
endif()
......@@ -457,7 +457,7 @@ Compound *CCDCompoundFactoryImpl::create(const std::string &id)
{
ccd = cif::loadResource("components.cif");
if (not ccd)
throw std::runtime_error("Could not locate the CCD components.cif file, please make sure the software is installed properly and/or use the update-dictionary-script to fetch the data.");
throw std::runtime_error("Could not locate the CCD components.cif file, please make sure the software is installed properly and/or use the update-libcifpp-data to fetch the data.");
}
else
ccd.reset(new std::ifstream(mCompoundsFile));
......@@ -484,7 +484,7 @@ Compound *CCDCompoundFactoryImpl::create(const std::string &id)
{
ccd = cif::loadResource("components.cif");
if (not ccd)
throw std::runtime_error("Could not locate the CCD components.cif file, please make sure the software is installed properly and/or use the update-dictionary-script to fetch the data.");
throw std::runtime_error("Could not locate the CCD components.cif file, please make sure the software is installed properly and/or use the update-libcifpp-data to fetch the data.");
}
else
ccd.reset(new std::ifstream(mCompoundsFile));
......
#!/bin/bash
set -e
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
if [ -f /etc/libcifpp.conf ] ; then
. /etc/libcifpp.conf
fi
# check to see if we're supposed to run at all
if [ "$update" != "true" ] ; then
exit
fi
# if cache directory doesn't exist, exit.
if ! [ -d /var/cache/libcifpp ]; then
exit
fi
fetch_dictionary () {
dict=$1
source=$2
wget -O${dict}.gz ${source}
# be careful not to nuke an existing dictionary file
# extract to a temporary file first
gunzip -c ${dict}.gz > ${dict}-tmp
# then move the extracted file to the final location
mv ${dict}-tmp ${dict}
# and clean up afterwards
rm ${dict}.gz
}
# fetch the dictionaries
fetch_dictionary "/var/cache/libcifpp/mmcif_pdbx_v50.dic" "https://mmcif.wwpdb.org/dictionaries/ascii/mmcif_pdbx_v50.dic.gz"
fetch_dictionary "/var/cache/libcifpp/components.cif" "ftp://ftp.wwpdb.org/pub/pdb/data/monomers/components.cif.gz"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment