]>
Commit | Line | Data |
---|---|---|
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 | if [ $# -gt 0 ]; then | |
18 | echo "$*" | tr ' ' '\n' > pear.channels | |
19 | fi | |
20 | ||
21 | # test that php is working | |
22 | php -r 'echo "PHP is working OK\n";' | |
23 | ||
24 | # test that pear is working | |
25 | pear info PEAR >/dev/null | |
26 | ||
27 | # needed pkgs for upgrade test | |
28 | rpm -q php-packagexml2cl php-pear-PEAR_Command_Packaging | |
29 | ||
30 | [ -s pear.desc ] || { poldek --upa; poldek -q -Q --skip-installed --cmd 'search -r php-pear | desc' > pear.desc; } | |
31 | [ -s pear.pkgs ] || { | |
32 | awk '/^Source.package:/{print $3}' < pear.desc | sed -re 's,-[^-]+-[^-]+.src.rpm$,,' | sort -u > pear.pkgs | |
33 | ||
34 | # filter out tests, see https://bugs.launchpad.net/poldek/+bug/620362 | |
35 | sed -i -e '/-tests/d' pear.pkgs | |
36 | # more packages affected | |
37 | sed -i -e '/php-pear-Auth_Container_ADOdb/d' pear.pkgs | |
38 | sed -i -e '/php-pear-DB_DataObject-cli/d' pear.pkgs | |
39 | # not pear pkg | |
40 | sed -i -e '/^php-pear$/d' pear.pkgs | |
41 | } | |
42 | ||
43 | [ -f pear.installed ] || { | |
44 | sudo poldek --update --upa | |
45 | sed -e 's,^,install ,' pear.pkgs | sudo poldek | |
46 | touch pear.installed | |
47 | } | |
48 | [ -s pear.upgrades ] || pear list-upgrades > pear.upgrades | |
49 | ||
50 | # process urls to aliases | |
51 | [ -s pear.rpms ] || { | |
52 | [ -s pear.channels ] || pear list-channels | sed -ne '4,$p' > pear.channels | |
53 | 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.channels > pear.rpms | |
56 | } | |
57 | ||
58 | # clear it if you do not want to upgrade pkgs. i.e bring ac to sync | |
59 | do_upgrade=1 | |
60 | #do_upgrade= | |
61 | ||
62 | topdir=$(rpm -E %_topdir) | |
63 | for pkg in $(cat pear.pkgs); do | |
64 | # check if there's update in channel | |
65 | ver=$(awk -vpkg=$pkg '$1 == pkg {print $2}' pear.rpms) | |
66 | [ "$ver" ] || continue | |
67 | ||
68 | # skip already processed packages | |
69 | [ -d $pkg ] && continue | |
70 | ||
71 | # try upgrading with specified version | |
72 | # pldnotify.awk uses "pear remote-info" which does not respect preferred package states | |
73 | $builder -bb $pkg ${do_upgrade:+-u --upgrade-version $ver} --define "_unpackaged_files_terminate_build 1" || { | |
74 | cat >&2 <<-EOF | |
75 | ||
76 | $pkg failed | |
77 | ||
78 | EOF | |
79 | exit 1 | |
80 | } | |
81 | ||
82 | # check for bad versions (which needs macros | |
83 | ver=$(awk '/^Version:/{print $2; exit}' $topdir/$pkg/$pkg.spec) | |
84 | case "$ver" in | |
85 | *RC* | *a* | *b* | *alpha* | *beta* | *dev*) | |
86 | cat >&2 <<-EOF | |
87 | ||
88 | Package $pkg contains bad version: $ver | |
89 | Update it to use %subver macro instead. | |
90 | ||
91 | EOF | |
92 | exit 1 | |
93 | ;; | |
94 | esac | |
95 | done |