source: scripts/patch/readline-patch.sh@ e8f3474

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

Really fix the patch scripts.

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