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 ~/tmp
|
---|
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 Readline Source
|
---|
28 | #
|
---|
29 | cd ~/tmp
|
---|
30 | if ! [ -e readline-${VERSION}.tar.gz ]; then
|
---|
31 | wget ftp://ftp.cwru.edu/pub/bash/readline-${VERSION}.tar.gz
|
---|
32 | fi
|
---|
33 |
|
---|
34 | # Set Patch Number
|
---|
35 | #
|
---|
36 | cd ~/tmp
|
---|
37 | wget http://patches.cross-lfs.org/dev/ --no-remove-listing
|
---|
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 |
|
---|
42 | # Cleanup Directory
|
---|
43 | #
|
---|
44 | cd ~/tmp
|
---|
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 | #
|
---|
51 | install -d ~/tmp/readline-${VERSION}-patches
|
---|
52 | cd ~/tmp/readline-${VERSION}
|
---|
53 | CURRENTDIR=$(pwd -P)
|
---|
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
|
---|
58 | cd ~/tmp/readline-${VERSION}
|
---|
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
|
---|
76 | cd ~/tmp/readline-${VERSION}-patches
|
---|
77 | wget --quiet ${PATCHURL}/readline${VERSION2}-${DLCOUNT}
|
---|
78 | fi
|
---|
79 | cd ${CURRENTDIR}
|
---|
80 | patch --dry-run -s -f -Np0 -i ~/tmp/readline-${VERSION}-patches/readline${VERSION2}-${DLCOUNT}
|
---|
81 | if [ "$?" = "0" ]; then
|
---|
82 | echo "Patch readline${VERSION2}-${DLCOUNT} applied"
|
---|
83 | patch -s -Np0 -i ~/tmp/readline-${VERSION}-patches/readline${VERSION2}-${DLCOUNT}
|
---|
84 | else
|
---|
85 | echo "Patch readline${VERSION2}-${DLCOUNT} not applied"
|
---|
86 | rm -f ~/tmp/readline-${VERSION}-patches/readline${VERSION2}-${DLCOUNT}
|
---|
87 | SKIPPED="${SKIPPED} ${DLCOUNT}"
|
---|
88 | fi
|
---|
89 | fi
|
---|
90 | COUNT=`expr ${COUNT} + 1`
|
---|
91 | done
|
---|
92 |
|
---|
93 | # Cleanup Directory
|
---|
94 | #
|
---|
95 | # Cleanup Directory
|
---|
96 | #
|
---|
97 | for dir in $(find * -type d); do
|
---|
98 | cd ~/tmp/readline-${VERSION}/${dir}
|
---|
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
|
---|
105 | done
|
---|
106 | cd ~/tmp/readline-${VERSION}
|
---|
107 | rm -f *~ *.orig
|
---|
108 |
|
---|
109 | # Create Patch
|
---|
110 | #
|
---|
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
|
---|
118 | if [ -n "${SKIPPED}" ]; then
|
---|
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
|
---|
121 | fi
|
---|
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
|
---|