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