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