2 # Try to update pear packages from current distro repos to latest in
5 # Created Date: 2010-08-19
6 # Author: Elan Ruusamäe <glen@pld-linux.org>
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/*
17 # test that php is working
18 php -r 'echo "PHP is working OK\n";'
20 # test that pear is working
21 pear info PEAR >/dev/null
23 # needed pkgs for upgrade test
24 rpm -q php-packagexml2cl php-pear-PEAR_Command_Packaging
26 [ -s pear.desc ] || { poldek --upa; poldek -q -Q --skip-installed --cmd 'search -r php-pear | desc' > pear.desc; }
28 awk '/^Source.package:/{print $3}' < pear.desc | sed -re 's,-[^-]+-[^-]+.src.rpm$,,' | sort -u > pear.pkgs
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
36 sed -i -e '/^php-pear$/d' pear.pkgs
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
50 [ -s pear.upgrades ] || pear list-upgrades > pear.upgrades
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
57 # clear it if you do not want to upgrade pkgs. i.e bring ac to sync
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
67 # skip already processed packages
68 [ -d $pkg ] && continue
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" || {
81 # check for bad versions (which needs macros
82 ver=$(awk '/^Version:/{print $2; exit}' $topdir/$pkg/$pkg.spec)
84 *RC* | *a* | *b* | *alpha* | *beta* | *dev*)
87 Package $pkg contains bad version: $ver
88 Update it to use %subver macro instead.