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