source: scripts/patch/gcc-patch.sh@ 612f7c4

Last change on this file since 612f7c4 was 4648865, checked in by Jim Gifford <clfs@…>, 15 years ago

Really fix the patch scripts.

  • Property mode set to 100755
File size: 6.4 KB
Line 
1#!/bin/bash
2# Create a GCC Patch
3
4# Get Version #
5#
6VERSION=$1
7
8# Check Input
9#
10if [ "${VERSION}" = "" ]; then
11 echo "$0 - GCC_Version"
12 echo "This will Create a Patch for GCC GCC_Version"
13 exit 255
14fi
15
16# Set Patch Directory
17#
18PATCH_DIR=$(pwd -P)/gcc
19
20# Download GCC Source
21#
22install -d ~/tmp
23cd ~/tmp
24if ! [ -e gcc-${VERSION}.tar.bz2 ]; then
25 wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-${VERSION}/gcc-${VERSION}.tar.bz2
26fi
27
28# Set Patch Number
29#
30cd ~/tmp
31wget http://svn.cross-lfs.org/svn/repos/patches/gcc/ --no-remove-listing
32for num in $(seq 1 99); do
33 PATCH_NUM=$(cat index.html | grep "${VERSION}" | grep branch_update-${num}.patch | 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
42done
43for num in $(seq 1 99); do
44 PATCH_NUM2=$(cat index.html | grep "${SOURCEVERSION}" | grep fixes-${num}.patch | 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
53done
54rm -f index.html
55
56# Cleanup Directory
57#
58cd ~/tmp
59rm -rf gcc-${VERSION} gcc-${VERSION}.orig
60tar xvf gcc-${VERSION}.tar.bz2
61mv gcc-${VERSION} gcc-${VERSION}.orig
62
63# Get Current Updates from SVN
64#
65cd ~/tmp
66NUM1=$(echo ${VERSION} | cut -f1 -d.)
67NUM2=$(echo ${VERSION} | cut -f2 -d.)
68FIXEDVERSION=$(echo -n "$NUM1" ; echo -n "_" ; echo -e "$NUM2")
69REVISION=$(svn info svn://gcc.gnu.org/svn/gcc/branches/gcc-${FIXEDVERSION}-branch | grep "Last Changed Rev" | cut -f2 -d: | sed -e 's/ //g')
70svn export svn://gcc.gnu.org/svn/gcc/branches/gcc-${FIXEDVERSION}-branch gcc-${VERSION}
71
72# Add a custom version string
73#
74cd ~/tmp
75DATE_STAMP=$(cat gcc-${VERSION}/gcc/DATESTAMP)
76echo "${VERSION}" > gcc-${VERSION}/gcc/BASE-VER
77sed -i "s:PKGVERSION:\"(GCC for Cross-LFS ${VERSION}.${DATE_STAMP}) \":" gcc-${VERSION}/gcc/version.c
78
79# Cleanup
80#
81cd ~/tmp
82DIRS="gcc-${VERSION} gcc-${VERSION}.orig"
83for 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 ..
106done
107
108# Create Patch
109#
110cd ~/tmp
111install -d ~/patches
112echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
113echo "Date: `date +%m-%d-%Y`" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
114echo "Initial Package Version: ${VERSION}" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
115echo "Origin: Upstream" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
116echo "Upstream Status: Applied" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
117echo "Description: This is a branch update for gcc-${VERSION}, and should be" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
118echo " rechecked periodically." >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
119echo "" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
120echo "This patch was made from Revision # ${REVISION}." >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
121echo "" >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
122diff -Naur gcc-${VERSION}.orig gcc-${VERSION} >> ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
123echo "Created ~/patches/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch."
124
125# Create Another Copy to create fixes patch
126#
127cd ~/tmp
128if [ -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."
178fi
179
180# Cleanup Directory
181#
182cd ~/tmp
183rm -rf gcc-${VERSION} gcc-${VERSION}.orig
Note: See TracBrowser for help on using the repository browser.