source: scripts/patch/gcc-patch.sh@ b73fed7

systemd
Last change on this file since b73fed7 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
RevLine 
[06dcdf6]1#!/bin/bash
2# Create a GCC Patch
3
4# Get Version #
5#
6VERSION=$1
7
8# Check Input
9#
10if [ "${VERSION}" = "" ]; then
[9676bac]11 echo "$0 - GCC_Version"
12 echo "This will Create a Patch for GCC GCC_Version"
13 exit 255
[06dcdf6]14fi
15
[3820147]16# Set Patch Directory
17#
18PATCH_DIR=$(pwd -P)/gcc
19
[06dcdf6]20# Download GCC Source
21#
[d8a9d8b]22install -d ~/tmp
23cd ~/tmp
[06dcdf6]24if ! [ -e gcc-${VERSION}.tar.bz2 ]; then
[0804c00]25 wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-${VERSION}/gcc-${VERSION}.tar.bz2
[06dcdf6]26fi
27
[c7ef534]28# Set Patch Number
29#
[d8a9d8b]30cd ~/tmp
[29f6db3]31wget http://svn.cross-lfs.org/svn/repos/patches/gcc/ --no-remove-listing
32for num in $(seq 1 99); do
[4648865]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)
[29f6db3]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
[4648865]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)
[29f6db3]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
[c7ef534]54rm -f index.html
55
[06dcdf6]56# Cleanup Directory
57#
[d8a9d8b]58cd ~/tmp
[3820147]59rm -rf gcc-${VERSION} gcc-${VERSION}.orig
60tar xvf gcc-${VERSION}.tar.bz2
61mv gcc-${VERSION} gcc-${VERSION}.orig
[06dcdf6]62
63# Get Current Updates from SVN
64#
[d8a9d8b]65cd ~/tmp
[3820147]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}
[06dcdf6]71
[099bfc2]72# Add a custom version string
[27e5b8e]73#
[d8a9d8b]74cd ~/tmp
[ead347c]75DATE_STAMP=$(cat gcc-${VERSION}/gcc/DATESTAMP)
[f81e00b]76echo "${VERSION}" > gcc-${VERSION}/gcc/BASE-VER
[ead347c]77sed -i "s:PKGVERSION:\"(GCC for Cross-LFS ${VERSION}.${DATE_STAMP}) \":" gcc-${VERSION}/gcc/version.c
[099bfc2]78
[06dcdf6]79# Cleanup
[3820147]80#
[d8a9d8b]81cd ~/tmp
[06dcdf6]82DIRS="gcc-${VERSION} gcc-${VERSION}.orig"
83for DIRECTORY in ${DIRS}; do
[d8a9d8b]84 cd ~/tmp/${DIRECTORY}
[d8bd081]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
[ee54da9]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"
[9676bac]93 for file in ${REMOVE}; do
94 rm -f $file
95 done
[d8bd081]96 for file in $(find . -name "ChangeLog*" | sed -e 's@./@@'); do
[d8a9d8b]97 rm -fv ${file}
[d8bd081]98 done
[d8a9d8b]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 ..
[06dcdf6]106done
107
108# Create Patch
109#
[d8a9d8b]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."
[3820147]124
125# Create Another Copy to create fixes patch
126#
[d8a9d8b]127cd ~/tmp
[3820147]128if [ -e ${PATCH_DIR}/${VERSION} ]; then
[d8a9d8b]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}
[3820147]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
[d8a9d8b]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
[3820147]162
[d8a9d8b]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
[960526e]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
[d8a9d8b]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
[3820147]179
[d8a9d8b]180# Cleanup Directory
[3820147]181#
[d8a9d8b]182cd ~/tmp
183rm -rf gcc-${VERSION} gcc-${VERSION}.orig
Note: See TracBrowser for help on using the repository browser.