Skip to content

Commit

Permalink
fixes for automatic update of data
Browse files Browse the repository at this point in the history
  • Loading branch information
mhekkel committed Nov 29, 2023
1 parent 7fd7dfd commit 88b3c87
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ jobs:
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config Release

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --build-config Release --output-on-failure

- name: Install
run: cmake --install ${{ steps.strings.outputs.build-output-dir }} --config Release
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,17 @@ if(NOT(BUILD_FOR_CCP4 AND WIN32))
option(BUILD_SHARED_LIBS "Build a shared library instead of a static one" OFF)
endif()

# Lots of code depend on the availability of the components.cif file
option(CIFPP_DOWNLOAD_CCD "Download the CCD file components.cif during installation" ON)
if(BUILD_FOR_CCP4)
unset(CIFPP_DOWNLOAD_CCD)
unset(CIFPP_INSTALL_UPDATE_SCRIPT)
else()
# Lots of code depend on the availability of the components.cif file
option(CIFPP_DOWNLOAD_CCD "Download the CCD file components.cif during installation" ON)

# An optional cron script can be installed to keep the data files up-to-date
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND NOT BUILD_FOR_CCP4)
option(CIFPP_INSTALL_UPDATE_SCRIPT "Install the script to update CCD and dictionary files" ON)
# An optional cron script can be installed to keep the data files up-to-date
if(UNIX)
option(CIFPP_INSTALL_UPDATE_SCRIPT "Install the script to update CCD and dictionary files" ON)
endif()
endif()

# When CCP4 is sourced in the environment, we can recreate the symmetry operations table
Expand Down Expand Up @@ -564,7 +569,7 @@ if(CIFPP_INSTALL_UPDATE_SCRIPT)
else()
set(CIFPP_CRON_DIR "${CIFPP_ETC_DIR}/cron.weekly" CACHE PATH "The cron directory, for the update script")
endif()
elseif(UNIX) # assume all others are like FreeBSD...
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(CIFPP_CRON_DIR "${CIFPP_ETC_DIR}/periodic/weekly" CACHE PATH "The cron directory, for the update script")
else()
message(FATAL_ERROR "Don't know where to install the update script")
Expand Down
19 changes: 12 additions & 7 deletions tools/update-libcifpp-data.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ euid=${EUID:-$(id -u)}

if [ "${euid}" -ne 0 ]; then
echo "Please run as root"
exit
exit 1
fi

if [ -f "@CIFPP_ETC_DIR@/libcifpp.conf" ]; then
Expand All @@ -19,12 +19,13 @@ fi

# check to see if we're supposed to run at all
if [ "$update" != "true" ]; then
exit
exit 0
fi

# if cache directory doesn't exist, exit.
if ! [ -d "@CIFPP_CACHE_DIR@" ]; then
exit
echo "Cache directory '@CIFPP_CACHE_DIR@' does not exist"
exit 1
fi

# Create a temp file in the right directory and
Expand Down Expand Up @@ -60,12 +61,16 @@ update_dictionary() {

# Update the dictionaries

update_dictionary "@CIFPP_CACHE_DIR@/components.cif" "https://ftp.wwpdb.org/pub/pdb/data/monomers/components.cif.gz"
update_dictionary "@CIFPP_CACHE_DIR@/components.cif" "https://files.wwpdb.org/pub/pdb/data/monomers/components.cif.gz"
update_dictionary "@CIFPP_CACHE_DIR@/mmcif_pdbx.dic" "https://mmcif.wwpdb.org/dictionaries/ascii/mmcif_pdbx_v50.dic.gz"
update_dictionary "@CIFPP_CACHE_DIR@/mmcif_ma.dic" "https://github.com/ihmwg/ModelCIF/raw/master/dist/mmcif_ma.dic"

# notify subscribers, will fail on FreeBSD
# notify subscribers, using find instead of run-parts to make it work on FreeBSD as well

if [ -d "@CIFPP_ETC_DIR@/libcifpp/cache-update.d" ] && [ -x /bin/run-parts ]; then
run-parts --arg "@CIFPP_CACHE_DIR@" -- "@CIFPP_ETC_DIR@/libcifpp/cache-update.d"
if [ -d "@CIFPP_ETC_DIR@/libcifpp/cache-update.d" ]; then
find "@CIFPP_ETC_DIR@/libcifpp/cache-update.d" \
-exec test -x {} \; -and -not -exec test -d {} \; \
-exec {} "@CIFPP_CACHE_DIR@" \;
fi

exit 0

0 comments on commit 88b3c87

Please sign in to comment.