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