From 88b3c87baeb9ec64e9e85efa52543827d6570985 Mon Sep 17 00:00:00 2001 From: "Maarten L. Hekkelman" Date: Wed, 29 Nov 2023 14:24:15 +0100 Subject: [PATCH] fixes for automatic update of data --- .github/workflows/cmake-multi-platform.yml | 4 +++- CMakeLists.txt | 17 +++++++++++------ tools/update-libcifpp-data.in | 19 ++++++++++++------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index bc2b4b1..3812cee 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 16c44f8..571106e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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") diff --git a/tools/update-libcifpp-data.in b/tools/update-libcifpp-data.in index 150013d..f6824bc 100755 --- a/tools/update-libcifpp-data.in +++ b/tools/update-libcifpp-data.in @@ -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 @@ -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 @@ -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