[06dcdf6] | 1 | #!/bin/bash
|
---|
| 2 | # Create a VIM Patch
|
---|
| 3 |
|
---|
| 4 | # Get Version #
|
---|
| 5 | #
|
---|
| 6 | VERSION=$1
|
---|
| 7 |
|
---|
| 8 | # Check Input
|
---|
| 9 | #
|
---|
| 10 | if [ "${VERSION}" = "" ]; then
|
---|
[9676bac] | 11 | echo "$0 - Vim_Version"
|
---|
| 12 | echo "This will Create a Patch for Vim Vim_Version"
|
---|
| 13 | exit 255
|
---|
[06dcdf6] | 14 | fi
|
---|
| 15 |
|
---|
| 16 | # Get the # of Patches
|
---|
| 17 | #
|
---|
| 18 | cd /usr/src
|
---|
| 19 | wget ftp://ftp.vim.org/pub/vim/patches/${VERSION}/ --no-remove-listing
|
---|
| 20 | FILES=$(cat index.html | grep "${VERSION}" | cut -f6 -d. | cut -f1 -d'"' | sed '/^$/d' | tail -n 1)
|
---|
| 21 | rm -f .listing
|
---|
| 22 | rm -f index.html
|
---|
| 23 | SERIES=$(echo ${VERSION} | sed -e 's/\.//g')
|
---|
| 24 | SKIPPATCH=""
|
---|
| 25 | SKIPPED=""
|
---|
| 26 |
|
---|
| 27 | # Download VIM Source
|
---|
| 28 | #
|
---|
| 29 | if ! [ -e vim-${VERSION}.tar.bz2 ]; then
|
---|
[9676bac] | 30 | wget ftp://ftp.vim.org/pub/vim/unix/vim-${VERSION}.tar.bz2
|
---|
[06dcdf6] | 31 | fi
|
---|
| 32 |
|
---|
| 33 | # Cleanup Directory
|
---|
| 34 | #
|
---|
| 35 | rm -rf vim${SERIES} vim${SERIES}.orig
|
---|
| 36 | tar xvf vim-${VERSION}.tar.bz2
|
---|
| 37 | cp -ar vim${SERIES} vim${SERIES}.orig
|
---|
| 38 | cd vim${SERIES}
|
---|
| 39 | CURRENTDIR=$(pwd -P)
|
---|
| 40 |
|
---|
| 41 | # Download and Apply Patches
|
---|
| 42 | #
|
---|
| 43 | PATCHURL=ftp://ftp.vim.org/pub/vim/patches/${VERSION}
|
---|
| 44 | mkdir /tmp/vim-${VERSION}
|
---|
| 45 | COUNT=1
|
---|
| 46 | while [ ${COUNT} -le ${FILES} ]; do
|
---|
[9676bac] | 47 | cd /tmp/vim-${VERSION}
|
---|
| 48 | DLCOUNT="${COUNT}"
|
---|
| 49 | SKIPME=no
|
---|
| 50 | if [ "${COUNT}" -lt "100" ]; then
|
---|
| 51 | DLCOUNT="0${COUNT}"
|
---|
| 52 | fi
|
---|
| 53 | if [ "${COUNT}" -lt "10" ]; then
|
---|
| 54 | DLCOUNT="00${COUNT}"
|
---|
| 55 | fi
|
---|
| 56 | for skip in ${SKIPPATCH} ; do
|
---|
| 57 | if [ "${DLCOUNT}" = "${skip}" ]; then
|
---|
| 58 | echo "Patch ${VERSION}.${DLCOUNT} skipped"
|
---|
| 59 | SKIPPED="${SKIPPED} ${DLCOUNT}"
|
---|
| 60 | SKIPME=yes
|
---|
| 61 | fi
|
---|
| 62 | done
|
---|
| 63 | if [ "${SKIPME}" != "yes" ]; then
|
---|
| 64 | if ! [ -e ${VERSION}.${DLCOUNT} ]; then
|
---|
| 65 | wget --quiet $PATCHURL/${VERSION}.${DLCOUNT}
|
---|
| 66 | fi
|
---|
| 67 | cd $CURRENTDIR
|
---|
| 68 | patch --dry-run -s -f -Np0 -i /tmp/vim-${VERSION}/${VERSION}.${DLCOUNT}
|
---|
| 69 | if [ "$?" = "0" ]; then
|
---|
| 70 | echo "Patch ${VERSION}.${DLCOUNT} applied"
|
---|
| 71 | patch -s -Np0 -i /tmp/vim-${VERSION}/${VERSION}.${DLCOUNT}
|
---|
| 72 | else
|
---|
| 73 | echo "Patch ${VERSION}.${DLCOUNT} not applied"
|
---|
| 74 | rm -f /tmp/vim-${VERSION}/${VERSION}.${DLCOUNT}
|
---|
| 75 | SKIPPED="${SKIPPED} ${DLCOUNT}"
|
---|
| 76 | fi
|
---|
| 77 | fi
|
---|
| 78 | COUNT=`expr ${COUNT} + 1`
|
---|
[06dcdf6] | 79 | done
|
---|
| 80 |
|
---|
[c0d5090] | 81 | # Cleanup Directory
|
---|
| 82 | #
|
---|
| 83 | for dir in $(find * -type d); do
|
---|
[9676bac] | 84 | cd /usr/src/vim${SERIES}
|
---|
| 85 | for file in $(find . -name '*~'); do
|
---|
| 86 | rm -f ${file}
|
---|
| 87 | done
|
---|
| 88 | for file in $(find . -name '*.orig'); do
|
---|
| 89 | rm -f ${file}
|
---|
| 90 | done
|
---|
[06dcdf6] | 91 | done
|
---|
[e91eb56] | 92 | cd /usr/src/vim${SERIES}
|
---|
[2803d79] | 93 | rm -f *~ *.orig
|
---|
[06dcdf6] | 94 |
|
---|
| 95 | # Create Patch
|
---|
| 96 | #
|
---|
| 97 | cd /usr/src
|
---|
[c94176e] | 98 | echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > vim-${VERSION}-branch_update-x.patch
|
---|
[06dcdf6] | 99 | echo "Date: `date +%m-%d-%Y`" >> vim-${VERSION}-branch_update-x.patch
|
---|
| 100 | echo "Initial Package Version: ${VERSION}" >> vim-${VERSION}-branch_update-x.patch
|
---|
| 101 | echo "Origin: Upstream" >> vim-${VERSION}-branch_update-x.patch
|
---|
| 102 | echo "Upstream Status: Applied" >> vim-${VERSION}-branch_update-x.patch
|
---|
| 103 | echo "Description: Contains all upstream patches up to ${VERSION}.${FILES}" >> vim-${VERSION}-branch_update-x.patch
|
---|
| 104 | if [ -n "${SKIPPED}" ]; then
|
---|
[9676bac] | 105 | echo " The following patches were skipped" >> vim-${VERSION}-branch_update-x.patch
|
---|
| 106 | echo " ${SKIPPED}" >> vim-${VERSION}-branch_update-x.patch
|
---|
[06dcdf6] | 107 | fi
|
---|
| 108 | echo "" >> vim-${VERSION}-branch_update-x.patch
|
---|
| 109 | diff -Naur vim${SERIES}.orig vim${SERIES} >> vim-${VERSION}-branch_update-x.patch
|
---|
| 110 | echo "Created /usr/src/vim-${VERSION}-branch_update-x.patch."
|
---|