source: scripts/patch/bash-patch.sh@ 4ba9807e

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

Updates to Patch Scripts

  • Property mode set to 100755
File size: 3.9 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
[c7ef534]37wget http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk/patches/ --no-remove-listing
38PATCH_NUM=$(cat index.html | grep bash | grep "${VERSION}" | grep branch_update | cut -f2 -d'"' | cut -f1 -d'"'| cut -f4 -d- | cut -f1 -d. | tail -n 1)
39PATCH_NUM=$(expr ${PATCH_NUM} + 1)
40rm -f index.html
41
[06dcdf6]42# Cleanup Directory
43#
[d8a9d8b]44cd ~/tmp
[06dcdf6]45rm -rf bash-${VERSION} bash-${VERSION}.orig
46tar xvf bash-${VERSION}.tar.gz
47cp -ar bash-${VERSION} bash-${VERSION}.orig
48
49# Download and Apply Patches
50#
[d8a9d8b]51install -d ~/tmp/bash-${VERSION}-patches
52cd ~/tmp/bash-${VERSION}
53CURRENTDIR=$(pwd -P)
[06dcdf6]54PATCHURL=ftp://ftp.cwru.edu/pub/bash/bash-${VERSION}-patches
55COUNT=1
56while [ ${COUNT} -le ${FILES} ]; do
[d8a9d8b]57 cd ~/tmp/bash-${VERSION}
[9676bac]58 DLCOUNT="${COUNT}"
59 SKIPME=no
60 if [ "${COUNT}" -lt "100" ]; then
61 DLCOUNT="0${COUNT}"
62 fi
63 if [ "${COUNT}" -lt "10" ]; then
64 DLCOUNT="00${COUNT}"
65 fi
66 for skip in ${SKIPPATCH} ; do
67 if [ "${DLCOUNT}" = "$skip" ]; then
68 echo "Patch bash${VERSION2}-${DLCOUNT} skipped"
69 SKIPPED="${SKIPPED} ${DLCOUNT}"
70 SKIPME=yes
71 fi
72 done
73 if [ "${SKIPME}" != "yes" ]; then
74 if ! [ -e ${VERSION}.${DLCOUNT} ]; then
[d8a9d8b]75 cd ~/tmp/bash-${VERSION}-patches
[9676bac]76 wget --quiet ${PATCHURL}/bash${VERSION2}-${DLCOUNT}
77 fi
78 cd ${CURRENTDIR}
[d8a9d8b]79 patch --dry-run -s -f -Np0 -i ~/tmp/bash-${VERSION}-patches/bash${VERSION2}-${DLCOUNT}
[9676bac]80 if [ "$?" = "0" ]; then
81 echo "Patch bash${VERSION2}-${DLCOUNT} applied"
[d8a9d8b]82 patch -s -Np0 -i ~/tmp/bash-${VERSION}-patches/bash${VERSION2}-${DLCOUNT}
[9676bac]83 else
84 echo "Patch bash${VERSION2}-${DLCOUNT} not applied"
[d8a9d8b]85 rm -f ~/tmp/bash-${VERSION}-patches/bash${VERSION2}-${DLCOUNT}
[9676bac]86 SKIPPED="${SKIPPED} ${DLCOUNT}"
87 fi
88 fi
89 COUNT=`expr ${COUNT} + 1`
[06dcdf6]90done
91
92# Cleanup Directory
93#
[d8a9d8b]94cd ~/tmp/bash-${VERSION}
[c0d5090]95for dir in $(find * -type d); do
[d8a9d8b]96 cd ~/tmp/bash-${VERSION}/${dir}
[9676bac]97 for file in $(find . -name '*~'); do
98 rm -f ${file}
99 done
100 for file in $(find . -name '*.orig'); do
101 rm -f ${file}
102 done
[06dcdf6]103done
[d8a9d8b]104cd ~/tmp/bash-${VERSION}
[2803d79]105rm -f *~ *.orig
[06dcdf6]106
107# Create Patch
108#
[d8a9d8b]109cd ~/tmp
110install -d ~/patches
111echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
112echo "Date: `date +%m-%d-%Y`" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
113echo "Initial Package Version: ${VERSION}" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
114echo "Origin: Upstream" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
115echo "Upstream Status: Applied" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
116echo "Description: Contains all upstream patches up to ${VERSION}-${FILES}" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
[06dcdf6]117if [ -n "${SKIPPED}" ]; then
[d8a9d8b]118 echo " The following patches were skipped" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
119 echo " ${SKIPPED}" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
[06dcdf6]120fi
[d8a9d8b]121echo "" >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
122diff -Naur bash-${VERSION}.orig bash-${VERSION} >> ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch
123echo "Created ~/patches/bash-${VERSION}-branch_update-${PATCH_NUM}.patch."
124
125# Cleanup Directory
126#
127cd ~/tmp
128rm -rf bash-${VERSION} bash-${VERSION}.orig
Note: See TracBrowser for help on using the repository browser.