# Is my /usr/src kept up to date?



## Morris (Sep 9, 2020)

Some time last year I ran into an issue that was solved by having the FreeBSD source in /usr/src. I can't remember what the issue was but extracting the source in that dir solved it.

Now, I have this source sitting there but it looks as if it's not kept up to date, at least not always. The last update seems to be April 2020 if I go by the timestamp on the files as the file UPDATING has that as its date. Most files date back to November 2019. src.txz has a timestamp of 14 March 2020. I have recently installed 12.1-p8 and 12.1-p9 just a few days ago, using freebsd-update(8).

Isn't freebsd-update(8) supposed to also keep the source up to date?

I did, at one point, try to use svn to keep it up to date. That was before I understood that freebsd-update(8) kept the source updated. Did that mess something up? I have never touched freebsd-update.conf and that still says 
	
	



```
Components src world kernel
```
 so it should update source, correct?


----------



## a6h (Sep 9, 2020)

Either user freebsd-update(8) or svn, not both. You've ruined your /usr/src. `rm -fr /usr/src` it and start from scratch.

For future only perform one of these method, not both

>> *METHOD 1*: svnlite(1) or devel/subversion:
/etc/freebsd-update.conf

```
Components world kernel
```
First time:
`svn checkout https://svn.freebsd.org/base/releng/12.1 /usr/src`
Update:
`svn update /usr/src`

>> *METHOD 2*: freebsd-update(8)
/etc/freebsd-update.conf

```
Components src world kernel
```
For update:
`freebsd-update fetch install`

** First you need to extract src to /urs/src
You can find src.txz for different version here:


			Index of /pub/FreeBSD/releases/amd64/
		

`tar -C / -xf src.txz`

*[EDIT] *I'm not familiar with git mechanism for checkout/update src. I hope somebody shine some light on subject with his comment. Thanks!


----------



## Morris (Sep 10, 2020)

Great thanks, I wanted to stick to freebsd-update anyway so that's what I'll do.

I'll delete the existing /usr/src files and download it again.

One thing, though. That tarball at http://ftp-archive.freebsd.org/pub/FreeBSD/releases/amd64/12.1-RELEASE/src.txz is from almost a year ago. If I extract that and subsequently run freebsd-update will it then be updated to the latest source, RELEASE12.1-p9?


----------



## Mjölnir (Sep 10, 2020)

Morris said:


> [...] One thing, though. That tarball at http://ftp-archive.freebsd.org/pub/FreeBSD/releases/amd64/12.1-RELEASE/src.txz is from almost a year ago. If I extract that and subsequently run freebsd-update will it then be updated to the latest source, RELEASE12.1-p9?


Yes, it should do so.


----------



## T-Daemon (Sep 10, 2020)

Morris said:


> One thing, though. That tarball at http://ftp-archive.freebsd.org/pub/FreeBSD/releases/amd64/12.1-RELEASE/src.txz is from almost a year ago. If I extract that and subsequently run freebsd-update will it then be updated to the latest source, RELEASE12.1-p9?


Why bother, download the latest available source:








						GitHub - freebsd/freebsd-src at releng/12.1
					

FreeBSD src tree (read-only mirror). Contribute to freebsd/freebsd-src development by creating an account on GitHub.




					github.com
				




Look for the "Code" marked green button, download zip file.


----------



## Morris (Sep 10, 2020)

OK, I have now used the p9 version as a Zip from Github. That works (though it takes some tries to get the actual URL to feed to curl).

For future occasions, is there also a link to the src.txz file of the latest version somewhere? Instead of getting the zip from Github? A link to a 'RELEASE-12.1-p9.txz', a '/releases/12.1-p9/src.txz' or perhaps a 'latest.txz'?


----------



## T-Daemon (Sep 10, 2020)

Morris said:


> OK, I have now used the p9 version as a Zip from Github. That works (though it takes some tries to get the actual URL to feed to curl).



Have you used `curl -LO ...` ? fetch(1) works good as well.


Morris said:


> For future occasions, is there also a link to the src.txz file of the latest version somewhere? Instead of getting the zip from Github? A link to a 'RELEASE-12.1-p9.txz', a '/releases/12.1-p9/src.txz' or perhaps a 'latest.txz'?



There are no _latest_ snapshots for releng src, at least I'm not aware of such. Only -STABLE or -CURRENT get those src.txz snapshots once a week, together with base and kernel and the other set of packages. The latest src snapshot for releng as a compressed file you get only from GitHub. Does it make a difference if the file is from GitHub? FreeBSD on GitHub is a official mirror.


----------



## Morris (Sep 10, 2020)

I'm not thinking of snapshots. I'm thinking of a URL to a src.txz that just contains the latest stable release. Today that file would contain p9, in six weeks that file might contain p10.

It would mean that you could use that in a script and be sure that it always downloads the most recent stable source code instead of having to change the script on every new release.


----------



## George (Sep 10, 2020)

There is a chapter in the handbook on updating the source as well:


> FreeBSD source code is located in /usr/src/. The preferred method of updating this source is through the Subversion version control system.











						Chapter 25. Updating and Upgrading FreeBSD
					

Information about how to keep a FreeBSD system up-to-date with freebsd-update or Git, how to rebuild and reinstall the entire base system, etc




					www.freebsd.org


----------

