source: scripts/patch/bash-patch.sh@ 715d370d

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

Really fix the patch scripts.

  • Property mode set to 100755
File size: 4.1 KB
RevLine 
[06dcdf6]1#!/bin/bash
2# Create a Bash Patch
3
4# Get Version #
5#
6VERSION=$1
7
8# Check Input
9#
10if [ "${VERSION}" = "" ]; then
[9676bac]11 echo "$0 - Bash_Version"
12 echo "This will Create a Patch for Bash Bash_Version"
13 exit 255
[06dcdf6]14fi
15
16# Get the # of Patches
17#
[d8a9d8b]18install -d ~/tmp
19cd ~/tmp
[06dcdf6]20wget ftp://ftp.cwru.edu/pub/bash/bash-${VERSION}-patches/ --no-remove-listing
21VERSION2=$(echo ${VERSION} | sed -e 's/\.//g')
22FILES=$(cat index.html | grep "${VERSION2}" | cut -f2 -d'"' | cut -f4 -d. | cut -f3 -d- | tail -n 1)
23rm -f .listing
24rm -f index.html
25SKIPPATCH=""
26SKIPPED=""
27
28# Download BASH Source
29#
30if ! [ -e bash-${VERSION}.tar.gz ]; then
[9676bac]31 wget ftp://ftp.cwru.edu/pub/bash/bash-${VERSION}.tar.gz
[06dcdf6]32fi
33
[c7ef534]34# Set Patch Number
35#
[d8a9d8b]36cd ~/tmp
[29f6db3]37wget http://svn.cross-lfs.org/svn/repos/patches/bash/ --no-remove-listing
38for num in $(seq 1 99); do
[4648865]39 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]40 if [ "${PATCH_NUM}" = "0" -a "${num}" = "1" ]; then
41 PATCH_NUM=$(expr ${PATCH_NUM} + 1)
42 break
43 fi
44 if [ "${PATCH_NUM}" != "${num}" ]; then
45 PATCH_NUM=$(expr ${num})
46 break
47 fi
48done
[c7ef534]49rm -f index.html
50
[06dcdf6]51# Cleanup Directory
52#
[d8a9d8b]53cd ~/tmp
[06dcdf6]54rm -rf bash-${VERSION} bash-${VERSION}.orig
55tar xvf bash-${VERSION}.tar.gz
56cp -ar bash-${VERSION} bash-${VERSION}.orig
57
58# Download and Apply Patches
59#
[d8a9d8b]60install -d ~/tmp/bash-${VERSION}-patches
61cd ~/tmp/bash-${VERSION}
62CURRENTDIR=$(pwd -P)
[06dcdf6]63PATCHURL=ftp://ftp.cwru.edu/pub/bash/bash-${VERSION}-patches
64COUNT=1
65while [ ${COUNT} -le ${FILES} ]; do
[d8a9d8b]66 cd ~/tmp/bash-${VERSION}
[9676bac]67 DLCOUNT="${COUNT}"
68 SKIPME=no
69 if [ "${COUNT}" -lt "100" ]; then
70 DLCOUNT="0${COUNT}"
71 fi
72 if [ "${COUNT}" -lt "10" ]; then
73 DLCOUNT="00${COUNT}"
74 fi
75 for skip in ${SKIPPATCH} ; do
76 if [ "${DLCOUNT}" = "$skip" ]; then
77 echo "Patch bash${VERSION2}-${DLCOUNT} skipped"
78 SKIPPED="${SKIPPED} ${DLCOUNT}"
79 SKIPME=yes
80 fi
81 done
82 if [ "${SKIPME}" != "yes" ]; then
83 if ! [ -e ${VERSION}.${DLCOUNT} ]; then
[d8a9d8b]84 cd ~/tmp/bash-${VERSION}-patches
[9676bac]85 wget --quiet ${PATCHURL}/bash${VERSION2}-${DLCOUNT}
86 fi
87 cd ${CURRENTDIR}
[d8a9d8b]88 patch --dry-run -s -f -Np0 -i ~/tmp/bash-${VERSION}-patches/bash${VERSION2}-${DLCOUNT}
[9676bac]89 if [ "$?" = "0" ]; then
90 echo "Patch bash${VERSION2}-${DLCOUNT} applied"
[d8a9d8b]91 patch -s -Np0 -i ~/tmp/bash-${VERSION}-patches/bash${VERSION2}-${DLCOUNT}
[9676bac]92 else
93 echo "Patch bash${VERSION2}-${DLCOUNT} not applied"
[d8a9d8b]94 rm -f ~/tmp/bash-${VERSION}-patches/bash${VERSION2}-${DLCOUNT}
[9676bac]95 SKIPPED="${SKIPPED} ${DLCOUNT}"
96 fi
97 fi
98 COUNT=`expr ${COUNT} + 1`
[06dcdf6]99done
100
101# Cleanup Directory
102#
[d8a9d8b]103cd ~/tmp/bash-${VERSION}
[c0d5090]104for dir in $(find * -type d); do
[d8a9d8b]105 cd ~/tmp/bash-${VERSION}/${dir}
[9676bac]106 for file in $(find . -name '*~'); do
107 rm -f ${file}
108 done
109 for file in $(find . -name '*.orig'); do
110 rm -f ${file}
111 done
[06dcdf6]112done
[d8a9d8b]113cd ~/tmp/bash-${VERSION}
[2803d79]114rm -f *~ *.orig
[06dcdf6]115
116# Create Patch
117#
[d8a9d8b]118cd ~/tmp
119install -d ~/patches
120echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
121echo "Date: `date +%m-%d-%Y`" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
122echo "Initial Package Version: ${VERSION}" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
123echo "Origin: Upstream" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
124echo "Upstream Status: Applied" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
125echo "Description: Contains all upstream patches up to ${VERSION}-${FILES}" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
[06dcdf6]126if [ -n "${SKIPPED}" ]; then
[d8a9d8b]127 echo " The following patches were skipped" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
128 echo " ${SKIPPED}" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
[06dcdf6]129fi
[d8a9d8b]130echo "" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
131diff -Naur bash-${VERSION}.orig bash-${VERSION} >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
132echo "Created ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch."
133
134# Cleanup Directory
135#
136cd ~/tmp
137rm -rf bash-${VERSION} bash-${VERSION}.orig
Note: See TracBrowser for help on using the repository browser.