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 ~/tmp |
---|
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 | cd ~/tmp |
---|
29 | if ! [ -e ncurses-${VERSION}.tar.gz ]; then |
---|
30 | wget ftp://invisible-island.net/ncurses/ncurses-${VERSION}.tar.gz |
---|
31 | fi |
---|
32 | |
---|
33 | # Set Patch Number |
---|
34 | # |
---|
35 | cd ~/tmp |
---|
36 | wget http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk/patches/ --no-remove-listing |
---|
37 | PATCH_NUM=$(cat index.html | grep ncurses | grep "${VERSION}" | grep branch_update | cut -f2 -d'"' | cut -f1 -d'"'| cut -f4 -d- | cut -f1 -d. | tail -n 1) |
---|
38 | PATCH_NUM=$(expr ${PATCH_NUM} + 1) |
---|
39 | rm -f index.html |
---|
40 | |
---|
41 | # Cleanup Directory |
---|
42 | # |
---|
43 | cd ~/tmp |
---|
44 | rm -rf ncurses-${VERSION} ncurses-${VERSION}.orig |
---|
45 | tar xvf ncurses-${VERSION}.tar.gz |
---|
46 | cp -ar ncurses-${VERSION} ncurses-${VERSION}.orig |
---|
47 | |
---|
48 | # Download and Apply Rollup Patch |
---|
49 | # |
---|
50 | cd ~/tmp/ncurses-${VERSION} |
---|
51 | CURRENTDIR=$(pwd -P) |
---|
52 | mkdir ~/tmp/ncurses-${VERSION}-patches |
---|
53 | cd ~/tmp/ncurses-${VERSION} |
---|
54 | if [ "${ROLLUP}" != "" ]; then |
---|
55 | echo "Getting Rollup ${ROLLUP} Patch..." |
---|
56 | cd ~/tmp/ncurses-${VERSION}-patches |
---|
57 | wget --quiet ftp://invisible-island.net/ncurses/${VERSION}/${ROLLUP} |
---|
58 | cd ${CURRENTDIR} |
---|
59 | echo "Applying Rollup ${ROLLUP} Patch..." |
---|
60 | cp ~/tmp/ncurses-${VERSION}-patches/${ROLLUP} ${CURRENTDIR}/${ROLLUP} |
---|
61 | bunzip2 ${ROLLUP} |
---|
62 | ROLLUP2=$(echo ${ROLLUP} | sed -e 's/.bz2//g') |
---|
63 | sh ${ROLLUP2} |
---|
64 | fi |
---|
65 | |
---|
66 | # Download and Apply Patches |
---|
67 | # |
---|
68 | install -d ~/tmp/ncurses-${VERSION}-patches |
---|
69 | cd ~/tmp/ncurses-${VERSION} |
---|
70 | CURRENTDIR=$(pwd -P) |
---|
71 | for file in ${FILES}; do |
---|
72 | if [ "${ROLLPATCH}" != "" ]; then |
---|
73 | TEST=$(echo ${file} | grep -c ${ROLLPATCH}) |
---|
74 | else |
---|
75 | TEST=0 |
---|
76 | fi |
---|
77 | if [ "${TEST}" = "0" ]; then |
---|
78 | cd ~/tmp/ncurses-${VERSION}-patches |
---|
79 | echo "Getting Patch ${file}..." |
---|
80 | wget --quiet ftp://invisible-island.net/ncurses/${VERSION}/${file} |
---|
81 | cd ${CURRENTDIR} |
---|
82 | gunzip -c ~/tmp/ncurses-${VERSION}-patches/${file} | patch --dry-run -s -f -Np1 |
---|
83 | if [ "$?" = "0" ]; then |
---|
84 | echo "Apply Patch ${file}..." |
---|
85 | gunzip -c ~/tmp/ncurses-${VERSION}-patches/${file} | patch -Np1 |
---|
86 | LASTFILE=$(echo ${file} | cut -f2 -d. | cut -f2 -d-) |
---|
87 | fi |
---|
88 | fi |
---|
89 | done |
---|
90 | |
---|
91 | # Cleanup Directory |
---|
92 | # |
---|
93 | cd ~/tmp |
---|
94 | cd ncurses-${VERSION} |
---|
95 | for dir in $(find * -type d); do |
---|
96 | cd ~/tmp/ncurses-${VERSION}/${dir} |
---|
97 | for file in $(find . -name '*~'); do |
---|
98 | rm -f ${file} |
---|
99 | done |
---|
100 | for file in $(find . -name '*.orig'); do |
---|
101 | rm -f ${file} |
---|
102 | done |
---|
103 | done |
---|
104 | cd ~/tmp/ncurses-${VERSION} |
---|
105 | rm -f *~ *.orig |
---|
106 | |
---|
107 | # Create Patch |
---|
108 | # |
---|
109 | cd ~/tmp |
---|
110 | echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch |
---|
111 | echo "Date: `date +%m-%d-%Y`" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch |
---|
112 | echo "Initial Package Version: ${VERSION}" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch |
---|
113 | echo "Origin: Upstream" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch |
---|
114 | echo "Upstream Status: Applied" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch |
---|
115 | echo "Description: This is a branch update for NCurses-${VERSION}, and should be" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch |
---|
116 | echo " rechecked periodically. This patch covers up to ${VERSION}-${LASTFILE}." >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch |
---|
117 | echo "" >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch |
---|
118 | diff -Naur ncurses-${VERSION}.orig ncurses-${VERSION} >> ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch |
---|
119 | echo "Created ~/patches/ncurses-${VERSION}-branch_update-${PATCH_NUM}.patch." |
---|
120 | |
---|
121 | # Cleanup Directory |
---|
122 | # |
---|
123 | cd ~/tmp |
---|
124 | rm -rf ncurses-${VERSION} ncurses-${VERSION}.orig |
---|