#!/bin/bash

#################################################
# File...: debian.glibc.patcher
# Purpose: Extract & Patch Debian's glibc source
# Author : Stuart Winter <stuart@armedslack.org>
# Date...: 30/01/04
##################################################

# unpack the debian orig source ball
tar zxf ${ORIGPATH}/source/glibc_*orig*
cd glibc*

# Use the Debian script to extract glibc and overlay linuxthreads
/bin/bash prep.sh

# Get the GLIBC version
GLIBCVER="$( find . -type d -name 'glibc-*' -printf "%f\n" )"

# Install the debian directory
zcat ${ORIGPATH}/source/glibc_*diff* | patch -p1

DPATCHES="$( grep -v '^#' debian/patches/00list )"
for pf in ${DPATCHES}; do
    patchf=debian/patches/${pf}.dpatch
    if [ -s ${patchf} ]; then
       chmod 755 ${patchf}
       ${patchf} -patch ${GLIBCVER}
    fi
done

