Annotation of truecrypt/linux/build.sh, revision 1.1.1.3

1.1       root        1: #!/bin/sh 
                      2: # TrueCrypt build script
                      3: 
                      4: KERNEL_SRC=/usr/src/linux-$(uname -r)
                      5: 
                      6: umask 022
                      7: 
                      8: error ()
                      9: {
                     10:        echo "Error: $*" >&2
                     11: }
                     12: 
                     13: check_kernel_version ()
                     14: {
                     15:        M="$1/Makefile"
1.1.1.3 ! root       16:        [ ! -f "$M" ] && return 1
        !            17:        
1.1.1.2   root       18:        VER=$(grep '^VERSION *=' "$M" | head -n 1 | tr -d ' ' | cut -d'=' -f2)
                     19:        VER=$VER.$(grep '^PATCHLEVEL *=' "$M" | head -n 1 | tr -d ' ' | cut -d'=' -f2)
                     20:        VER=$VER.$(grep '^SUBLEVEL *=' "$M" | head -n 1 | tr -d ' ' | cut -d'=' -f2)
1.1       root       21: 
                     22:        [ $VER = $( uname -r | tr -- - . | cut -d. -f1-3) ] && return 0
                     23:        return 1
                     24: }
                     25: 
                     26: # Prerequisites
                     27: 
                     28: echo "Checking build requirements..."
                     29: 
1.1.1.3 ! root       30: [ $(id -u) -ne 0 ] && error "Administrator (root) privileges required for kernel source configuration." && exit 1
1.1       root       31: 
                     32: V=""
                     33: case "$(uname -r)" in
                     34:        [01].*) V=1 ;;
                     35:        2.[0-5].*) V=1 ;;
                     36:        2.6.[0-4]) V=1 ;;
                     37:        2.6.[0-4][.-]*) V=1 ;;
                     38: esac
                     39: [ "$V" ] && error "TrueCrypt requires Linux kernel 2.6.5 or later" && exit 1
                     40: 
1.1.1.3 ! root       41: [ ! -d "$KERNEL_SRC" ] && KERNEL_SRC=/usr/src/linux
        !            42: if [ ! -d "$KERNEL_SRC" ] || ! check_kernel_version "$KERNEL_SRC"
1.1       root       43: then
                     44:        echo -n "Linux kernel ($(uname -r)) source directory [$KERNEL_SRC]: "
                     45:        read A
                     46:        [ "$A" ] && KERNEL_SRC="$A"
1.1.1.3 ! root       47:        [ ! -d "$KERNEL_SRC" ] && error "$KERNEL_SRC does not exit" && exit 1
1.1       root       48: fi 
                     49: 
                     50: if ! check_kernel_version "$KERNEL_SRC"
                     51: then
                     52:        error "Kernel source version in $KERNEL_SRC is not $(uname -r)"
                     53:        exit 1
                     54: fi
                     55: 
                     56: if [ ! -f "$KERNEL_SRC/.config" ]
                     57: then
1.1.1.3 ! root       58:        if [ -f /proc/config.gz -o -f /boot/config-$(uname -r) ]
        !            59:        then
        !            60:                echo -n "Configure kernel source according to the currently running kernel? [Y/n]: "
        !            61:                read A
        !            62:                if [ -z "$A" -o "$A" = "y" -o "$A" = "Y" ]
        !            63:                then
        !            64:                        echo -n "Configuring kernel source in $KERNEL_SRC... "
        !            65:                        
        !            66:                        if [ -f /proc/config.gz ]
        !            67:                        then
        !            68:                                zcat /proc/config.gz >$KERNEL_SRC/.config || exit 1
        !            69:                        else
        !            70:                                cp /boot/config-$(uname -r) $KERNEL_SRC/.config || exit 1
        !            71:                        fi
        !            72:                        
        !            73:                        make -C $KERNEL_SRC oldconfig >/dev/null || exit 1
        !            74:                        echo Done.
        !            75:                fi
        !            76:        fi
        !            77: 
        !            78:        if [ ! -f "$KERNEL_SRC/.config" ]
        !            79:        then
        !            80:                error "Kernel not configured. You should run make -C $KERNEL_SRC config"
        !            81:                exit 1
        !            82:        fi
        !            83: fi
        !            84: 
        !            85: if [ ! -f "$KERNEL_SRC/scripts/modpost" -a ! -f "$KERNEL_SRC/scripts/mod/modpost" ]
        !            86: then
        !            87:        if grep -q modules_prepare $KERNEL_SRC/Makefile
        !            88:        then
        !            89:                echo -n "Preparing kernel build system in $KERNEL_SRC... "
        !            90:                make -C $KERNEL_SRC modules_prepare >/dev/null || exit 1
        !            91:                echo Done.
        !            92:        else
        !            93:                error "Kernel build system not ready. You should run make -C $KERNEL_SRC modules"
        !            94:                exit 1
        !            95:        fi
1.1       root       96: fi
                     97: 
1.1.1.2   root       98: if [ ! -f "$KERNEL_SRC/drivers/md/dm.h" ]
                     99: then
                    100:        error "Kernel source code is incomplete - header file dm.h not found."
                    101:        exit 1
                    102: fi
                    103: 
1.1       root      104: grep -qi 'CONFIG_BLK_DEV_DM=N' $KERNEL_SRC/.config && echo "Warning: kernel device mapper support (CONFIG_BLK_DEV_DM) is disabled in $KERNEL_SRC" && sleep 5
                    105: 
                    106: 
                    107: # Build
                    108: 
                    109: echo -n "Building kernel module... "
                    110: cd Kernel && make "KERNEL_SRC=$KERNEL_SRC" NO_WARNINGS=1 >/dev/null
                    111: [ $? -ne 0 ] && error "Failed to build kernel module" && exit 1
                    112: echo Done.
                    113: 
                    114: echo -n "Building truecrypt... "
                    115: cd ../Cli && make NO_WARNINGS=1 >/dev/null
                    116: [ $? -ne 0 ] && error "Failed to build truecrypt" && exit 1
                    117: echo Done.
                    118: 
                    119: exit 0

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.