FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 03-02-2009, 05:54 PM
Allan McRae
 
Default contrib/pacsrcipts - print install scripts from a package

Prints the install script from a given package file or from a package
in the pacman repo.

Original-work-by: Giulio "giulivo" Fidente <giulivo.navigante@gmail.com>
Improvements-by: Xavier Chantry <shiningxc@gmail.com>

Signed-off-by: Allan McRae <allan@archlinux.org>
---
contrib/Makefile.am | 1 +
contrib/README | 3 +
contrib/pacscripts | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++ +
3 files changed, 136 insertions(+), 0 deletions(-)
create mode 100755 contrib/pacscripts

diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 2f131ef..3843a3f 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -5,6 +5,7 @@ EXTRA_DIST =
gensync
pacdiff
paclist
+ pacscripts
pacsearch
pactree
updatesync
diff --git a/contrib/README b/contrib/README
index 29962b4..0d2153b 100644
--- a/contrib/README
+++ b/contrib/README
@@ -16,6 +16,9 @@ paclist - list all packages installed from a given repository. Useful for
seeing which packages you may have installed from the testing repository,
for instance.

+pacscripts - tries to print out the {pre,post}_{install,remove,upgrade}
+scripts of a given package.
+
pacsearch - a colorized search combining both -Ss and -Qs output. Installed
packages are easily identified with a *** and local-only packages are also
listed.
diff --git a/contrib/pacscripts b/contrib/pacscripts
new file mode 100755
index 0000000..101fb15
--- /dev/null
+++ b/contrib/pacscripts
@@ -0,0 +1,132 @@
+#!/bin/bash
+#
+# pacscripts : tries to print out the {pre,post}_{install,remove,upgrade}
+# scripts of a given package
+#
+# Copyright (c) 2009 Giulio "giulivo" Fidente <giulivo.navigante@gmail.com>
+# Copyright (c) 2009 Xavier Chantry <shiningxc@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/>.
+#
+
+# bash options
+set -o nounset
+set -o errexit
+
+progname=$(basename $0)
+progver="0.4"
+
+conf="/etc/pacman.conf"
+
+if [ ! -r "$conf" ]; then
+ echo "ERROR: unable to read $conf"
+ exit 1
+fi
+
+eval $(awk '/DBPath/ {print $1$2$3}' "$conf")
+eval $(awk '/CacheDir/ {print $1$2$3}' "$conf")
+pac_db="${DBPath:-/var/lib/pacman}/local"
+pac_cache="${CacheDir:-/var/cache/pacman/pkg}"
+
+error() {
+ local mesg=$1; shift
+ printf "==> $(gettext "ERROR:") ${mesg}
" "$@" >&2
+}
+
+usage() {
+ echo "This program prints out the {pre,post}_{install,remove,upgrade} scripts"
+ echo "of a given package."
+ echo "Usage: $progname pkgname|pkgfile"
+ echo
+ echo " OPTIONS:"
+ echo " -h, --help Print this help message"
+ echo " -v, --version Print program name and version"
+ echo
+ echo "Example: $progname gconf-editor"
+ echo "Example: $progname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz"
+}
+
+spacman() {
+ if [ $EUID -eq 0 ]; then
+ pacman "$@"
+ else
+ if [ ! "$(type -p sudo)" ]; then
+ error "Cannot find the sudo binary! Is sudo installed?"
+ error "Otherwise try to run the program as root"
+ exit 1
+ else
+ sudo pacman "$@"
+ fi
+ fi
+}
+
+print_db() {
+ pkg=$(pacman -Q "$1")
+ pkg=${pkg/ /-}
+ if [ -f $pac_db/$pkg*/install ]; then
+ cat $pac_db/$pkg*/install
+ echo
+ return 0
+ else
+ error "Package $1 does not include any .INSTALL script"
+ return 1
+ fi
+}
+
+print_pkg() {
+ if ! bsdtar -xOf "$1" .INSTALL 2>/dev/null; then
+ error "Package $1 does not include any .INSTALL script"
+ return 1
+ fi
+ echo
+}
+
+print_scriptlet() {
+ if [ -f "$1" ]; then
+ if bsdtar tf "$1" .PKGINFO &>/dev/null; then
+ print_pkg "$1"
+ return
+ fi
+ fi
+ if pacman -Q "$1" &>/dev/null; then
+ print_db "$1"
+ return
+ fi
+ if ! pacman -Si $1 &>/dev/null; then
+ error "Package $1 not found"
+ return 1
+ fi
+ url=$(spacman -Sdp $1 | tail -n1)
+ filename=$(basename $url)
+ if [ ! -f "$pac_cache/$filename" ]; then
+ if ! spacman -Sdw --noconfirm $1 >&2; then
+ error "Failed to download $1"
+ return 1
+ fi
+ echo >&2
+ fi
+ print_pkg "$pac_cache/$filename"
+ return
+}
+
+if [ $# -ne 1 ] ; then
+ usage
+ exit 1
+fi
+
+case "$1" in
+ --help|-h) usage; exit 0 ;;
+ --version|-v) echo "$progname version $progver"; exit 0 ;;
+ *) print_scriptlet $1 ;;
+esac
--
1.6.1.3

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://www.archlinux.org/mailman/listinfo/pacman-dev
 

Thread Tools




All times are GMT. The time now is 08:26 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org