How to obtain source for a given pkg

What is the recommended way of obtaining the source for a given pkg from the github freebsd ports tree?

Should I use git clone?

How would I start off if I wanted to build sysutils/atop ?
 
cd /usr/ports/sysutils/atop
make install clean

If you want to see and/or play with the source code then before building the port:

make fetch extract
Thanks, but what I meant was how to get the source from github.
 
You dont usually download single ports because of dependencies you download the whole tree.
portsnap auto

It is possible to download single port but I bet you need more.

You then build packages from ports.
cd /usr/ports/sysutils/atop
make pkg
Then you can scape packages.
 
You dont usually download single ports because of dependencies you download the whole tree.
portsnap auto

It is possible to download single port but I bet you need more.

You then build packages from ports.
cd /usr/ports/sysutils/atop
make pkg
Then you can scape packages.
It's ages since I built anything and have forgotten about how to get started, so thanks for reminder about portsnap.
 
but you have to have ports under /use/ports.
To be more specific: You can have a port wherever you want it to be - just the missing build and run dependencies of your "somewhere port" are expected to be found in /usr/ports.
 
What is the recommended way of obtaining the source for a given pkg from the github freebsd ports tree?
So you want a port to build a FreeBSD package, and not just compiling the source of a software; A port assumes an environment: The ports tree. A port may (but mustn't) depend on other ports a) for build, and b) to be executed. If you are willing to solve both dependencies by yourself you could go with just the files of that one port, but: In most cases you won't have much fun with this - some depend on +100 others.

So you're asking of the "recommended way": That is to get the whole ports tree. You could use "git" or "portsnap" to get it, but I would recommend the port/package "gitup" (just execute gitup ports).
 
Are you saying I need to 'git clone' the whole ports tree if I just want to build a single pkg?
If you want to find the source for a package, it takes doing some research.

The FreeBSD ports tree is merely the infrastructure to pull in source tarballs and compile them properly for your system. If you want to read the code of what's inside the tarball itself, you can look the package up on freshports, and see where the tarballs are published. This is where the ports infrastructure downloads the tarball from.

Another way to look at a package source tarball is in /usr/ports/distfiles.

But frankly, I'd recommend getting the whole ports tree in one go. This will save the headaches of hunting down deps later if what you have locally is outdated for the port you want.

Updating any given package - now that's a different bowl of fish, and invites dependency hell. However, that is something that all of Open Source Software is living with - BSD, Linux, you name it. Even Android is not great at updating single apps. Apple and Microsoft are closed source, and have their own ways of dealing with updates. However, they also have other, rather unrelated issues that drove me to FreeBSD...
 
Are you saying I need to 'git clone' the whole ports tree if I just want to build a single pkg?
Pretty much, yes.

The reason is because ports building depends on bsd.port.mk and all the files it includes. There may be tools that allow you to build ports without a ports tree, but at the most basic level, you need the port-building infrastructure in ports/Mk.

Here's the process I use to view the source for a particular package (in this case I'll use poudriere-devel).

1. Look at the Makefile.
2. See where the sources point to – in this case, it has GH_TAGNAME= 3.3.0-1135-g137c376a8
3. Look up that tag on GitHub: https://github.com/freebsd/poudriere/tree/3.3.0-1135-g137c376a8

That's if you want to explore the code online (which I do).

Another option is to use the fetch target to download the source code.
 
Back
Top