1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-10-31 23:55:04 -04:00
Commit Graph

14 Commits

Author SHA1 Message Date
Lukas Fleischer
a77e638c77 contrib/*: Support the "--help" and "--version" options
Add "--help"/"-h" and "--version"/"-V" support to all contrib scripts.
Also, update scripts that used "-v" as a short option for "--version"
and use "-V" for the sake of consistency.

Additionally:

* Move version and usage messages to separate convenience functions in
  all scripts.

* Add a workaround to paccache to support "--help" and "--version". This
  should be replaced by a proper POSIX-compliant command line parser
  that supports long options in a future patch.

* Add a "$myver" variable to all scripts and use it whenever we refer to
  the program version (e.g. in version messages). Also, use the pacman
  version number everywhere instead of using a different versioning
  scheme for each contrib script. This is achieved by adding a
  "PACKAGE_VERSION" placeholder that is replaced by sed(1) when the
  script is built.

* Ensure we always return with exit status 0 if "--help" is used and
  return with exit status 1 if we display the usage message due to
  invalid arguments.

* Add "AUTOMAKE_OPTIONS = std-options" and add all scripts to
  "bin_SCRIPTS" to make `make installcheck` check that installed scripts
  actually support the "--help" and "--version" options.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-23 14:49:46 -06:00
Dan McGee
2a4df070c3 Merge branch 'maint' 2011-12-12 14:07:44 -06:00
Dave Reisner
67290441b8 contrib/paccache: silence possible output from cd
If CDPATH is set, this could possibly write to stdout.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-12 12:52:40 -06:00
Lukas Fleischer
1038e66964 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>
2011-12-07 09:59:30 -06:00
Dave Reisner
1052709921 paccache: add vim modeline
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-26 17:46:59 -05:00
Dave Reisner
24881034f6 paccache: ensure seen/seenarch vars are set
Doesn't do a whole lot of good to compare against values that are never
set. Fixes bug where -vvv output wasn't grouping packages together
properly.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-26 17:46:53 -05:00
lolilolicon
6bb5948025 paccache: proper quoting in [[ expression ]]
Always quote the right-hand side of expression when the == or != operator
is used, unless intended as a pattern.

Signed-off-by: lolilolicon <lolilolicon@gmail.com>
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-30 10:48:49 -05:00
lolilolicon
e0400fff96 paccache: declare variables explicitly
Declare and initialize integer variables 'needsroot' and 'verbose'.
Don't use the fact that (( undefined_variable )) evaluates to 0.

Signed-off-by: lolilolicon <lolilolicon@gmail.com>
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-30 10:48:43 -05:00
lolilolicon
83c05e71bc paccache: allow strictly integer for -k option
Verify the argument to -k is a non-negative integer.  Leading zeros
are simply stripped.

'declare -i keep' allowed the argument to -k to be any arithmetic
evaluation expression.  The simple assignment 'keep=$OPTARG' triggers
arithmetic evaluation implicitly, which can either consume a huge amount
of resources with input such as '2**2**32' or immediately produce an error
on invalid input.  Instead, we simply 'declare -- keep' and avoid all that.

Signed-off-by: lolilolicon <lolilolicon@gmail.com>
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-29 13:02:41 -05:00
Dave Reisner
7ad78c2c88 paccache: remove unnecessary if check
This is superfluous as the ensuing for loop will exit immediately on the
same condition avoided by the if.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-18 15:34:54 -05:00
Dave Reisner
7f1235ccbc paccache: escape . in trimming of diskspace string
Before:
==> finished dry run: 2 candidates (diskspace saved: 7. MiB)

After:
==> finished dry run: 2 candidates (diskspace saved: 7.8 MiB)

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-11 13:46:07 +10:00
Dave Reisner
5136df0f39 paccache: use pacsort instead of sort -V
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08 16:49:56 -05:00
Dave Reisner
1e16b94a85 contrib/paccache: misc cleanup and bugfix
* change error verbiage when run as root
* delete sigs along with packages
* fix bug in diskspace calculations
* merge END block in pkgfilter

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08 13:29:45 -05:00
Dave Reisner
6997a738bb paccache: add new contrib script
paccache is a robust and flexible package cache cleaner with a variety
of options. Much credit goes to DJ Mills and Pat Brisbin for ideas
behind this script.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
[Dan: add .gitignore entry]
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-02 08:24:06 -04:00