[06dcdf6] | 1 | #!/bin/bash
|
---|
| 2 | # Create a Binutils Patch
|
---|
| 3 |
|
---|
| 4 | # Get Version #
|
---|
| 5 | #
|
---|
| 6 | VERSION=$1
|
---|
[06fb515] | 7 | SOURCEVERSION=$2
|
---|
[06dcdf6] | 8 |
|
---|
| 9 | # Check Input
|
---|
| 10 | #
|
---|
[7df856d] | 11 | if [ "${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] | 16 | fi
|
---|
| 17 |
|
---|
[914669c] | 18 | # Set Patch Directory
|
---|
| 19 | #
|
---|
| 20 | PATCH_DIR=$(pwd -P)/binutils
|
---|
| 21 |
|
---|
[06dcdf6] | 22 | # Download Binutils Source
|
---|
| 23 | #
|
---|
[d8a9d8b] | 24 | install -d ~/tmp
|
---|
| 25 | cd ~/tmp
|
---|
[06fb515] | 26 | if ! [ -e binutils-${SOURCEVERSION}.tar.bz2 ]; then
|
---|
| 27 | wget ftp://ftp.gnu.org/gnu/binutils/binutils-${SOURCEVERSION}.tar.bz2
|
---|
[06dcdf6] | 28 | fi
|
---|
| 29 |
|
---|
[c7ef534] | 30 | # Set Patch Number
|
---|
| 31 | #
|
---|
[d8a9d8b] | 32 | cd ~/tmp
|
---|
[29f6db3] | 33 | wget http://svn.cross-lfs.org/svn/repos/patches/binutils/ --no-remove-listing
|
---|
| 34 | for 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
|
---|
| 44 | done
|
---|
| 45 | for 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
|
---|
| 55 | done
|
---|
[c7ef534] | 56 | rm -f index.html
|
---|
| 57 |
|
---|
[06dcdf6] | 58 | # Cleanup Directory
|
---|
| 59 | #
|
---|
[d8a9d8b] | 60 | cd ~/tmp
|
---|
[06fb515] | 61 | rm -rf binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
|
---|
| 62 | tar xvf binutils-${SOURCEVERSION}.tar.bz2
|
---|
[06dcdf6] | 63 |
|
---|
| 64 | # Get Current Updates from CVS
|
---|
| 65 | #
|
---|
[d8a9d8b] | 66 | cd ~/tmp
|
---|
| 67 | mv binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
|
---|
| 68 | CURRENTDIR=$(pwd -P)
|
---|
[06dcdf6] | 69 | FIXEDVERSION=$(echo ${VERSION} | sed -e 's/\./_/g')
|
---|
| 70 | cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src export -rbinutils-${FIXEDVERSION}-branch binutils
|
---|
[06fb515] | 71 | mv src binutils-${SOURCEVERSION}
|
---|
[06dcdf6] | 72 |
|
---|
| 73 | # Cleanup
|
---|
| 74 | #
|
---|
[d8a9d8b] | 75 | cd ~/tmp
|
---|
[06fb515] | 76 | DIRS="binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig"
|
---|
[06dcdf6] | 77 | for 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] | 93 | done
|
---|
[d8a9d8b] | 94 | cd ~/tmp/binutils-${SOURCEVERSION}
|
---|
| 95 | rm -f ~/tmp/binutils-${SOURCEVERSION}.orig/md5.sum
|
---|
[06dcdf6] | 96 |
|
---|
| 97 | # Make Binutils a Release
|
---|
| 98 | #
|
---|
[d8a9d8b] | 99 | cd ~/tmp/binutils-${SOURCEVERSION}
|
---|
[06dcdf6] | 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 |
|
---|
[cd317ff] | 103 | # Customize the version string, so we know it's patched
|
---|
| 104 | #
|
---|
[d8a9d8b] | 105 | cd ~/tmp/binutils-${SOURCEVERSION}
|
---|
[08433c1] | 106 | DATE_STAMP=$(date +%Y%m%d)
|
---|
[d8a9d8b] | 107 | cd ~/tmp/binutils-${SOURCEVERSION}
|
---|
[4261659] | 108 | sed -i "s:@PKGVERSION@:(GNU Binutils for Cross-LFS - Retrieved on ${DATE_STAMP}) :" bfd/Makefile.in
|
---|
[cd317ff] | 109 |
|
---|
[06dcdf6] | 110 | # Create Patch
|
---|
| 111 | #
|
---|
[d8a9d8b] | 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."
|
---|
[3820147] | 126 |
|
---|
| 127 | # Cleanliness is the name of my game!
|
---|
| 128 | #
|
---|
| 129 | unset DATE_STAMP
|
---|
[d8a9d8b] | 130 |
|
---|
[55439e2] | 131 | # Create a copy of the Original Directory So We can do some Updates
|
---|
[d8a9d8b] | 132 | #
|
---|
| 133 | cd ~/tmp
|
---|
[55439e2] | 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 | #
|
---|
[914669c] | 144 | if [ -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] | 168 | fi
|
---|
[d8a9d8b] | 169 |
|
---|
[55439e2] | 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
|
---|
[d8a9d8b] | 177 |
|
---|
[55439e2] | 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."
|
---|
[d8a9d8b] | 192 |
|
---|
| 193 | # Cleanup Directory
|
---|
| 194 | #
|
---|
| 195 | cd ~/tmp
|
---|
| 196 | rm -rf binutils-${SOURCEVERSION} binutils-${SOURCEVERSION}.orig
|
---|