# moving a port into the local source tree



## babel17 (Sep 14, 2011)

I'd like to be able to move a port into my local FreeBSD source tree (because I am constantly modifying some of the header files on which the port depends).  My naive approach is to (and I'll use net-snmp as an example):


```
cd /usr/ports/net-mgmt/net-snmp
make configure
mkdir <path_to_freebsd_src>/usr.sbin/net-snmp
cp -a work/net-snmp<version>/ <path_to_freebsd_src>/usr.sbin/net-snmp
```

Then modify the Makefile to be compatible with the build world environment.

Does this approach seem reasonable?

Are there gotcha's I should look out for?

Is there a better way to achieve the same result?


----------



## wblock@ (Sep 14, 2011)

The port Makefile is probably dependent on a lot of the ports system; see /usr/ports/Mk.

Ports are very different from system source.  Not saying it can't be done, just that it's sort of nontrivial.


----------



## Wiedmann (Sep 14, 2011)

> I'd like to be able to move a port into my local FreeBSD source tree (because I am constantly modifying some of the header files on which the port depends).
> 
> Is there a better way to achieve the same result?


This is a good guide how to do this:
http://myfreebsd.homeunix.net/hints_n_kinks/local-ports.html


----------



## babel17 (Sep 14, 2011)

Wiedmann:
  Unfortunately that approach won't work, as I'm not modifying the port, I'm modifying FreeBSD header files on which the port depends...

wblock:
  That is not the answer I wanted to hear.  Please try again. Something like "Just download port-2-src from this website."  :e


----------



## wblock@ (Sep 14, 2011)

babel17 said:
			
		

> wblock:
> That is not the answer I wanted to hear.  Please try again. Something like "Just download port-2-src from this website."  :e



I nearly posted a link to the "and then a miracle occurs" cartoon.  Wiedmann's suggestion is a more practical approach.  If you don't mind the pkg_* programs complaining, you can even keep a custom port in your own directory outside of the ports tree entirely.  It's not very neat, but it works.

If you just have local patches to a port, use csup(1) to update the ports tree.  It ignores files that aren't in CVS, so your local patches in files/ will be left alone.


----------

