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
41 # also update patches README
42 wget -nv $baseurl/README -O README.patches
43 ver=$(tail -n1 sources | awk '{print $NF}')
46 curpatch=$(awk '/^%define[ ]+patchlevel[ ]+/{print $NF}' $specfile)
47 curver=$basever.$curpatch
49 if [ "$curver" != "$ver" ]; then
50 echo "Updating $specfile to $ver"
51 patch=${ver#$basever.}
52 if [ -z "$patch" ]; then
53 echo >&2 "Will not set empty patchlevel"
57 s/^\(%define[ \t]\+patchlevel[ \t]\+\)[0-9]\+\$/\1$patch/
60 # fetch missing/mismatching files manually. faster than builder does that
61 md5sum -c sources 2>/dev/null|awk -F: '$NF != " OK" {print $1}' | while read file; do
65 WGET_OPTS="-nv" ../builder -g $specfile
67 if [ "$build_package" != 0 ]; then
68 dist=$(rpm -E %{pld_release})
69 arch=$(rpm -E %{_host_cpu})
70 outdir=$(readlink -f $dir)/BUILD-$dist-$arch
71 logfile=$outdir/$pkg.log
75 # setup custom logfile via $HOME_ETC hack
76 # TODO: just add --logfile support for builder
77 cat > $outdir/.builderrc <<-EOF
78 if [ -n "$HOME_ETC" ]; then
79 . "$HOME_ETC/.builderrc"
80 elif [ -r ~/.builderrc ]; then
88 ../builder -bb --clean \
89 --define "_unpackaged_files_terminate_build 1" \
90 --define '_enable_debug_packages 0' \
91 --define "_builddir $outdir" \
92 --define "_rpmdir $rpmdir" \
94 echo "Package build failed"
95 tail -n 1000 $logfile >&2
99 rpmdest=~/public_html/$dist/$arch/
100 if [ "$publish_packages" ] && [ "$(ls $rpmdir/*.rpm 2>/dev/null)" ]; then
103 chmod 644 $rpmdir/*.rpm
104 mv -v $rpmdir/*.rpm $rpmdest/
105 poldek --cachedir=$HOME/tmp --mkidx -s $rpmdest/ --mt=pndir
109 echo "$specfile already up to $ver"