Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2011-06-09 20:43:25 +1000
committerDan McGee <dan@archlinux.org>2011-06-15 09:18:05 -0500
commit4272b37d3d9f112b9f089dafc2e7538c4c24f7b2 (patch)
tree54fd5b534896f19da2b212848f0f5454317bb58a /scripts
parent6f3a2145b0de7f27a1bf5932af3fe0a67171a881 (diff)
scripts: refactor output formatting functions
Move the common output formatting functions into a separate library file and import that into each script. makepkg is excluded due to its additional color formatting. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.am28
-rw-r--r--scripts/library/output_format.sh21
-rw-r--r--scripts/pacman-db-upgrade.sh.in9
-rw-r--r--scripts/pacman-key.sh.in21
-rw-r--r--scripts/pkgdelta.sh.in16
-rw-r--r--scripts/repo-add.sh.in22
6 files changed, 48 insertions, 69 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 5e8b57c4..1abf9c4c 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -25,6 +25,7 @@ EXTRA_DIST = \
$(LIBRARY)
LIBRARY = \
+ library/output_format.sh \
library/parse_options.sh
# Files that should be removed, but which Automake does not know.
@@ -69,13 +70,30 @@ $(OURSCRIPTS): Makefile
@chmod a-w $@.tmp
@mv $@.tmp $@
-makepkg: $(srcdir)/makepkg.sh.in $(srcdir)/library/parse_options.sh
-pacman-db-upgrade: $(srcdir)/pacman-db-upgrade.sh.in
-pacman-key: $(srcdir)/pacman-key.sh.in
+makepkg: \
+ $(srcdir)/makepkg.sh.in \
+ $(srcdir)/library/parse_options.sh
+
+pacman-db-upgrade: \
+ $(srcdir)/pacman-db-upgrade.sh.in \
+ $(srcdir)/library/output_format.sh
+
+pacman-key: \
+ $(srcdir)/pacman-key.sh.in \
+ $(srcdir)/library/output_format.sh
+
pacman-optimize: $(srcdir)/pacman-optimize.sh.in
-pkgdelta: $(srcdir)/pkgdelta.sh.in
+
+pkgdelta: \
+ $(srcdir)/pkgdelta.sh.in \
+ $(srcdir)/library/output_format.sh
+
rankmirrors: $(srcdir)/rankmirrors.sh.in
-repo-add: $(srcdir)/repo-add.sh.in
+
+repo-add: \
+ $(srcdir)/repo-add.sh.in \
+ $(srcdir)/library/output_format.sh
+
repo-remove: $(srcdir)/repo-add.sh.in
rm -f repo-remove
$(LN_S) repo-add repo-remove
diff --git a/scripts/library/output_format.sh b/scripts/library/output_format.sh
new file mode 100644
index 00000000..9e890e76
--- /dev/null
+++ b/scripts/library/output_format.sh
@@ -0,0 +1,21 @@
+msg() {
+ (( QUIET )) && return
+ local mesg=$1; shift
+ printf "==> ${mesg}\n" "$@" >&1
+}
+
+msg2() {
+ (( QUIET )) && return
+ local mesg=$1; shift
+ printf " -> ${mesg}\n" "$@" >&1
+}
+
+warning() {
+ local mesg=$1; shift
+ printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2
+}
+
+error() {
+ local mesg=$1; shift
+ printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
+} \ No newline at end of file
diff --git a/scripts/pacman-db-upgrade.sh.in b/scripts/pacman-db-upgrade.sh.in
index 17d8beb4..eaaa9346 100644
--- a/scripts/pacman-db-upgrade.sh.in
+++ b/scripts/pacman-db-upgrade.sh.in
@@ -28,15 +28,8 @@ myver='@PACKAGE_VERSION@'
eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
dbroot="${DBPath:-@localstatedir@/lib/pacman/}"
-msg() {
- local mesg=$1; shift
- printf "==> ${mesg}\n" "$@" >&2
-}
+m4_include(library/output_format.sh)
-error () {
- local mesg=$1; shift
- printf "==> ERROR: ${mesg}\n" "$@" >&2
-}
usage() {
printf "pacman-db-upgrade (pacman) %s\n\n" "$myver"
printf "$(gettext "Usage: %s [pacman_db_root]")\n\n" "$0"
diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in
index 20ec20fa..a757c9b8 100644
--- a/scripts/pacman-key.sh.in
+++ b/scripts/pacman-key.sh.in
@@ -26,26 +26,7 @@ export TEXTDOMAINDIR='@localedir@'
myver="@PACKAGE_VERSION@"
-msg() {
- local mesg=$1; shift
- printf "==> ${mesg}\n" "$@" >&1
-}
-
-msg2() {
- (( QUIET )) && return
- local mesg=$1; shift
- printf " -> ${mesg}\n" "$@" >&1
-}
-
-warning() {
- local mesg=$1; shift
- printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2
-}
-
-error() {
- local mesg=$1; shift
- printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
-}
+m4_include(library/output_format.sh)
usage() {
printf "pacman-key (pacman) %s\n" ${myver}
diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in
index d17b41d2..c5a48828 100644
--- a/scripts/pkgdelta.sh.in
+++ b/scripts/pkgdelta.sh.in
@@ -34,21 +34,7 @@ QUIET=0
# ensure we have a sane umask set
umask 0022
-msg() {
- (( QUIET )) && return
- local mesg=$1; shift
- printf "==> ${mesg}\n" "$@" >&1
-}
-
-warning() {
- local mesg=$1; shift
- printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2
-}
-
-error() {
- local mesg=$1; shift
- printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
-}
+m4_include(library/output_format.sh)
# print usage instructions
usage() {
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 0ffc0df5..6ccefd7b 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -38,27 +38,7 @@ CLEAN_LOCK=0
# ensure we have a sane umask set
umask 0022
-msg() {
- (( QUIET )) && return
- local mesg=$1; shift
- printf "==> ${mesg}\n" "$@" >&1
-}
-
-msg2() {
- (( QUIET )) && return
- local mesg=$1; shift
- printf " -> ${mesg}\n" "$@" >&1
-}
-
-warning() {
- local mesg=$1; shift
- printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2
-}
-
-error() {
- local mesg=$1; shift
- printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
-}
+m4_include(library/output_format.sh)
# print usage instructions
usage() {