[06dcdf6] | 1 | #!/bin/bash
|
---|
| 2 | # Create a Readline Patch
|
---|
| 3 |
|
---|
| 4 | # Get Version #
|
---|
| 5 | #
|
---|
| 6 | VERSION=$1
|
---|
| 7 |
|
---|
| 8 | # Check Input
|
---|
| 9 | #
|
---|
| 10 | if [ "${VERSION}" = "" ]; then
|
---|
[9676bac] | 11 | echo "$0 - Readline_Version"
|
---|
| 12 | echo "This will Create a Patch for Readline Readline_Version"
|
---|
| 13 | exit 255
|
---|
[06dcdf6] | 14 | fi
|
---|
| 15 |
|
---|
| 16 | # Get the # of Patches
|
---|
| 17 | #
|
---|
[d8a9d8b] | 18 | cd ~/tmp
|
---|
[06dcdf6] | 19 | wget ftp://ftp.cwru.edu/pub/bash/readline-${VERSION}-patches/ --no-remove-listing
|
---|
| 20 | VERSION2=$(echo ${VERSION} | sed -e 's/\.//g')
|
---|
| 21 | FILES=$(cat index.html | grep "${VERSION2}" | cut -f2 -d'"' | cut -f4 -d. | cut -f3 -d- | tail -n 1)
|
---|
| 22 | rm -f .listing
|
---|
| 23 | rm -f index.html
|
---|
| 24 | SKIPPATCH=""
|
---|
| 25 | SKIPPED=""
|
---|
| 26 |
|
---|
[10b98b1] | 27 | # Download Readline Source
|
---|
[06dcdf6] | 28 | #
|
---|
[d8a9d8b] | 29 | cd ~/tmp
|
---|
[06dcdf6] | 30 | if ! [ -e readline-${VERSION}.tar.gz ]; then
|
---|
[9676bac] | 31 | wget ftp://ftp.cwru.edu/pub/bash/readline-${VERSION}.tar.gz
|
---|
[06dcdf6] | 32 | fi
|
---|
| 33 |
|
---|
[c7ef534] | 34 | # Set Patch Number
|
---|
| 35 | #
|
---|
[d8a9d8b] | 36 | cd ~/tmp
|
---|
[29f6db3] | 37 | wget http://svn.cross-lfs.org/svn/repos/patches/readline/ --no-remove-listing
|
---|
| 38 | for num in $(seq 1 99); do
|
---|
[4648865] | 39 | 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)
|
---|
[29f6db3] | 40 | if [ "${PATCH_NUM}" = "0" -a "${num}" = "1" ]; then
|
---|
| 41 | PATCH_NUM=$(expr ${PATCH_NUM} + 1)
|
---|
| 42 | break
|
---|
| 43 | fi
|
---|
| 44 | if [ "${PATCH_NUM}" != "${num}" ]; then
|
---|
| 45 | PATCH_NUM=$(expr ${num})
|
---|
| 46 | break
|
---|
| 47 | fi
|
---|
| 48 | done
|
---|
[c7ef534] | 49 | rm -f index.html
|
---|
| 50 |
|
---|
[06dcdf6] | 51 | # Cleanup Directory
|
---|
| 52 | #
|
---|
[d8a9d8b] | 53 | cd ~/tmp
|
---|
[06dcdf6] | 54 | rm -rf readline-${VERSION} readline-${VERSION}.orig
|
---|
| 55 | tar xvf readline-${VERSION}.tar.gz
|
---|
| 56 | cp -ar readline-${VERSION} readline-${VERSION}.orig
|
---|
| 57 |
|
---|
| 58 | # Download and Apply Patches
|
---|
| 59 | #
|
---|
[d8a9d8b] | 60 | install -d ~/tmp/readline-${VERSION}-patches
|
---|
| 61 | cd ~/tmp/readline-${VERSION}
|
---|
| 62 | CURRENTDIR=$(pwd -P)
|
---|
[06dcdf6] | 63 | PATCHURL=ftp://ftp.cwru.edu/pub/bash/readline-${VERSION}-patches
|
---|
| 64 | mkdir /tmp/readline-${VERSION}
|
---|
| 65 | COUNT=1
|
---|
| 66 | while [ ${COUNT} -le ${FILES} ]; do
|
---|
[d8a9d8b] | 67 | cd ~/tmp/readline-${VERSION}
|
---|
[9676bac] | 68 | DLCOUNT="${COUNT}"
|
---|
| 69 | SKIPME=no
|
---|
| 70 | if [ "${COUNT}" -lt "100" ]; then
|
---|
| 71 | DLCOUNT="0${COUNT}"
|
---|
| 72 | fi
|
---|
| 73 | if [ "${COUNT}" -lt "10" ]; then
|
---|
| 74 | DLCOUNT="00${COUNT}"
|
---|
| 75 | fi
|
---|
| 76 | for skip in ${SKIPPATCH} ; do
|
---|
| 77 | if [ "${DLCOUNT}" = "$skip" ]; then
|
---|
| 78 | echo "Patch readline${VERSION2}-${DLCOUNT} skipped"
|
---|
| 79 | SKIPPED="${SKIPPED} ${DLCOUNT}"
|
---|
| 80 | SKIPME=yes
|
---|
| 81 | fi
|
---|
| 82 | done
|
---|
| 83 | if [ "${SKIPME}" != "yes" ]; then
|
---|
| 84 | if ! [ -e ${VERSION}.${DLCOUNT} ]; then
|
---|
[d8a9d8b] | 85 | cd ~/tmp/readline-${VERSION}-patches
|
---|
[9676bac] | 86 | wget --quiet ${PATCHURL}/readline${VERSION2}-${DLCOUNT}
|
---|
| 87 | fi
|
---|
| 88 | cd ${CURRENTDIR}
|
---|
[d8a9d8b] | 89 | patch --dry-run -s -f -Np0 -i ~/tmp/readline-${VERSION}-patches/readline${VERSION2}-${DLCOUNT}
|
---|
[9676bac] | 90 | if [ "$?" = "0" ]; then
|
---|
| 91 | echo "Patch readline${VERSION2}-${DLCOUNT} applied"
|
---|
[d8a9d8b] | 92 | patch -s -Np0 -i ~/tmp/readline-${VERSION}-patches/readline${VERSION2}-${DLCOUNT}
|
---|
[9676bac] | 93 | else
|
---|
| 94 | echo "Patch readline${VERSION2}-${DLCOUNT} not applied"
|
---|
[d8a9d8b] | 95 | rm -f ~/tmp/readline-${VERSION}-patches/readline${VERSION2}-${DLCOUNT}
|
---|
[9676bac] | 96 | SKIPPED="${SKIPPED} ${DLCOUNT}"
|
---|
| 97 | fi
|
---|
| 98 | fi
|
---|
| 99 | COUNT=`expr ${COUNT} + 1`
|
---|
[06dcdf6] | 100 | done
|
---|
| 101 |
|
---|
| 102 | # Cleanup Directory
|
---|
| 103 | #
|
---|
[c0d5090] | 104 | # Cleanup Directory
|
---|
| 105 | #
|
---|
| 106 | for dir in $(find * -type d); do
|
---|
[d8a9d8b] | 107 | cd ~/tmp/readline-${VERSION}/${dir}
|
---|
[9676bac] | 108 | for file in $(find . -name '*~'); do
|
---|
| 109 | rm -f ${file}
|
---|
| 110 | done
|
---|
| 111 | for file in $(find . -name '*.orig'); do
|
---|
| 112 | rm -f ${file}
|
---|
| 113 | done
|
---|
[06dcdf6] | 114 | done
|
---|
[d8a9d8b] | 115 | cd ~/tmp/readline-${VERSION}
|
---|
[2803d79] | 116 | rm -f *~ *.orig
|
---|
[06dcdf6] | 117 |
|
---|
| 118 | # Create Patch
|
---|
| 119 | #
|
---|
[d8a9d8b] | 120 | cd ~/tmp
|
---|
| 121 | echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 122 | echo "Date: `date +%m-%d-%Y`" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 123 | echo "Initial Package Version: ${VERSION}" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 124 | echo "Origin: Upstream" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 125 | echo "Upstream Status: Applied" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 126 | echo "Description: Contains all upstream patches up to ${VERSION}-${FILES}" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
[06dcdf6] | 127 | if [ -n "${SKIPPED}" ]; then
|
---|
[d8a9d8b] | 128 | echo " Thee following patches were skipped" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 129 | echo " ${SKIPPED}" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
[06dcdf6] | 130 | fi
|
---|
[d8a9d8b] | 131 | echo "" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 132 | diff -Naur readline-${VERSION}.orig readline-${VERSION} >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 133 | echo "Created ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch."
|
---|
| 134 |
|
---|
| 135 | # Cleanup Directory
|
---|
| 136 | #
|
---|
| 137 | cd ~/tmp
|
---|
| 138 | rm -rf readline-${VERSION} readline-${VERSION}.orig
|
---|