# Install a program from source without fetching entire ports tree



## TheUser (Aug 14, 2020)

Hello, i want to install a program from source without fetching entire ports tree, for example, as we know, I can search for the existence of a program for example: 


```
pkg search ufetch
```

and install it with:


```
pkg install ufetch
```

I want to download / modify / compile / install only that program from FreeBSD source ports without fetching all ports source tree.


----------



## richardtoohey2 (Aug 14, 2020)

You might (?) be able to check it out from the Subversion repository, but unless it's a very simple port with no build or run-time dependencies you are likely to have to find & download each dependency as well.


----------



## sidetone (Aug 14, 2020)

With net/svnup, you can choose which category directories you want to download by its configuration file in /etc/local/etc/svnup.conf. However, this will take more time, especially if it has a lot of dependencies which span many categories.

There is a way to do this with portsnap too through its configuration file, but portsnap is being phased out.

Use ports-mgmt/psearch to find ports.


----------



## George (Aug 14, 2020)

The ports tree is just a bunch of Makefiles (and patches, and scripts..).

You might get away with downloading the Makefile and pkg-descr, then do `make makesum` and `make install`.


----------



## Mjölnir (Aug 14, 2020)

There are a few ports without dependencies, e.g. shell scripts.  Some are even self-contained in the ports tree (no external files to download (MASTER_SITES=<empty>) & not available via official packages).  For ports that are compiled, direct build on the host is not recommended.  Use ports-mgmt/synth or ports-mgmt/poudriere to build jailed.  Unless you want to change some port's knobs from the defaults, there's no reason to choose ports (build yourself) over packages.  If the port you want to build has dependencies, these dependencies have dependencies themselves, etc.pp. ...  Thus, you're better off downloading the ports tree; it's ~ 1GB text files, so if space is a concern: it compresses well.


----------



## T-Daemon (Aug 14, 2020)

TheUser said:


> I want to download / modify / compile / install only that program from FreeBSD source ports without fetching all ports source tree.



You can do that. sysutils/ufetch is a simple program having only ports-mgmt/pkg as build dependency.

But you need to meet three conditions. ufetch is seeking /usr/ports/Templates/BSD.local.dist, /usr/ports/Mk/bsd.ports.mk and /usr/ports/distfiles. You should have the distfile directory created, and the other directories checked out with svn(lite) before building ufetch. You can  also override the /usr/ports directory with _PORTSDIR_ ( ports(7) ) if you prefer the ports directory in a users home directory.

If something is unknown to you in my explanation, please don't hesitate to ask.


----------



## Deleted member 63539 (Aug 14, 2020)

It seemed he's looking for something like `apt-get source` and `apt-get build-dep`:









						How do I get and modify the source code of packages installed through apt-get?
					

I am assuming that all application installed through apt-get are open source; but for those that are available in that manner, where can I get the source code for these applications as well as update




					askubuntu.com
				




I don't think there is anything equivalent for `pkg`.


----------



## SirDice (Aug 14, 2020)

This would be somewhat equivalent:


```
cd /tmp
svnlite co https://svn.freebsd.org/ports/head/sysutils/ufetch
cd ufetch
make fetch
make extract
cd work/ufetch-*
```


----------



## a6h (Aug 14, 2020)

Compiling different programs in context an operating system, and at the same keep track of all dependencies, versioning and possible connflicts is not a trivial task. That's why there're large number of BSD-based OS and Linux distro, but only a few number of package managers, such as FreeBSD port system, apt, pacman, etc.


----------



## TheUser (Aug 15, 2020)

T-Daemon said:


> You can do that. sysutils/ufetch is a simple program having only ports-mgmt/pkg as build dependency.
> 
> But you need to meet three conditions. ufetch is seeking /usr/ports/Templates/BSD.local.dist, /usr/ports/Mk/bsd.ports.mk and /usr/ports/distfiles. You should have the distfile directory created, and the other directories checked out with svn(lite) before building ufetch. You can  also override the /usr/ports directory with _PORTSDIR_ ( ports(7) ) if you prefer the ports directory in a users home directory.
> 
> If something is unknown to you in my explanation, please don't hesitate to ask.





Thanks for the answers, I'm reading and testing the variants that you suggest, could you indicate me how to make the svnlite check out of the file /usr/ports/Templates/BSD.local.dist and the file /usr/ports/Mk/bsd.ports.mk? because it would be the basic requirement to apply the step that SirDice indicates because without it an error appears trying to locate those files.

A random example with tty-clock

```
make fetch
make: "/usr/share/mk/bsd.port.mk" line 32: Cannot open /usr/ports/Mk/bsd.port.mk
make: Fatal errors encountered -- cannot continue
make: stopped in /tmp/tty-clock
```


----------



## T-Daemon (Aug 15, 2020)

TheUser said:


> ... could you indicate me how to make the svnlite check out of the file /usr/ports/Templates/BSD.local.dist and the file /usr/ports/Mk/bsd.ports.mk?



You can't check out files individually, only directories. For Templates and Mk please execute:

```
svnlite co https://svn.freebsd.org/ports/head/Templates /usr/ports/Templates
svnlite co https://svn.freebsd.org/ports/head/Mk /usr/ports/Mk
```


----------



## TheUser (Aug 15, 2020)

T-Daemon said:


> You can't check out files individually, only directories. For Templates and Mk please execute:
> 
> ```
> svnlite co https://svn.freebsd.org/ports/head/Templates /usr/ports/Templates
> ...



It Works.  

However, it seems that with more complex software it will be necessary to have the ports tree downloaded. So it is better to have space and a good partitioning plan to have the resources to compile from the sources. The scenario would be for small boxes or limited resources. With minimal tty and/or Xorg based applications this does work. Thanks a lot to all of you for helping me.


----------

