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