gen_kernel_patch 1.07 KB
Newer Older
1 2 3
#!/bin/bash

cat_patch() {
4
  file=${srcdir}/$(basename ${1})
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
  ftype=$(file -bizL "${file}")
  case "$ftype" in
    *application/x-gzip*)
      zcat ${file} ;;
    *application/x-bzip*)
      bzcat ${file} ;;
    *)
      cat ${file} ;;
  esac
}

get_file() {
  file=$(basename ${1})
  OPWD=${PWD}
  if [ "${file}" != "${1}" ]; then
    cd ${SRCDEST}
    [ ! -f ${file} ] && wget -c ${1}
22
    cd ${srcdir}
23
    ln -s ../../_sources/${file} .
24
  else
25
    cd ${srcdir}
26 27 28 29 30 31 32 33 34 35
    ln -s ../patches/${file} .
  fi
  cd ${OPWD}
}

source PATCHCFG

export SRCNAME

export startdir=${PWD}
36 37
mkdir ${srcdir}
cd ${srcdir}
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

get_file ${SRC}
bsdtar -xf $(basename ${SRC})
cp -a ${SRCORIG} ${SRCNAME}
cd ${SRCNAME}

pre_apply

for p in ${PATCHES[@]}; do
  patchname=$(echo ${p} | cut -d% -f1)
  patchstrip=$(echo ${p} | cut -d% -f2)
  get_file ${patchname}
  cat_patch ${patchname} | patch -Np${patchstrip} || exit 1
done

post_apply

Phil's avatar
Phil committed
55 56
rm -v $(find . -type f -name '*.orig')

57
cd ${srcdir}
58 59
diff -Nur ${SRCORIG} ${SRCNAME} > $startdir/${PATCHNAME}
bzip2 --best $startdir/${PATCHNAME}
philm's avatar
philm committed
60
md5sum $startdir/${PATCHNAME}.bz2
61