]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - pear-autoup.sh
- search pear packages using php-pear dep to match other "pear" channels too
[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 # $Id$
6 # Author: Elan Ruusamäe <glen@pld-linux.org>
7
8 set -e
9
10 # test that php is working
11 php -r 'echo "PHP is working OK\n";'
12
13 # test that pear is working
14 pear info PEAR >/dev/null
15
16 # needed pkgs for upgrade test
17 rpm -q php-packagexml2cl php-pear-PEAR_Command_Packaging
18
19 [ -s pear.desc ] || { poldek --upa; poldek -q -Q --skip-installed --cmd 'search -r php-pear | desc' > pear.desc; }
20 [ -s pear.pkgs ] || {
21         awk '/^Source.package:/{print $3}' < pear.desc | sed -re 's,-[^-]+-[^-]+.src.rpm$,,' | sort -u > pear.pkgs
22
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
28         # not pear pkg
29         sed -i -e '/^php-pear$/d' pear.pkgs
30 }
31
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
41         touch pear.installed
42 }
43 [ -s pear.upgrades ] || pear list-upgrades > pear.upgrades
44
45 subst=$(pear list-channels | awk -vORS="|" '/^[a-z]/{print $2}')
46 subst="s/^php-(${subst%\|})-//"
47
48 for pkg in $(cat pear.pkgs); do
49         # check if there's update in channel
50         pearpkg=$(echo "$pkg" | sed -re "$subst")
51         ver=$(awk -vpkg=$pearpkg '$2 == pkg {print $5}' pear.upgrades)
52         [ "$ver" ] || continue
53
54         # skip already processed packages
55         [ -d $pkg ] && continue
56
57         # try upgrading with specified version
58         # pldnotify.awk uses "pear remote-info" which does not respect preferred package states
59         ./builder -bb -u $pkg --upgrade-version $ver --define "_unpackaged_files_terminate_build 1" || {
60                 cat >&2 <<-EOF
61
62                 $pkg failed
63
64                 EOF
65                 exit 1
66         }
67
68         # check for bad versions (which needs macros
69         ver=$(awk '/^Version:/{print $2; exit}' $pkg/$pkg.spec)
70         case "$ver" in
71         *RC* | *a* | *b* | *alpha* | *beta* | *dev*)
72                 cat >&2 <<-EOF
73
74                 Package $pkg contains bad version: $ver
75                 Update it to use %subver macro instead.
76
77                 EOF
78                 exit 1
79                 ;;
80         esac
81 done
This page took 0.0786249999999999 seconds and 4 git commands to generate.