# Obtaining source from installation media



## GROND (Jun 6, 2013)

I neglected to select the src distribution when installing 9.1-RELEASE. I don't want to track a development release on this machine, but I ended up needing the source. Where/how would I get the source from the installation DVD?


----------



## Dies_Irae (Jun 6, 2013)

You can find the sources in the usr/freebsd-dist/src.txz archive on the installation media.
To extract it, run `# tar --unlink -xvpJf src.txz -C /` and then you will find your sources in /usr/src.


----------



## ShelLuser (Jun 6, 2013)

There are several ways to achieve this, while I personally think the best way is to make sure you have devel/subversion installed and check out the source out yourself. This way you'll make sure that you have the most up to date version.

Checking out the source is as simple as making sure that you grab the right version. 9.1 Release for example can be easily found. Simply make sure to remember the main system: svn.freebsd.org, and also remember that you normally use svn to utilize a very common protocol, HTTPS, which your browser can use as well.

So here's what I always do:


Open a browser and point it to https://svn.freebsd.org.
Select the 'ViewVC browser' option.
Go where you need to go, in your case /base/release/9.1.0.
Now copy the URL from your browser: http://svnweb.freebsd.org/base/release/9.1.0/.
Realize that we need svn instead of svnweb and HTTPS and you end up with: https://svn.freebsd.org/base/release/9.1.0.
Optionally check for a mirror site from the mirrors webpage. You might actually want to start here.
You manually pieced your URL together, check it out: `# svn co [url=https://svn.freebsd.org/base/release/9.1.0]https://svn.freebsd.org/base/release/9.1.0[/url] /usr/src`
But I know this isn't what you asked, so I'll answer that question as well. Just realize that this is probably the better option since you get the latest version with all the patches and updates.

When you install FreeBSD all you're doing is actually extracting a few archives 

So the answer is simple: mount the CD or DVD and simply go look for the archives. You'll find them (from the base of CD) right here: usr/freebsd-dist, you'll want the src.txz archive: `$ tar xvzf /mnt/usr/freebsd-dist/src.tgx`.

If you execute that command from your FreeBSD root then the archive contents will end right up on their rightful place at /usr/src, with the assumption that you mounted your CD (or DVD) at /mnt.


----------



## GROND (Jun 6, 2013)

Thank you. For some reason I missed the freebsd-dist directory on the disc. I knew there was an archive on there, but for some reason I couldn't find it.

I have Subversion and have checked out a development branch before. But it seems like I can use it to sync with the -RELEASE sources? If so, that's what I'll do.


----------



## kpa (Jun 6, 2013)

The releng/9.1 branch is the SVN branch you want to use if you want the sources for 9.1-RELEASE.

`svn co [url=https://svn.freebsd.org/base/releng/9.1]https://svn.freebsd.org/base/releng/9.1[/url] /usr/src`

Use of release/9.1.0 is strongly discouraged because that branch will never receive any bugfixes or security updates. Think of it as a "snapshot" from the time of the release.


----------



## jozze (Jun 6, 2013)

ShelLuser said:
			
		

> There are several ways to achieve this, while I personally think the best way is to make sure you have devel/subversion installed and check out the source out yourself. This way you'll make sure that you have the most up to date version.



I agree with @ShelLuser. Port devel/subversion is a great tool, and even if the updates for -RELENG aren't released often, you can use it for your ports tree as well. Consider following this post, but only for the ports (since following the RELENG has already been described here).


----------



## GROND (Jun 7, 2013)

Is the use of devel/subversion for the ports tree advantageous over the portsnap mechanism?

I plan on tracking the 9-STABLE release in the short future, for which I will of course use svn, but for now I only need to compile a kernel module (an nvidia driver), and I don't have the time to devote to a rebuild. In fact, the reason I chose not to install the src distribution at install time was because I planned to track 9-STABLE, but I hadn't anticipated needing the source  this soon (foolish, I know).

Is there any advantage to using svn for releng/9.1 over the archive on the dvd?


----------



## wblock@ (Jun 7, 2013)

If you're planning on tracking STABLE, might as well start now.  The only disadvantage to SVN is that it takes more disk space because of the history.  Some people say portsnap(8) is faster, but it has not seemed that way to me.


----------



## jb_fvwm2 (Jun 7, 2013)

One can also write small wrappers for `svn`

```
#!/bin/sh -x
svn up /usr/ports/$1 | tee -a /tmp/svn_up.log
# usage: sh svn_wrapper.sh devel OR devel/boost-libs ...
```
For one or several ports, once the ports tree is `svn-`ified.


----------



## wblock@ (Jun 7, 2013)

But update the whole ports tree.  Updating just subdirectories will lead to problems.


----------



## jb_fvwm2 (Jun 7, 2013)

Here, it is typically updated with `svn` daily. But once a week or so just a port or category, for which I wrote that wrapper... if there is no time at the moment to do a full `svn`--port rebuild cycle...


----------



## jozze (Jun 7, 2013)

Well in my opinion, portsnap is faster, but it does keep another copy of the entire ports tree under /var. Then again, svn is a large port. But if you plan on tracking -STABLE, you'll need svn anyway and then there is no need to keep two tools that essentially do the same job.

Also, portsnap might 1) have an occasional hiccup, and 2) is not giving the true current version of ports (usually it's a few hours behind). With svn, you get the "freshest" of the fresh.

Back to the speed comparison: svn is slower, especially if there are lot of updates (if you didn't update your ports tree in like 3 days), otherwise it's pretty cool. You feel the sluggishness especially on the beginning: when you do `# svn up /usr/{ports,src}` for example, on the beginning just halts for a while. I guess it's checking for changes port by port whereas portsnap just takes the snapshot. But maybe it's just a feeling. I haven't used portsnap for quite a while now and I don't even keep it in my world anymore, so maybe I'm not the one to talk about it


----------



## kpa (Jun 7, 2013)

There's one quite significant advantage in using portsnap(8). You get an up to date INDEX file every time you update your ports tree and the construction of the INDEX file doesn't take too many seconds because the all the time consuming indexing work is done beforehand for you. With svn(1) you'll have to use `make fetchindex` and it's not always guaranteed that the fetched INDEX file actually matches the ports tree you just updated.


----------



## pkubaj (Jun 7, 2013)

No one has suggested it, but there's an alternative to both devel/subversion and portsnap(8) - net/svnup. With the last update (version 0.73) it has the performance near to devel/subversion while having no dependencies that devel/subversion carry.


----------



## jozze (Jun 7, 2013)

As far as I knew, net/svnup was only experimental, or did this change?


----------



## pkubaj (Jun 7, 2013)

It's now good enough to use it on a daily basis.


----------

