|
|
1.1 root 1: #!/bin/sh 1.1.1.5 ! root 2: # ! 3: # Copyright (c) TrueCrypt Foundation. All rights reserved. ! 4: # ! 5: # Covered by the TrueCrypt License 2.2 the full text of which is contained ! 6: # in the file License.txt included in TrueCrypt binary and source code ! 7: # distribution packages. ! 8: # 1.1 root 9: 1.1.1.5 ! root 10: KERNEL_VER=$(uname -r) 1.1 root 11: 1.1.1.5 ! root 12: TMP=.build.sh.tmp 1.1 root 13: umask 022 14: 15: error () 16: { 17: echo "Error: $*" >&2 18: } 19: 20: check_kernel_version () 21: { 22: M="$1/Makefile" 1.1.1.3 root 23: [ ! -f "$M" ] && return 1 24: 1.1.1.2 root 25: VER=$(grep '^VERSION *=' "$M" | head -n 1 | tr -d ' ' | cut -d'=' -f2) 26: VER=$VER.$(grep '^PATCHLEVEL *=' "$M" | head -n 1 | tr -d ' ' | cut -d'=' -f2) 27: VER=$VER.$(grep '^SUBLEVEL *=' "$M" | head -n 1 | tr -d ' ' | cut -d'=' -f2) 1.1 root 28: 1.1.1.5 ! root 29: [ $VER = $(echo $KERNEL_VER | cut -d- -f1 | cut -d. -f1-3) ] && return 0 1.1 root 30: return 1 31: } 32: 33: # Prerequisites 34: 35: echo "Checking build requirements..." 36: 1.1.1.3 root 37: [ $(id -u) -ne 0 ] && error "Administrator (root) privileges required for kernel source configuration." && exit 1 1.1 root 38: 39: V="" 1.1.1.5 ! root 40: case "$KERNEL_VER" in 1.1 root 41: [01].*) V=1 ;; 42: 2.[0-5].*) V=1 ;; 43: 2.6.[0-4]) V=1 ;; 44: 2.6.[0-4][.-]*) V=1 ;; 45: esac 46: [ "$V" ] && error "TrueCrypt requires Linux kernel 2.6.5 or later" && exit 1 47: 1.1.1.5 ! root 48: KERNEL_SRC=/usr/src/linux-source-$KERNEL_VER ! 49: check_kernel_version "$KERNEL_SRC" || KERNEL_SRC=/usr/src/linux-source-$(echo $KERNEL_VER | cut -d'-' -f1) ! 50: check_kernel_version "$KERNEL_SRC" || KERNEL_SRC=/usr/src/linux-$KERNEL_VER ! 51: check_kernel_version "$KERNEL_SRC" || KERNEL_SRC=/usr/src/linux-$(echo $KERNEL_VER | cut -d'-' -f1) ! 52: check_kernel_version "$KERNEL_SRC" || KERNEL_SRC=/usr/src/kernels/$KERNEL_VER-$(uname -p) 1.1.1.4 root 53: check_kernel_version "$KERNEL_SRC" || KERNEL_SRC=/usr/src/linux 54: 55: if ! check_kernel_version "$KERNEL_SRC" 1.1 root 56: then 1.1.1.5 ! root 57: echo -n "Linux kernel ($KERNEL_VER) source directory [$KERNEL_SRC]: " 1.1 root 58: read A 59: [ "$A" ] && KERNEL_SRC="$A" 1.1.1.3 root 60: [ ! -d "$KERNEL_SRC" ] && error "$KERNEL_SRC does not exit" && exit 1 1.1 root 61: fi 62: 63: if ! check_kernel_version "$KERNEL_SRC" 64: then 1.1.1.5 ! root 65: error "Kernel source version in $KERNEL_SRC is not $KERNEL_VER" 1.1 root 66: exit 1 67: fi 68: 1.1.1.4 root 69: if [ ! -f "$KERNEL_SRC/drivers/md/dm.h" ] 70: then 1.1.1.5 ! root 71: error "Kernel source code is incomplete - $KERNEL_SRC/drivers/md/dm.h not found." 1.1.1.4 root 72: exit 1 73: fi 74: 1.1 root 75: if [ ! -f "$KERNEL_SRC/.config" ] 76: then 1.1.1.5 ! root 77: if [ -f /proc/config.gz -o -f /boot/config-$KERNEL_VER -o -f /boot/config-$(uname -r) ] 1.1.1.3 root 78: then 1.1.1.5 ! root 79: echo -n "Configure kernel source according to the system configuration? [Y/n]: " 1.1.1.3 root 80: read A 81: if [ -z "$A" -o "$A" = "y" -o "$A" = "Y" ] 82: then 83: echo -n "Configuring kernel source in $KERNEL_SRC... " 84: 85: if [ -f /proc/config.gz ] 86: then 87: zcat /proc/config.gz >$KERNEL_SRC/.config || exit 1 88: else 1.1.1.5 ! root 89: if [ -f /boot/config-$(uname -r) ] ! 90: then ! 91: cp /boot/config-$(uname -r) $KERNEL_SRC/.config || exit 1 ! 92: else ! 93: cp /boot/config-$KERNEL_VER $KERNEL_SRC/.config || exit 1 ! 94: fi 1.1.1.3 root 95: fi 96: 1.1.1.5 ! root 97: make -C $KERNEL_SRC oldconfig </dev/null >/dev/null || exit 1 1.1.1.3 root 98: echo Done. 99: fi 100: fi 101: 102: if [ ! -f "$KERNEL_SRC/.config" ] 103: then 104: error "Kernel not configured. You should run make -C $KERNEL_SRC config" 105: exit 1 106: fi 107: fi 108: 1.1.1.5 ! root 109: if [ ! -d "$KERNEL_SRC/include/asm" ] && grep -q modules_prepare $KERNEL_SRC/Makefile 1.1.1.3 root 110: then 1.1.1.5 ! root 111: echo -n "Preparing kernel build system in $KERNEL_SRC... " ! 112: if ! make -C $KERNEL_SRC modules_prepare >/dev/null 2>$TMP 1.1.1.3 root 113: then 1.1.1.5 ! root 114: cat $TMP; rm $TMP 1.1.1.3 root 115: exit 1 116: fi 1.1.1.5 ! root 117: rm $TMP ! 118: echo Done. 1.1 root 119: fi 120: 1.1.1.4 root 121: grep -qi 'CONFIG_BLK_DEV_DM=[YM]' $KERNEL_SRC/.config || echo "Warning: kernel device mapper support (CONFIG_BLK_DEV_DM) is disabled in $KERNEL_SRC" 122: 1.1.1.5 ! root 123: if [ ! -d "$KERNEL_SRC/include/asm" -o ! -f "$KERNEL_SRC/Module.symvers" ] 1.1.1.2 root 124: then 1.1.1.5 ! root 125: echo -n "Building internal kernel modules (may take a long time)... " ! 126: if ! make -C $KERNEL_SRC modules >/dev/null 2>$TMP ! 127: then ! 128: cat $TMP; rm $TMP ! 129: exit 1 ! 130: fi ! 131: rm $TMP ! 132: echo Done. ! 133: fi ! 134: ! 135: if [ ! -d "$KERNEL_SRC/include/asm" ] ! 136: then ! 137: error "Kernel source code is not prepared for building of modules - $KERNEL_SRC/include/asm not found." ! 138: exit 1 1.1.1.2 root 139: fi 140: 1.1 root 141: 142: # Build 143: 144: echo -n "Building kernel module... " 145: cd Kernel && make "KERNEL_SRC=$KERNEL_SRC" NO_WARNINGS=1 >/dev/null 146: [ $? -ne 0 ] && error "Failed to build kernel module" && exit 1 147: echo Done. 148: 149: echo -n "Building truecrypt... " 150: cd ../Cli && make NO_WARNINGS=1 >/dev/null 151: [ $? -ne 0 ] && error "Failed to build truecrypt" && exit 1 152: echo Done. 153: 154: exit 0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.