Category Archives: FreeBSD ports collection

Upgrading PostgreSQL 9.4.6 to 9.5.1

All commands were done as the root user unless indicated.

su -l pgsql
pg_dumpall | bzip2 -9c > all-db-9.4.6-2016-02-17.sql.bz2
chmod 0600 all-db-9.4.6-2016-02-17.sql.bz2
exit
/usr/local/etc/rc.d/postgresql stop
make -C /usr/ports/databases/postgresql95-server config-recursive
pkg delete databases/postgresql94-contrib
portupgrade -fpvo databases/postgresql95-client databases/postgresql94-client
portupgrade -Nfpv databases/postgresql95-contrib
portupgrade -fpvo databases/postgresql95-server databases/postgresql94-server
portupgrade -fprv -x databases/postgresql95-client -x databases/postgresql95-server -x databases/postgresql95-contrib databases/postgresql95-client
mv /usr/local/pgsql/data /usr/local/pgsql/data0
su -l pgsql -c 'mkdir /usr/local/pgsql/data'
/usr/local/etc/rc.d/postgresql initdb
/usr/local/etc/rc.d/postgresql start
su -l pgsql
bzcat all-db-9.4.6-2016-02-17.sql.bz2 | psql -f - template1
# Transfer all relevant settings from /usr/local/pgsql/data0 to /usr/local/pgsql/data for pg_hba.conf and postgresql.conf
exit
/usr/local/etc/rc.d/postgresql restart
su -l pgsql
pg_dumpall | bzip2 -9c > all-db-9.5.1-2016-02-17.sql.bz2
chmod 0600 all-db-9.5.1-2016-02-17.sql.bz2
exit
rm -R /usr/local/pgsql/data0

Adding 24 hour clock to FreeBSD’s hardstatus string for GNU Screen

FreeBSD gives the user an option of installing the file /usr/local/etc/screenrc with some sensible defaults along with GNU Screen, aka sysutils/screen.

Among the defaults are a format string for the hardstatus line. It shows the date using yy/dd/mm notation and the time as a 12 hour clock. That may be fine in the English speaking parts of the world.

hardstatus string '%{gk}[%{G}%H%{g}][%= %{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}]%{=b C}[%m/%d/%y %C %A]%{W}'

Continue reading Adding 24 hour clock to FreeBSD’s hardstatus string for GNU Screen

Ascertaining installed ports for a specific architecture

When upgrading from one major version of FreeBSD to another, in my case from FreeBSD/amd64 stable/9 to FreeBSD/amd64 stable/10, it’s customary to upgrade the installed ports afterwards, beginning with ports-mgmt/pkg.

I forcefully upgraded all installed ports using portupgrade -afpv, but the upgrade of lang/ruby21 failed miserably.

I removed all traces of Ruby 2.1, i.e. ports-mgmt/portupgrade and databases/ruby-bdb, before manually compiling and installing lang/ruby21, databases/ruby-bdb, and ports-mgmt/portupgrade using the ports collection.

Now, I needed to know which remaining ports were still compiled for stable/9. The following snippet allowed me to gather the origins of such ports:

pkg query -a %o:%q | grep freebsd:9: | cut -d : -f 1

Now, I could feed that list to the newly installed portupgrade and upgrade the remaining ports:

portupgrade -fprv `pkg query -a %o:%q | grep freebsd:9: | cut -d : -f 1`

In the end, I should have removed lang/ruby21 completely after upgrading ports-mgmt/pkg, and reinstalled ports-mgmt/portupgrade manually using the ports collection. Only then is it safe to forcefully rebuild and reinstall all the other ports. Don’t forget to add devel/cvs if you used to rely on cvs in base, and adjust all references from /usr/bin/cvs to /usr/local/bin/cvs.

Upgrading lang/php5 to lang/php56

The 20150220 entry in /usr/ports/UPDATING contains no instructions for upgrading lang/php5 to lang/php56, at least not for us compiling our own ports.

I learned the hard way using portupgrade what needs to be done. I have summarised my steps into the script below. Use the script as a guide, and if you do run my script, then you’re on your own. To save you some effort, here’s the script ready for downloading. Continue reading Upgrading lang/php5 to lang/php56

Running dns/bind910 within a chroot after r382109

dns/bind910 gained native chroot support in r382109. Those of us who used to store the BIND files in /var/named/etc/namedb and ran BIND with /var/named as the chroot environment, must do five things:

  1. Rename the /var/named directory to something else, like /var/Named. This is to avoid upsetting make -C /usr/src delete-old and still retain the meaning of the directory’s name.
  2. Rename the /var/Named/etc/namedb directory to /var/Named/usr/local/etc/namedb.
  3. Edit /var/Named/usr/local/etc/namedb/named.conf to reflect that the BIND files now resides in /usr/local/etc/namedb, as seen from within the chroot environment.
  4. Change the appropriate line in /etc/rc.conf to read named_chrootdir="/var/Named".
  5. Restart BIND using /usr/local/etc/rc.d/named restart, or start BIND using /usr/local/etc/rc.d/named start if the former fails.