source: scripts/fetch/binutils.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: 4.3 KB
Line 
1#!/bin/bash
2# Create a Binutils Tarball
3
4# Get Version #
5#
6VERSION=$1
7
8# Check Input
9#
10if [ "${VERSION}" = "" ]; then
11 echo "$0 - Binutils_Version"
12 echo "This will Create a Tarball for Binutils Binutils_Version"
13 echo "Example $0 2.19.51"
14 exit 255
15fi
16
17# Clear out old Directory
18#
19rm -rf ~/tmp
20
21# Set Patch Directory
22#
23PATCH_DIR=$(pwd -P)/binutils
24
25# Get Current binutils from SVN
26#
27install -d ~/tmp
28cd ~/tmp
29echo "Pulling latest Binutils trunk from CVS..."
30cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src export -rHEAD binutils
31
32# Set Patch Number
33#
34cd ~/tmp
35wget http://svn.cross-lfs.org/svn/repos/patches/binutils/ --no-remove-listing
36for num in $(seq 1 99); do
37 PATCH_NUM=$(cat index.html | grep "${VERSION}" | grep fixes-${num}.patch | cut -f2 -d'"' | cut -f1 -d'"'| cut -f4 -d- | cut -f1 -d. | tail -n 1)
38 if [ "${PATCH_NUM}" = "0" -a "${num}" = "1" ]; then
39 PATCH_NUM=$(expr ${PATCH_NUM} + 1)
40 break
41 fi
42 if [ "${PATCH_NUM}" != "${num}" ]; then
43 PATCH_NUM=$(expr ${num})
44 break
45 fi
46done
47rm -f index.html
48
49# Customize the version string, so we know it's patched
50#
51cd ~/tmp
52mv src binutils-${VERSION}
53DL_DATE=$(date +%Y%m%d)
54cd ~/tmp/binutils-${VERSION}
55sed -i "s:@PKGVERSION@:(GNU Binutils for Cross-LFS - Retrieved on ${DL_DATE}) :" bfd/Makefile.in
56
57# Remove Files not needed
58#
59cd ~/tmp/binutils-${VERSION}
60FILE_LIST=".cvsignore"
61for files in ${FILE_LIST}; do
62 REMOVE=$(find * -name ${files})
63 for file in $REMOVE; do
64 rm -f ${file}
65 done
66done
67
68# Create a copy of the Original Directory So We can do some Updates
69#
70cd ~/tmp
71cp -ar binutils-${VERSION} binutils-${VERSION}.orig
72
73# Apply Patches from directories
74#
75cd ~/tmp/binutils-${VERSION}
76if [ -e ${PATCH_DIR}/${VERSION} ]; then
77 PATCH_FILES=$(ls ${PATCH_DIR}/${VERSION}/*.patch)
78 if [ "${PATCH_FILES}" != "" ]; then
79 for pfile in ${PATCH_FILES}; do
80 echo "Applying - ${pfile}..."
81 for pvalue in $(seq 0 5); do
82 patch --dry-run -Np${pvalue} -i ${pfile} > /dev/null 2>&1
83 if [ "${?}" = "0" ]; then
84 PVALUE=${pvalue}
85 break
86 fi
87 done
88 if [ "${PVALUE}" != "" ]; then
89 patch -Np${PVALUE} -i ${pfile}
90 else
91 echo "Patch: ${pfile} Failed to Apply..."
92 exit 255
93 fi
94 done
95 fi
96fi
97
98# Cleanup Directory
99#
100for dir in $(find * -type d); do
101 cd ~/tmp/binutils-${VERSION}
102 for file in $(find . -name '*~'); do
103 rm -f ${file}
104 done
105 for file in $(find . -name '*.orig'); do
106 rm -f ${file}
107 done
108 for file in $(find . -name '*.rej'); do
109 rm -f ${file}
110 done
111done
112cd ~/tmp/binutils-${VERSION}
113rm -rf *.orig *~ *.rej
114
115# Create Patch
116#
117diff -Naur ~/tmp/binutils-${VERSION} ~/tmp/binutils-${VERSION}.orig >> ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch
118if [ "$(cat ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch)" != "" ]; then
119 cd ~/tmp/binutils-${VERSION}
120 install -d ~/public_html/
121 echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch
122 echo "Date: `date +%m-%d-%Y`" >> ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch
123 echo "Initial Package Version: ${VERSION}" >> ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch
124 echo "Origin: Upstream" >> ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch
125 echo "Upstream Status: Applied" >> ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch
126 echo "Description: These are fixes binutils-${VERSION}, and should be" >> ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch
127 echo " rechecked periodically." >> ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch
128 echo "" >> ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch
129 diff -Naur ~/tmp/binutils-${VERSION} ~/tmp/binutils-${VERSION}.orig >> ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch
130 echo "Created ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch."
131else
132 rm ~/public_html/binutils-${VERSION}-fixes-${PATCH_NUM}.patch
133fi
134
135# Remove Patched Copy
136#
137cd ~/tmp
138rm -rf binutils-${VERSION}
139mv binutils-${VERSION}.orig binutils-${VERSION}
140
141# Compress
142#
143cd ~/tmp
144install -d ~/packages
145echo "Creating Tarball for Binutils ${VERSION}...."
146tar cjf ~/packages/binutils-${VERSION}-${DL_DATE}.tar.bz2 binutils-${VERSION}
147
148# Clean up Directores
149#
150cd ~/tmp
151rm -rf binutils-${VERSION}
Note: See TracBrowser for help on using the repository browser.