]>
wolfpit.net Git - tool/Arch-pacman/.git/blob - contrib/pacscripts.sh.in
368e0850a347a9a52c9f975f0f7ce5c6f7c2b4e5
3 # pacscripts : tries to print out the {pre,post}_{install,remove,upgrade}
4 # scripts of a given package
6 # Copyright (c) 2009 Giulio "giulivo" Fidente <giulivo.navigante@gmail.com>
7 # Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>
8 # Copyright (c) 2009-2013 Pacman Development Team <pacman-dev@archlinux.org>
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
28 declare -r myname
='pacscripts'
29 declare -r myver
='@PACKAGE_VERSION@'
31 conf
="@sysconfdir@/pacman.conf"
33 if [ ! -r "$conf" ]; then
34 echo "ERROR: unable to read $conf"
38 eval $(awk '/DBPath/ {print $1$2$3}' "$conf")
39 eval $(awk '/CacheDir/ {print $1$2$3}' "$conf")
40 pac_db
="${DBPath:-@localstatedir@/lib/pacman}/local"
41 pac_cache
="${CacheDir:-@localstatedir@/cache/pacman/pkg}"
45 printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
49 echo "This program prints out the {pre,post}_{install,remove,upgrade} scripts"
50 echo "of a given package."
51 echo "Usage: $myname pkgname|pkgfile"
54 echo " -h, --help Print this help message"
55 echo " -v, --version Print program name and version"
57 echo "Example: $myname gconf-editor"
58 echo "Example: $myname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz"
62 printf "%s %s\n" "$myname" "$myver"
63 echo 'Copyright (c) 2009 Giulio "giulivo" Fidente <giulivo.navigante@gmail.com>'
64 echo 'Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>'
68 if [ $EUID -eq 0 ]; then
71 if ! type -p sudo
; then
72 error
"Cannot find the sudo binary! Is sudo installed?"
73 error
"Otherwise try to run the program as root"
84 if [ -f $pac_db/$pkg*/install ]; then
85 cat $pac_db/$pkg*/install
89 error
"Package $1 does not include any .INSTALL script"
95 if ! bsdtar
-xqOf "$1" .INSTALL
2>/dev
/null
; then
96 error
"Package $1 does not include any .INSTALL script"
104 if bsdtar tf
"$1" .PKGINFO
&>/dev
/null
; then
109 if pacman
-Q "$1" &>/dev
/null
; then
113 if ! pacman
-Si $1 &>/dev
/null
; then
114 error
"Package $1 not found"
117 url
=$(spacman -Sdp $1 | tail -n1)
118 filename
=$(basename $url)
119 if [ ! -f "$pac_cache/$filename" ]; then
120 if ! spacman
-Sdw --noconfirm $1 >&2; then
121 error
"Failed to download $1"
126 print_pkg
"$pac_cache/$filename"
130 if [ $# -ne 1 ] ; then
136 --help|-h) usage
; exit 0 ;;
137 --version|-V) version
; exit 0 ;;
138 *) print_scriptlet
$1 ;;