mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
contrib/*: Hardcode program names
Add a read-only variable "$myname" to every contrib script and hardcode program names instead of relying on "$0". The variable name "$myname" was chosen because it is already used in pacman and because we use "$myver" to specify the program version in the official scripts. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
48188fbeee
commit
1038e66964
@ -23,7 +23,7 @@
|
|||||||
shopt -s extglob
|
shopt -s extglob
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
|
|
||||||
readonly progname="bacman"
|
declare -r myname='bacman'
|
||||||
readonly progver="0.2.1"
|
readonly progver="0.2.1"
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -31,8 +31,8 @@ readonly progver="0.2.1"
|
|||||||
#
|
#
|
||||||
usage() {
|
usage() {
|
||||||
echo "This program recreates a package using pacman's db and system files"
|
echo "This program recreates a package using pacman's db and system files"
|
||||||
echo "Usage: $progname <installed package name>"
|
echo "Usage: $myname <installed package name>"
|
||||||
echo "Example: $progname kernel26"
|
echo "Example: $myname kernel26"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (( $# != 1 )); then
|
if (( $# != 1 )); then
|
||||||
@ -46,7 +46,7 @@ if [[ $1 == "--help" || $1 == "-h" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $1 == "--version" || $1 == "-v" ]]; then
|
if [[ $1 == "--version" || $1 == "-v" ]]; then
|
||||||
echo "$progname version $progver"
|
echo "$myname version $progver"
|
||||||
echo "Copyright (C) 2008 locci"
|
echo "Copyright (C) 2008 locci"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -61,7 +61,7 @@ if (( EUID )); then
|
|||||||
/usr/bin/fakeroot -u -- "$0" "$@"
|
/usr/bin/fakeroot -u -- "$0" "$@"
|
||||||
exit $?
|
exit $?
|
||||||
else
|
else
|
||||||
echo "WARNING: installing fakeroot or running ${progname} as root is required to"
|
echo "WARNING: installing fakeroot or running $myname as root is required to"
|
||||||
echo " preserve the ownership permissions of files in some packages"
|
echo " preserve the ownership permissions of files in some packages"
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
@ -151,7 +151,7 @@ while read i; do
|
|||||||
echo ""
|
echo ""
|
||||||
echo "ERROR: unable to add /$i to the package"
|
echo "ERROR: unable to add /$i to the package"
|
||||||
echo " If your user does not have permssion to read this file then"
|
echo " If your user does not have permssion to read this file then"
|
||||||
echo " you will need to run $progname as root"
|
echo " you will need to run $myname as root"
|
||||||
rm -rf "$work_dir"
|
rm -rf "$work_dir"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -177,7 +177,7 @@ pkg_size=$(du -sk | awk '{print $1 * 1024}')
|
|||||||
# TODO adopt makepkg's write_pkginfo() into this or scripts/library
|
# TODO adopt makepkg's write_pkginfo() into this or scripts/library
|
||||||
#
|
#
|
||||||
echo Generating .PKGINFO metadata...
|
echo Generating .PKGINFO metadata...
|
||||||
echo "# Generated by $progname $progver" > .PKGINFO
|
echo "# Generated by $myname $progver" > .PKGINFO
|
||||||
if [[ $INFAKEROOT == "1" ]]; then
|
if [[ $INFAKEROOT == "1" ]]; then
|
||||||
echo "# Using $(fakeroot -v)" >> .PKGINFO
|
echo "# Using $(fakeroot -v)" >> .PKGINFO
|
||||||
fi
|
fi
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
shopt -s extglob
|
shopt -s extglob
|
||||||
|
|
||||||
|
declare -r myname='paccache'
|
||||||
|
|
||||||
declare -a candidates=() cmdopts=() whitelist=() blacklist=()
|
declare -a candidates=() cmdopts=() whitelist=() blacklist=()
|
||||||
declare -i delete=0 dryrun=0 filecount=0 move=0 needsroot=0 totalsaved=0 verbose=0
|
declare -i delete=0 dryrun=0 filecount=0 move=0 needsroot=0 totalsaved=0 verbose=0
|
||||||
declare cachedir=@localstatedir@/cache/pacman/pkg delim=$'\n' keep=3 movedir= scanarch=
|
declare cachedir=@localstatedir@/cache/pacman/pkg delim=$'\n' keep=3 movedir= scanarch=
|
||||||
@ -174,9 +176,9 @@ summarize() {
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
usage: ${0##*/} <operation> [options] [targets...]
|
usage: $myname <operation> [options] [targets...]
|
||||||
|
|
||||||
${0##*/} is a flexible pacman cache cleaning utility, which has numerous
|
$myname is a flexible pacman cache cleaning utility, which has numerous
|
||||||
options to help control how much, and what, is deleted from any directory
|
options to help control how much, and what, is deleted from any directory
|
||||||
containing pacman package tarballs.
|
containing pacman package tarballs.
|
||||||
|
|
||||||
|
@ -17,17 +17,19 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
declare -r myname='pacdiff'
|
||||||
|
|
||||||
diffprog=${DIFFPROG:-vimdiff}
|
diffprog=${DIFFPROG:-vimdiff}
|
||||||
diffsearchpath=${DIFFSEARCHPATH:-/etc}
|
diffsearchpath=${DIFFSEARCHPATH:-/etc}
|
||||||
locate=0
|
locate=0
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "pacdiff : a simple pacnew/pacorig/pacsave updater"
|
echo "$myname : a simple pacnew/pacorig/pacsave updater"
|
||||||
echo "Usage : pacdiff [-l]"
|
echo "Usage : $myname [-l]"
|
||||||
echo " -l/--locate makes pacdiff use locate rather than find"
|
echo " -l/--locate makes $myname use locate rather than find"
|
||||||
echo " DIFFPROG variable allows to override the default vimdiff"
|
echo " DIFFPROG variable allows to override the default vimdiff"
|
||||||
echo " DIFFSEARCHPATH allows to override the default /etc path"
|
echo " DIFFSEARCHPATH allows to override the default /etc path"
|
||||||
echo "Example : DIFFPROG=meld DIFFSEARCHPATH=\"/boot /etc /usr\" pacdiff"
|
echo "Example : DIFFPROG=meld DIFFSEARCHPATH=\"/boot /etc /usr\" $myname"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd() {
|
cmd() {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
declare -r myname='paclist'
|
||||||
|
|
||||||
export TEXTDOMAIN='pacman'
|
export TEXTDOMAIN='pacman'
|
||||||
export TEXTDOMAINDIR='/usr/share/locale'
|
export TEXTDOMAINDIR='/usr/share/locale'
|
||||||
|
|
||||||
@ -28,9 +30,9 @@ if ! type gettext &>/dev/null; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $1 ]]; then
|
if [[ -z $1 ]]; then
|
||||||
printf '%s - List all packages installed from a given repo\n' "${0##*/}"
|
printf '%s - List all packages installed from a given repo\n' "$myname"
|
||||||
printf 'Usage: %s <repo>\n' "${0##*/}"
|
printf 'Usage: %s <repo>\n' "$myname"
|
||||||
printf 'Example: %s testing\n' "${0##*/}"
|
printf 'Example: %s testing\n' "$myname"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -17,14 +17,16 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
declare -r myname='paclog-pkglist'
|
||||||
|
|
||||||
export TEXTDOMAIN='pacman'
|
export TEXTDOMAIN='pacman'
|
||||||
export TEXTDOMAINDIR='/usr/share/locale'
|
export TEXTDOMAINDIR='/usr/share/locale'
|
||||||
declare logfile=${1:-@localstatedir@/log/pacman.log}
|
declare logfile=${1:-@localstatedir@/log/pacman.log}
|
||||||
|
|
||||||
if [[ $1 ]]; then
|
if [[ $1 ]]; then
|
||||||
if [[ $1 = -@(h|-help) ]]; then
|
if [[ $1 = -@(h|-help) ]]; then
|
||||||
printf 'usage: %s [pacman log]\n' "${0##*/}"
|
printf 'usage: %s [pacman log]\n' "$myname"
|
||||||
printf 'example: %s @localstatedir@/log/pacman.log\n' "${0##*/}"
|
printf 'example: %s @localstatedir@/log/pacman.log\n' "$myname"
|
||||||
printf '\ndefaults to: @localstatedir@/log/pacman.log\n'
|
printf '\ndefaults to: @localstatedir@/log/pacman.log\n'
|
||||||
exit 0
|
exit 0
|
||||||
elif [[ ! -e $logfile ]]; then
|
elif [[ ! -e $logfile ]]; then
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
set -o nounset
|
set -o nounset
|
||||||
set -o errexit
|
set -o errexit
|
||||||
|
|
||||||
progname=$(basename $0)
|
declare -r myname='pacscripts'
|
||||||
progver="0.4"
|
progver="0.4"
|
||||||
|
|
||||||
conf="@sysconfdir@/pacman.conf"
|
conf="@sysconfdir@/pacman.conf"
|
||||||
@ -47,14 +47,14 @@ error() {
|
|||||||
usage() {
|
usage() {
|
||||||
echo "This program prints out the {pre,post}_{install,remove,upgrade} scripts"
|
echo "This program prints out the {pre,post}_{install,remove,upgrade} scripts"
|
||||||
echo "of a given package."
|
echo "of a given package."
|
||||||
echo "Usage: $progname pkgname|pkgfile"
|
echo "Usage: $myname pkgname|pkgfile"
|
||||||
echo
|
echo
|
||||||
echo " OPTIONS:"
|
echo " OPTIONS:"
|
||||||
echo " -h, --help Print this help message"
|
echo " -h, --help Print this help message"
|
||||||
echo " -v, --version Print program name and version"
|
echo " -v, --version Print program name and version"
|
||||||
echo
|
echo
|
||||||
echo "Example: $progname gconf-editor"
|
echo "Example: $myname gconf-editor"
|
||||||
echo "Example: $progname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz"
|
echo "Example: $myname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz"
|
||||||
}
|
}
|
||||||
|
|
||||||
spacman() {
|
spacman() {
|
||||||
@ -127,6 +127,6 @@ fi
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--help|-h) usage; exit 0 ;;
|
--help|-h) usage; exit 0 ;;
|
||||||
--version|-v) echo "$progname version $progver"; exit 0 ;;
|
--version|-v) echo "$myname version $progver"; exit 0 ;;
|
||||||
*) print_scriptlet $1 ;;
|
*) print_scriptlet $1 ;;
|
||||||
esac
|
esac
|
||||||
|
@ -24,13 +24,13 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
my $progname = "pacsearch";
|
my $myname = 'pacsearch';
|
||||||
my $version = "2.0";
|
my $version = "2.0";
|
||||||
|
|
||||||
if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") {
|
if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") {
|
||||||
print "$progname - Add color and install information to a pacman -Ss search\n";
|
print "$myname - Add color and install information to a pacman -Ss search\n";
|
||||||
print "Usage: $progname <pattern>\n";
|
print "Usage: $myname <pattern>\n";
|
||||||
print "Example: $progname ^gnome\n";
|
print "Example: $myname ^gnome\n";
|
||||||
if ($#ARGV lt 0) {
|
if ($#ARGV lt 0) {
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($ARGV[0] eq "--version" || $ARGV[0] eq "-v") {
|
if ($ARGV[0] eq "--version" || $ARGV[0] eq "-v") {
|
||||||
print "$progname version $version\n";
|
print "$myname version $version\n";
|
||||||
print "Copyright (C) 2006-2011 Dan McGee\n";
|
print "Copyright (C) 2006-2011 Dan McGee\n";
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user