source: /cluster/svnroot/bccd-ng/branches/skylar/bccd-3.4.0/trees/bin/nvidia_build @ 5211

Last change on this file since 5211 was 5211, checked in by skylar, 6 years ago

v3.4.0 needs explicit compat32 libdir re #896

  • Property svn:executable set to *
File size: 3.3 KB
Line 
1#!/bin/bash
2
3# $Id$
4
5set -eo pipefail
6
7# $Id$
8
9FPM="/var/lib/gems/1.9.1/bin/fpm"
10
11function get_bits() {
12    local ARCH=$(uname -m)
13   
14    if [ "${ARCH}" = "x86_64" ]; then
15        BITS=64
16    elif [ "${ARCH}" = "i686" ]; then
17        BITS=32
18    else
19        echo "Unknown architecture ${ARCH}" >&2
20        return 2
21    fi
22
23    echo ${BITS}
24    return 0
25}
26
27function cleanup() {
28    local RC=$1
29    local DIR=$2
30
31    trap - INT TERM EXIT ERR
32
33    if [ ${DEBUG} -eq 1 ] && [ ! -z ${DIR} ] && [ -d ${DIR} ]; then
34        if ! /bin/rm -fr ${DIR}; then
35            echo "Removing ${DIR} failed" >&2
36            RC=$?
37        fi
38    fi
39
40    exit ${RC}
41}
42
43function install_fpm() {
44    /usr/bin/apt-get update
45    /usr/bin/apt-get --force-yes -y install ruby-dev
46    /usr/bin/gem install fpm
47}
48
49function usage() {
50    echo "$(basename $0) -f <nvidia-install-file> -k <kernel-path> -v <deb-version>" >&2
51    exit 1
52}
53
54DEBUG=0
55
56trap 'cleanup $? ${DEBUG} ${NV_TMP}' INT TERM EXIT ERR
57
58if [ "$(whoami)" != "root" ]; then
59    echo "Must be run as root!" >&2
60    usage
61fi
62
63while getopts ":df:k:v:" opt; do
64    case ${opt} in
65        d)
66            DEBUG=1
67            ;;
68        f)
69            FILE=${OPTARG}
70            ;;
71        k)
72            KERNEL_PATH=${OPTARG}
73            ;;
74        v)
75            NV_VER=${OPTARG}
76            ;;
77        \?)
78            usage
79            ;;
80    esac
81done
82
83BCCD_REV=$(/usr/bin/perl -wpl -e \
84    's!^((?:\d+\.){2}\d+).*?$!(!g' \
85    < /etc/bccd-revision)
86
87KERN_REV=$(/bin/uname -r)
88
89# Install fpm if needed
90if [ ! -x ${FPM} ]; then
91    install_fpm
92fi
93
94if [ ${DEBUG} -eq 1 ] ; then
95    FPM="${FPM} --debug --verbose"
96fi
97
98if [ -z ${FILE} ] || [ -z ${KERNEL_PATH} ] || [ -z ${NV_VER} ]; then
99    usage
100    exit 1
101fi
102
103if [ ! -f ${FILE} ]; then
104    echo "Cannot find NVIDIA installer ${FILE}" >&2
105    exit 1
106fi
107
108if [ ! -d ${KERNEL_PATH} ]; then
109    echo "Cannot find kernel path ${KERNEL_PATH}" >&2
110    exit 1
111fi
112
113# Make path to FILE fully-qualified if it is not
114if [[ ! "${FILE}" =~ ^/ ]]; then
115    FILE="$(pwd)/${FILE}"
116fi
117
118BITS=$(get_bits)
119if [ ${BITS} -eq 32 ]; then
120    ARCH="i386"
121elif [ ${BITS} -eq 64 ]; then
122    ARCH="amd64"
123else
124    echo "Unhandled bits ${BITS}" >&2
125    exit 2
126fi
127
128NV_TMP=$(/bin/mktemp -d /tmp/nvidia.XXXXXX)
129NV_DEB="${NV_TMP}/deb"
130
131pushd ${NV_TMP}
132
133/bin/sh ${FILE} -a -x
134
135# NVIDIA extract directory will be the only contents of NV_TMP right now
136NV_DIR=$(/usr/bin/find . -mindepth 1 -maxdepth 1 -type d)
137
138# Make directory hold the temporary files for the .deb package
139/bin/mkdir ${NV_DEB}
140
141pushd ${NV_DIR}
142
143./nvidia-installer \
144    -a \
145    --kernel-source-path=${KERNEL_PATH} \
146    --installer-prefix=${NV_DEB}/usr \
147    --x-prefix=${NV_DEB}/usr \
148    --x-module-path=${NV_DEB}/$(X -showDefaultModulePath 2>&1 ) \
149    --x-library-path=${NV_DEB}/$(X -showDefaultLibPath 2>&1 ) \
150    --opengl-prefix=${NV_DEB}/usr \
151    --utility-prefix=${NV_DEB}/usr \
152    --documentation-prefix=${NV_DEB}/usr \
153    --kernel-install-path=${NV_DEB}/lib/modules/${KERN_REV}/kernel/drivers/video \
154    --no-cc-version-check \
155    --no-opengl-files \
156    --compat32-libdir=/usr/lib32 \
157    --no-check-for-alternate-installs
158
159popd
160
161popd
162
163/bin/rm -f ${NV_DEB}/usr/lib/xorg/modules/libwfb.so
164
165${FPM}  \
166    -n nvidia \
167    -v ${NV_VER}~${BCCD_REV} \
168    -a ${ARCH} \
169    -s dir \
170    -t deb \
171    -C ${NV_DEB} \
172    -d "linux-image-${KERN_REV} = ${BCCD_REV}" \
173    .
Note: See TracBrowser for help on using the repository browser.