aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-13 14:38:32 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-13 14:38:32 +0000
commit2b560957155a3b490142c0539844e7ee965bcbd1 (patch)
tree34e3592dbac21aff6515fb5cdaa869a51eb3e03f
parentc040a6630ad3013f9edaa50fdc792a711b9fb10d (diff)
downloadpaludis-2b560957155a3b490142c0539844e7ee965bcbd1.tar.gz
paludis-2b560957155a3b490142c0539844e7ee965bcbd1.tar.xz
Add symlink fixing hook
-rw-r--r--hooks/Makefile.am.m418
-rwxr-xr-xhooks/fix_symlinks.bash56
2 files changed, 68 insertions, 6 deletions
diff --git a/hooks/Makefile.am.m4 b/hooks/Makefile.am.m4
index 43c0860..f34b95c 100644
--- a/hooks/Makefile.am.m4
+++ b/hooks/Makefile.am.m4
@@ -20,7 +20,8 @@ installhookcommonprog_SCRIPTS = \
news.bash \
installable_cache_regen.bash \
installed_cache_regen.bash \
- write_cache_clean.bash
+ write_cache_clean.bash \
+ fix_symlinks.bash
installhookinstallallpost_SCRIPTS = \
find_config_updates.bash
@@ -205,6 +206,8 @@ install-data-local :
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/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/merger_install_sym_post/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/merger_check_sym_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/
@@ -235,13 +238,16 @@ install-data-local :
ln -sf ../common/installed_cache_regen.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_post/
ln -sf ../common/installed_cache_regen.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_post/
ln -sf ../common/installed_cache_regen.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/clean_post/
+ ln -sf ../common/fix_symlinks.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/merger_check_sym_post/
+ ln -sf ../common/fix_symlinks.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/merger_install_sym_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
- rm $(DESTDIR)/$(libexecdir)/paludis/hooks/*/write_cache_clean.bash
+ rm -f $(DESTDIR)/$(libexecdir)/paludis/hooks/*/gnu_info_index.bash
+ rm -f $(DESTDIR)/$(libexecdir)/paludis/hooks/*/eselect_env_update.bash
+ rm -f $(DESTDIR)/$(libexecdir)/paludis/hooks/*/log.bash
+ rm -f $(DESTDIR)/$(libexecdir)/paludis/hooks/*/news.bash
+ rm -f $(DESTDIR)/$(libexecdir)/paludis/hooks/*/write_cache_clean.bash
+ rm -f $(DESTDIR)/$(libexecdir)/paludis/hooks/*/fix_symlinks.bash
Makefile.am : Makefile.am.m4
$(top_srcdir)/misc/do_m4.bash Makefile.am
diff --git a/hooks/fix_symlinks.bash b/hooks/fix_symlinks.bash
new file mode 100755
index 0000000..d6a4536
--- /dev/null
+++ b/hooks/fix_symlinks.bash
@@ -0,0 +1,56 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# Copyright (c) 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
+
+export PATH="$(${PALUDIS_EBUILD_DIR}/utils/canonicalise ${PALUDIS_EBUILD_DIR}/utils/ ):${PATH}"
+source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
+
+shopt -s extglob
+
+image=$(tr -s / <<<"${IMAGE}" )
+
+case "${HOOK}" in
+
+ merger_check_sym_post)
+ target=$(readlink ${INSTALL_SOURCE} | tr -s / )
+ [[ "${target#${image}}" == "${target}" ]] && exit 0
+
+ ewarn "Bad symlink ${INSTALL_SOURCE} -> $(readlink ${INSTALL_SOURCE} ) will be rewritten"
+ ;;
+
+ merger_install_sym_post)
+ target=$(readlink ${INSTALL_DESTINATION} | tr -s / )
+ [[ "${target#${image}}" == "${target}" ]] && exit 0
+
+ new_target=${target#${image}}
+ new_target=/${new_target##+(/)}
+ ewarn "Relinking bad symlink ${INSTALL_DESTINATION} -> $(readlink \
+ ${INSTALL_DESTINATION} ) to ${new_target}"
+ echo rm -f "${INSTALL_DESTINATION}" 1>&2
+ rm -f "${INSTALL_DESTINATION}"
+ echo ln -s "${new_target}" "${INSTALL_DESTINATION}" 1>&2
+ ln -s "${new_target}" "${INSTALL_DESTINATION}"
+ ;;
+
+ *)
+ ewarn "$0: Don't know how to respond to HOOK ${HOOK}"
+ ;;
+
+esac
+
+true
+