source: scripts/patch/binutils-patch.sh@ 79071fa

clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 79071fa 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
RevLine 
[06dcdf6]1#!/bin/bash
2# Create a Binutils Patch
3
4# Get Version #
5#
6VERSION=$1
[06fb515]7SOURCEVERSION=$2
[06dcdf6]8
9# Check Input
10#
[7df856d]11if [ "${VERSION}" = "" -o "${SOURCEVERSION}" = "" ]; then
[9676bac]12 echo "$0 - Binutils_Version"
[06fb515]13 echo "This will Create a Patch for Binutils Binutils_Series Binutils_Version"
[7df856d]14 echo "Example $0 2.19 2.19.1"
[9676bac]15 exit 255
[06dcdf6]16fi
17
[914669c]18# Set Patch Directory
19#
20PATCH_DIR=$(pwd -P)/binutils
21
[06dcdf6]22# Download Binutils Source
23#
[d8a9d8b]24install -d ~/tmp
25cd ~/tmp
[06fb515]26if ! [ -e binutils-${SOURCEVERSION}.tar.bz2 ]; then
27 wget ftp://ftp.gnu.org/gnu/binutils/binutils-${SOURCEVERSION}.tar.bz2
[06dcdf6]28fi
29
[c7ef534]30# Set Patch Number
31#
[d8a9d8b]32cd ~/tmp
[29f6db3]33wget http://svn.cross-lfs.org/svn/repos/patches/binutils/ --no-remove-listing
34for num in $(seq 1 99); do
[4648865]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)
[29f6db3]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
[4648865]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)
[29f6db3]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
[c7ef534]56rm -f index.html
57
[06dcdf6]58# Cleanup Directory
59#
[d8a9d8b]60cd ~/tmp
[06fb515]61rm -rf binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
62tar xvf binutils-${SOURCEVERSION}.tar.bz2
[06dcdf6]63
64# Get Current Updates from CVS
65#
[d8a9d8b]66cd ~/tmp
67mv binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
68CURRENTDIR=$(pwd -P)
[06dcdf6]69FIXEDVERSION=$(echo ${VERSION} | sed -e 's/\./_/g')
70cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src export -rbinutils-${FIXEDVERSION}-branch binutils
[06fb515]71mv src binutils-${SOURCEVERSION}
[06dcdf6]72
73# Cleanup
74#
[d8a9d8b]75cd ~/tmp
[06fb515]76DIRS="binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig"
[06dcdf6]77for DIRECTORY in ${DIRS}; do
[d8a9d8b]78 cd ~/tmp/${DIRECTORY}
[9676bac]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
[06dcdf6]86
[9676bac]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 ..
[06dcdf6]93done
[d8a9d8b]94cd ~/tmp/binutils-${SOURCEVERSION}
95rm -f ~/tmp/binutils-${SOURCEVERSION}.orig/md5.sum
[06dcdf6]96
97# Make Binutils a Release
98#
[d8a9d8b]99cd ~/tmp/binutils-${SOURCEVERSION}
[06dcdf6]100sed -i 's/# RELEASE=y/RELEASE=y/g' bfd/Makefile.am
101sed -i 's/# RELEASE=y/RELEASE=y/g' bfd/Makefile.in
102
[cd317ff]103# Customize the version string, so we know it's patched
104#
[d8a9d8b]105cd ~/tmp/binutils-${SOURCEVERSION}
[08433c1]106DATE_STAMP=$(date +%Y%m%d)
[d8a9d8b]107cd ~/tmp/binutils-${SOURCEVERSION}
[4261659]108sed -i "s:@PKGVERSION@:(GNU Binutils for Cross-LFS - Retrieved on ${DATE_STAMP}) :" bfd/Makefile.in
[cd317ff]109
[06dcdf6]110# Create Patch
111#
[d8a9d8b]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."
[3820147]126
127# Cleanliness is the name of my game!
128#
129unset DATE_STAMP
[d8a9d8b]130
[55439e2]131# Create a copy of the Original Directory So We can do some Updates
[d8a9d8b]132#
133cd ~/tmp
[55439e2]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#
[914669c]144if [ -e ${PATCH_DIR}/${SOURCEVERSION} ]; then
[d8a9d8b]145
146 # Apply Patches from directories
147 #
148 cd ~/tmp/binutils-${SOURCEVERSION}
[914669c]149 PATCH_FILES=$(ls ${PATCH_DIR}/${SOURCEVERSION}/*.patch)
[d8a9d8b]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
[55439e2]168fi
[d8a9d8b]169
[55439e2]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
[d8a9d8b]177
[55439e2]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."
[d8a9d8b]192
193# Cleanup Directory
194#
195cd ~/tmp
196rm -rf binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
Note: See TracBrowser for help on using the repository browser.