source: scripts/patch/bash-patch.sh@ 5e6f8f2

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 5e6f8f2 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
Line 
1#!/bin/bash
2# Create a Bash Patch
3
4# Get Version #
5#
6VERSION=$1
7
8# Check Input
9#
10if [ "${VERSION}" = "" ]; then
11 echo "$0 - Bash_Version"
12 echo "This will Create a Patch for Bash Bash_Version"
13 exit 255
14fi
15
16# Get the # of Patches
17#
18install -d ~/tmp
19cd ~/tmp
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
31 wget ftp://ftp.cwru.edu/pub/bash/bash-${VERSION}.tar.gz
32fi
33
34# Set Patch Number
35#
36cd ~/tmp
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
42# Cleanup Directory
43#
44cd ~/tmp
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#
51install -d ~/tmp/bash-${VERSION}-patches
52cd ~/tmp/bash-${VERSION}
53CURRENTDIR=$(pwd -P)
54PATCHURL=ftp://ftp.cwru.edu/pub/bash/bash-${VERSION}-patches
55COUNT=1
56while [ ${COUNT} -le ${FILES} ]; do
57 cd ~/tmp/bash-${VERSION}
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
75 cd ~/tmp/bash-${VERSION}-patches
76 wget --quiet ${PATCHURL}/bash${VERSION2}-${DLCOUNT}
77 fi
78 cd ${CURRENTDIR}
79 patch --dry-run -s -f -Np0 -i ~/tmp/bash-${VERSION}-patches/bash${VERSION2}-${DLCOUNT}
80 if [ "$?" = "0" ]; then
81 echo "Patch bash${VERSION2}-${DLCOUNT} applied"
82 patch -s -Np0 -i ~/tmp/bash-${VERSION}-patches/bash${VERSION2}-${DLCOUNT}
83 else
84 echo "Patch bash${VERSION2}-${DLCOUNT} not applied"
85 rm -f ~/tmp/bash-${VERSION}-patches/bash${VERSION2}-${DLCOUNT}
86 SKIPPED="${SKIPPED} ${DLCOUNT}"
87 fi
88 fi
89 COUNT=`expr ${COUNT} + 1`
90done
91
92# Cleanup Directory
93#
94cd ~/tmp/bash-${VERSION}
95for dir in $(find * -type d); do
96 cd ~/tmp/bash-${VERSION}/${dir}
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
103done
104cd ~/tmp/bash-${VERSION}
105rm -f *~ *.orig
106
107# Create Patch
108#
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
117if [ -n "${SKIPPED}" ]; then
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
120fi
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.