aboutsummaryrefslogtreecommitdiff
path: root/0.8.0/hooks
diff options
context:
space:
mode:
Diffstat (limited to '0.8.0/hooks')
-rw-r--r--0.8.0/hooks/Makefile.am.m4202
-rwxr-xr-x0.8.0/hooks/eselect_env_update.bash27
-rwxr-xr-x0.8.0/hooks/find_config_updates.bash46
-rwxr-xr-x0.8.0/hooks/gnu_info_index.bash84
-rwxr-xr-x0.8.0/hooks/log.bash86
-rwxr-xr-x0.8.0/hooks/news.bash51
-rwxr-xr-x0.8.0/hooks/update_config_protect_list.bash60
7 files changed, 556 insertions, 0 deletions
diff --git a/0.8.0/hooks/Makefile.am.m4 b/0.8.0/hooks/Makefile.am.m4
new file mode 100644
index 0000000..4764f67
--- /dev/null
+++ b/0.8.0/hooks/Makefile.am.m4
@@ -0,0 +1,202 @@
+ifdef(`__gnu__',`',`errprint(`This is not GNU m4...
+')m4exit(1)') include(`misc/generated-file.txt')
+
+dnl vim: set ft=m4 noet :
+
+MAINTAINERCLEANFILES = Makefile.in Makefile.am
+CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda .keep
+SUBDIRS = .
+
+installvarlibpaludisnewsdir = $(localstatedir)/paludis/news
+
+installhookcommonprogdir = $(libexecdir)/paludis/hooks/common
+installhookinstallallpostdir = $(libexecdir)/paludis/hooks/install_all_post
+installhookinstallpostdir = $(libexecdir)/paludis/hooks/install_post
+
+installhookcommonprog_SCRIPTS = \
+ gnu_info_index.bash \
+ eselect_env_update.bash \
+ log.bash \
+ news.bash
+
+installhookinstallallpost_SCRIPTS = \
+ find_config_updates.bash
+
+installhookinstallpost_SCRIPTS = \
+ update_config_protect_list.bash
+
+installvarlibpaludisnews_DATA = \
+ .keep
+
+TESTS_ENVIRONMENT = env \
+ PALUDIS_EBUILD_DIR="$(srcdir)/ebuild/" \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ bash $(top_srcdir)/ebuild/run_test.bash
+
+TESTS =
+EXTRA_DIST = \
+ Makefile.am.m4 \
+ $(installhookcommonprog_SCRIPTS) \
+ $(installhookinstallallpost_SCRIPTS) \
+ $(installhookinstallpost_SCRIPTS) \
+ $(TESTS)
+
+check_SCRIPTS = $(TESTS)
+check_PROGRAMS =
+
+.keep :
+ touch $@
+
+define(`userhook', `
+installuserhooks$1dir = $(datadir)/paludis/hooks/$1
+installuserhooks$1_DATA = .keep')
+
+userhook(`install_pre')
+userhook(`install_fail')
+userhook(`install_post')
+userhook(`install_all_pre')
+userhook(`install_all_post')
+userhook(`install_pretend_pre')
+userhook(`install_pretend_post')
+userhook(`uninstall_pre')
+userhook(`uninstall_fail')
+userhook(`uninstall_post')
+userhook(`uninstall_all_pre')
+userhook(`uninstall_all_post')
+userhook(`sync_pre')
+userhook(`sync_fail')
+userhook(`sync_post')
+userhook(`sync_all_pre')
+userhook(`sync_all_post')
+userhook(`fetch_all_pre')
+userhook(`fetch_all_post')
+userhook(`fetch_all_all_pre')
+userhook(`fetch_all_all_post')
+userhook(`ebuild_metadata_pre')
+userhook(`ebuild_metadata_fail')
+userhook(`ebuild_metadata_post')
+userhook(`ebuild_init_pre')
+userhook(`ebuild_init_fail')
+userhook(`ebuild_init_post')
+userhook(`ebuild_fetch_pre')
+userhook(`ebuild_fetch_fail')
+userhook(`ebuild_fetch_post')
+userhook(`ebuild_merge_pre')
+userhook(`ebuild_merge_fail')
+userhook(`ebuild_merge_post')
+userhook(`ebuild_unmerge_pre')
+userhook(`ebuild_unmerge_fail')
+userhook(`ebuild_unmerge_post')
+userhook(`ebuild_tidyup_pre')
+userhook(`ebuild_tidyup_fail')
+userhook(`ebuild_tidyup_post')
+userhook(`ebuild_strip_pre')
+userhook(`ebuild_strip_fail')
+userhook(`ebuild_strip_post')
+userhook(`ebuild_unpack_pre')
+userhook(`ebuild_unpack_fail')
+userhook(`ebuild_unpack_post')
+userhook(`ebuild_compile_pre')
+userhook(`ebuild_compile_fail')
+userhook(`ebuild_compile_post')
+userhook(`ebuild_install_pre')
+userhook(`ebuild_install_fail')
+userhook(`ebuild_install_post')
+userhook(`ebuild_test_pre')
+userhook(`ebuild_test_fail')
+userhook(`ebuild_test_post')
+userhook(`ebuild_setup_pre')
+userhook(`ebuild_setup_fail')
+userhook(`ebuild_setup_post')
+userhook(`ebuild_config_pre')
+userhook(`ebuild_config_fail')
+userhook(`ebuild_config_post')
+userhook(`ebuild_nofetch_pre')
+userhook(`ebuild_nofetch_fail')
+userhook(`ebuild_nofetch_post')
+userhook(`ebuild_preinst_pre')
+userhook(`ebuild_preinst_fail')
+userhook(`ebuild_preinst_post')
+userhook(`ebuild_postinst_pre')
+userhook(`ebuild_postinst_fail')
+userhook(`ebuild_postinst_post')
+userhook(`ebuild_prerm_pre')
+userhook(`ebuild_prerm_fail')
+userhook(`ebuild_prerm_post')
+userhook(`ebuild_postrm_pre')
+userhook(`ebuild_postrm_fail')
+userhook(`ebuild_postrm_post')
+
+define(`systemhook', `
+installsystemhooks$1dir = $(libexecdir)/paludis/hooks/$1
+installsystemhooks$1_DATA = .keep')
+
+systemhook(`install_pre')
+systemhook(`install_post')
+systemhook(`install_all_pre')
+systemhook(`install_all_post')
+systemhook(`install_pretend_pre')
+systemhook(`install_pretend_post')
+systemhook(`uninstall_pre')
+systemhook(`uninstall_post')
+systemhook(`uninstall_all_pre')
+systemhook(`uninstall_all_post')
+systemhook(`sync_pre')
+systemhook(`sync_post')
+systemhook(`sync_all_pre')
+systemhook(`sync_all_post')
+systemhook(`fetch_all_pre')
+systemhook(`fetch_all_post')
+systemhook(`fetch_all_all_pre')
+systemhook(`fetch_all_all_post')
+
+install-data-local :
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_all_pre/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_all_post/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_pre/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_post/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/install_pre/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/install_post/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/install_all_pre/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/install_all_post/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/install_pretend_pre/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/install_pretend_post/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_pre/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_post/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_all_pre/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_all_post/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/fetch_all_pre/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/fetch_all_post/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/fetch_pre/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/fetch_post/
+ ln -sf ../common/gnu_info_index.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_all_post/
+ ln -sf ../common/gnu_info_index.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_all_post/
+ ln -sf ../common/eselect_env_update.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_all_post/
+ ln -sf ../common/eselect_env_update.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_post/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_all_pre/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_all_post/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_pre/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_post/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/fetch_all_pre/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/fetch_all_post/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/fetch_pre/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/fetch_post/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_all_pre/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_all_post/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_pre/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_post/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_pre/
+ ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_post/
+ ln -sf ../common/news.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_all_post/
+ ln -sf ../common/news.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_all_post/
+ ln -sf ../common/news.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_pretend_post/
+
+uninstall-local :
+ rm $(DESTDIR)/$(libexecdir)/paludis/hooks/*/gnu_info_index.bash
+ rm $(DESTDIR)/$(libexecdir)/paludis/hooks/*/eselect_env_update.bash
+ rm $(DESTDIR)/$(libexecdir)/paludis/hooks/*/log.bash
+ rm $(DESTDIR)/$(libexecdir)/paludis/hooks/*/news.bash
+
+Makefile.am : Makefile.am.m4
+ $(top_srcdir)/misc/do_m4.bash Makefile.am
+
diff --git a/0.8.0/hooks/eselect_env_update.bash b/0.8.0/hooks/eselect_env_update.bash
new file mode 100755
index 0000000..00ac62b
--- /dev/null
+++ b/0.8.0/hooks/eselect_env_update.bash
@@ -0,0 +1,27 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# Copyright (c) 2006 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 as published by the Free Software Foundation; either version
+# 2 of the License, or (at your option) any later version.
+#
+# 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
+
+export PATH="$(${PALUDIS_EBUILD_DIR}/utils/canonicalise ${PALUDIS_EBUILD_DIR}/utils/ ):${PATH}"
+source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
+
+echo
+einfo "Regenerating environment..."
+eselect env update || exit 1
+einfo "Done regenerating environment"
+
diff --git a/0.8.0/hooks/find_config_updates.bash b/0.8.0/hooks/find_config_updates.bash
new file mode 100755
index 0000000..0058995
--- /dev/null
+++ b/0.8.0/hooks/find_config_updates.bash
@@ -0,0 +1,46 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# Copyright (c) 2006 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 as published by the Free Software Foundation; either version
+# 2 of the License, or (at your option) any later version.
+#
+# 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
+
+echo
+einfo "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 "Found ${c} files in ${ROOT%%+(/)}/${dir}"
+ dir_count=$((dir_count + 1))
+ fi
+done
+
+if [[ 0 -eq "${dir_count}" ]] ; then
+ einfo "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/0.8.0/hooks/gnu_info_index.bash b/0.8.0/hooks/gnu_info_index.bash
new file mode 100755
index 0000000..62e70ca
--- /dev/null
+++ b/0.8.0/hooks/gnu_info_index.bash
@@ -0,0 +1,84 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# Copyright (c) 2006 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 as published by the Free Software Foundation; either version
+# 2 of the License, or (at your option) any later version.
+#
+# 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
+
+export PATH="$(${PALUDIS_EBUILD_DIR}/utils/canonicalise ${PALUDIS_EBUILD_DIR}/utils/ ):${PATH}"
+source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
+
+echo
+einfo "Checking whether the GNU info directory needs updating..."
+
+regen_info_dirs=
+vdb_loc=$(${PALUDIS_COMMAND} --configuration-variable installed location )
+for info_path in ${INFOPATH/:/ } ; do
+ info_path="${ROOT%/}/${info_path}"
+ [[ -d "${info_path}" ]] || continue
+ info_time=$(getmtime "${info_path}" )
+
+ if [[ -f "${vdb_loc}/.cache/info_time_cache" ]] ; then
+ info_time_cache=$(getmtime "${vdb_loc}"/.cache/info_time_cache )
+ [[ "${info_time}" -le "${info_time_cache}" ]] && continue
+ fi
+
+ regen_info_dirs="${regen_info_dirs} ${info_path}"
+done
+
+if [[ -z "${regen_info_dirs}" ]] ; then
+ einfo "No updates needed"
+ exit 0
+fi
+
+good_count=0
+bad_count=0
+
+for info_path in ${regen_info_dirs} ; do
+ einfo "Updating directory ${info_path}..."
+
+ [[ -e "${info_path}"/dir ]] && mv -f "${info_path}/"dir{,.old}
+
+ for d in ${regen_info_dirs}/* ; do
+ [[ -f "${d}" ]] || continue
+ [[ "${d}" != "${d%dir}" ]] && continue
+ [[ "${d}" != "${d%dir.old}" ]] && continue
+
+ is_bad=
+ /usr/bin/install-info --quiet --dir-file="${info_path}/dir" "${d}" 2>&1 | \
+ while read line ; do
+ [[ "${line/already exists, for file/}" != "${line}" ]] && continue
+ [[ "${line/warning: no info dir entry in /}" != "${line}" ]] && continue
+ is_bad=probably
+ done
+
+ if [[ -n "${is_bad}" ]] ; then
+ bad_count=$(( bad_count + 1 ))
+ else
+ good_count=$(( good_count + 1 ))
+ fi
+ done
+done
+
+touch "${vdb_loc}/.cache/info_time_cache"
+
+if [[ ${bad_count} -gt 0 ]] ; then
+ ewarn "Processed $(( good_count + bad_count )) info files, with ${bad_count} errors"
+ exit 1
+else
+ einfo "Processed ${good_count} info files"
+ exit 0
+fi
+
diff --git a/0.8.0/hooks/log.bash b/0.8.0/hooks/log.bash
new file mode 100755
index 0000000..ef06cf7
--- /dev/null
+++ b/0.8.0/hooks/log.bash
@@ -0,0 +1,86 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# Copyright (c) 2006 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 as published by the Free Software Foundation; either version
+# 2 of the License, or (at your option) any later version.
+#
+# 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
+
+mkdir -p "${ROOT}/var/log"
+
+(
+ echo -n "$(date +%s ): "
+
+ case "${HOOK}" in
+ install_pre)
+ echo "starting install of package ${TARGET}"
+ ;;
+
+ install_post)
+ echo "finished install of package ${TARGET}"
+ ;;
+
+ install_all_pre)
+ echo "starting install of targets ${TARGETS}"
+ ;;
+
+ install_all_post)
+ echo "finished install of targets ${TARGETS}"
+ ;;
+
+ uninstall_pre)
+ echo "starting uninstall of package ${TARGET}"
+ ;;
+
+ uninstall_post)
+ echo "finished uninstall of package ${TARGET}"
+ ;;
+
+ uninstall_all_pre)
+ echo "starting uninstall of targets ${TARGETS}"
+ ;;
+
+ uninstall_all_post)
+ echo "finished uninstall of targets ${TARGETS}"
+ ;;
+
+ fetch_pre)
+ echo "starting fetch of package ${TARGET}"
+ ;;
+
+ fetch_post)
+ echo "finished fetch of package ${TARGET}"
+ ;;
+
+ fetch_all_pre)
+ echo "starting fetch of targets ${TARGETS}"
+ ;;
+
+ fetch_all_post)
+ echo "finished fetch of targets ${TARGETS}"
+ ;;
+
+ sync_pre)
+ echo "starting sync of repository ${TARGET}"
+ ;;
+
+ sync_post)
+ echo "finished sync of repository ${TARGET}"
+ ;;
+
+ *)
+ echo "unknown hook ${HOOK}"
+ esac
+) >> ${ROOT}/var/log/paludis.log
+
diff --git a/0.8.0/hooks/news.bash b/0.8.0/hooks/news.bash
new file mode 100755
index 0000000..44c379d
--- /dev/null
+++ b/0.8.0/hooks/news.bash
@@ -0,0 +1,51 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# Copyright (c) 2006 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 as published by the Free Software Foundation; either version
+# 2 of the License, or (at your option) any later version.
+#
+# 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
+
+export PATH="$(${PALUDIS_EBUILD_DIR}/utils/canonicalise ${PALUDIS_EBUILD_DIR}/utils/ ):${PATH}"
+source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
+
+mkdir -p ${ROOT}/var/lib/paludis/news/
+
+done_echo=
+
+if [[ "${HOOK/pretend}" == "${HOOK}" ]] ; then
+ [[ -z "${done_echo}" ]] && echo ; done_echo=yes
+ einfo "Checking for news items..."
+
+ ${PALUDIS_COMMAND} --update-news
+fi
+
+count=0
+for f in "${ROOT}/var/lib/paludis/news/"news-*.unread ; do
+ [[ -f "${f}" ]] || continue
+ if grep --silent . "${f}" ; then
+ count=$(( count + $(grep --count . < "${f}" ) ))
+ fi
+done
+
+if [[ ${count} -gt 0 ]] ; then
+ [[ -z "${done_echo}" ]] && echo ; done_echo=yes
+ ewarn "You have ${count} unread news items"
+elif [[ "${HOOK/pretend}" == "${HOOK}" ]] ; then
+ [[ -z "${done_echo}" ]] && echo ; done_echo=yes
+ einfo "No unread news items found"
+fi
+
+true
+
diff --git a/0.8.0/hooks/update_config_protect_list.bash b/0.8.0/hooks/update_config_protect_list.bash
new file mode 100755
index 0000000..d7c3861
--- /dev/null
+++ b/0.8.0/hooks/update_config_protect_list.bash
@@ -0,0 +1,60 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# Copyright (c) 2006 Mike Kelly <pioto@gentoo.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 as published by the Free Software Foundation; either version
+# 2 of the License, or (at your option) any later version.
+#
+# 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
+
+vdb_loc=$(${PALUDIS_COMMAND} --configuration-variable installed location )
+cfg_protect_list="${vdb_loc}/.cache/all_CONFIG_PROTECT"
+cfg_protect_mask_list="${vdb_loc}/.cache/all_CONFIG_PROTECT_MASK"
+
+if [[ ! -f "${cfg_protect_list}" || ! -f "${cfg_protect_mask_list}" ]] ; then
+ # Generate this list for the first time. *slow*
+ echo "Creating the CONFIG_PROTECT and CONFIG_PROTECT_MASK lists."
+ echo "This will take a while."
+ > "${cfg_protect_list}"
+ > "${cfg_protect_mask_list}"
+
+ installed_pkgs=$(${PALUDIS_COMMAND} --list-packages --repository installed |grep "^*" |cut -d" " -f2)
+
+ for p in ${installed_pkgs} ; do
+ cfg_protect=$(${PALUDIS_COMMAND} --environment-variable ${p} CONFIG_PROTECT)
+ for x in ${cfg_protect} ; do
+ echo "${x}" >> "${cfg_protect_list}"
+ done
+
+ cfg_protect_mask=$(${PALUDIS_COMMAND} --environment-variable ${p} CONFIG_PROTECT_MASK)
+ for x in ${cfg_protect_mask} ; do
+ echo "${x}" >> "${cfg_protect_mask_list}"
+ done
+ done
+fi
+
+# Now, update the lists with our current values.
+for x in ${CONFIG_PROTECT} ; do
+ echo "${x}" >> "${cfg_protect_list}"
+done
+
+for x in ${CONFIG_PROTECT_MASK} ; do
+ echo "${x}" >> "${cfg_protect_mask_list}"
+done
+
+# Finally, ensure we have no duplicates in these lists.
+sort -u "${cfg_protect_list}" > "${cfg_protect_list}.$$"
+mv "${cfg_protect_list}.$$" "${cfg_protect_list}"
+
+sort -u "${cfg_protect_mask_list}" > "${cfg_protect_mask_list}.$$"
+mv "${cfg_protect_mask_list}.$$" "${cfg_protect_mask_list}"