#!/bin/bash oldpwd="$(pwd)" thetmpdir="/tmp/remove_me" attachmentid=215326 mkdir "${thetmpdir}" cd "${thetmpdir}" eval "$( emerge --info | egrep '^PORTDIR=|^PORTAGE_TMPDIR=' \ | sed 's/^\(.*\)=/\L\1=/')" ebuild "${portdir}/sys-libs/gdbm/gdbm-1.8.3-r3.ebuild" install \ && gdbmtmp="${portage_tmpdir}/portage/sys-libs/gdbm-1.8.3-r3" \ && cp "${gdbmtmp}/image/usr/lib/libgdbm.a" . || { echo something bad happend.; exit 1 ; } ebuild "${portdir}/sys-libs/gdbm/gdbm-1.8.3-r3.ebuild" clean wget -S -O converter.c "http://bugs.gentoo.org/attachment.cgi?id=${attachmentid}" \ && gcc converter.c -o converter libgdbm.a -ldl \ && find /etc /var -type f -exec file {} + \ | grep 'GNU dbm 1.x or ndbm database' \ | sed 's/:.*$//' | while read f ; do echo converting "$f" ./converter "$f" || { echo sorry, converting "$f" failed; break; } echo "Successful. You may wish to remove "${f}.upgrade.tmp" done cd "${oldpwd}" echo "You may wish to remove ${thetmpdir}" echo "If conversion was successful, it serves no further purpose."