@@ 0,0 1,57 @@
+---
+layout: post
+title: "Setting up a private package repo for FreeBSD"
+date: 2020-04-07
+comments: true
+tags: freebsd, pkgng
+---
+
+Lately the EU mirror for FreeBSD packages(<http://pkg0.bme.freebsd.org>) has been really slow for me. My best guess is the mirror is being overloaded, it could be because of my ISP peering weirdly too.
+
+I already have a [Poudriere](https://www.freebsd.org/doc/handbook/ports-poudriere.html) setup running on a beefy server. How hard it would be building all the packages that I need? Turns out its not that hard at all.
+
+First step is to get all the packages that I currently use and their port names
+
+```bash
+$ pkg query '%o' > x230-packages
+
+# make sure they look right
+$ head x230-packages
+math/coinmp
+x11-fonts/gentium-basic
+graphics/ImageMagick6
+devel/ORBit2
+graphics/aalib
+sysutils/accountsservice
+print/adobe-cmaps
+x11-themes/adwaita-icon-theme
+x11/alacritty
+audio/alsa-lib
+```
+
+Setup poudriere with instructions from handbook: <https://www.freebsd.org/doc/handbook/ports-poudriere.html>
+
+Build the packages
+```bash
+/usr/local/bin/poudriere ports -p local -u
+/usr/local/bin/poudriere bulk -j 12amd64 -p local -z x230 -f /root/x230-packages
+```
+
+After **a day and half** poudriere built all the packages I need :)
+
+Now all that left is to disable the official repo and replace it with mine
+
+```bash
+cat > /usr/local/etc/pkg/repos/Mine.conf <<EOF
+FreeBSD: { enabled: no }
+
+builder: {
+ url: "https://<path to repo>/repo/12amd64-local-x230/",
+ enabled: yes
+}
+EOF
+```
+Bye bye slow mirrors!
+
+
+This should be filed under over-engineering, and I should really investigate why the mirror is slow; This does work and love how simple and powerful the pkg system is. Workflow is far better than I am used to bulk building debian or arch packages.