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