[06dcdf6] | 1 | #!/bin/bash
|
---|
| 2 | # Create a GCC Patch
|
---|
| 3 |
|
---|
| 4 | # Get Version #
|
---|
| 5 | #
|
---|
| 6 | VERSION=$1
|
---|
| 7 |
|
---|
| 8 | # Check Input
|
---|
| 9 | #
|
---|
| 10 | if [ "${VERSION}" = "" ]; then
|
---|
[9676bac] | 11 | echo "$0 - GCC_Version"
|
---|
| 12 | echo "This will Create a Patch for GCC GCC_Version"
|
---|
| 13 | exit 255
|
---|
[06dcdf6] | 14 | fi
|
---|
| 15 |
|
---|
[3820147] | 16 | # Set Patch Directory
|
---|
| 17 | #
|
---|
| 18 | PATCH_DIR=$(pwd -P)/gcc
|
---|
| 19 |
|
---|
[06dcdf6] | 20 | # Download GCC Source
|
---|
| 21 | #
|
---|
[d8a9d8b] | 22 | install -d ~/tmp
|
---|
| 23 | cd ~/tmp
|
---|
[06dcdf6] | 24 | if ! [ -e gcc-${VERSION}.tar.bz2 ]; then
|
---|
[0804c00] | 25 | wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-${VERSION}/gcc-${VERSION}.tar.bz2
|
---|
[06dcdf6] | 26 | fi
|
---|
| 27 |
|
---|
[c7ef534] | 28 | # Set Patch Number
|
---|
| 29 | #
|
---|
[d8a9d8b] | 30 | cd ~/tmp
|
---|
[639e34d] | 31 | wget http://patches.cross-lfs.org/dev/ --no-remove-listing
|
---|
[c7ef534] | 32 | PATCH_NUM=$(cat index.html | grep gcc | grep "${VERSION}" | grep branch_update | cut -f2 -d'"' | cut -f1 -d'"'| cut -f4 -d- | cut -f1 -d. | tail -n 1)
|
---|
| 33 | PATCH_NUM=$(expr ${PATCH_NUM} + 1)
|
---|
[3820147] | 34 | PATCH_NUM2=$(cat index.html | grep gcc | grep "${VERSION}" | grep fixes | cut -f2 -d'"' | cut -f1 -d'"'| cut -f4 -d- | cut -f1 -d. | tail -n 1)
|
---|
| 35 | PATCH_NUM2=$(expr ${PATCH_NUM2} + 1)
|
---|
[c7ef534] | 36 | rm -f index.html
|
---|
| 37 |
|
---|
[06dcdf6] | 38 | # Cleanup Directory
|
---|
| 39 | #
|
---|
[d8a9d8b] | 40 | cd ~/tmp
|
---|
[3820147] | 41 | rm -rf gcc-${VERSION} gcc-${VERSION}.orig
|
---|
| 42 | tar xvf gcc-${VERSION}.tar.bz2
|
---|
| 43 | mv gcc-${VERSION} gcc-${VERSION}.orig
|
---|
[06dcdf6] | 44 |
|
---|
| 45 | # Get Current Updates from SVN
|
---|
| 46 | #
|
---|
[d8a9d8b] | 47 | cd ~/tmp
|
---|
[3820147] | 48 | NUM1=$(echo ${VERSION} | cut -f1 -d.)
|
---|
| 49 | NUM2=$(echo ${VERSION} | cut -f2 -d.)
|
---|
| 50 | FIXEDVERSION=$(echo -n "$NUM1" ; echo -n "_" ; echo -e "$NUM2")
|
---|
| 51 | REVISION=$(svn info svn://gcc.gnu.org/svn/gcc/branches/gcc-${FIXEDVERSION}-branch | grep "Last Changed Rev" | cut -f2 -d: | sed -e 's/ //g')
|
---|
| 52 | svn export svn://gcc.gnu.org/svn/gcc/branches/gcc-${FIXEDVERSION}-branch gcc-${VERSION}
|
---|
[06dcdf6] | 53 |
|
---|
[099bfc2] | 54 | # Add a custom version string
|
---|
[27e5b8e] | 55 | #
|
---|
[d8a9d8b] | 56 | cd ~/tmp
|
---|
[ead347c] | 57 | DATE_STAMP=$(cat gcc-${VERSION}/gcc/DATESTAMP)
|
---|
[f81e00b] | 58 | echo "${VERSION}" > gcc-${VERSION}/gcc/BASE-VER
|
---|
[ead347c] | 59 | sed -i "s:PKGVERSION:\"(GCC for Cross-LFS ${VERSION}.${DATE_STAMP}) \":" gcc-${VERSION}/gcc/version.c
|
---|
[099bfc2] | 60 |
|
---|
[06dcdf6] | 61 | # Cleanup
|
---|
[3820147] | 62 | #
|
---|
[d8a9d8b] | 63 | cd ~/tmp
|
---|
[06dcdf6] | 64 | DIRS="gcc-${VERSION} gcc-${VERSION}.orig"
|
---|
| 65 | for DIRECTORY in ${DIRS}; do
|
---|
[d8a9d8b] | 66 | cd ~/tmp/${DIRECTORY}
|
---|
[d8bd081] | 67 | REMOVE="ABOUT-NLS COPYING COPYING.LIB MAINTAINERS Makefile.def
|
---|
| 68 | Makefile.in Makefile.tpl README README.SCO BUGS FAQ LAST_UPDATED
|
---|
| 69 | MD5SUMS NEWS bugs.html faq.html gcc/BASE-VER gcc/DEV-PHASE
|
---|
[ee54da9] | 70 | gcc/f/BUGS gcc/f/NEWS gcc/gengtype-lex.c INSTALL/binaries.html
|
---|
| 71 | INSTALL/build.html INSTALL/configure.html INSTALL/download.html
|
---|
| 72 | INSTALL/finalinstall.html INSTALL/gfdl.html INSTALL/index.html
|
---|
| 73 | INSTALL/old.html INSTALL/prerequisites.html INSTALL/specific.html
|
---|
| 74 | INSTALL/test.html"
|
---|
[9676bac] | 75 | for file in ${REMOVE}; do
|
---|
| 76 | rm -f $file
|
---|
| 77 | done
|
---|
[d8bd081] | 78 | for file in $(find . -name "ChangeLog*" | sed -e 's@./@@'); do
|
---|
[d8a9d8b] | 79 | rm -fv ${file}
|
---|
[d8bd081] | 80 | done
|
---|
[d8a9d8b] | 81 | REMVOVE_DIRS="INSTALL"
|
---|
| 82 | for dir in ${REMOVE_DIRS}; do
|
---|
| 83 | rm -rfv ${dir}
|
---|
| 84 | done
|
---|
| 85 | rm -fv fastjar/*.{1,info} gcc/doc/*.{1,info,7} gcc/fortran/*.{1,info,7} gcc/po/*.{gmo,po}
|
---|
| 86 | rm -rf libcpp/po/*.{gmo,po} libgomp/*.{1,info,7} libjava/classpath/doc/*.{1,info}
|
---|
| 87 | cd ..
|
---|
[06dcdf6] | 88 | done
|
---|
| 89 |
|
---|
| 90 | # Create Patch
|
---|
| 91 | #
|
---|
[d8a9d8b] | 92 | cd ~/tmp
|
---|
| 93 | install -d ~/patches
|
---|
| 94 | echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 95 | echo "Date: `date +%m-%d-%Y`" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 96 | echo "Initial Package Version: ${VERSION}" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 97 | echo "Origin: Upstream" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 98 | echo "Upstream Status: Applied" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 99 | echo "Description: This is a branch update for gcc-${VERSION}, and should be" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 100 | echo " rechecked periodically." >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 101 | echo "" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 102 | echo "This patch was made from Revision # ${REVISION}." >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 103 | echo "" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 104 | diff -Naur gcc-${VERSION}.orig gcc-${VERSION} >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 105 | echo "Created ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch."
|
---|
[3820147] | 106 |
|
---|
| 107 | # Create Another Copy to create fixes patch
|
---|
| 108 | #
|
---|
[d8a9d8b] | 109 | cd ~/tmp
|
---|
[3820147] | 110 | if [ -e ${PATCH_DIR}/${VERSION} ]; then
|
---|
[d8a9d8b] | 111 | rm -rf gcc-${VERSION}.orig
|
---|
| 112 | cp -ar gcc-${VERSION} gcc-${VERSION}.orig
|
---|
| 113 |
|
---|
| 114 | # Apply Patches from directories
|
---|
| 115 | #
|
---|
| 116 | cd ~/tmp/gcc-${VERSION}
|
---|
[3820147] | 117 | PATCH_FILES=$(ls ${PATCH_DIR}/${VERSION}/*.patch)
|
---|
| 118 | if [ "${PATCH_FILES}" != "" ]; then
|
---|
| 119 | for pfile in ${PATCH_FILES}; do
|
---|
| 120 | echo "Applying - ${pfile}..."
|
---|
| 121 | for pvalue in $(seq 0 5); do
|
---|
| 122 | patch --dry-run -Np${pvalue} -i ${pfile} > /dev/null 2>&1
|
---|
| 123 | if [ "${?}" = "0" ]; then
|
---|
| 124 | PVALUE=${pvalue}
|
---|
| 125 | break
|
---|
| 126 | fi
|
---|
| 127 | done
|
---|
| 128 | if [ "${PVALUE}" != "" ]; then
|
---|
| 129 | patch -Np${PVALUE} -i ${pfile}
|
---|
| 130 | else
|
---|
| 131 | echo "Patch: ${pfile} Failed to Apply..."
|
---|
| 132 | exit 255
|
---|
| 133 | fi
|
---|
| 134 | done
|
---|
| 135 | fi
|
---|
| 136 |
|
---|
[d8a9d8b] | 137 | # Cleanup Directory
|
---|
| 138 | #
|
---|
| 139 | cd ~/tmp/gcc-${VERSION}
|
---|
| 140 | rm -f $(find * -name "*~")
|
---|
| 141 | rm -f $(find * -name "*.orig")
|
---|
| 142 | rm -f $(find * -name "*.rej")
|
---|
| 143 | rm -f *.orig *~ *.rej
|
---|
[3820147] | 144 |
|
---|
[d8a9d8b] | 145 | # Create Patch
|
---|
| 146 | #
|
---|
| 147 | cd ~/tmp
|
---|
| 148 | install -d ~/patches
|
---|
| 149 | echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
| 150 | echo "Date: `date +%m-%d-%Y`" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
| 151 | echo "Initial Package Version: ${VERSION}" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
| 152 | echo "Origin: Upstream" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
| 153 | echo "Upstream Status: Applied" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
| 154 | echo "Description: This Patch contains fixes for gcc-${VERSION}, and should be" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
[960526e] | 155 | echo " rechecked periodically. These patches are not for inclusion in the book" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
| 156 | echo " but for testing purposes only. " >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
[d8a9d8b] | 157 | echo "" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
| 158 | diff -Naur gcc-${VERSION}.orig gcc-${VERSION} >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
| 159 | echo "Created ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch."
|
---|
| 160 | fi
|
---|
[3820147] | 161 |
|
---|
[d8a9d8b] | 162 | # Cleanup Directory
|
---|
[3820147] | 163 | #
|
---|
[d8a9d8b] | 164 | cd ~/tmp
|
---|
| 165 | rm -rf gcc-${VERSION} gcc-${VERSION}.orig
|
---|