[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 | #
|
---|
[d8a9d8b] | 18 | cd ~/tmp
|
---|
[06dcdf6] | 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 |
|
---|
[c7ef534] | 33 | # Set Patch Number
|
---|
| 34 | #
|
---|
[d8a9d8b] | 35 | cd ~/tmp
|
---|
[29f6db3] | 36 | wget http://svn.cross-lfs.org/svn/repos/patches/vim/ --no-remove-listing
|
---|
| 37 | for num in $(seq 1 99); do
|
---|
[4648865] | 38 | PATCH_NUM=$(cat index.html | grep "${VERSION}" | grep branch_update-${num}.patch | cut -f2 -d'"' | cut -f1 -d'"'| cut -f4 -d- | cut -f1 -d. | tail -n 1)
|
---|
[29f6db3] | 39 | if [ "${PATCH_NUM}" = "0" -a "${num}" = "1" ]; then
|
---|
| 40 | PATCH_NUM=$(expr ${PATCH_NUM} + 1)
|
---|
| 41 | break
|
---|
| 42 | fi
|
---|
| 43 | if [ "${PATCH_NUM}" != "${num}" ]; then
|
---|
| 44 | PATCH_NUM=$(expr ${num})
|
---|
| 45 | break
|
---|
| 46 | fi
|
---|
| 47 | done
|
---|
[c7ef534] | 48 | rm -f index.html
|
---|
| 49 |
|
---|
[06dcdf6] | 50 | # Cleanup Directory
|
---|
| 51 | #
|
---|
| 52 | rm -rf vim${SERIES} vim${SERIES}.orig
|
---|
| 53 | tar xvf vim-${VERSION}.tar.bz2
|
---|
| 54 | cp -ar vim${SERIES} vim${SERIES}.orig
|
---|
| 55 |
|
---|
| 56 | # Download and Apply Patches
|
---|
| 57 | #
|
---|
[d8a9d8b] | 58 | install -d ~/tmp/vim-${VERSION}-patches
|
---|
| 59 | cd ~/tmp/vim${SERIES}
|
---|
| 60 | CURRENTDIR=$(pwd -P)
|
---|
[06dcdf6] | 61 | PATCHURL=ftp://ftp.vim.org/pub/vim/patches/${VERSION}
|
---|
| 62 | COUNT=1
|
---|
| 63 | while [ ${COUNT} -le ${FILES} ]; do
|
---|
[d8a9d8b] | 64 | cd ~/tmp/vim${SERIES}
|
---|
[9676bac] | 65 | DLCOUNT="${COUNT}"
|
---|
| 66 | SKIPME=no
|
---|
| 67 | if [ "${COUNT}" -lt "100" ]; then
|
---|
| 68 | DLCOUNT="0${COUNT}"
|
---|
| 69 | fi
|
---|
| 70 | if [ "${COUNT}" -lt "10" ]; then
|
---|
| 71 | DLCOUNT="00${COUNT}"
|
---|
| 72 | fi
|
---|
| 73 | for skip in ${SKIPPATCH} ; do
|
---|
| 74 | if [ "${DLCOUNT}" = "${skip}" ]; then
|
---|
| 75 | echo "Patch ${VERSION}.${DLCOUNT} skipped"
|
---|
| 76 | SKIPPED="${SKIPPED} ${DLCOUNT}"
|
---|
| 77 | SKIPME=yes
|
---|
| 78 | fi
|
---|
| 79 | done
|
---|
| 80 | if [ "${SKIPME}" != "yes" ]; then
|
---|
| 81 | if ! [ -e ${VERSION}.${DLCOUNT} ]; then
|
---|
[d8a9d8b] | 82 | cd ~/tmp/vim-${VERSION}-patches
|
---|
[9676bac] | 83 | wget --quiet $PATCHURL/${VERSION}.${DLCOUNT}
|
---|
| 84 | fi
|
---|
| 85 | cd $CURRENTDIR
|
---|
[d8a9d8b] | 86 | patch --dry-run -s -f -Np0 -i ~/tmp/vim-${VERSION}-patches/${VERSION}.${DLCOUNT}
|
---|
[9676bac] | 87 | if [ "$?" = "0" ]; then
|
---|
| 88 | echo "Patch ${VERSION}.${DLCOUNT} applied"
|
---|
[d8a9d8b] | 89 | patch -s -Np0 -i ~/tmp/vim-${VERSION}-patches/${VERSION}.${DLCOUNT}
|
---|
[9676bac] | 90 | else
|
---|
| 91 | echo "Patch ${VERSION}.${DLCOUNT} not applied"
|
---|
| 92 | SKIPPED="${SKIPPED} ${DLCOUNT}"
|
---|
| 93 | fi
|
---|
| 94 | fi
|
---|
[c7ef534] | 95 | COUNT=$(expr ${COUNT} + 1)
|
---|
[06dcdf6] | 96 | done
|
---|
| 97 |
|
---|
[c0d5090] | 98 | # Cleanup Directory
|
---|
| 99 | #
|
---|
| 100 | for dir in $(find * -type d); do
|
---|
[d8a9d8b] | 101 | cd ~/tmp/vim${SERIES}
|
---|
[9676bac] | 102 | for file in $(find . -name '*~'); do
|
---|
| 103 | rm -f ${file}
|
---|
| 104 | done
|
---|
| 105 | for file in $(find . -name '*.orig'); do
|
---|
| 106 | rm -f ${file}
|
---|
| 107 | done
|
---|
[06dcdf6] | 108 | done
|
---|
[d8a9d8b] | 109 | cd ~/tmp/vim${SERIES}
|
---|
[2803d79] | 110 | rm -f *~ *.orig
|
---|
[06dcdf6] | 111 |
|
---|
| 112 | # Create Patch
|
---|
| 113 | #
|
---|
[d8a9d8b] | 114 | cd ~/tmp
|
---|
| 115 | echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/vim-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 116 | echo "Date: `date +%m-%d-%Y`" >> ~/patches/vim-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 117 | echo "Initial Package Version: ${VERSION}" >> ~/patches/vim-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 118 | echo "Origin: Upstream" >> ~/patches/vim-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 119 | echo "Upstream Status: Applied" >> ~/patches/vim-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 120 | echo "Description: Contains all upstream patches up to ${VERSION}.${FILES}" >> ~/patches/vim-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
[06dcdf6] | 121 | if [ -n "${SKIPPED}" ]; then
|
---|
[d8a9d8b] | 122 | echo " The following patches were skipped" >> ~/patches/vim-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 123 | echo " ${SKIPPED}" >> ~/patches/vim-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
[06dcdf6] | 124 | fi
|
---|
[d8a9d8b] | 125 | echo "" >> ~/patches/vim-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 126 | diff -Naur vim${SERIES}.orig vim${SERIES} >> ~/patches/vim-${VERSION}-branch_update-${PATCH_NUM}.patch
|
---|
| 127 | echo "Created ~/patches/vim-${VERSION}-branch_update-${PATCH_NUM}.patch."
|
---|
| 128 |
|
---|
| 129 | # Cleanup Directory
|
---|
| 130 | #
|
---|
| 131 | rm -rf vim${SERIES} vim${SERIES}.orig
|
---|