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 # test that php is working
13 php -r 'echo "PHP is working OK\n";'
15 # test that pear is working
16 pear info PEAR >/dev/null
18 # needed pkgs for upgrade test
19 rpm -q php-packagexml2cl php-pear-PEAR_Command_Packaging
21 [ -s pear.desc ] || { poldek --upa; poldek -q -Q --skip-installed --cmd 'search -r php-pear | desc' > pear.desc; }
23 awk '/^Source.package:/{print $3}' < pear.desc | sed -re 's,-[^-]+-[^-]+.src.rpm$,,' | sort -u > pear.pkgs
25 # filter out tests, see https://bugs.launchpad.net/poldek/+bug/620362
26 sed -i -e '/-tests/d' pear.pkgs
27 # more packages affected
28 sed -i -e '/php-pear-Auth_Container_ADOdb/d' pear.pkgs
29 sed -i -e '/php-pear-DB_DataObject-cli/d' pear.pkgs
31 sed -i -e '/^php-pear$/d' pear.pkgs
34 [ -f pear.installed ] || {
35 sudo poldek --update --upa
36 # as sudo & poldek don't allow us to capture (no pipe or redirection work),
37 # we create markers which we could grab when invoked via "script"
38 echo "BEGIN INSTALL PACKAGES"
39 sed -e 's,^,install ,' pear.pkgs | sudo poldek
40 echo "END INSTALL PACKAGES"
41 # rm -f pear.installed && script -c ./pear-autoup.sh pear.install.log
42 # 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
45 [ -s pear.upgrades ] || pear list-upgrades > pear.upgrades
47 subst=$(pear list-channels | awk -vORS="|" '/^[a-z]/{print $2}')
48 subst="s/^php-(${subst%\|})-//"
50 # clear it if you do not want to upgrade pkgs. i.e bring ac to sync
54 topdir=$(rpm -E %_topdir)
55 for pkg in $(cat pear.pkgs); do
56 # check if there's update in channel
57 pearpkg=$(echo "$pkg" | sed -re "$subst")
58 ver=$(awk -vpkg=$pearpkg '$2 == pkg {print $5}' pear.upgrades)
59 [ "$ver" ] || continue
61 # skip already processed packages
62 [ -d $pkg ] && continue
64 # try upgrading with specified version
65 # pldnotify.awk uses "pear remote-info" which does not respect preferred package states
66 $builder -bb $pkg ${do_upgrade:+-u --upgrade-version $ver} --define "_unpackaged_files_terminate_build 1" || {
75 # check for bad versions (which needs macros
76 ver=$(awk '/^Version:/{print $2; exit}' $topdir/$pkg/$pkg.spec)
78 *RC* | *a* | *b* | *alpha* | *beta* | *dev*)
81 Package $pkg contains bad version: $ver
82 Update it to use %subver macro instead.