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