1 | #!/bin/bash
|
---|
2 | # Create a Binutils Patch
|
---|
3 |
|
---|
4 | # Get Version #
|
---|
5 | #
|
---|
6 | VERSION=$1
|
---|
7 | SOURCEVERSION=$2
|
---|
8 |
|
---|
9 | # Check Input
|
---|
10 | #
|
---|
11 | if [ "${VERSION}" = "" -o "${SOURCEVERSION}" = "" ]; then
|
---|
12 | echo "$0 - Binutils_Version"
|
---|
13 | echo "This will Create a Patch for Binutils Binutils_Series Binutils_Version"
|
---|
14 | echo "Example $0 2.19 2.19.1"
|
---|
15 | exit 255
|
---|
16 | fi
|
---|
17 |
|
---|
18 | # Set Patch Directory
|
---|
19 | #
|
---|
20 | PATCH_DIR=$(pwd -P)/binutils
|
---|
21 |
|
---|
22 | # Download Binutils Source
|
---|
23 | #
|
---|
24 | install -d ~/tmp
|
---|
25 | cd ~/tmp
|
---|
26 | if ! [ -e binutils-${SOURCEVERSION}.tar.bz2 ]; then
|
---|
27 | wget ftp://ftp.gnu.org/gnu/binutils/binutils-${SOURCEVERSION}.tar.bz2
|
---|
28 | fi
|
---|
29 |
|
---|
30 | # Set Patch Number
|
---|
31 | #
|
---|
32 | cd ~/tmp
|
---|
33 | wget http://svn.cross-lfs.org/svn/repos/patches/binutils/ --no-remove-listing
|
---|
34 | for num in $(seq 1 99); do
|
---|
35 | PATCH_NUM=$(cat index.html | grep "${VERSION}" | grep branch_update-${num} | cut -f2 -d'"' | cut -f1 -d'"'| cut -f4 -d- | cut -f1 -d. | tail -n 1)
|
---|
36 | if [ "${PATCH_NUM}" = "0" -a "${num}" = "1" ]; then
|
---|
37 | PATCH_NUM=$(expr ${PATCH_NUM} + 1)
|
---|
38 | break
|
---|
39 | fi
|
---|
40 | if [ "${PATCH_NUM}" != "${num}" ]; then
|
---|
41 | PATCH_NUM=$(expr ${num})
|
---|
42 | break
|
---|
43 | fi
|
---|
44 | done
|
---|
45 | for num in $(seq 1 99); do
|
---|
46 | PATCH_NUM2=$(cat index.html | grep "${SOURCEVERSION}" | grep fixes-${num} | cut -f2 -d'"' | cut -f1 -d'"'| cut -f4 -d- | cut -f1 -d. | tail -n 1)
|
---|
47 | if [ "${PATCH_NUM2}" = "0" -a "${num}" = "1" ]; then
|
---|
48 | PATCH_NUM2=$(expr ${PATCH_NUM2} + 1)
|
---|
49 | break
|
---|
50 | fi
|
---|
51 | if [ "${PATCH_NUM2}" != "${num}" ]; then
|
---|
52 | PATCH_NUM2=$(expr ${num})
|
---|
53 | break
|
---|
54 | fi
|
---|
55 | done
|
---|
56 | rm -f index.html
|
---|
57 |
|
---|
58 | # Cleanup Directory
|
---|
59 | #
|
---|
60 | cd ~/tmp
|
---|
61 | rm -rf binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
|
---|
62 | tar xvf binutils-${SOURCEVERSION}.tar.bz2
|
---|
63 |
|
---|
64 | # Get Current Updates from CVS
|
---|
65 | #
|
---|
66 | cd ~/tmp
|
---|
67 | mv binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
|
---|
68 | CURRENTDIR=$(pwd -P)
|
---|
69 | FIXEDVERSION=$(echo ${VERSION} | sed -e 's/\./_/g')
|
---|
70 | cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src export -rbinutils-${FIXEDVERSION}-branch binutils
|
---|
71 | mv src binutils-${SOURCEVERSION}
|
---|
72 |
|
---|
73 | # Cleanup
|
---|
74 | #
|
---|
75 | cd ~/tmp
|
---|
76 | DIRS="binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig"
|
---|
77 | for DIRECTORY in ${DIRS}; do
|
---|
78 | cd ~/tmp/${DIRECTORY}
|
---|
79 | FILE_LIST=".cvsignore *.gmo"
|
---|
80 | for files in ${FILE_LIST}; do
|
---|
81 | REMOVE=$(find * -name ${files})
|
---|
82 | for file in $REMOVE; do
|
---|
83 | rm -f ${file}
|
---|
84 | done
|
---|
85 | done
|
---|
86 |
|
---|
87 | REMOVE=".cvsignore MAINTAINERS COPYING.LIBGLOSS COPYING.NEWLIB README-maintainer-mode depcomp
|
---|
88 | ChangeLog compile ltgcc.m4 lt~obsolete.m4 etc/ChangeLog etc/add-log.el etc/add-log.vi"
|
---|
89 | for file in $REMOVE; do
|
---|
90 | rm -f ${file}
|
---|
91 | done
|
---|
92 | cd ..
|
---|
93 | done
|
---|
94 | cd ~/tmp/binutils-${SOURCEVERSION}
|
---|
95 | rm -f ~/tmp/binutils-${SOURCEVERSION}.orig/md5.sum
|
---|
96 |
|
---|
97 | # Make Binutils a Release
|
---|
98 | #
|
---|
99 | cd ~/tmp/binutils-${SOURCEVERSION}
|
---|
100 | sed -i 's/# RELEASE=y/RELEASE=y/g' bfd/Makefile.am
|
---|
101 | sed -i 's/# RELEASE=y/RELEASE=y/g' bfd/Makefile.in
|
---|
102 |
|
---|
103 | # Customize the version string, so we know it's patched
|
---|
104 | #
|
---|
105 | cd ~/tmp/binutils-${SOURCEVERSION}
|
---|
106 | DATE_STAMP=$(date +%Y%m%d)
|
---|
107 | cd ~/tmp/binutils-${SOURCEVERSION}
|
---|
108 | sed -i "s:@PKGVERSION@:(GNU Binutils for Cross-LFS - Retrieved on ${DATE_STAMP}) :" bfd/Makefile.in
|
---|
109 |
|
---|
110 | # Create Patch
|
---|
111 | #
|
---|
112 | cd ~/tmp
|
---|
113 | install -d ~/patches
|
---|
114 | echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
|
---|
115 | echo "Date: `date +%m-%d-%Y`" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
|
---|
116 | echo "Initial Package Version: ${SOURCEVERSION}" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
|
---|
117 | echo "Origin: Upstream" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
|
---|
118 | echo "Upstream Status: Applied" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
|
---|
119 | echo "Description: This is a branch update for binutils-${SOURCEVERSION}, and should be" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
|
---|
120 | echo " rechecked periodically." >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
|
---|
121 | echo "" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
|
---|
122 | echo "This patch was created on ${DATE_STAMP}" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
|
---|
123 | echo "" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
|
---|
124 | diff -Naur binutils-${SOURCEVERSION}.orig binutils-${SOURCEVERSION} >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
|
---|
125 | echo "Created ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch."
|
---|
126 |
|
---|
127 | # Cleanliness is the name of my game!
|
---|
128 | #
|
---|
129 | unset DATE_STAMP
|
---|
130 |
|
---|
131 | # Create a copy of the Original Directory So We can do some Updates
|
---|
132 | #
|
---|
133 | cd ~/tmp
|
---|
134 | rm -rf binutils-${SOURCEVERSION}.orig
|
---|
135 | cp -ar binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
|
---|
136 |
|
---|
137 | # Make testsuite fixes
|
---|
138 | #
|
---|
139 | cd ~/tmp/binutils-${SOURCEVERSION}
|
---|
140 | sed -i -e 's/getline/_getline/' libiberty/testsuite/test-demangle.c
|
---|
141 |
|
---|
142 | # Create fixes patch
|
---|
143 | #
|
---|
144 | if [ -e ${PATCH_DIR}/${SOURCEVERSION} ]; then
|
---|
145 |
|
---|
146 | # Apply Patches from directories
|
---|
147 | #
|
---|
148 | cd ~/tmp/binutils-${SOURCEVERSION}
|
---|
149 | PATCH_FILES=$(ls ${PATCH_DIR}/${SOURCEVERSION}/*.patch)
|
---|
150 | if [ "${PATCH_FILES}" != "" ]; then
|
---|
151 | for pfile in ${PATCH_FILES}; do
|
---|
152 | echo "Applying - ${pfile}..."
|
---|
153 | for pvalue in $(seq 0 5); do
|
---|
154 | patch --dry-run -Np${pvalue} -i ${pfile} > /dev/null 2>&1
|
---|
155 | if [ "${?}" = "0" ]; then
|
---|
156 | PVALUE=${pvalue}
|
---|
157 | break
|
---|
158 | fi
|
---|
159 | done
|
---|
160 | if [ "${PVALUE}" != "" ]; then
|
---|
161 | patch -Np${PVALUE} -i ${pfile}
|
---|
162 | else
|
---|
163 | echo "Patch: ${pfile} Failed to Apply..."
|
---|
164 | exit 255
|
---|
165 | fi
|
---|
166 | done
|
---|
167 | fi
|
---|
168 | fi
|
---|
169 |
|
---|
170 | # Cleanup Directory
|
---|
171 | #
|
---|
172 | cd ~/tmp/binutils-${SOURCEVERSION}
|
---|
173 | rm -f $(find * -name "*~")
|
---|
174 | rm -f $(find * -name "*.orig")
|
---|
175 | rm -f $(find * -name "*.rej")
|
---|
176 | rm -f *.orig *~ *.rej
|
---|
177 |
|
---|
178 | # Create Patch
|
---|
179 | #
|
---|
180 | cd ~/tmp
|
---|
181 | install -d ~/patches
|
---|
182 | echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
|
---|
183 | echo "Date: `date +%m-%d-%Y`" >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
|
---|
184 | echo "Initial Package Version: ${VERSION}" >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
|
---|
185 | echo "Origin: Upstream" >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
|
---|
186 | echo "Upstream Status: Applied" >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
|
---|
187 | echo "Description: This Patch contains fixes for binutils-${SOURCEVERSION}, and should be" >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
|
---|
188 | echo " rechecked periodically." >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
|
---|
189 | echo "" >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
|
---|
190 | diff -Naur binutils-${SOURCEVERSION}.orig binutils-${SOURCEVERSION} >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
|
---|
191 | echo "Created ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch."
|
---|
192 |
|
---|
193 | # Cleanup Directory
|
---|
194 | #
|
---|
195 | cd ~/tmp
|
---|
196 | rm -rf binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
|
---|