X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=pear-autoup.sh;h=2811026b73d7ab8e95ad4dd2e933b3ece16fb1ff;hb=4f1efb15546a841cbdd878ff85c50769d1fd5dd0;hp=a1b63feecc995ac7cf1bf9fa2a76a0a6c1664f39;hpb=900580bb1da8cd5246a2d77542429293c8a93536;p=packages%2Frpm-build-tools.git diff --git a/pear-autoup.sh b/pear-autoup.sh index a1b63fe..2811026 100644 --- a/pear-autoup.sh +++ b/pear-autoup.sh @@ -7,12 +7,16 @@ set -e -[ -s pear.ls ] || poldek -q --skip-installed --cmd 'ls php-pear-*' > pear.ls -[ -s pear.desc ] || { - for pkg in $(cat pear.ls); do - poldek -q --skip-installed --cmd "desc $pkg" - done -} > pear.desc +# test that php is working +php -r 'echo "PHP is working OK\n";' + +# test that pear is working +pear info PEAR >/dev/null + +# needed pkgs for upgrade test +rpm -q php-packagexml2cl php-pear-PEAR_Command_Packaging + +[ -s pear.desc ] || { poldek --upa; poldek -q -Q --skip-installed --cmd 'search -r php-pear | desc' > pear.desc; } [ -s pear.pkgs ] || { awk '/^Source.package:/{print $3}' < pear.desc | sed -re 's,-[^-]+-[^-]+.src.rpm$,,' | sort -u > pear.pkgs @@ -27,17 +31,27 @@ set -e [ -f pear.installed ] || { sudo poldek --update --upa + # as sudo & poldek don't allow us to capture (no pipe or redirection work), + # we create markers which we could grab when invoked via "script" + echo "BEGIN INSTALL PACKAGES" sed -e 's,^,install ,' pear.pkgs | sudo poldek + echo "END INSTALL PACKAGES" + # rm -f pear.installed && script -c ./pear-autoup.sh pear.install.log + # 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 touch pear.installed } [ -s pear.upgrades ] || pear list-upgrades > pear.upgrades -# test that php is working -php -r 'echo "PHP is working OK\n";' +subst=$(pear list-channels | awk -vORS="|" '/^[a-z]/{print $2}') +subst="s/^php-(${subst%\|})-//" + +# clear it if you do not want to upgrade pkgs. i.e bring ac to sync +do_upgrade=1 +#do_upgrade= for pkg in $(cat pear.pkgs); do # check if there's update in channel - pearpkg=${pkg#php-pear-} + pearpkg=$(echo "$pkg" | sed -re "$subst") ver=$(awk -vpkg=$pearpkg '$2 == pkg {print $5}' pear.upgrades) [ "$ver" ] || continue @@ -46,7 +60,7 @@ for pkg in $(cat pear.pkgs); do # try upgrading with specified version # pldnotify.awk uses "pear remote-info" which does not respect preferred package states - ./builder -bb -u $pkg --upgrade-version $ver --define "_unpackaged_files_terminate_build 1" || { + ./builder -bb $pkg ${do_upgrade:+-u --upgrade-version $ver} --define "_unpackaged_files_terminate_build 1" || { cat >&2 <<-EOF $pkg failed