• Finding pkgsrc orphans

    From pnwdaemon@always.wet@21:1/5 to All on Wed Oct 19 01:43:00 2016
    I came across an executable - xxd - installed under ../pkgsrc/bin which
    didn't seem to be either an actual pkgsrc package nor a recognized
    dependency for a package. Furthermore, the manpage xxd(1) didn't provide
    any clues as to where it might have come from. Using the output of
    'pkg_info -a -L' and grepping for "bin/" revealed is was bundled with "vim-share", data files for the vim editor, which gets auto-installed by vim(1). This isn't really a common problem but was sufficiently annoying
    that I wrote a helper script for future use:

    --
    #!/bin/sh -e
    # pkg_orphan - greps 'pkg_info -a -L' output to determine which
    # pkgsrc package installed ORPHAN
    #

    ORPHAN=${1:--help}
    FIRSTCHAR=$(echo "${ORPHAN}" | sed "s/\(^.\).*$/\1/")

    # print_usage function:
    print_usage() {
    echo "
    usage: pkg_orphan [-h|-?|<executable under /usr/pkg/{,s}bin/>]

    ex) pkg_orphan xxd => xxd installed by vim-share-7.2.446
    "
    }

    # find_orphan function:
    find_orphan() {
    pkg_info -a -L | grep -B30 -e "bin/${ORPHAN}" | \
    sed -n "{
    /^Information/s/Information for/${ORPHAN} installed by/
    /^${ORPHAN}/s/:$//
    /^${ORPHAN}/p }" | \
    tail -n1
    }

    # main:
    case $FIRSTCHAR in
    -) print_usage ;;
    *) find_orphan ;;
    esac

    exit 0
    --

    The "grep -B30" bit is just a guess at how far back one would need to look
    for the associated PLIST header; on my system the pkg with the most "bin/" PLIST entries is ImageMagick (16 entries). Also, the script assumes the defaults for pkg_info(1) WRT the pkg_dbdir; would need to be tweaked with
    the '-K pkg_dbdir' option for non-std setups.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John McCue@21:1/5 to pnwdaemon@always.wet on Thu Oct 20 00:09:21 2016
    pnwdaemon@always.wet wrote:
    I came across an executable - xxd - installed under ../pkgsrc/bin which didn't seem to be either an actual pkgsrc package nor a recognized
    dependency for a package. Furthermore, the manpage xxd(1) didn't provide
    any clues as to where it might have come from. Using the output of
    'pkg_info -a -L' and grepping for "bin/" revealed is was bundled with "vim-share", data files for the vim editor, which gets auto-installed by vim(1). This isn't really a common problem but was sufficiently annoying
    that I wrote a helper script for future use:
    <snip>

    Very nice,

    John

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)