source: scripts/patch/readline-patch.sh @ 92671d0

clfs-3.0.0-systemdsystemd
Last change on this file since 92671d0 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
Line 
1#!/bin/bash
2# Create a Readline Patch
3
4# Get Version #
5#
6VERSION=$1
7
8# Check Input
9#
10if [ "${VERSION}" = "" ]; then
11  echo "$0 - Readline_Version"
12  echo "This will Create a Patch for Readline Readline_Version"
13  exit 255
14fi
15
16# Get the # of Patches
17#
18cd ~/tmp
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
27# Download Readline Source
28#
29cd ~/tmp
30if ! [ -e readline-${VERSION}.tar.gz ]; then
31  wget ftp://ftp.cwru.edu/pub/bash/readline-${VERSION}.tar.gz
32fi
33
34# Set Patch Number
35#
36cd ~/tmp
37wget http://svn.cross-lfs.org/svn/repos/patches/readline/ --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 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#
60install -d ~/tmp/readline-${VERSION}-patches
61cd ~/tmp/readline-${VERSION}
62CURRENTDIR=$(pwd -P)
63PATCHURL=ftp://ftp.cwru.edu/pub/bash/readline-${VERSION}-patches
64mkdir /tmp/readline-${VERSION}
65COUNT=1
66while [ ${COUNT} -le ${FILES} ]; do
67  cd ~/tmp/readline-${VERSION}           
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
85      cd ~/tmp/readline-${VERSION}-patches
86      wget --quiet ${PATCHURL}/readline${VERSION2}-${DLCOUNT}
87    fi
88    cd ${CURRENTDIR}
89    patch --dry-run -s -f -Np0 -i ~/tmp/readline-${VERSION}-patches/readline${VERSION2}-${DLCOUNT}
90    if [ "$?" = "0" ]; then
91      echo "Patch readline${VERSION2}-${DLCOUNT} applied"
92      patch -s -Np0 -i ~/tmp/readline-${VERSION}-patches/readline${VERSION2}-${DLCOUNT}
93    else
94      echo "Patch readline${VERSION2}-${DLCOUNT} not applied"
95      rm -f ~/tmp/readline-${VERSION}-patches/readline${VERSION2}-${DLCOUNT}
96      SKIPPED="${SKIPPED} ${DLCOUNT}"
97     fi
98    fi
99    COUNT=`expr ${COUNT} + 1`
100done
101
102# Cleanup Directory
103#
104# Cleanup Directory
105#
106for dir in $(find * -type d); do
107  cd ~/tmp/readline-${VERSION}/${dir}
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
114done
115cd ~/tmp/readline-${VERSION}
116rm -f *~ *.orig
117
118# Create Patch
119#
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
127if [ -n "${SKIPPED}" ]; then
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
130fi
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.