]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - pear-autoup.sh
- haskell hackage support
[packages/rpm-build-tools.git] / pear-autoup.sh
1 #!/bin/sh
2 # Try to update pear packages from current distro repos to latest in
3 # pear.php.net.
4 #
5 # Created Date: 2010-08-19
6 # Author: Elan Ruusamäe <glen@pld-linux.org>
7
8 set -e
9
10 builder=builder
11
12 if [ "$1" = "clean" ]; then
13         rm -rf php-pear-* php-phpunit-* php-symfony-* php-symfony2-* php-firephp-* php-horde-* php-phpdocs-* pear.* BUILD/* RPMS/*
14         exit 0
15 fi
16
17 # test that php is working
18 php -r 'echo "PHP is working OK\n";'
19
20 # test that pear is working
21 pear info PEAR >/dev/null
22
23 # needed pkgs for upgrade test
24 rpm -q php-packagexml2cl php-pear-PEAR_Command_Packaging
25
26 [ -s pear.desc ] || { poldek --upa; poldek -q -Q --skip-installed --cmd 'search -r php-pear | desc' > pear.desc; }
27 [ -s pear.pkgs ] || {
28         awk '/^Source.package:/{print $3}' < pear.desc | sed -re 's,-[^-]+-[^-]+.src.rpm$,,' | sort -u > pear.pkgs
29
30         # filter out tests, see https://bugs.launchpad.net/poldek/+bug/620362
31         sed -i -e '/-tests/d' pear.pkgs
32         # more packages affected
33         sed -i -e '/php-pear-Auth_Container_ADOdb/d' pear.pkgs
34         sed -i -e '/php-pear-DB_DataObject-cli/d' pear.pkgs
35         # not pear pkg
36         sed -i -e '/^php-pear$/d' pear.pkgs
37 }
38
39 [ -f pear.installed ] || {
40         sudo poldek  --update --upa
41         # as sudo & poldek don't allow us to capture (no pipe or redirection work),
42         # we create markers which we could grab when invoked via "script"
43         echo "BEGIN INSTALL PACKAGES"
44         sed -e 's,^,install ,' pear.pkgs | sudo poldek
45         echo "END INSTALL PACKAGES"
46         # rm -f pear.installed && script -c ./pear-autoup.sh pear.install.log
47         # sed -ne '/BEGIN INSTALL PACKAGES/,/END INSTALL PACKAGES/p' pear.install.log | grep -vE 'poldek:/.*install|: ambiguous name|equal version installed, skipped|Nothing to do' | less
48         touch pear.installed
49 }
50 [ -s pear.upgrades ] || pear list-upgrades > pear.upgrades
51
52 # process urls to aliases
53 [ -s pear.rpms ] || pear list-channels | sed -ne '4,$p' | while read url alias desc; do
54         awk -vurl="$url" -valias="$alias" '$1 == url {printf("php-%s-%s %s\n", alias, $2, $5)}' pear.upgrades
55 done > pear.rpms
56
57 # clear it if you do not want to upgrade pkgs. i.e bring ac to sync
58 do_upgrade=1
59 #do_upgrade=
60
61 topdir=$(rpm -E %_topdir)
62 for pkg in $(cat pear.pkgs); do
63         # check if there's update in channel
64         ver=$(awk -vpkg=$pkg '$1 == pkg {print $2}' pear.rpms)
65         [ "$ver" ] || continue
66
67         # skip already processed packages
68         [ -d $pkg ] && continue
69
70         # try upgrading with specified version
71         # pldnotify.awk uses "pear remote-info" which does not respect preferred package states
72         $builder -bb $pkg ${do_upgrade:+-u --upgrade-version $ver} --define "_unpackaged_files_terminate_build 1" || {
73                 cat >&2 <<-EOF
74
75                 $pkg failed
76
77                 EOF
78                 exit 1
79         }
80
81         # check for bad versions (which needs macros
82         ver=$(awk '/^Version:/{print $2; exit}' $topdir/$pkg/$pkg.spec)
83         case "$ver" in
84         *RC* | *a* | *b* | *alpha* | *beta* | *dev*)
85                 cat >&2 <<-EOF
86
87                 Package $pkg contains bad version: $ver
88                 Update it to use %subver macro instead.
89
90                 EOF
91                 exit 1
92                 ;;
93         esac
94 done
This page took 0.059592 seconds and 3 git commands to generate.