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/cross-lfs/trunk/patches/ --no-remove-listing > /dev/null 2>&1
|
---|
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)
|
---|
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)
|
---|
36 | rm -f index.html
|
---|
37 |
|
---|
38 | # Cleanup Directory
|
---|
39 | #
|
---|
40 | cd ~/tmp
|
---|
41 | rm -rf gcc-${VERSION} gcc-${VERSION}.orig
|
---|
42 | tar xvf gcc-${VERSION}.tar.bz2
|
---|
43 | mv gcc-${VERSION} gcc-${VERSION}.orig
|
---|
44 |
|
---|
45 | # Get Current Updates from SVN
|
---|
46 | #
|
---|
47 | cd ~/tmp
|
---|
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}
|
---|
53 |
|
---|
54 | # Add a custom version string
|
---|
55 | #
|
---|
56 | cd ~/tmp
|
---|
57 | DATE_STAMP=$(cat gcc-${VERSION}/gcc/DATESTAMP)
|
---|
58 | echo "${VERSION}" > gcc-${VERSION}/gcc/BASE-VER
|
---|
59 | sed -i "s:PKGVERSION:\"(GCC for Cross-LFS ${VERSION}.${DATE_STAMP}) \":" gcc-${VERSION}/gcc/version.c
|
---|
60 |
|
---|
61 | # Cleanup
|
---|
62 | #
|
---|
63 | cd ~/tmp
|
---|
64 | DIRS="gcc-${VERSION} gcc-${VERSION}.orig"
|
---|
65 | for DIRECTORY in ${DIRS}; do
|
---|
66 | cd ~/tmp/${DIRECTORY}
|
---|
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
|
---|
70 | gcc/f/BUGS gcc/f/NEWS gcc/gengtype-lex.c"
|
---|
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 -fv ${file}
|
---|
76 | done
|
---|
77 | REMVOVE_DIRS="INSTALL"
|
---|
78 | for dir in ${REMOVE_DIRS}; do
|
---|
79 | rm -rfv ${dir}
|
---|
80 | done
|
---|
81 | rm -fv fastjar/*.{1,info} gcc/doc/*.{1,info,7} gcc/fortran/*.{1,info,7} gcc/po/*.{gmo,po}
|
---|
82 | rm -rf libcpp/po/*.{gmo,po} libgomp/*.{1,info,7} libjava/classpath/doc/*.{1,info}
|
---|
83 | cd ..
|
---|
84 | done
|
---|
85 |
|
---|
86 | # Create Patch
|
---|
87 | #
|
---|
88 | cd ~/tmp
|
---|
89 | install -d ~/patches
|
---|
90 | echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
91 | echo "Date: `date +%m-%d-%Y`" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
92 | echo "Initial Package Version: ${VERSION}" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
93 | echo "Origin: Upstream" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
94 | echo "Upstream Status: Applied" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
95 | echo "Description: This is a branch update for gcc-${VERSION}, and should be" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
96 | echo " rechecked periodically." >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
97 | echo "" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
98 | echo "This patch was made from Revision # ${REVISION}." >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
99 | echo "" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
100 | diff -Naur gcc-${VERSION}.orig gcc-${VERSION} >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
101 | echo "Created ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch."
|
---|
102 |
|
---|
103 | # Create Another Copy to create fixes patch
|
---|
104 | #
|
---|
105 | cd ~/tmp
|
---|
106 | if [ -e ${PATCH_DIR}/${VERSION} ]; then
|
---|
107 | rm -rf gcc-${VERSION}.orig
|
---|
108 | cp -ar gcc-${VERSION} gcc-${VERSION}.orig
|
---|
109 |
|
---|
110 | # Apply Patches from directories
|
---|
111 | #
|
---|
112 | cd ~/tmp/gcc-${VERSION}
|
---|
113 | PATCH_FILES=$(ls ${PATCH_DIR}/${VERSION}/*.patch)
|
---|
114 | if [ "${PATCH_FILES}" != "" ]; then
|
---|
115 | for pfile in ${PATCH_FILES}; do
|
---|
116 | echo "Applying - ${pfile}..."
|
---|
117 | for pvalue in $(seq 0 5); do
|
---|
118 | patch --dry-run -Np${pvalue} -i ${pfile} > /dev/null 2>&1
|
---|
119 | if [ "${?}" = "0" ]; then
|
---|
120 | PVALUE=${pvalue}
|
---|
121 | break
|
---|
122 | fi
|
---|
123 | done
|
---|
124 | if [ "${PVALUE}" != "" ]; then
|
---|
125 | patch -Np${PVALUE} -i ${pfile}
|
---|
126 | else
|
---|
127 | echo "Patch: ${pfile} Failed to Apply..."
|
---|
128 | exit 255
|
---|
129 | fi
|
---|
130 | done
|
---|
131 | fi
|
---|
132 |
|
---|
133 | # Cleanup Directory
|
---|
134 | #
|
---|
135 | cd ~/tmp/gcc-${VERSION}
|
---|
136 | rm -f $(find * -name "*~")
|
---|
137 | rm -f $(find * -name "*.orig")
|
---|
138 | rm -f $(find * -name "*.rej")
|
---|
139 | rm -f *.orig *~ *.rej
|
---|
140 |
|
---|
141 | # Create Patch
|
---|
142 | #
|
---|
143 | cd ~/tmp
|
---|
144 | install -d ~/patches
|
---|
145 | echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
146 | echo "Date: `date +%m-%d-%Y`" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
147 | echo "Initial Package Version: ${VERSION}" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
148 | echo "Origin: Upstream" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
149 | echo "Upstream Status: Applied" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
150 | echo "Description: This Patch contains fixes for gcc-${VERSION}, and should be" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
151 | echo " rechecked periodically." >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
152 | echo "" >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
153 | diff -Naur gcc-${VERSION}.orig gcc-${VERSION} >> ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
|
---|
154 | echo "Created ~/patches/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch."
|
---|
155 | fi
|
---|
156 |
|
---|
157 | # Cleanup Directory
|
---|
158 | #
|
---|
159 | cd ~/tmp
|
---|
160 | rm -rf gcc-${VERSION} gcc-${VERSION}.orig
|
---|