aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-16 06:34:28 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-16 06:34:28 +0000
commitdb58a4b92bd704d51c77e49dc3589eb6d8ba167f (patch)
tree1b00370739433dcce4e0b1f40c6e4b39eaf1fa12
parent72e8bfd7964af70efc72ac219000b5a025063d1d (diff)
downloadpaludis-db58a4b92bd704d51c77e49dc3589eb6d8ba167f.tar.gz
paludis-db58a4b92bd704d51c77e49dc3589eb6d8ba167f.tar.xz
New style hook goodness
-rw-r--r--hooks/Makefile.am.m42
-rwxr-xr-xhooks/find_config_updates.bash50
-rwxr-xr-xhooks/find_config_updates.hook58
3 files changed, 59 insertions, 51 deletions
diff --git a/hooks/Makefile.am.m4 b/hooks/Makefile.am.m4
index a149f74..9d70a1f 100644
--- a/hooks/Makefile.am.m4
+++ b/hooks/Makefile.am.m4
@@ -24,7 +24,7 @@ installhookcommonprog_SCRIPTS = \
fix_symlinks.bash
installhookinstallallpost_SCRIPTS = \
- find_config_updates.bash
+ find_config_updates.hook
installhookinstallpost_SCRIPTS = \
update_config_protect_list.bash
diff --git a/hooks/find_config_updates.bash b/hooks/find_config_updates.bash
deleted file mode 100755
index f7af8e0..0000000
--- a/hooks/find_config_updates.bash
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-# vim: set et sw=4 sts=4 :
-
-# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
-#
-# This file is part of the Paludis package manager. Paludis is free software;
-# you can redistribute it and/or modify it under the terms of the GNU General
-# Public License, version 2, as published by the Free Software Foundation.
-#
-# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-# details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-# Place, Suite 330, Boston, MA 02111-1307 USA
-
-shopt -s extglob
-
-export PATH="$(${PALUDIS_EBUILD_DIR}/utils/canonicalise ${PALUDIS_EBUILD_DIR}/utils/ ):${PATH}"
-source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
-
-if [[ -n "${PALUDIS_NO_LIVE_DESTINATION}" ]] ; then
- einfo_unhooked "No need to search for configuration files requiring action"
- exit 0
-fi
-
-echo
-einfo_unhooked "Searching for configuration files requiring action..."
-
-dir_count=0
-for dir in /etc ${CONFIG_PROTECT} ; do
- [[ -d "${ROOT%/}/${dir}" ]] || continue
- c=$(find "${ROOT%/}/${dir}" -iname '._cfg????_*' | wc -l )
- if [[ ${c} -gt 0 ]] ; then
- einfo_unhooked "Found ${c} files in ${ROOT%%+(/)}/${dir}"
- dir_count=$((dir_count + 1))
- fi
-done
-
-if [[ 0 -eq "${dir_count}" ]] ; then
- einfo_unhooked "No configuration file updates required"
- exit 0
-else
- ewarn "Found files in ${dir_count} directories"
- ewarn "Your action is required"
- exit 0
-fi
-
diff --git a/hooks/find_config_updates.hook b/hooks/find_config_updates.hook
new file mode 100755
index 0000000..9a7b618
--- /dev/null
+++ b/hooks/find_config_updates.hook
@@ -0,0 +1,58 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+#
+# This file is part of the Paludis package manager. Paludis is free software;
+# you can redistribute it and/or modify it under the terms of the GNU General
+# Public License, version 2, as published by the Free Software Foundation.
+#
+# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA
+
+check_for_config_updates()
+{
+ shopt -s extglob
+
+ export PATH="$(${PALUDIS_EBUILD_DIR}/utils/canonicalise ${PALUDIS_EBUILD_DIR}/utils/ ):${PATH}"
+ source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
+
+ if [[ -n "${PALUDIS_NO_LIVE_DESTINATION}" ]] ; then
+ einfo_unhooked "No need to search for configuration files requiring action"
+ exit 0
+ fi
+
+ echo
+ einfo_unhooked "Searching for configuration files requiring action..."
+
+ dir_count=0
+ for dir in /etc ${CONFIG_PROTECT} ; do
+ [[ -d "${ROOT%/}/${dir}" ]] || continue
+ c=$(find "${ROOT%/}/${dir}" -iname '._cfg????_*' | wc -l )
+ if [[ ${c} -gt 0 ]] ; then
+ einfo_unhooked "Found ${c} files in ${ROOT%%+(/)}/${dir}"
+ dir_count=$((dir_count + 1))
+ fi
+ done
+
+ if [[ 0 -eq "${dir_count}" ]] ; then
+ einfo_unhooked "No configuration file updates required"
+ exit 0
+ else
+ ewarn "Found files in ${dir_count} directories"
+ ewarn "Your action is required"
+ exit 0
+ fi
+}
+
+for h in install_all_post ; do
+ eval "hook_run_${h}() { check_for_config_updates ; }"
+ eval "hook_after_${h}() { echo log write_cache_clean news ; }"
+done
+