]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - pear-autoup.sh
restore execute bits
[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 # clear it if you do not want to upgrade pkgs. i.e bring ac to sync
49 do_upgrade=1
50 #do_upgrade=
51
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
57
58         # skip already processed packages
59         [ -d $pkg ] && continue
60
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" || {
64                 cat >&2 <<-EOF
65
66                 $pkg failed
67
68                 EOF
69                 exit 1
70         }
71
72         # check for bad versions (which needs macros
73         ver=$(awk '/^Version:/{print $2; exit}' $pkg/$pkg.spec)
74         case "$ver" in
75         *RC* | *a* | *b* | *alpha* | *beta* | *dev*)
76                 cat >&2 <<-EOF
77
78                 Package $pkg contains bad version: $ver
79                 Update it to use %subver macro instead.
80
81                 EOF
82                 exit 1
83                 ;;
84         esac
85 done
This page took 0.040459 seconds and 4 git commands to generate.