updated on Sun Jan 15 16:02:00 UTC 2012
[aur-mirror.git] / vimgdb / fetch_runtime.sh
blob5825447fb1e915ea3425c0e7fd15cdbf940da174
1 # the purpose of this magic is to pull in the latest runtime files for vim
2 # we start withe theruntime provoded by the tarballs and compare MD5s against
3 # the latest runtime
4 # if this fails we look in the local source cache if they have been fetched
5 # for an earlier build and compare those MD5 files
6 # if this fails, we fetch the stuff from online and store it in the local src
7 # cache.
8 # The local cache has to be set (makepkg.conf) AND it has to be writable
10 update_runtime() {
11 _OLDDIR=$(pwd) #get absolute path
12 _errors=0
13 _ftp="ftp://ftp.vim.org/pub/vim/runtime"
15 # we're gonna be sneaky and grok the A-A-P recipe for the files we need
16 _recipe="getunix.aap"
17 _srccache="${SRCDEST}/vim-${_srcver}/"
19 echo "getting runtime recipe"
20 cd ${srcdir}
21 [ -f "${_recipe}" ] && rm "${_recipe}"
22 wget "${_ftp}/${_recipe}" >/dev/null 2>&1
24 cd "${_runtimedir}"
25 _runtimedir=$(pwd) #get absolute path
27 # change IFS to loop line-by-line
28 _OLDIFS=$IFS
29 IFS="
31 echo "begin fetching updated runtime files..."
32 for _file in $(grep "file = " "${srcdir}/${_recipe}"); do
33 _file=$(echo ${_file} | sed "s|.*file = \(.*\)|\1|")
34 _md5=$(grep -A2 "file = ${_file} *$" "${srcdir}/${_recipe}" | \
35 grep "get_md5" | \
36 sed 's|@if get_md5(file) != "\(.*\)":|\1|g')
37 _dir=$(dirname "${_file}")
39 mkdir -p "${_dir}"
41 echo -e "\t${_file}"
42 _havefile=0
43 # if we have the file and the MD5sum fails, we technically don't have the file
44 if [ -f ${_file} ]; then
45 # MD5 fails ? ... we don't have the file
46 if [ $(echo "${_md5} ${_file}" | md5sum --status -c -) ]; then
47 rm ${_file}
48 else
49 _havefile=1
52 # look files that were not copied from the unzipped sources
53 _cachefile=${srcdir}/${_versiondir}/runtime/${_file}
54 if [ ${_havefile} -ne 1 -a -f ${_cachefile} ]; then
55 # MD5 fails ? ... we lookup if we downloaded another version earlier
56 if [ $(echo "${_md5} ${_cachefile}" | md5sum --status -c -) ]; then
57 _cachefile=${_srccache}/${_file}
58 if [ -f ${_cachefile} ]; then
59 if [ $(echo "${_md5} ${_cachefile}" | md5sum --status -c -) ]; then
60 rm ${_cachefile}
61 else
62 cp ${_cachefile} ${_dir}
63 _havefile=1
66 else
67 cp ${_cachefile} ${_dir}
68 _havefile=1
71 # look up the local $SRCDEST
72 _cachefile=${_srccache}/${_file}
73 if [ ${_havefile} -ne 1 -a -f ${_cachefile} ]; then
74 # MD5 fails ? ... we don't have the file
75 if [ $(echo "${_md5} ${_cachefile}" | md5sum --status -c -) ]; then
76 rm ${_cachefile}
77 else
78 cp ${_cachefile} ${_dir}
79 _havefile=1
82 # so we finally have to fetch it and store it to $SRCDEST (cache)
83 if [ ${_havefile} -ne 1 ]; then
84 echo -n -e "\t ... fetching file ${_file} ..."
85 cd "${_dir}"
86 wget "${_ftp}/${_file}" >/dev/null 2>&1
87 cd "${_runtimedir}"
88 # store freshly downloaded file in SRCDEST
89 mkdir -p ${_srccache}/${_dir}
90 cp ${_file} ${_srccache}/${_dir}
91 echo -e " done!"
94 # check the MD5 sum finally
95 if [ $(echo "${_md5} ${_file}" | md5sum --status -c -) ]; then
96 echo "!!!! md5sum check for ${_file} failed !!!!"
97 errors=$((${_errors} + 1))
99 done
100 IFS=${_OLDIFS}
102 echo "vim runtime got updated"
104 if [ ${_errors} -gt 0 ]; then
105 echo "${_errors} failed MD5 checks while updating runtime files -> build can't be completed"
106 return 1
107 else
108 echo -e "\tpatching filetype.vim for better handling of pacman related files ..."
109 sed -i "s/rpmsave/pacsave/;s/rpmnew/pacnew/;s/,\*\.ebuild/\0,PKGBUILD*,*.install/" filetype.vim
110 sed -i "/find the end/,+3{s/changelog_date_entry_search/changelog_date_end_entry_search/}" ftplugin/changelog.vim
112 # make Aaron happy
113 wget http://www.vim.org/scripts/download_script.php\?src_id=10872 \
114 -O autoload/pythoncomplete.vim
115 cd "${_OLDDIR}"
116 return 0