source: scripts/patch/ncurses-patch.sh@ b47a4a1

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

Really fix the patch scripts.

  • Property mode set to 100755
File size: 4.1 KB
Line 
1#!/bin/bash
2# Create a Ncuruses Patch
3
4# Get Version #
5#
6VERSION=$1
7
8# Check Input
9#
10if [ "${VERSION}" = "" ]; then
11 echo "$0 - Ncurses_Version"
12 echo "This will Create a Patch for Ncurses Ncurses_Version"
13 exit 255
14fi
15
16# Get Patch Names
17#
18cd ~/tmp
19wget ftp://invisible-island.net/ncurses/${VERSION}/ --no-remove-listing
20ROLLUP=$(cat index.html | grep bz2 | cut -f2 -d'>' | cut -f1 -d'<' | tail -n 1)
21ROLLPATCH=$(echo ${ROLLUP} | cut -f3 -d-)
22FILES=$(cat index.html | grep ${VERSION}-2 | grep patch.gz | cut -f2 -d'>' | cut -f1 -d'<')
23rm -f .listing
24rm -f index.html
25
26# Download Ncurses Source
27#
28cd ~/tmp
29if ! [ -e ncurses-${VERSION}.tar.gz ]; then
30 wget ftp://invisible-island.net/ncurses/ncurses-${VERSION}.tar.gz
31fi
32
33# Set Patch Number
34#
35cd ~/tmp
36wget http://svn.cross-lfs.org/svn/repos/patches/ncurses/ --no-remove-listing
37for num in $(seq 1 99); do
38 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)
39 if [ "${PATCH_NUM}" = "0" -a "${num}" = "1" ]; then
40 PATCH_NUM=$(expr ${PATCH_NUM} + 1)
41 break
42 fi
43 if [ "${PATCH_NUM}" != "${num}" ]; then
44 PATCH_NUM=$(expr ${num})
45 break
46 fi
47done
48rm -f index.html
49
50# Cleanup Directory
51#
52cd ~/tmp
53rm -rf ncurses-${VERSION} ncurses-${VERSION}.orig
54tar xvf ncurses-${VERSION}.tar.gz
55cp -ar ncurses-${VERSION} ncurses-${VERSION}.orig
56
57# Download and Apply Rollup Patch
58#
59cd ~/tmp/ncurses-${VERSION}
60CURRENTDIR=$(pwd -P)
61mkdir ~/tmp/ncurses-${VERSION}-patches
62cd ~/tmp/ncurses-${VERSION}
63if [ "${ROLLUP}" != "" ]; then
64 echo "Getting Rollup ${ROLLUP} Patch..."
65 cd ~/tmp/ncurses-${VERSION}-patches
66 wget --quiet ftp://invisible-island.net/ncurses/${VERSION}/${ROLLUP}
67 cd ${CURRENTDIR}
68 echo "Applying Rollup ${ROLLUP} Patch..."
69 cp ~/tmp/ncurses-${VERSION}-patches/${ROLLUP} ${CURRENTDIR}/${ROLLUP}
70 bunzip2 ${ROLLUP}
71 ROLLUP2=$(echo ${ROLLUP} | sed -e 's/.bz2//g')
72 sh ${ROLLUP2}
73fi
74
75# Download and Apply Patches
76#
77install -d ~/tmp/ncurses-${VERSION}-patches
78cd ~/tmp/ncurses-${VERSION}
79CURRENTDIR=$(pwd -P)
80for file in ${FILES}; do
81 if [ "${ROLLPATCH}" != "" ]; then
82 TEST=$(echo ${file} | grep -c ${ROLLPATCH})
83 else
84 TEST=0
85 fi
86 if [ "${TEST}" = "0" ]; then
87 cd ~/tmp/ncurses-${VERSION}-patches
88 echo "Getting Patch ${file}..."
89 wget --quiet ftp://invisible-island.net/ncurses/${VERSION}/${file}
90 cd ${CURRENTDIR}
91 gunzip -c ~/tmp/ncurses-${VERSION}-patches/${file} | patch --dry-run -s -f -Np1
92 if [ "$?" = "0" ]; then
93 echo "Apply Patch ${file}..."
94 gunzip -c ~/tmp/ncurses-${VERSION}-patches/${file} | patch -Np1
95 LASTFILE=$(echo ${file} | cut -f2 -d. | cut -f2 -d-)
96 fi
97 fi
98done
99
100# Cleanup Directory
101#
102cd ~/tmp
103cd ncurses-${VERSION}
104for dir in $(find * -type d); do
105 cd ~/tmp/ncurses-${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/ncurses-${VERSION}
114rm -f *~ *.orig
115
116# Create Patch
117#
118cd ~/tmp
119echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
120echo "Date: `date +%m-%d-%Y`" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
121echo "Initial Package Version: ${VERSION}" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
122echo "Origin: Upstream" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
123echo "Upstream Status: Applied" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
124echo "Description: This is a branch update for NCurses-${VERSION}, and should be" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
125echo " rechecked periodically. This patch covers up to ${VERSION}-${LASTFILE}." >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
126echo "" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
127diff -Naur ncurses-${VERSION}.orig ncurses-${VERSION} >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch
128echo "Created ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch."
129
130# Cleanup Directory
131#
132cd ~/tmp
133rm -rf ncurses-${VERSION} ncurses-${VERSION}.orig
Note: See TracBrowser for help on using the repository browser.