source: scripts/patch/gcc-patch.sh@ 536f7b0

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 536f7b0 was 3820147, checked in by Jim Gifford <clfs@…>, 15 years ago

Update Patch Scripts

  • Property mode set to 100755
File size: 5.6 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#
22cd /usr/src
23if ! [ -e gcc-${VERSION}.tar.bz2 ]; then
24 wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-${VERSION}/gcc-${VERSION}.tar.bz2
25fi
26
27# Set Patch Number
28#
29cd /usr/src
30wget http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk/patches/ --no-remove-listing > /dev/null 2>&1
31PATCH_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)
32PATCH_NUM=$(expr ${PATCH_NUM} + 1)
33PATCH_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)
34PATCH_NUM2=$(expr ${PATCH_NUM2} + 1)
35rm -f index.html
36
37# Cleanup Directory
38#
39rm -rf gcc-${VERSION} gcc-${VERSION}.orig
40tar xvf gcc-${VERSION}.tar.bz2
41mv gcc-${VERSION} gcc-${VERSION}.orig
42CURRENTDIR=$(pwd -P)
43
44# Get Current Updates from SVN
45#
46cd /usr/src
47NUM1=$(echo ${VERSION} | cut -f1 -d.)
48NUM2=$(echo ${VERSION} | cut -f2 -d.)
49FIXEDVERSION=$(echo -n "$NUM1" ; echo -n "_" ; echo -e "$NUM2")
50REVISION=$(svn info svn://gcc.gnu.org/svn/gcc/branches/gcc-${FIXEDVERSION}-branch | grep "Last Changed Rev" | cut -f2 -d: | sed -e 's/ //g')
51svn export svn://gcc.gnu.org/svn/gcc/branches/gcc-${FIXEDVERSION}-branch gcc-${VERSION}
52
53# Add a custom version string
54#
55DATE_STAMP=$(cat gcc-${VERSION}/gcc/DATESTAMP)
56echo "${VERSION}" > gcc-${VERSION}/gcc/BASE-VER
57sed -i "s:PKGVERSION:\"(GCC for Cross-LFS ${VERSION}.${DATE_STAMP}) \":" gcc-${VERSION}/gcc/version.c
58
59# Cleanup
60#
61DIRS="gcc-${VERSION} gcc-${VERSION}.orig"
62for 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 ..
82done
83
84# Create Patch
85#
86cd /usr/src
87echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
88echo "Date: `date +%m-%d-%Y`" >> gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
89echo "Initial Package Version: ${VERSION}" >> gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
90echo "Origin: Upstream" >> gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
91echo "Upstream Status: Applied" >> gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
92echo "Description: This is a branch update for gcc-${VERSION}, and should be" >> gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
93echo " rechecked periodically." >> gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
94echo "" >> gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
95echo "This patch was made from Revision # ${REVISION}." >> gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
96echo "" >> gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
97diff -Naur gcc-${VERSION}.orig gcc-${VERSION} >> gcc-${VERSION}-branch_update-${PATCH_NUM}.patch
98echo "Created /usr/src/gcc-${VERSION}-branch_update-${PATCH_NUM}.patch."
99
100# Create Another Copy to create fixes patch
101#
102cd /usr/src
103rm -rf gcc-${VERSION}.orig
104cp -ar gcc-${VERSION} gcc-${VERSION}.orig
105
106# Apply Patches from directories
107#
108cd /usr/src/gcc-${VERSION}
109if [ -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
129fi
130
131# Cleanup Directory
132#
133
134for 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
145done
146cd /usr/src/gcc-${VERSION}/
147rm -rf *.orig *~ *.rej
148
149# Create Patch
150#
151cd /usr/src
152echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
153echo "Date: `date +%m-%d-%Y`" >> gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
154echo "Initial Package Version: ${VERSION}" >> gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
155echo "Origin: Upstream" >> gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
156echo "Upstream Status: Applied" >> gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
157echo "Description: This Patch contains fixes for gcc-${VERSION}, and should be" >> gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
158echo " rechecked periodically." >> gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
159echo "" >> gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
160diff -Naur gcc-${VERSION}.orig gcc-${VERSION} >> gcc-${VERSION}-fixes-${PATCH_NUM2}.patch
161echo "Created /usr/src/gcc-${VERSION}-fixes-${PATCH_NUM2}.patch."
Note: See TracBrowser for help on using the repository browser.