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