• Aucun résultat trouvé

Generating dependencies and recompiling

Dans le document The NetBSD Operating System (Page 65-68)

options PCKBD_LAYOUT="KB_IT"

TheadjustkernelPerl script, which can be found at http://www.feyrer.de/Misc/adjustkernel, analizes the output of dmesg(8) and automatically generates a minimal configuration file. To run it you need to have Perl installed on your system. The installation of new software is described in detail in the Chapter 10. If you want to install Perl now, download the pre-compiled packageperl-5.00404.tgz and write the following command:

# pkg_add perl-5.00404.tgz

Now Perl is installed, configured and ready to work: easier than this it’s impossible...

You can now run the script with:

# cd /sys/arch/i386/conf

# perl adjustkernel GENERIC > MYKERNEL

I tried this script and it worked very well, saving me a lot of manual editing. Beware that the script only configures the available devices: you must still configure manually the other options (eg. Linux emulation, ...)

9.6 Configuring the kernel

When you’ve finished modifying the kernel configuration file (which we’ll callMYKERNEL), you should issue the following command:

# config MYKERNEL

IfMYKERNELcontains no errors, the config(8) program will create the necessary files for the compilation of the kernel, otherwise it will be necessary to correct the errors before running config(8) again.

9.7 Generating dependencies and recompiling

Dependencies generation and kernel compilation is performed by the following commands:

# cd ../compile/MYKERNEL

# make depend

Chapter 9 Compiling the kernel

# make

It can happen that the compilation stops with errors; there can be a variety of reasons but the most common cause is an error in the configuration file which didn’t get caught by config(8). Sometimes the failure is caused by a hardware problem (often faulty RAM chips): the compilation puts a higher stress on the system than most applications do. Another typical error is the following: option B, active, requires option A which is not active.

A full compilation of the kernel can last from some minutes to several hours, depending on the hardware.

See the following table for some examples:

CPU RAM (MB) Approx. time

486 DX2 50 20 1 hour

P166 96 15 minutes

PIII 128 5 minutes

68030/25 8 4 hours

The output of the make command is thenetbsdfile in the compile directory: this file should be copied in the root directory, after saving the previous version.

# mv /netbsd /netbsd.old

# mv netbsd /

Customization can considerably reduce the kernel’s size. In the following examplenetbsd.oldis the install kernel andnetbsdis the new kernel.

-rwxr-xr-x 1 root wheel 1342567 Nov 13 16:47 /netbsd -rwxr-xr-x 1 root wheel 3111739 Sep 27 01:20 /netbsd.old The new kernel is activated after rebooting:

# reboot

9.8 If something went wrong

When the PC is restarted it can happen that the new new kernel doesn’t work as expected or even doesn’t boot at all. Don’t worry: if this happens, just reboot with the previously saved kernel and remove the new one (it is better to reboot “single user”.)

Reboot the machine

Press the space bar at the boot prompt during the 5 seconds countdown boot:

Type

> boot netbsd.old -s

Chapter 9 Compiling the kernel

Now issue the following commands to restore the previous version of the kernel:

# fsck /

# mount /

# mv netbsd.old netbsd

# exit

Chapter 10

The package collection

The NetBSD package collection is a collection of tools that greatly simplify the compilation and installation of a huge quantity of free software for Unix systems. Only one or two commands are required to install a perfectly configured and working package.

The first contact with the NetBSD package system can generate a little confusion: apparently there are different commands that do the same thing. The question is actually very simple: here are two ways to install a program. You can

compile a package from source on your system. This is accomplished using the package collection, which can automatically download the sources from the Internet, compile them, install and configure the program and the documentation with only two commands. The Package Collection consists of a set of makefiles and configuration files which use the standard Unix tools installed with the base system. Another nice feaure of the package system is that it can automatically check the required dependencies and download and install the dependent packages too. The package collection is not installed automatically with the base system because it undergoes frequent updates: the following sections explain how to download and install it on your system. The NetBSD site contains a very thorough technical description of the package system.

install a precompiled and preconfigured version of the program. This is accomplished with the pkgtools set of utilities, which are installed with the base system. This method is faster but less flexible than the previous one (for example, you can’t configure the compile time options.) The pkgtools are also used for the management of the installed programs (both from source and precompiled), which are recorded in a database: you can, for example, list the installed packages, remove a package, etc.

If you only want to install precompiled programs, you don’t need to download the package collection.

The two aforementioned methods both require that someone else has “created a package”, i.e. has ported and configured a program for NetBSD. Although the package collection comprises more that 3500 programs, it is possible that the one that you want is still not included. In this case you can compile it without using the package system and, once you get it working, create a package that can be added to the collection: other users will benefit from your work.

Dans le document The NetBSD Operating System (Page 65-68)