print error-message to a file?

Hello,
I've made a custom kernel, but it fails at compiling with an error message.
I just want to print that error in a file but as I'm a newbie to FreeBSD I can't figure it out how to do that.

I tried:
Code:
make KERNCONF=MYKERNEL kernel > file
But that only prints the whole output of the complining process to the file, and stops to print the error message to the screen.

So what do I have to do?
Or is there any error-log for this, I didn't discover yet?

Thanks...
 
It depends somewhat on the shell you are using. If you use bash add 2>&1 to the end of the line. That will redirect STDERR to STDOUT and as a result to your file.

Code:
make buildkernel KERNCONF=MYKERNEL > file 2>&1

For (t)csh you will need to use >&.
Code:
make buildkernel KERNCONF=MYKERNEL > file >&

A simpler approach that will always work is to make use of the script(1) command.
 
Yes, thanks for that lightbulb...
I'll try script(1).
I've read something about it some days ago but somehow it didn't come to my mind. xD
I'm really oblivious...
 
Just the errors?

Code:
make buildkernel KERNCONF=MYKERNEL 2>file

Mind you; without the context leading up to the error, this may be uninformative. better capture everything and cut from it what you need to recognise and/or address the problem.
 
DutchDaemon said:
Just the errors?

Code:
make buildkernel KERNCONF=MYKERNEL 2>file

Mind you; without the context leading up to the error, this may be uninformative. better capture everything and cut from it what you need to recognise and/or address the problem.

Yeah, you are right...the context might be as important es the error itself.
Now I captured everything with script(1).
That's effective and easy :)

By the way...I build my kernel with:
Code:
make KERNCONF=MYKERNEL kernel
What's the difference to:
Code:
make buildkernel KERNCONF=MYKERNEL
?
 
swills said:
There's no difference as far as I know. Personally, I like to set KERNCONF=MYKERNEL in /etc/make.conf.

This file doesn't exist by default, so you have to create it manually?
 
Nokobon said:
By the way...I build my kernel with:
Code:
make KERNCONF=MYKERNEL kernel
What's the difference to:
Code:
make buildkernel KERNCONF=MYKERNEL
?

make kernel runs (in essence) make buildkernel; make installkernel. IOW, the kernel gets installed right away, as soon as it is built.

I prefer to do it in two steps (build, then install) as you can use additional flags like KODIR=/boot/newkernel with the installkernel, to install the new kernel to a separate directory. Then you can use nextboot -k newkernel to configure the system to boot using the new kernel on the next boot only. If something goes wrong, you just reboot, and it comes back up with the working, known-good, /boot/kernel.

A little extra safety protection is always good. :)
 
Nokobon said:
This file doesn't exist by default, so you have to create it manually?

Yes, you can create /etc/make.conf if it doesn't exist.
 
You can try something as follows to save the output:
Code:
script /var/tmp/build.output
make ...
exit
Do not save to /tmp, as it may get clean out after reboot.
 
phoenix said:
make kernel runs (in essence) make buildkernel; make installkernel. IOW, the kernel gets installed right away, as soon as it is built.

I prefer to do it in two steps (build, then install) as you can use additional flags like KODIR=/boot/newkernel with the installkernel, to install the new kernel to a separate directory. Then you can use nextboot -k newkernel to configure the system to boot using the new kernel on the next boot only. If something goes wrong, you just reboot, and it comes back up with the working, known-good, /boot/kernel.

A little extra safety protection is always good. :)
I think nextbootis great and I'll use it in the future when ever I build a kernel.

But first I will trie to build a bad kernel and then remove it using the loader prompt...just for educational purpose.
Practise these things may be a good way to become a sysadmin...^^

Regarding to /etc/make.conf:
I don't really see a reason why I should set KERNCONF=MYKERNEL in /etc/make.conf.
When building a kernel with a new name, it seems to be more complicated to set it in a conf-file than to set it directly in the command...
 
Nokobon said:
Regarding to /etc/make.conf:
I don't really see a reason why I should set KERNCONF=MYKERNEL in /etc/make.conf.
When building a kernel with a new name, it seems to be more complicated to set it in a conf-file than to set it directly in the command...
If you set it in make.conf you don't have to add the KERNCONF= define to make buildkernel and installkernel. Since most people install the same kernel version for each machine it makes sense to put it in make.conf. That way you will always get the correct kernel when doing make installkernel. If KERNCONF isn't defined in make.conf or on the commandline it will install GENERIC.
 
SirDice said:
If you set it in make.conf you don't have to add the KERNCONF= define to make buildkernel and installkernel. Since most people install the same kernel version for each machine it makes sense to put it in make.conf. That way you will always get the correct kernel when doing make installkernel. If KERNCONF isn't defined in make.conf or on the commandline it will install GENERIC.

Okay, so setting KERNCONF in make.conf only makes sense when you install the same kernel on many machines or when you keep the same name for the kernel after editing it.
But I build that kernel only once on one machine so setting KERNCONF on the command-line is less circuitous.
 
Nokobon said:
But I build that kernel only once on one machine so setting KERNCONF on the command-line is less circuitous.
You have to buildkernel etc. when you update, so it'll save typing and you don't have to remember which kernel config you used on that machine :e
 
SirDice said:
You have to buildkernel etc. when you update, so it'll save typing and you don't have to remember which kernel config you used on that machine :e

Okay, I didn't know that I have do rebuild the kernel when I update.
So far I haven't occupied myself with updating, but soon I will to get 7.2 :)
 
Back
Top