The following commit has been merged in the master branch: commit 05ce02f897fbe2a455cacb064fd5bc5a6bf182d9 Author: Guillem Jover <guil...@debian.org> Date: Fri Aug 19 18:07:13 2011 +0200
u-a: Update alternative links only if they change There's no point in changing the links to the same target. This also helps when systems might have a read-only file system mounted, but a writable database. Closes: #636700 Based-on-patch-by: Salvatore Bonaccorso <car...@debian.org> Signed-off-by: Guillem Jover <guil...@debian.org> diff --git a/debian/changelog b/debian/changelog index 4967e00..468f3ac 100644 --- a/debian/changelog +++ b/debian/changelog @@ -204,6 +204,9 @@ dpkg (1.16.1) UNRELEASED; urgency=low Prompted by Timo Juhani Lindfors <timo.lindf...@iki.fi>. * Print an actual error or warning message instead of assert()ing on readlink()/stat() size discrepancies. Closes: #639229 + * Update alternative links only if they change. This allows for a + read-only file system and a writable database. Closes: #636700 + Based on a patch by Salvatore Bonaccorso <car...@debian.org>. [ Updated dpkg translations ] * German (Sven Joachim). Closes: #620312 diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c index e7516aa..feef7ed 100644 --- a/utils/update-alternatives.c +++ b/utils/update-alternatives.c @@ -1681,6 +1681,34 @@ alternative_can_replace_path(const char *linkname) return true; } +static bool +alternative_path_needs_update(const char *linkname, const char *filename) +{ + char *linktarget; + bool update; + + if (opt_force) + return true; + + switch (alternative_path_classify(linkname)) { + case ALT_PATH_SYMLINK: + linktarget = xreadlink(linkname); + if (strcmp(linktarget, filename) == 0) + update = false; + else + update = true; + free(linktarget); + + return update; + case ALT_PATH_OTHER: + warning(_("not replacing %s with a link."), linkname); + return false; + case ALT_PATH_MISSING: + default: + return true; + } +} + static void alternative_prepare_install_single(struct alternative *a, const char *name, const char *linkname, const char *file) @@ -1695,15 +1723,13 @@ alternative_prepare_install_single(struct alternative *a, const char *name, alternative_add_commit_op(a, opcode_mv, fntmp, fn); free(fntmp); - if (alternative_can_replace_path(linkname)) { + if (alternative_path_needs_update(linkname, fn)) { /* Create alternative link. */ xasprintf(&fntmp, "%s" DPKG_TMP_EXT, linkname); checked_rm(fntmp); checked_symlink(fn, fntmp); alternative_add_commit_op(a, opcode_mv, fntmp, linkname); free(fntmp); - } else { - warning(_("not replacing %s with a link."), linkname); } free(fn); } -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org