source: scripts/patch/bash-patch.sh@ aa020293

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since aa020293 was c7ef534, checked in by Jim Gifford <clfs@…>, 16 years ago

Figure out what the last patch # is and grab the next #

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