4 # env variables controlling behaviour
5 # build_package=[0|1] - build package when new version is fetched
6 # publish_packages=[0|1] - publish built packages in ~/public_html/$dist/$arch
7 # quiet=[0|1] - discard stdout of process
9 echo >&2 This script no longer works
18 local patch msg over file
20 echo "Updating $specfile to $ver"
21 patch=${ver#$basever.}
22 if [ -z "$patch" ]; then
23 echo >&2 "Will not set empty patchlevel"
27 s/^\(%define[ \t]\+patchlevel[ \t]\+\)[0-9]\+\$/\1$patch/
28 s/^\(%define[ \t]\+rel[ \t]\+\)[0-9.]\+\$/\11/
31 # fetch missing/mismatching files manually. faster than builder script does that
32 md5sum -c sources 2>/dev/null | awk -F: '$NF != " OK" {print $1}' | while read file; do
36 WGET_OPTS="-nv" ../builder -g $specfile
38 if [ "$build_package" != 0 ]; then
44 echo "updated to $ver" > $msg
46 over=$(git diff sources | awk '/^\+[0-9a-f]+/{over=$NF; gsub(/\./, "\\.",over); print over; exit}')
47 sed -ne "/$over/,\$p" README.patches | sed -re 's,^[ 0-9]+ ,,' >> $msg
48 git commit -F $msg $specfile sources
53 local logfile=$outdir/$pkg.log
57 # setup custom logfile via $HOME_ETC hack
58 # TODO: just add --logfile support for builder
59 cat > $outdir/.builderrc <<-EOF
60 if [ -n "$HOME_ETC" ]; then
61 . "$HOME_ETC/.builderrc"
62 elif [ -r ~/.builderrc ]; then
70 ../builder -bb --clean \
71 --define "_unpackaged_files_terminate_build 1" \
72 --define '_enable_debug_packages 0' \
73 --define "_builddir $outdir" \
74 --define "_rpmdir $rpmdir" \
76 echo "Package build failed" >&2
77 tail -n 1000 $logfile >&2
80 echo >&2 "Package build OK"
82 if [ "$publish_packages" ] && [ "$(ls $rpmdir/*.rpm 2>/dev/null)" ]; then
88 local rpmdest=~/public_html/$dist/$arch/
92 chmod 644 $rpmdir/*.rpm
93 mv -v $rpmdir/*.rpm $rpmdest/
94 poldek --cachedir=$HOME/tmp --mkidx -s $rpmdest/ --mt=pndir
100 # setup $quiet, you may override with env it
101 quiet=${quiet:-$(tty -s && echo 0 || echo 1)}
102 if [ "$quiet" = "1" ]; then
103 # we do not want output when running on cron
110 baseurl=ftp://ftp.vim.org/pub/editors/vim/patches/$basever
111 sources=ftp://ftp.vim.org/pub/editors/vim/patches/$basever/MD5SUMS
114 dist=$(rpm -E %{pld_release})
115 arch=$(rpm -E %{_host_cpu})
116 outdir=$(readlink -f $dir)/BUILD-$dist-$arch
119 status=$(git status --porcelain sources)
120 if [ "$status" ]; then
121 echo >&2 "WARNING: sources status not clean; commit or stash any pending changes"
128 echo "Fetching latest patches list..."
129 wget -nv $sources -O sources.tmp 2>&1
130 sort -k 2 -V < sources.tmp > sources.new
131 # exclude files already in git tree
132 git ls-files "$basever.*" | sed -e 's/\./\\./g;s/$/$/'| grep -vf - sources.new > sources
133 rm sources.new sources.tmp
134 # also update patches README
135 wget -nv $baseurl/README -O README.patches 2>&1
136 ver=$(tail -n1 sources | awk '{print $NF}')
139 curpatch=$(awk '/^%define[ ]+patchlevel[ ]+/{print $NF}' $specfile)
140 curver=$basever.$curpatch
142 if [ "$curver" != "$ver" ]; then
143 update_sources "$ver"
145 echo "$specfile already up to $ver"