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