Add Portage post.
authorW. Trevor King <wking@tremily.us>
Sat, 23 Jun 2012 18:50:41 +0000 (14:50 -0400)
committerW. Trevor King <wking@tremily.us>
Sat, 23 Jun 2012 18:50:41 +0000 (14:50 -0400)
posts/Portage.mdwn [new file with mode: 0644]

diff --git a/posts/Portage.mdwn b/posts/Portage.mdwn
new file mode 100644 (file)
index 0000000..6b82d2f
--- /dev/null
@@ -0,0 +1,63 @@
+[Portage][] is [[Gentoo]]'s default package manager.  This post isn't
+supposed to be a tutorial, the [handbook][] does a pretty good job of
+that already.  I'm just recording a few tricks so I don't forget them.
+
+User patches
+============
+
+While playing around with [[LDAP]], I was trying to troubleshoot the
+`SASL_NOCANON` handling.  “Gee,” I thought, “wouldn't it be nice to be
+able to add debugging printfs to figure out what was happening?”
+Unfortunately, I had trouble getting `ldapwhoami` working when I
+compiled it by hand.  “Grrr,” I though, “I just want to add a simple
+patch and do whatever the ebuild already does.”  This is actually
+pretty easy to do, once you're looking in the right places.
+
+Write your patch
+----------------
+
+I'm not going to cover that here.
+
+Place your patch where `epatch_user` will find it
+-------------------------------------------------
+
+This would be under
+
+    /etc/portage/patches/<CATEGORY>/<PF|P|PN>/
+
+If your ebuild already calls `epatch_user`, or it uses an eclass like
+`base` that calls `epatch_user` internally, you're done.  If not, read
+on…
+
+Forcing `epatch_user`
+---------------------
+
+While you could always write an [[overlay|Gentoo_overlay]] with an
+improved ebuild, a quicker fix for this kind of hack is
+[/etc/portage/bashrc][bashrc].  I used:
+
+    if [ "${EBUILD_PHASE}" == "prepare" ]; then
+        echo ":: Calling epatch_user";
+        pushd "${S}"
+        epatch_user
+        popd
+    fi
+
+to insert my patches at the beginning of the `prepare` phase.
+
+Cleaning up
+-----------
+
+It's safe to call `epatch_user` multiple times, so you can leave this
+setup in place if you like.  However, you might run into problems [if
+you touch autoconf files][autoconf], so you may want to move your
+`bashrc` somewhere else until you need it again!
+
+
+[Portage]: http://www.gentoo.org/proj/en/portage/index.xml
+[handbook]: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=1
+[bashrc]: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=3&chap=6#doc_chap3
+[autoconf]: http://comments.gmane.org/gmane.linux.gentoo.devel/76466
+
+[[!tag tags/tools]]
+[[!tag tags/programming]]