source: scripts/patch/binutils-patch.sh@ c7eb7a2

systemd
Last change on this file since c7eb7a2 was 4648865, checked in by Jim Gifford <clfs@…>, 15 years ago

Really fix the patch scripts.

  • Property mode set to 100755
File size: 6.6 KB
Line 
1#!/bin/bash
2# Create a Binutils Patch
3
4# Get Version #
5#
6VERSION=$1
7SOURCEVERSION=$2
8
9# Check Input
10#
11if [ "${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
16fi
17
18# Set Patch Directory
19#
20PATCH_DIR=$(pwd -P)/binutils
21
22# Download Binutils Source
23#
24install -d ~/tmp
25cd ~/tmp
26if ! [ -e binutils-${SOURCEVERSION}.tar.bz2 ]; then
27 wget ftp://ftp.gnu.org/gnu/binutils/binutils-${SOURCEVERSION}.tar.bz2
28fi
29
30# Set Patch Number
31#
32cd ~/tmp
33wget http://svn.cross-lfs.org/svn/repos/patches/binutils/ --no-remove-listing
34for num in $(seq 1 99); do
35 PATCH_NUM=$(cat index.html | grep "${VERSION}" | grep branch_update-${num}.patch | 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
44done
45for num in $(seq 1 99); do
46 PATCH_NUM2=$(cat index.html | grep "${SOURCEVERSION}" | grep fixes-${num}.patch | 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
55done
56rm -f index.html
57
58# Cleanup Directory
59#
60cd ~/tmp
61rm -rf binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
62tar xvf binutils-${SOURCEVERSION}.tar.bz2
63
64# Get Current Updates from CVS
65#
66cd ~/tmp
67mv binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
68CURRENTDIR=$(pwd -P)
69FIXEDVERSION=$(echo ${VERSION} | sed -e 's/\./_/g')
70cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src export -rbinutils-${FIXEDVERSION}-branch binutils
71mv src binutils-${SOURCEVERSION}
72
73# Cleanup
74#
75cd ~/tmp
76DIRS="binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig"
77for 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 ..
93done
94cd ~/tmp/binutils-${SOURCEVERSION}
95rm -f ~/tmp/binutils-${SOURCEVERSION}.orig/md5.sum
96
97# Make Binutils a Release
98#
99cd ~/tmp/binutils-${SOURCEVERSION}
100sed -i 's/# RELEASE=y/RELEASE=y/g' bfd/Makefile.am
101sed -i 's/# RELEASE=y/RELEASE=y/g' bfd/Makefile.in
102
103# Customize the version string, so we know it's patched
104#
105cd ~/tmp/binutils-${SOURCEVERSION}
106DATE_STAMP=$(date +%Y%m%d)
107cd ~/tmp/binutils-${SOURCEVERSION}
108sed -i "s:@PKGVERSION@:(GNU Binutils for Cross-LFS - Retrieved on ${DATE_STAMP}) :" bfd/Makefile.in
109
110# Create Patch
111#
112cd ~/tmp
113install -d ~/patches
114echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
115echo "Date: `date +%m-%d-%Y`" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
116echo "Initial Package Version: ${SOURCEVERSION}" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
117echo "Origin: Upstream" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
118echo "Upstream Status: Applied" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
119echo "Description: This is a branch update for binutils-${SOURCEVERSION}, and should be" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
120echo " rechecked periodically." >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
121echo "" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
122echo "This patch was created on ${DATE_STAMP}" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
123echo "" >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
124diff -Naur binutils-${SOURCEVERSION}.orig binutils-${SOURCEVERSION} >> ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch
125echo "Created ~/patches/binutils-${SOURCEVERSION}-branch_update-${PATCH_NUM}.patch."
126
127# Cleanliness is the name of my game!
128#
129unset DATE_STAMP
130
131# Create a copy of the Original Directory So We can do some Updates
132#
133cd ~/tmp
134rm -rf binutils-${SOURCEVERSION}.orig
135cp -ar binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
136
137# Make testsuite fixes
138#
139cd ~/tmp/binutils-${SOURCEVERSION}
140sed -i -e 's/getline/_getline/' libiberty/testsuite/test-demangle.c
141
142# Create fixes patch
143#
144if [ -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
168fi
169
170# Cleanup Directory
171#
172cd ~/tmp/binutils-${SOURCEVERSION}
173rm -f $(find * -name "*~")
174rm -f $(find * -name "*.orig")
175rm -f $(find * -name "*.rej")
176rm -f *.orig *~ *.rej
177
178# Create Patch
179#
180cd ~/tmp
181install -d ~/patches
182echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
183echo "Date: `date +%m-%d-%Y`" >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
184echo "Initial Package Version: ${VERSION}" >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
185echo "Origin: Upstream" >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
186echo "Upstream Status: Applied" >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
187echo "Description: This Patch contains fixes for binutils-${SOURCEVERSION}, and should be" >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
188echo " rechecked periodically." >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
189echo "" >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
190diff -Naur binutils-${SOURCEVERSION}.orig binutils-${SOURCEVERSION} >> ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch
191echo "Created ~/patches/binutils-${SOURCEVERSION}-fixes-${PATCH_NUM2}.patch."
192
193# Cleanup Directory
194#
195cd ~/tmp
196rm -rf binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
Note: See TracBrowser for help on using the repository browser.