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

clfs-1.2clfs-2.1clfs-3.0.0-systemdclfs-3.0.0-sysvinitsystemdsysvinit
Last change on this file since 4648865 was 4648865, checked in by Jim Gifford <clfs@…>, 11 years ago

Really fix the patch scripts.

  • Property mode set to 100755
File size: 4.1 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/patches/bash/ --no-remove-listing
38for num in $(seq 1 99); do
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)
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
49rm -f index.html
50
51# Cleanup Directory
52#
53cd ~/tmp
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#
60install -d ~/tmp/bash-${VERSION}-patches
61cd ~/tmp/bash-${VERSION}
62CURRENTDIR=$(pwd -P)
63PATCHURL=ftp://ftp.cwru.edu/pub/bash/bash-${VERSION}-patches
64COUNT=1
65while [ ${COUNT} -le ${FILES} ]; do
66  cd ~/tmp/bash-${VERSION}           
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
84      cd ~/tmp/bash-${VERSION}-patches
85      wget --quiet ${PATCHURL}/bash${VERSION2}-${DLCOUNT}
86    fi
87    cd ${CURRENTDIR}
88    patch --dry-run -s -f -Np0 -i ~/tmp/bash-${VERSION}-patches/bash${VERSION2}-${DLCOUNT}
89    if [ "$?" = "0" ]; then
90      echo "Patch bash${VERSION2}-${DLCOUNT} applied"
91      patch -s -Np0 -i ~/tmp/bash-${VERSION}-patches/bash${VERSION2}-${DLCOUNT}
92    else
93     echo "Patch bash${VERSION2}-${DLCOUNT} not applied"
94     rm -f ~/tmp/bash-${VERSION}-patches/bash${VERSION2}-${DLCOUNT}
95     SKIPPED="${SKIPPED} ${DLCOUNT}"
96    fi
97  fi
98  COUNT=`expr ${COUNT} + 1`
99done
100
101# Cleanup Directory
102#
103cd ~/tmp/bash-${VERSION}
104for dir in $(find * -type d); do
105  cd ~/tmp/bash-${VERSION}/${dir}
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
112done
113cd ~/tmp/bash-${VERSION}
114rm -f *~ *.orig
115
116# Create Patch
117#
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
126if [ -n "${SKIPPED}" ]; then
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
129fi
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.