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
16 # setup $quiet, you may override with env it
17 quiet=${quiet:-$(tty -s && echo 0 || echo 1)}
18 if [ "$quiet" = "1" ]; then
19 # we do not want output when running on cron
26 baseurl=ftp://ftp.vim.org/pub/editors/vim/patches/$basever
27 sources=ftp://ftp.vim.org/pub/editors/vim/patches/$basever/MD5SUMS
29 status=$(git status --porcelain sources)
30 if [ "$status" ]; then
31 echo >&2 "sources status not clean; commit or stash any pending changes"
39 echo "Fetching latest patches list..."
40 wget -nv $sources -O sources.tmp 2>&1
41 sort -k 2 -V < sources.tmp > sources.new
42 # exclude files already in git tree
43 git ls-files "$basever.*" | sed -e 's/\./\\./g;s/$/$/'| grep -vf - sources.new > sources
44 rm sources.new sources.tmp
45 # also update patches README
46 wget -nv $baseurl/README -O README.patches 2>&1
47 ver=$(tail -n1 sources | awk '{print $NF}')
50 curpatch=$(awk '/^%define[ ]+patchlevel[ ]+/{print $NF}' $specfile)
51 curver=$basever.$curpatch
53 if [ "$curver" != "$ver" ]; then
54 echo "Updating $specfile to $ver"
55 patch=${ver#$basever.}
56 if [ -z "$patch" ]; then
57 echo >&2 "Will not set empty patchlevel"
61 s/^\(%define[ \t]\+patchlevel[ \t]\+\)[0-9]\+\$/\1$patch/
64 # fetch missing/mismatching files manually. faster than builder does that
65 md5sum -c sources 2>/dev/null|awk -F: '$NF != " OK" {print $1}' | while read file; do
69 WGET_OPTS="-nv" ../builder -g $specfile
71 if [ "$build_package" != 0 ]; then
72 dist=$(rpm -E %{pld_release})
73 arch=$(rpm -E %{_host_cpu})
74 outdir=$(readlink -f $dir)/BUILD-$dist-$arch
75 logfile=$outdir/$pkg.log
79 # setup custom logfile via $HOME_ETC hack
80 # TODO: just add --logfile support for builder
81 cat > $outdir/.builderrc <<-EOF
82 if [ -n "$HOME_ETC" ]; then
83 . "$HOME_ETC/.builderrc"
84 elif [ -r ~/.builderrc ]; then
92 ../builder -bb --clean \
93 --define "_unpackaged_files_terminate_build 1" \
94 --define '_enable_debug_packages 0' \
95 --define "_builddir $outdir" \
96 --define "_rpmdir $rpmdir" \
98 echo "Package build failed" >&2
99 tail -n 1000 $logfile >&2
102 echo >&2 "Package build OK"
104 rpmdest=~/public_html/$dist/$arch/
105 if [ "$publish_packages" ] && [ "$(ls $rpmdir/*.rpm 2>/dev/null)" ]; then
108 chmod 644 $rpmdir/*.rpm
109 mv -v $rpmdir/*.rpm $rpmdest/
110 poldek --cachedir=$HOME/tmp --mkidx -s $rpmdest/ --mt=pndir
116 echo "updated to $ver" > $msg
118 over=$(git diff sources | awk '/^\+[0-9a-f]+/{over=$NF; gsub(/\./, "\\.",over); print over; exit}')
119 sed -ne "/$over/,\$p" README.patches | sed -re 's,^[ 0-9]+ ,,' >> $msg
120 git commit -F $msg $specfile sources
123 echo "$specfile already up to $ver"