# Difference between Freebsd-update and csup to apply patches



## alelab (Jul 2, 2009)

Hi,

I have noticed anything strange with freebsd-update and csup.

I have recently updated my system (with custom kernel) to 7.2-RELEASE-p2 with the commands
# freebsd-update fetch install
# nextboot -k GENERIC
# shutdown -r now
# make buildkernel KERNCONF=MYKERNEL
# make installkernel KERNCONF=MYKERNEL

But I have noticed that if I do a csup to synchronize sources, files like /usr/src/sys/dev/bce/if_bce.c (and 5 more files) have been synchronized.
After that, if I #freebsd-update fetch the same files were downloaded to.
I have verified the date of the files when they are downloaded with csup and freebsd-update.
The files are more recent whith freebsd-update (1st july). The file when downloaded by csup is dated from the end of june (24th it seems to me).

I use the freebsd-update.conf by default (no modification to the file).
I have tested csup with cvsup5.fr.freebsd.org and cvsup6.fr.freebsd.org with the same result.

Why the files have got diferent date ?
Have I jumped a step ?
Or is there anything I have misunderstood in the update process ?

Thanks in advance for your lights


----------



## danger@ (Jul 2, 2009)

freebsd-update(8) is a tool the purpose of which is to provoide a *binary* updates for your system. It does not support custom kernels (only GENERIC). It does not touch files in /usr/src/.

On the other hand, csup(1) is a tool that synchronizes your source tree (/usr/src/), which you can later use to build your own world and (custom) kernel.

It is not common to use both.


----------



## DutchDaemon (Jul 2, 2009)

Note that freebsd-update can be used to get sources:


```
# Components of the base system which should be kept updated.
Components src world kernel

# Example for updating the userland and the kernel source code only:
# Components src/base src/sys world
```

I guess you could have a purpose-built kernel in coexistence with the GENERIC kernel if you use nextboot(8) or some loader variables.


----------



## harishankar (Jul 2, 2009)

I've not found any documentation on how to upgrade *binary* packages in FreeBSD added with pkg_add. Is there any way to do this without ports? Or should installed binary packages be upgraded using portupgrade?

The manual doesn't tell anything about how to go about this.


----------



## DutchDaemon (Jul 2, 2009)

That is quite a deviation from the topic ... Let's keep it short.

1. portupgrade -PP option (portupgrade(1)) can be used; you'll need a local ports tree for that.
2. sysutils/bsdadminscripts contains a pkg_upgrade script.


----------



## harishankar (Jul 2, 2009)

Thanks. I was under the impression that portupgrade also does package updates.


----------



## DutchDaemon (Jul 2, 2009)

It does, as stated, with the correct flags.


----------



## alelab (Jul 3, 2009)

Thanks for your replies 

My configuration is the one posted by DutchDaemon

```
# Components of the base system which should be kept updated. 
Components src world kernel
```
Have you ever experienced my findings or not ?
I have read the handbook to know how apply patches to my system, and it is writtent that I can apply patches to my system even to a system that use a custom kernel. That is why I do 
	
	



```
# nextboot -k GENERIC
```
 because *freebsd-update* can only apply patches to this kernel. After I rebuild my custom kernel with sources get by *freebsd-update*.
My question was why some files are more recent when I get source with *freebsd-update*, than when I use *csup* ?


----------



## danger@ (Jul 3, 2009)

Here's the reply from the creator of freebsd-update(8):



			
				&quot said:
			
		

> 10:53:44 <@cperciva> DanGer: freebsd-update updates source code now
> 10:54:11 <@cperciva> DanGer: the recommended solution for people with custom kernels is to use freebsd-update to update src + world, then do a buildkernel
> 10:55:38 <@cperciva> DanGer: as for the question of file modification time -- freebsd-update doesn't play games with mtime, so his July 1st is just when he ran freebsd-update
> 10:56:35 <@cperciva> DanGer: the source code he gets via freebsd-update should be identical to what he gets via csup and RELENG_7_2 except for $FreeBSD$ strings, since freebsd-update patches are created before the CVS commits are done (and thus before we know what will be in those $FreeBSD$ tags)


----------



## alelab (Jul 3, 2009)

Thanks for your valuable help :stud

If I have well understood the recommended solution described by Colin Percival, I have properly followed it in my upgrade steps.
The parameter "Component Kernel" in the configuration file, apply upgrade to GENERIC kernel only (found in the Handbook). Then I have to boot on this kernel to compile my custom kernel with updated sources. But maybe the reboot on the GENERIC kernel can be jumped in the security patches case (also it is written to boot on this kernel if I do a major or minor upgrade but nothing in the security patches case).


----------



## danger@ (Jul 3, 2009)

You don't have to boot GENERIC in order to build a custom kernel from updated sources.

Note that some security advisories affect kernel too; you should read carefully each security advisory for recommended ways to update your system.


----------



## alelab (Jul 6, 2009)

In my previous post, I was talking about the *freebsd-update* tool.
But I read each security adisory to know what it affects.

I want to really thanks you for your help. I have tried to explain the situation the most clearly as possible, and you helped me really well. 
Thanks again Danger@, Colin Percival & DutchDaemon


----------



## noodlefling (Nov 23, 2009)

danger@ said:
			
		

> Here's the reply from the creator of freebsd-update(8):
> 
> 
> 
> ...



Just trying to understand exactly what this means...

So, I should be able to use freebsd-update in the general case of security patches, with the knowledge that if I ever do a proper rebuild of the world, I will have all the freshest source?

*And* it's OK to use a custom kernel with freebsd-update, as long as, just to be safe, I rebuild the kernel after every freebsd-update (which I do anyway to change the version info in /etc/motd)?

Is that all accurate, or am I making things more complex than necessary?


----------



## jb_fvwm2 (Nov 23, 2009)

Your first question needs a more detailed answer than
I can suggest, but AFAIK if you use a custom kernel,
freebsd-update is not to be used (unless one 
somehow has dual kernels residing somewhere, dual
paths to build directories, etc..) (guessing)


----------



## Dru (Nov 23, 2009)

If youve only built your kernel once, and have kernel.old in /boot. You should be able to rename kernel.old to GENERIC, and use freebsd-update, then rebuild the kernel afterwards, if i understand correctly. 

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/updating-upgrading-freebsdupdate.html

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/updating-upgrading-freebsdupdate.html#FREEBSDUPDATE-UPGRADE

But who knows, I think most of everything I post around here trying to be helpful is wrong. And sorry if this is wandering a little off topic.



> The freebsd-update utility can automatically update the GENERIC kernel only. If a custom kernel is in use, it will have to be rebuilt and reinstalled after freebsd-update finishes installing the rest of the updates. However, freebsd-update will detect and update the GENERIC kernel in /boot/GENERIC (if it exists), even if it is not the current (running) kernel of the system.


----------



## danger@ (Nov 23, 2009)

yes, just do a normal procedure of build/install{world,kernel} every time you use freebsd-update.

I think it may be possible to use freebsd-update for userland advisories while normal source upgrade in case of custom kernel advisories. Never tried that though.


----------



## DutchDaemon (Nov 23, 2009)

Building _world_ does not seem to be necessary, or is it? I think the installed world and the source code in /usr/src/ are always in synch when using freebsd-update, so building the kernel should be all that's needed when running a custom kernel.


----------



## vivek (Nov 23, 2009)

You can mix both as quoted from IRC logs. But, I prefer to stick to one method. It is easier to use buildworld+buildkernl as I do customize both heavily. If you have lots of freebsd boxes. You can roll out your own build server and just sync with your own upstream.


----------



## fender0107401 (Nov 23, 2009)

DutchDaemon said:
			
		

> Building _world_ does not seem to be necessary, or is it? I think the installed world and the source code in /usr/src/ are always in synch when using freebsd-update, so building the kernel should be all that's needed when running a custom kernel.



I only used freebsd-update a few times, but I think after run freebsd-update the userland and gen-kernel (if it exist in /boot/kernel) is updated, and if freebsd-update can manage /usr/src, only customized kernel need to to recompile.



			
				vivek said:
			
		

> You can mix both as quoted from IRC logs. But, I prefer to stick to one method. It is easier to use buildworld+buildkernl as I do customize both heavily. If you have lots of freebsd boxes. You can roll out your own build server and just sync with your own upstream.



I think you are right, and I always "cd /usr/src; make update" and re-compile everything.


----------



## noodlefling (Nov 24, 2009)

So...if I understand everyone correctly, a simple freebsd-update will handle everything if the most recent advisory doesn't include the kernel.  In this case, even if you have a custom kernel, everything should be fine, right?

If the kernel is involved with the update, then you do need to do that manually?  Is that right?

Also, freebsd-update will keep your source freshened up, so if you ever do need recompile the source manually, it will all be up to date?

Or am I mixing my apples with my oranges?


----------

