Index: scripts/patch/ncurses-patch.sh
===================================================================
--- scripts/patch/ncurses-patch.sh	(revision 57b3f19b23cfc82bd90fe220d304f2e52f3dae68)
+++ scripts/patch/ncurses-patch.sh	(revision 20a0aa0ccb8c794cf5227b9de66cbb2326fe6d88)
@@ -1,7 +1,7 @@
-#!/bin/bash
-# Create a Ncuruses Patch
+#!/bin/sh
+# Jonathan Norman
 
-# Get Version #
-#
+# Ncurses branch update patch generator
+
 VERSION=$1
 
@@ -9,125 +9,62 @@
 #
 if [ "${VERSION}" = "" ]; then
-  echo "$0 - Ncurses_Version"
-  echo "This will Create a Patch for Ncurses Ncurses_Version"
+  echo "$0 [ncurses_version]"
+  echo "This will Create a Patch for ncurses ncurses_Version"
   exit 255
 fi
 
-# Get Patch Names
-#
-cd ~/tmp
-wget ftp://invisible-island.net/ncurses/${VERSION}/ --no-remove-listing
-ROLLUP=$(cat index.html | grep bz2 | cut -f2 -d'>' | cut -f1 -d'<' | tail -n 1)
-ROLLPATCH=$(echo ${ROLLUP} | cut -f3 -d-)
-FILES=$(cat index.html | grep ${VERSION}-2 | grep patch.gz | cut -f2 -d'>' | cut -f1 -d'<')
-rm -f .listing
-rm -f index.html
+TMP=~/tmp/ncurses-${VERSION}
+PATCHDIR=${TMP}/patches
+PATCHURL=ftp://invisible-island.net/ncurses/
+SERIES=$(echo ${VERSION} | sed -e 's/\.//g')
+CLFS_PATCHS=http://patches.cross-lfs.org/dev/
 
-# Download Ncurses Source
-#
-cd ~/tmp
-if ! [ -e ncurses-${VERSION}.tar.gz ]; then
-  wget ftp://invisible-island.net/ncurses/ncurses-${VERSION}.tar.gz
-fi
+# Figure out patch number
+UPDATE_NUM=0
+UPDATE_NUM=$(curl -ls http://patches.cross-lfs.org/dev/ | grep ncurses-${VERSION}-branch_update | cut -d . -f 3 | cut -d - -f 3-)
+UPDATE_NUM=$(expr ${UPDATE_NUM} + 1)
 
-# Set Patch Number
-#
-cd ~/tmp
-wget http://svn.cross-lfs.org/svn/repos/patches/ncurses/ --no-remove-listing
-for num in $(seq 1 99); do
-  PATCH_NUM=$(cat index.html | grep "${VERSION}" | grep branch_update-${num}.patch | cut -f2 -d'"' | cut -f1 -d'"'| cut -f4 -d- | cut -f1 -d. | tail -n 1)
-  if [ "${PATCH_NUM}" = "0" -a "${num}" = "1" ]; then
-    PATCH_NUM=$(expr ${PATCH_NUM} + 1)
-    break
-  fi
-  if [ "${PATCH_NUM}" != "${num}" ]; then
-    PATCH_NUM=$(expr ${num})
-    break
-  fi
-done
-rm -f index.html
-
-# Cleanup Directory
-#
-cd ~/tmp
-rm -rf ncurses-${VERSION} ncurses-${VERSION}.orig
-tar xvf ncurses-${VERSION}.tar.gz
-cp -ar ncurses-${VERSION} ncurses-${VERSION}.orig
-
-# Download and Apply Rollup Patch
-#
-cd ~/tmp/ncurses-${VERSION}
-CURRENTDIR=$(pwd -P)
-mkdir ~/tmp/ncurses-${VERSION}-patches
-cd ~/tmp/ncurses-${VERSION}
-if [ "${ROLLUP}" != "" ]; then
-  echo "Getting Rollup ${ROLLUP} Patch..."
-  cd ~/tmp/ncurses-${VERSION}-patches
-  wget --quiet ftp://invisible-island.net/ncurses/${VERSION}/${ROLLUP}
-  cd ${CURRENTDIR}
-  echo "Applying Rollup ${ROLLUP} Patch..."
-  cp ~/tmp/ncurses-${VERSION}-patches/${ROLLUP} ${CURRENTDIR}/${ROLLUP}
-  bunzip2 ${ROLLUP}
-  ROLLUP2=$(echo ${ROLLUP} | sed -e 's/.bz2//g')
-  sh ${ROLLUP2}
-fi
-
-# Download and Apply Patches
-#
-install -d ~/tmp/ncurses-${VERSION}-patches
-cd ~/tmp/ncurses-${VERSION}
-CURRENTDIR=$(pwd -P)
-for file in ${FILES}; do
-  if [ "${ROLLPATCH}" != "" ]; then
-    TEST=$(echo ${file} | grep -c ${ROLLPATCH})
-  else
-    TEST=0
-  fi
-  if [ "${TEST}" = "0" ]; then
-    cd ~/tmp/ncurses-${VERSION}-patches
-    echo "Getting Patch ${file}..."
-    wget --quiet ftp://invisible-island.net/ncurses/${VERSION}/${file}
-    cd ${CURRENTDIR}
-    gunzip -c ~/tmp/ncurses-${VERSION}-patches/${file} | patch --dry-run -s -f -Np1
-    if [ "$?" = "0" ]; then
-      echo "Apply Patch ${file}..."
-      gunzip -c ~/tmp/ncurses-${VERSION}-patches/${file} | patch -Np1
-      LASTFILE=$(echo ${file} | cut -f2 -d. | cut -f2 -d-)
-    fi
-  fi
+# Download patches
+echo "Downloading patches for Ncurses ${VERSION}"
+FILES=$(curl -sl ftp://invisible-island.net/ncurses/${VERSION}/ | grep patch | grep -v bz2 | grep -v asc)
+mkdir -p $PATCHDIR
+cd $PATCHDIR
+for FILE in $FILES; do
+	curl -O -# $PATCHURL/$VERSION/$FILE
 done
 
-# Cleanup Directory
-#
-cd ~/tmp
+
+echo "Downloading source for Ncurses $VERSION"
+cd $TMP
+curl -sO ftp://invisible-island.net/ncurses/ncurses-${VERSION}.tar.gz
+tar -xvf ncurses-${VERSION}.tar.gz
+cp -R ncurses-${VERSION} ncurses-${VERSION}.orig
+
+echo -n "Generating Patch..."
 cd ncurses-${VERSION}
-for dir in $(find * -type d); do
-  cd ~/tmp/ncurses-${VERSION}/${dir}
-  for file in $(find . -name '*~'); do
-    rm -f ${file}
-  done
-  for file in $(find . -name '*.orig'); do
-    rm -f ${file}
-  done
+
+gunzip -c $PATCHDIR/*.sh.gz | sh
+for PATCH in $(ls $PATCHDIR | grep patch.gz); do
+	gunzip -c $PATCHDIR/$PATCH | patch -Np1
 done
-cd ~/tmp/ncurses-${VERSION}
-rm -f *~ *.orig
 
-# Create Patch
-#
-cd ~/tmp
-echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
-echo "Date: `date +%m-%d-%Y`" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
-echo "Initial Package Version: ${VERSION}" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
-echo "Origin: Upstream" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
-echo "Upstream Status: Applied" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
-echo "Description: This is a branch update for NCurses-${VERSION}, and should be" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
-echo "             rechecked periodically. This patch covers up to ${VERSION}-${LASTFILE}." >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
-echo "" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
-diff -Naur ncurses-${VERSION}.orig ncurses-${VERSION} >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
-echo "Created ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch."
+cd $TMP
 
-# Cleanup Directory
-#
-cd ~/tmp
-rm -rf ncurses-${VERSION} ncurses-${VERSION}.orig
+DATE=$(ls $PATCHDIR | tail -n1 | cut -d- -f3 | cut -d. -f1);
+
+# Create patch
+echo "Submitted By: Jonathan Norman (jonathan at bluesquarelinux dot co dot uk)" > ncurses-${VERSION}-branch_update-$UPDATE_NUM.patch
+echo "Date: `date +%Y-%m-%d`" >> ncurses-${VERSION}-branch_update-$UPDATE_NUM.patch
+echo "Initial Package Version: ${VERSION}" >> ncurses-${VERSION}-branch_update-$UPDATE_NUM.patch
+echo "Origin: Upstream" >> ncurses-${VERSION}-branch_update-$UPDATE_NUM.patch
+echo "Upstream Status: Applied" >> ncurses-${VERSION}-branch_update-$UPDATE_NUM.patch
+echo "Description: Contains all upstream patches up to ${VERSION}-${DATE}" >> ncurses-${VERSION}-branch_update-$UPDATE_NUM.patch
+echo "" >> ncurses-${VERSION}-branch_update-$UPDATE_NUM.patch
+
+LC_ALL=C TZ=UTC0 diff -Naur ncurses-${VERSION}.orig ncurses-${VERSION} >> ncurses-${VERSION}-branch_update-$UPDATE_NUM.patch
+
+echo "Done"
+echo "Cleaning up"
+rm -rf ncurses-${VERSION} ncurses-${VERSION}.orig #ncurses-${VERSION}.tar.bz2
+
+echo "Created: $PWD/ncurses-${VERSION}-branch_update-$UPDATE_NUM.patch"
