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