[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
|
---|
[639e34d] | 37 | wget http://patches.cross-lfs.org/dev/ --no-remove-listing
|
---|
[c7ef534] | 38 | PATCH_NUM=$(cat index.html | grep readline | grep "${VERSION}" | grep branch_update | cut -f2 -d'"' | cut -f1 -d'"'| cut -f4 -d- | cut -f1 -d. | tail -n 1)
|
---|
| 39 | PATCH_NUM=$(expr ${PATCH_NUM} + 1)
|
---|
| 40 | rm -f index.html
|
---|
| 41 |
|
---|
[06dcdf6] | 42 | # Cleanup Directory
|
---|
| 43 | #
|
---|
[d8a9d8b] | 44 | cd ~/tmp
|
---|
[06dcdf6] | 45 | rm -rf readline-${VERSION} readline-${VERSION}.orig
|
---|
| 46 | tar xvf readline-${VERSION}.tar.gz
|
---|
| 47 | cp -ar readline-${VERSION} readline-${VERSION}.orig
|
---|
| 48 |
|
---|
| 49 | # Download and Apply Patches
|
---|
| 50 | #
|
---|
[d8a9d8b] | 51 | install -d ~/tmp/readline-${VERSION}-patches
|
---|
| 52 | cd ~/tmp/readline-${VERSION}
|
---|
| 53 | CURRENTDIR=$(pwd -P)
|
---|
[06dcdf6] | 54 | PATCHURL=ftp://ftp.cwru.edu/pub/bash/readline-${VERSION}-patches
|
---|
| 55 | mkdir /tmp/readline-${VERSION}
|
---|
| 56 | COUNT=1
|
---|
| 57 | while [ ${COUNT} -le ${FILES} ]; do
|
---|
[d8a9d8b] | 58 | cd ~/tmp/readline-${VERSION}
|
---|
[9676bac] | 59 | DLCOUNT="${COUNT}"
|
---|
| 60 | SKIPME=no
|
---|
| 61 | if [ "${COUNT}" -lt "100" ]; then
|
---|
| 62 | DLCOUNT="0${COUNT}"
|
---|
| 63 | fi
|
---|
| 64 | if [ "${COUNT}" -lt "10" ]; then
|
---|
| 65 | DLCOUNT="00${COUNT}"
|
---|
| 66 | fi
|
---|
| 67 | for skip in ${SKIPPATCH} ; do
|
---|
| 68 | if [ "${DLCOUNT}" = "$skip" ]; then
|
---|
| 69 | echo "Patch readline${VERSION2}-${DLCOUNT} skipped"
|
---|
| 70 | SKIPPED="${SKIPPED} ${DLCOUNT}"
|
---|
| 71 | SKIPME=yes
|
---|
| 72 | fi
|
---|
| 73 | done
|
---|
| 74 | if [ "${SKIPME}" != "yes" ]; then
|
---|
| 75 | if ! [ -e ${VERSION}.${DLCOUNT} ]; then
|
---|
[d8a9d8b] | 76 | cd ~/tmp/readline-${VERSION}-patches
|
---|
[9676bac] | 77 | wget --quiet ${PATCHURL}/readline${VERSION2}-${DLCOUNT}
|
---|
| 78 | fi
|
---|
| 79 | cd ${CURRENTDIR}
|
---|
[d8a9d8b] | 80 | patch --dry-run -s -f -Np0 -i ~/tmp/readline-${VERSION}-patches/readline${VERSION2}-${DLCOUNT}
|
---|
[9676bac] | 81 | if [ "$?" = "0" ]; then
|
---|
| 82 | echo "Patch readline${VERSION2}-${DLCOUNT} applied"
|
---|
[d8a9d8b] | 83 | patch -s -Np0 -i ~/tmp/readline-${VERSION}-patches/readline${VERSION2}-${DLCOUNT}
|
---|
[9676bac] | 84 | else
|
---|
| 85 | echo "Patch readline${VERSION2}-${DLCOUNT} not applied"
|
---|
[d8a9d8b] | 86 | rm -f ~/tmp/readline-${VERSION}-patches/readline${VERSION2}-${DLCOUNT}
|
---|
[9676bac] | 87 | SKIPPED="${SKIPPED} ${DLCOUNT}"
|
---|
| 88 | fi
|
---|
| 89 | fi
|
---|
| 90 | COUNT=`expr ${COUNT} + 1`
|
---|
[06dcdf6] | 91 | done
|
---|
| 92 |
|
---|
| 93 | # Cleanup Directory
|
---|
| 94 | #
|
---|
[c0d5090] | 95 | # Cleanup Directory
|
---|
| 96 | #
|
---|
| 97 | for dir in $(find * -type d); do
|
---|
[d8a9d8b] | 98 | cd ~/tmp/readline-${VERSION}/${dir}
|
---|
[9676bac] | 99 | for file in $(find . -name '*~'); do
|
---|
| 100 | rm -f ${file}
|
---|
| 101 | done
|
---|
| 102 | for file in $(find . -name '*.orig'); do
|
---|
| 103 | rm -f ${file}
|
---|
| 104 | done
|
---|
[06dcdf6] | 105 | done
|
---|
[d8a9d8b] | 106 | cd ~/tmp/readline-${VERSION}
|
---|
[2803d79] | 107 | rm -f *~ *.orig
|
---|
[06dcdf6] | 108 |
|
---|
| 109 | # Create Patch
|
---|
| 110 | #
|
---|
[d8a9d8b] | 111 | cd ~/tmp
|
---|
| 112 | echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 113 | echo "Date: `date +%m-%d-%Y`" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 114 | echo "Initial Package Version: ${VERSION}" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 115 | echo "Origin: Upstream" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 116 | echo "Upstream Status: Applied" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 117 | echo "Description: Contains all upstream patches up to ${VERSION}-${FILES}" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
[06dcdf6] | 118 | if [ -n "${SKIPPED}" ]; then
|
---|
[d8a9d8b] | 119 | echo " Thee following patches were skipped" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 120 | echo " ${SKIPPED}" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
[06dcdf6] | 121 | fi
|
---|
[d8a9d8b] | 122 | echo "" >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 123 | diff -Naur readline-${VERSION}.orig readline-${VERSION} >> ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 124 | echo "Created ~/patches/readline-${VERSION}-branch_update-${PATCH_NUM}.patch."
|
---|
| 125 |
|
---|
| 126 | # Cleanup Directory
|
---|
| 127 | #
|
---|
| 128 | cd ~/tmp
|
---|
| 129 | rm -rf readline-${VERSION} readline-${VERSION}.orig
|
---|