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