I am maintaining a code base that depends on Postgis 1.5. My local dev VM is running FreeBSD 9.2. I have recently been tinkering with packages and inadvertently deleted postgis, so I attempted to reinstall, only to find that 1.5 postgis port has been removed from the port tree. How can I get that port back? I know I can just install from source, but I would rather have it pkg controlled.
I'm guessing you just deleted the actual port tree directory. In that case, you'll need to use svn to retrieve the relevant section of the ports tree from the central FreeBSD repository. This primer will help you achieve that, most relevant to you is probably the "Partial Checkout" sections. If that's too time consuming, just check out the entire ports tree and grab what you need, and make sure you have enough disk space to hold it.
If a port has been deleted, then you can pull it out of the rubbish bin via SVN, but it isn't guaranteed to keep working. Most ports in FreeBSD are now 'staged', an infrastructure change to improve package building.
Anyway, you can see the history of the port here:
You can see it was deleted in revision 340004, so check out the last revision before that
svn co -r 340003 svn://svn.freebsd.org/ports/head/databases/postgis /usr/ports/databases/
And compile as normal. It might break, especially since it might depend on older versions of things like perl and postgres
You might be better off checking out an entire ports tree from back then and using it, but then you lack all of the security updates.
Important Life lessons:
As you've discovered Postgis 1.x no longer appears in the ports tree, and I don't see any packages for it either (It's from 2012 so you shouldn't be surprised by this! It predates the operating system you're running...).
If you want to build this port yourself you will need to retrieve the ports tree from SVN and check out a revision that still contains the postgis 1.5 port. Instructions on doing so can be found in the FreeBSD handbook and the svn documentation (