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