Friday, May 11, 2007

UNINSTALL_PROTECT in Paludis

Update: Check this for the current bash version of this hook or this for a better performing python one.

This is somehow related to my previous posts about the moduledb as the idea also arose when playing with kernel modules.

When installing modules for a new kernel I noticed that Paludis treated them as any other package and removed the old installs leaving my old kernel without the modules. Nothing really surprising here, just different than the portage behaviour. Wanting to avoid this in the future my first thought was just to add /lib64/modules to the CONFIG_PROTECT, but after a second I realised it wasn't the best idea as I didn't want to review modules' changes when upgrading, I just wanted them to be not removed when uninstalling. Hence that it wasn't long until making an Unmerger Hook came to my mind.

/etc/paludis/hooks/uninstall_protect.hook:
#!/bin/bash

UNINSTALL_PROTECT="/lib64/modules/"

hook_run_unmerger_unlink_file_pre() {
    for PROTECT in ${UNINSTALL_PROTECT}; do
        if [[ "${UNLINK_TARGET}" == "${PROTECT}"* ]]; then
            mv "${UNLINK_TARGET}" "${UNLINK_TARGET}.protect"
        fi
    done
}

hook_run_unmerger_unlink_file_post() {
    if [[ -e "${UNLINK_TARGET}.protect" ]]; then
        mv "${UNLINK_TARGET}.protect" "${UNLINK_TARGET}"
        echo "protected '${UNLINK_TARGET}'"
    fi
}

And two symlinks pointing at it:

/etc/paludis/hooks/unmerger_unlink_file_pre/uninstall_protect.hook -> ../uninstall_protect.hook

/etc/paludis/hooks/unmerger_unlink_file_post/uninstall_protect.hook -> ../uninstall_protect.hook

5 comments:

  1. Thanks Piotr, Very handy. :-)

    ReplyDelete
  2. Just noticed yout second solution, which seems much nicer

    http://blog.piotrj.org/2007/05/uninstallprotect-in-paludis-2.html

    ReplyDelete
  3. Instead of hiring skilled reside recreation dealers, on line casino HR departments will be in search of people contemporary out of school with a degree in communications. The best 카지노 hand identified as} a blackjack, where you make 21 along with your first two cards, so an ace and a ten or an ace and a picture card. In this case, you’ll mechanically win a three-to-two payout .

    ReplyDelete