<commit_before>#!/bin/sh
#
# DKMS PRE_BUILD script
# Script to be run before a build is performed.
#
# This script checks if the existing loadable kernel module
# needs to be patched. Applies the correct patch if necessary.
#

set -e

echo ""
echo "dkms: Pre-build script started..."
echo ""

if [ ! -z ${1-x} ]
then
	kernelver="$1"
else
    echo "Missing kernelver, can not build"
    exit 2
fi

PACKAGE_NAME="uvcvideo"
PACKAGE_VERSION="1.1.1-2-realsense"

PATCH_DIR="/usr/src/${PACKAGE_NAME}-${PACKAGE_VERSION}/patches/"
PATCH="/dev/null"

# Clean up old source link first
if [ -L linux-src ]
then
    /bin/rm -rf $(readlink linux-src)
    /bin/rm -rf linux-src
fi

echo "Downloading kernel sources..."
# Get the linux kernel and change into source tree
apt-get source linux-image-${kernelver} | egrep -v '^ ' || true
workdir=$(pwd)
cd linux-* 1>/dev/null 2>/dev/null || true
currentdir=$(pwd)
if [ ${workdir} = ${currentdir} ]
then
    echo ""
    echo "ERROR: Could not download kernel sources."
    echo "       Ensure the 'deb-src' entry for your kernel is uncommented"
    echo "       in /etc/apt/sources.list or /etc/apt/sources.list.d/*"
    echo "       then update APT before retrying this package:"
    echo "           sudo apt-get update"
    # See: http://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list"
    echo "       See: http://tinyurl.com/pxbtvh5"
    echo ""
    exit 86
fi

# Create a known path for the kernel sources
/bin/ln -s $(basename $(pwd)) ../linux-src

# Check for uvcvideo patches in drivers/media/usb/uvc/uvc_driver.c
UVC_MODULE_PATH="drivers/media/usb/uvc"
PATCHED_FORMATS=$(/bin/egrep '\((Y8I|Y12I|Z16|RW10|INVZ|INZI|INVR|INRI|INVI|RELI|L8|L16|D16)\)' \
    ${UVC_MODULE_PATH}/uvc_driver.c | /usr/bin/wc -l)
case "${PATCHED_FORMATS}" in
  13)
    echo "INFO: Intel RealSense(TM) F200, SR300, R200, LR200, and ZR300 cameras are already supported."
  ;;
  3)
    PATCH="${PATCH_DIR}/realsense-uvcvideo-add-10-formats.patch"
    echo "INFO: Only Intel RealSense(TM) R200 camera is currently supported."
  ;;
  *)
    PATCH="${PATCH_DIR}/realsense-uvcvideo-add-13-formats.patch"
    echo "INFO: No Intel RealSense(TM) cameras are currently supported."
  ;;
esac

if [ ${PATCH} != "/dev/null" ]
then
    echo "Patching uvcvideo sources..."
    # Apply the one, simple UVC format patch
    patch -p1 < ${PATCH}
fi

# Copy configuration
cp /usr/src/linux-headers-${kernelver}/.config .
cp /usr/src/linux-headers-${kernelver}/Module.symvers .

# Basic build so we can build just the uvcvideo module
# Ensure 'olddefconfig' is first so default choices are selected
make olddefconfig scripts modules_prepare

exit 0
<commit_msg>Provide Debian source package helper script<commit_after>#!/bin/sh
#
# DKMS PRE_BUILD script
# Script to be run before a build is performed.
#
# This script checks if the existing loadable kernel module
# needs to be patched. Applies the correct patch if necessary.
#

set -e

echo ""
echo "dkms: Pre-build script started..."
echo ""

if [ ! -z ${1-x} ]
then
	kernelver="$1"
else
    echo "Missing kernelver, can not build"
    exit 2
fi

PACKAGE_NAME="uvcvideo"
PACKAGE_VERSION="1.1.1-2-realsense"

PATCH_DIR="/usr/src/${PACKAGE_NAME}-${PACKAGE_VERSION}/patches/"
PATCH="/dev/null"

# Clean up old source link first
if [ -L linux-src ]
then
    /bin/rm -rf $(readlink linux-src)
    /bin/rm -rf linux-src
fi

echo "Downloading kernel sources..."
# Get the linux kernel and change into source tree
apt-get source linux-image-${kernelver} | egrep -v '^ ' || true
workdir=$(pwd)
cd linux-* 1>/dev/null 2>/dev/null || true
currentdir=$(pwd)
if [ ${workdir} = ${currentdir} ]
then
    echo ""
    echo "ERROR: Could not download kernel sources."
    echo "       Ensure the 'deb-src' entry for your kernel is uncommented"
    echo "       in /etc/apt/sources.list or /etc/apt/sources.list.d/*"
    echo "       then update APT before retrying this package:"
    echo "           sudo apt-get update"
    echo ""
    echo "       wget -O enable_kernel_sources.sh http://tinyurl.com/zaukmdq"
    echo "       bash ./enable_kernel_sources.sh"
    echo ""
    # See: http://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list"
    echo "       See: http://tinyurl.com/pxbtvh5"
    echo ""
    exit 86
fi

# Create a known path for the kernel sources
/bin/ln -s $(basename $(pwd)) ../linux-src

# Check for uvcvideo patches in drivers/media/usb/uvc/uvc_driver.c
UVC_MODULE_PATH="drivers/media/usb/uvc"
PATCHED_FORMATS=$(/bin/egrep '\((Y8I|Y12I|Z16|RW10|INVZ|INZI|INVR|INRI|INVI|RELI|L8|L16|D16)\)' \
    ${UVC_MODULE_PATH}/uvc_driver.c | /usr/bin/wc -l)
case "${PATCHED_FORMATS}" in
  13)
    echo "INFO: Intel RealSense(TM) F200, SR300, R200, LR200, and ZR300 cameras are already supported."
  ;;
  3)
    PATCH="${PATCH_DIR}/realsense-uvcvideo-add-10-formats.patch"
    echo "INFO: Only Intel RealSense(TM) R200 camera is currently supported."
  ;;
  *)
    PATCH="${PATCH_DIR}/realsense-uvcvideo-add-13-formats.patch"
    echo "INFO: No Intel RealSense(TM) cameras are currently supported."
  ;;
esac

if [ ${PATCH} != "/dev/null" ]
then
    echo "Patching uvcvideo sources..."
    # Apply the one, simple UVC format patch
    patch -p1 < ${PATCH}
fi

# Copy configuration
cp /usr/src/linux-headers-${kernelver}/.config .
cp /usr/src/linux-headers-${kernelver}/Module.symvers .

# Basic build so we can build just the uvcvideo module
# Ensure 'olddefconfig' is first so default choices are selected
make olddefconfig scripts modules_prepare

exit 0

{'fraction_non_alphanumeric': 0.13593974175035867, 'fraction_numerical': 0.020444763271162122, 'mean_word_length': 3.3536299765807964, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5414672', 'n_tokens_mistral': 2069, 'n_tokens_neox': 1970, 'n_words': 551}