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