Kernel “combinado” de NetBSD (reloaded)
2008-07-20 18:06:57-05
Hacks
Introducción
La laptop que tengo tiene una tarjeta de red inalámbrica Intel PRO/Wireless 3945ABG así como tambien un procesador Intel Duo, que a según dicen tiene doble núcleo y que tambien es bueno para la virtualización “por hardware” del Xen.
El detalle es que con los kernels que trae por default el disco de instalación del NetBSD no puedo ambas cosas:
- GENERIC.MP <- Solamente puedo usar los dos procesadores sin conexión inalámbrica.
- GENERIC_LAPTOP <- Aquí si tengo conexión pero nada más puedo usar un sólo CPU.
El siguiente es un script para reducir los pasos de la compilación del kernel “combinado”.
En lugar de hacer:
- Tomamos una copia del kernel de SMP para el nuevo kernel:
[#] cp GENERIC.MP wanda
- Le agregamos las bondades del kernel para laptops:
[#] cat GENERIC_LAPTOP >> wanda
- Comentamos la siguiente directiva
[#] vi wanda
#include "arch/i386/conf/std.i386"
#include "arch/i386/conf/std.i386"
- Obtenemos las líneas de los errores:
[#] config wanda > wanda-errors.log 2>&1
...
wanda:25: already have options `INCLUDE_CONFIG_FILE=1'
wanda:29: duplicate maxusers parameter
wanda:33: already have options `I486_CPU=1'
wanda:34: already have options `I586_CPU=1'
wanda:35: already have options `I686_CPU=1'
wanda:37: already have makeoptions `CPUFLAGS=-march=i486 -mtune=pentiumpro'
wanda:42: already have options `VM86=1'
wanda:43: already have options `USER_LDT=1'
wanda:46: already have options `ENHANCED_SPEEDSTEP=1'
...
...
wanda:25: already have options `INCLUDE_CONFIG_FILE=1'
wanda:29: duplicate maxusers parameter
wanda:33: already have options `I486_CPU=1'
wanda:34: already have options `I586_CPU=1'
wanda:35: already have options `I686_CPU=1'
wanda:37: already have makeoptions `CPUFLAGS=-march=i486 -mtune=pentiumpro'
wanda:42: already have options `VM86=1'
wanda:43: already have options `USER_LDT=1'
wanda:46: already have options `ENHANCED_SPEEDSTEP=1'
...
- Aislamos el número de línea solamente:
[#] cat wanda-errors.log | sed 's/wanda://' | sed 's/: .*//' > wanda-lines.log
...
25
29
33
34
35
37
42
43
46
...
...
25
29
33
34
35
37
42
43
46
...
- Y comentamos todas esas líneas una por una a mano.
- Mezclamos ambos kernels:
[#] cat GENERIC.MP GENERIC_LAPTOP > wanda
- Corregimos los errores:
[#] preparar_kernel.sh wanda
- Creamos el directorio de compilación:
[#] config wanda
- Nos situamos dentro y compilamos:
[#] cd ../compile/urara
Si es que estamos en
/usr/src/sys/arch/i386/conf
[#] make depend && make
Y listo. Ahora Solamente:
- Renombramos el otro kernel:
[#] mv /netbsd /netbsd.old
- Y situamos nuestro nuevo kernel recien horneadito:
[#] mv netbsd /
- Y reiniciamos para probarlo.
Código fuente
Este es el pedazo de “maravilla”:
#!/bin/ksh
#-------------------------------------------------------------------------------
#
# preparar_kernel.sh: Script para comentar las lineas
# cuando se combinan dos kernels.
#
# Copyright (c) 2008, asarch.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of copyright holders nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#-------------------------------------------------------------------------------
#-----------------------------------------------------------
# Validacion de los argumentos del script
#-----------------------------------------------------------
#
if (( $# == 0 )); then
echo Forma de uso: $0 nombre_del_nuevo_kernel
exit 1
fi
#-----------------------------------------------------------
# Validacion del usuario
#-----------------------------------------------------------
#
if [[ $USER != "root" ]]; then
echo Necesitas ser el root.
exit 1
fi
#-----------------------------------------------------------
# Inicializacion de variables
#-----------------------------------------------------------
#
BASE_DIR="/tmp"
KERN_FILE=$1
ERR_LOG=$BASE_DIR"/"$KERN_FILE".log"
ERR_LINES=$BASE_DIR"/"$KERN_FILE"-err-lines.log"
#-----------------------------------------------------------
#
# Comentamos la siguiente linea
#
# include "arch/i386/conf/std.i386"
#
#-----------------------------------------------------------
#
ex - $KERN_FILE << EOS
/std.i386
s/include/#include/
p
w
EOS
#-----------------------------------------------------------
# Obtenemos los errores
#-----------------------------------------------------------
#
config $KERN_FILE > $ERR_LOG 2>&1
#-----------------------------------------------------------
# Verificamos que se haya podido crear el registro de errores
#-----------------------------------------------------------
#
if [[ ! -e $ERR_LOG ]]; then
echo No se pudo crear el registro de los errores: $ERR_LOG
exit 1
fi
#-----------------------------------------------------------
# Obtenemos las lineas de los errores
#-----------------------------------------------------------
#
SED_CMD="s/${KERN_FILE}://"
cat $ERR_LOG | sed $SED_CMD | sed 's/: .*//' > $ERR_LINES
#-----------------------------------------------------------
# Verificamos que se haya podido crear el registro de las lineas
#-----------------------------------------------------------
#
if [[ ! -e $ERR_LINES ]]; then
echo No se pudo crear el registro de las lineas: $ERR_LINES
exit 1
fi
#-----------------------------------------------------------
# Contamos el total de lineas a procesar
#-----------------------------------------------------------
#
TOTAL=$( wc -l < $ERR_LINES )
#-----------------------------------------------------------
# Verificamos que se hayan encontrado las lineas
#-----------------------------------------------------------
#
if (( $TOTAL == 0 )); then
echo No hay lineas por corregir
exit 1
fi
#-----------------------------------------------------------
# Un hack para que funcione
#-----------------------------------------------------------
#
let "TOTAL--"
I=1
#-----------------------------------------------------------
# Proceso principal
#-----------------------------------------------------------
#
while (( $I <= $TOTAL )); do
LINE=$( head -n $I < $ERR_LINES | tail -n 1 )
echo Editando la linea $LINE
ex - $KERN_FILE << EOS
$LINE
i
#
.
j
p
w
EOS
echo
let "I++"
done
#-------------------------------------------------------------------------------
#
# preparar_kernel.sh: Script para comentar las lineas
# cuando se combinan dos kernels.
#
# Copyright (c) 2008, asarch.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of copyright holders nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#-------------------------------------------------------------------------------
#-----------------------------------------------------------
# Validacion de los argumentos del script
#-----------------------------------------------------------
#
if (( $# == 0 )); then
echo Forma de uso: $0 nombre_del_nuevo_kernel
exit 1
fi
#-----------------------------------------------------------
# Validacion del usuario
#-----------------------------------------------------------
#
if [[ $USER != "root" ]]; then
echo Necesitas ser el root.
exit 1
fi
#-----------------------------------------------------------
# Inicializacion de variables
#-----------------------------------------------------------
#
BASE_DIR="/tmp"
KERN_FILE=$1
ERR_LOG=$BASE_DIR"/"$KERN_FILE".log"
ERR_LINES=$BASE_DIR"/"$KERN_FILE"-err-lines.log"
#-----------------------------------------------------------
#
# Comentamos la siguiente linea
#
# include "arch/i386/conf/std.i386"
#
#-----------------------------------------------------------
#
ex - $KERN_FILE << EOS
/std.i386
s/include/#include/
p
w
EOS
#-----------------------------------------------------------
# Obtenemos los errores
#-----------------------------------------------------------
#
config $KERN_FILE > $ERR_LOG 2>&1
#-----------------------------------------------------------
# Verificamos que se haya podido crear el registro de errores
#-----------------------------------------------------------
#
if [[ ! -e $ERR_LOG ]]; then
echo No se pudo crear el registro de los errores: $ERR_LOG
exit 1
fi
#-----------------------------------------------------------
# Obtenemos las lineas de los errores
#-----------------------------------------------------------
#
SED_CMD="s/${KERN_FILE}://"
cat $ERR_LOG | sed $SED_CMD | sed 's/: .*//' > $ERR_LINES
#-----------------------------------------------------------
# Verificamos que se haya podido crear el registro de las lineas
#-----------------------------------------------------------
#
if [[ ! -e $ERR_LINES ]]; then
echo No se pudo crear el registro de las lineas: $ERR_LINES
exit 1
fi
#-----------------------------------------------------------
# Contamos el total de lineas a procesar
#-----------------------------------------------------------
#
TOTAL=$( wc -l < $ERR_LINES )
#-----------------------------------------------------------
# Verificamos que se hayan encontrado las lineas
#-----------------------------------------------------------
#
if (( $TOTAL == 0 )); then
echo No hay lineas por corregir
exit 1
fi
#-----------------------------------------------------------
# Un hack para que funcione
#-----------------------------------------------------------
#
let "TOTAL--"
I=1
#-----------------------------------------------------------
# Proceso principal
#-----------------------------------------------------------
#
while (( $I <= $TOTAL )); do
LINE=$( head -n $I < $ERR_LINES | tail -n 1 )
echo Editando la linea $LINE
ex - $KERN_FILE << EOS
$LINE
i
#
.
j
p
w
EOS
echo
let "I++"
done
Si encuentras un error por favor repórtalo. Muchas gracias.
Permalink: http://www.mononeurona.org/users/entry/asarch/1444
Comentblogs:1.-
vendaval wrote:
recomiendo que también metas el script en un archivo y lo subas a la MN, el editor de blogs se "come" los signos > y < y otras cosillas, por lo que el código podría no funcionar correctamente al obtenerlo con "copy&paste". te estas rifando estos días en los "hacks".
2008-07-21 06:53:24-05
recomiendo que también metas el script en un archivo y lo subas a la MN, el editor de blogs se "come" los signos > y < y otras cosillas, por lo que el código podría no funcionar correctamente al obtenerlo con "copy&paste". te estas rifando estos días en los "hacks".
2008-07-21 06:53:24-05
2.-
asarch wrote:
Si primero editas (creas) la entrada del blog usando el editor web del Seamonkey (el hermano mayor del Firefox) y le aplicas un cambio de fuentes al texto (en este caso el codigo fuente) al estilo "Courier":
Format->Font->Courier
y luego solamente copias y pegas ese texto en el editor del blog de la pagina, curiosamente *SI* te respeta todos esos detalles.
De todas formas voy a hacer una entrada (a manera de directorio) en donde puedas descargar el codigo tal cual.
Suerte :-)
2008-07-21 10:13:02-05
Si primero editas (creas) la entrada del blog usando el editor web del Seamonkey (el hermano mayor del Firefox) y le aplicas un cambio de fuentes al texto (en este caso el codigo fuente) al estilo "Courier":
Format->Font->Courier
y luego solamente copias y pegas ese texto en el editor del blog de la pagina, curiosamente *SI* te respeta todos esos detalles.
De todas formas voy a hacer una entrada (a manera de directorio) en donde puedas descargar el codigo tal cual.
Suerte :-)
2008-07-21 10:13:02-05
3.-
saidjose wrote:
De nuevo mi pregunta amigo por que utilizas la licencia copyright en vez de copyleft o la BSD, se me hace curioso asarch.
2008-07-21 11:15:31-05
De nuevo mi pregunta amigo por que utilizas la licencia copyright en vez de copyleft o la BSD, se me hace curioso asarch.
2008-07-21 11:15:31-05
4.-
asarch wrote:
Te insisto de nuevo: !!!ES LA LICENCIA BSD!!!
Checa las clausulas que uso.
2008-07-21 11:33:10-05
Te insisto de nuevo: !!!ES LA LICENCIA BSD!!!
Checa las clausulas que uso.
2008-07-21 11:33:10-05










