kiss-repository

personal kiss repository
git clone git://git.ckyln.com/~cem/kiss-repository.git
Log | Files | Refs | Submodules | README | LICENSE

build (2317B)


      1 #!/bin/sh -e
      2 
      3 # POSIX install functions, similar to 'install -Dm'
      4 # and 'install -Dm* -t'
      5 kinstall() {
      6     # usage: kinstall 644 file /usr/bin/prog
      7     mkdir -p "${3%/*}"; rmdir "$3" 2>/dev/null ||:
      8     cp "$2" "$3"
      9     [ -d "$3" ] && set -- "$1" "$3/${2##*/}"
     10     chmod "$1" "${3:-$2}"
     11 }
     12 
     13 kinstall_t() {
     14     # usage: kinstall_t 644 /usr/bin prog1 prog2
     15     mod=$1 dir=$2; mkdir -p "$dir"
     16     shift 2
     17     for file; do
     18         cp "$file" "$dir"
     19         chmod "$mod" "$dir/${file##*/}"
     20     done
     21 }
     22 
     23 # Use an out function similar to KISS' log.
     24 out() { printf '\033[1;33m-> \033[1;36mlinux \033[m%s\n' "$@" >&2 ;}
     25 
     26 patch -p1 < kernel-no-perl.patch
     27 
     28 cp .config oldconfig
     29 make olddefconfig
     30 
     31 # Store the build version in a file and a variable.
     32 make kernelrelease > version
     33 read ver < version
     34 
     35 modulepath="$1/usr/lib/modules/$ver/build"
     36 
     37 out "Compiling the kernel"
     38 make
     39 
     40 out "Installing the kernel"
     41 kinstall 644 "$(make -s image_name)" "$1/boot/vmlinuz-$ver"
     42 kinstall 644 System.map              "$1/boot/System.map-$ver"
     43 kinstall 644 .config                 "$1/boot/Config-$ver"
     44 
     45 out "Installing kernel modules"
     46 make INSTALL_MOD_PATH="$1/usr" modules_install
     47 
     48 out "Creating module source directory"
     49 rm -f "${modulepath%/*}/build" "${modulepath%/*}/source"
     50 kinstall_t 644 "$modulepath/arch/x86"        arch/x86/Makefile
     51 kinstall_t 644 "$modulepath/arch/x86/kernel" arch/x86/kernel/asm-offsets.s
     52 kinstall_t 644 "$modulepath/kernel"          kernel/Makefile
     53 kinstall_t 644 "$modulepath/drivers/md"      drivers/md/*.h
     54 kinstall_t 644 "$modulepath/net/mac80211"    net/mac80211/*.h
     55 kinstall_t 755 "$modulepath/tools/objtool"   tools/objtool/objtool
     56 kinstall_t 644 "$modulepath"                 .config Makefile Module.symvers \
     57                                              System.map version vmlinux
     58 
     59 
     60 cp -a scripts          "$modulepath/scripts"
     61 cp -a include          "$modulepath/include"
     62 cp -a arch/x86/include "$modulepath/arch/x86/include"
     63 
     64 find . -name 'Kconfig*' | while read -r file; do
     65     kinstall 644 "$file" "$modulepath/$file"
     66 done
     67 
     68 out "Removing junk"
     69 find -L "${modulepath%/*}" -type l             -exec rm -rf {} +
     70 find    "${modulepath%/*}" -type f -name '*.o' -exec rm -rf {} +
     71 
     72 out "Linking /usr/src/linux to the module directory"
     73 mkdir -p "$1/usr/src"
     74 ln -sf "${modulepath#$1}" "$1/usr/src/linux"
     75 
     76 out Done.