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