[pacman-dev] [PATCH] checkupdates: add new contrib script
checkupdates provides a way of checking for new updates without touching the local sync database. Based heavily on a script by Dave Reisner. --- contrib/.gitignore | 1 + contrib/Makefile.am | 3 +++ contrib/checkupdates.in | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 0 deletions(-) create mode 100644 contrib/checkupdates.in diff --git a/contrib/.gitignore b/contrib/.gitignore index 19b81e0..36c0918 100644 --- a/contrib/.gitignore +++ b/contrib/.gitignore @@ -1,5 +1,6 @@ bacman bash_completion +checkupdates paccache pacdiff paclist diff --git a/contrib/Makefile.am b/contrib/Makefile.am index eca39e7..1ead042 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -6,6 +6,7 @@ bin_SCRIPTS = \ OURSCRIPTS = \ bacman \ + checkupdates \ paccache \ pacdiff \ paclist \ @@ -22,6 +23,7 @@ EXTRA_DIST = \ PKGBUILD.vim \ bacman.in \ bash_completion.in \ + checkupdates.in \ paccache.in \ paclog-pkglist.in \ pacdiff.in \ @@ -76,6 +78,7 @@ uninstall-local: bacman: $(srcdir)/bacman.in bash_completion: $(srcdir)/bash_completion.in +checkupdates: $(srcdir)/checkupdates.in paccache: $(srcdir)/paccache.in pacdiff: $(srcdir)/pacdiff.in paclist: $(srcdir)/paclist.in diff --git a/contrib/checkupdates.in b/contrib/checkupdates.in new file mode 100644 index 0000000..e16378f --- /dev/null +++ b/contrib/checkupdates.in @@ -0,0 +1,44 @@ +#!/bin/bash +# +# checkupdates: Safely print a list of pending updates. +# +# Copyright (c) 2011 Kyle Keen <keenerd@gmail.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +if (( $# > 0 )); then + echo "checkupdate: Safely print a list of pending updates." + echo "Use: checkupdates" + echo "Export the 'CHECKUPDATE_DB' variable to change the path of the temporary database." + exit 0 +fi + +if [[ -z $CHECKUPDATE_DB ]]; then + CHECKUPDATE_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/" +fi + +trap 'rm -f $CHECKUPDATE_DB/db.lck' INT TERM EXIT + +eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf) +DBPath="${DBPath:-@localstatedir@/lib/pacman/}" + +mkdir -p "$CHECKUPDATE_DB" +ln -s "${DBPath}/local" "$CHECKUPDATE_DB" &> /dev/null +fakeroot pacman -Sqy --dbpath "$CHECKUPDATE_DB" &> /dev/null +pacman -Qqu --dbpath "$CHECKUPDATE_DB" 2> /dev/null + +exit 0 + +# vim: set ts=2 sw=2 noet: -- 1.7.9
On 24/02/12 15:39, keenerd wrote:
checkupdates provides a way of checking for new updates without touching the local sync database. Based heavily on a script by Dave Reisner.
Ack. Although note there was a line wrap done in the middle of this patch. Did you send using git-send-email? Allan
On Fri, Feb 24, 2012 at 12:39 AM, keenerd <keenerd@gmail.com> wrote:
checkupdates provides a way of checking for new updates without touching the local sync database. Based heavily on a script by Dave Reisner. --- contrib/.gitignore | 1 + contrib/Makefile.am | 3 +++ contrib/checkupdates.in | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 0 deletions(-) create mode 100644 contrib/checkupdates.in
diff --git a/contrib/.gitignore b/contrib/.gitignore index 19b81e0..36c0918 100644 --- a/contrib/.gitignore +++ b/contrib/.gitignore @@ -1,5 +1,6 @@ bacman bash_completion +checkupdates paccache pacdiff paclist diff --git a/contrib/Makefile.am b/contrib/Makefile.am index eca39e7..1ead042 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -6,6 +6,7 @@ bin_SCRIPTS = \
OURSCRIPTS = \ bacman \ + checkupdates \ paccache \ pacdiff \ paclist \ @@ -22,6 +23,7 @@ EXTRA_DIST = \ PKGBUILD.vim \ bacman.in \ bash_completion.in \ + checkupdates.in \ paccache.in \ paclog-pkglist.in \ pacdiff.in \ @@ -76,6 +78,7 @@ uninstall-local:
bacman: $(srcdir)/bacman.in bash_completion: $(srcdir)/bash_completion.in +checkupdates: $(srcdir)/checkupdates.in paccache: $(srcdir)/paccache.in pacdiff: $(srcdir)/pacdiff.in paclist: $(srcdir)/paclist.in diff --git a/contrib/checkupdates.in b/contrib/checkupdates.in new file mode 100644 index 0000000..e16378f --- /dev/null +++ b/contrib/checkupdates.in @@ -0,0 +1,44 @@ +#!/bin/bash +# +# checkupdates: Safely print a list of pending updates. +# +# Copyright (c) 2011 Kyle Keen <keenerd@gmail.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +if (( $# > 0 )); then + echo "checkupdate: Safely print a list of pending updates."
Very minor, but shouldn't that be checkupdates and not checkupdate?
+ echo "Use: checkupdates" + echo "Export the 'CHECKUPDATE_DB' variable to change the path of the temporary database." + exit 0 +fi + +if [[ -z $CHECKUPDATE_DB ]]; then + CHECKUPDATE_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/" +fi + +trap 'rm -f $CHECKUPDATE_DB/db.lck' INT TERM EXIT
If I export CHECKUPDATE_DB to a path with a space this could delete a file that it shouldn't.
+ +eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf) +DBPath="${DBPath:-@localstatedir@/lib/pacman/}" + +mkdir -p "$CHECKUPDATE_DB" +ln -s "${DBPath}/local" "$CHECKUPDATE_DB" &> /dev/null +fakeroot pacman -Sqy --dbpath "$CHECKUPDATE_DB" &> /dev/null +pacman -Qqu --dbpath "$CHECKUPDATE_DB" 2> /dev/null + +exit 0 + +# vim: set ts=2 sw=2 noet: -- 1.7.9
participants (3)
-
Allan McRae
-
canyonknight@gmail.com
-
keenerd