segunda-feira, 30 de agosto de 2010

compiling the kernel

#!/bin/bash

# This script will download, check, compile and install modules of a chosen kernel
# at a setted directory. You must suply your password for root needed
# actions
 
# set variables
VERSION='2.6.35.4' # what is the kernel version
UNPACKDIR=/usr/src/ # where to unpack
EXTENSION=tar.bz2 # the kernel extension
RC=1 # this will be incremented at every compile
TARGET=/home/geckos/projects/goot # where to copy kernel
T_ROOT=${TARGET}/root # where to install modules
# stop here

SRC=linux-${VERSION}
SRCDIR=${UNPACKDIR}${SRC}
SRCFILE="${SRC}.${EXTENSION}"
CHECKSUM="${SRCFILE}.sign"
LINUX_URL="ftp://ftp.kernel.org/pub/linux/kernel/v2.6"
MAKEOPTION="menuconfig"

for ARG in $@; do
 case $ARG in
 makeopt=*) 
  MAKEOPTION=`echo $ARG | cut -f2 -d=`
 ;;
 unpack)
  sudo rm ${SRCDIR} -r
 ;;
 download)
  rm ${SRCFILE} ${CHECKSUM}
 ;;
 esac
done
  
# check source
chk_src () {
 echo "Checking source ..."
 if [ ! -d "${SRCDIR}" ]; then
  if [ ! -r "${SRCFILE}" ]; then
   wget -c "${LINUX_URL}/${SRCFILE}" || return 1
  fi
  if [ ! -r "${CHECKSUM}" ]; then
   wget -c "${LINUX_URL}/${CHECKSUM}" || return 1

  fi
  gpg2 --keyserver wwwkeys.pgp.net --recv-keys 0x517D0F0E 
  gpg2 --verify ${CHECKSUM} ${SRCFILE} || return 1 
  sudo tar vxf ${SRCFILE} -C ${UNPACKDIR} && return 0 || return 1
 fi
 echo "DONE"
 return 0
}

# build kernel
build () {
 echo "Starting build ..."
 # to install modules at target
 export INSTALL_MOD_PATH=${T_ROOT}
 { sudo make -C ${SRCDIR} mrproper ; } &&
 { sudo make -C ${SRCDIR} ${MAKEOPTION}; } &&
 { sudo make -C ${SRCDIR}; } &&
 { sudo make -C ${SRCDIR} modules_install; } || return 1;
 echo "DONE"
}

# copy files
cpy_files () {
 echo "Copying files..."
 cp ${SRCDIR}/arch/x86/boot/bzImage ${TARGET}vmlinuz-${VERSION} -v;
 cp ${SRCDIR}/.config ${TARGET}config-${VERSION} -v;
 echo "DONE"
}

# increment the RC of this file at every execution 
inc_rc () {
 N=`sed -n 's|^RC=\([0-9]\{1,2\}\)$|\1|p' $0`
 let N++
 sed -e "s|^RC=.*$|RC=$N|" -i $0
}

# main
echo "Start.."
{
 chk_src &&
 build &&
 cpy_files &&
 inc_rc
} &&
echo "Finish" || echo "Fails"

quinta-feira, 26 de agosto de 2010

I like pencil

I bought a new pencil today. Lost the last one so
I have no choise. Also I install slackware 13
(long time ago) at a flash drive and yesterday I
build a boot cd for it based on slackware 13 disk 1
cd. I mix the initrd of flash drive installation
with the slack cd, keeping only the kernels and
isolinux directories on new cd. The final iso gets
only 16mb and with root=/dev/disk parameters can boot a
lot stuff. :-)

terça-feira, 17 de agosto de 2010

I want the POSIX guide book :-P

I want this

Linked list API

Well, working on a general linked list API.
... note: I guess this will be never released, because I'm so lazzyyy! :-(

sexta-feira, 13 de agosto de 2010