diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-09-11 10:52:43 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-09-11 15:43:37 -0400 |
commit | 7f62d865ae7384f4c4bd489e2682ba52fabb7b62 (patch) | |
tree | 46d698d171d551ff412a0843d2ca90dfce7088e3 | |
parent | 834db9d400be1795426eb88cf25c9e817141d326 (diff) |
chroot-tools: internationalize
-rw-r--r-- | src/chroot-tools/Makefile | 3 | ||||
-rwxr-xr-x | src/chroot-tools/chcleanup | 12 | ||||
-rwxr-xr-x | src/chroot-tools/distcc-tool | 42 | ||||
-rwxr-xr-x | src/chroot-tools/librechroot | 155 | ||||
-rwxr-xr-x | src/chroot-tools/libremakepkg | 62 |
5 files changed, 145 insertions, 129 deletions
diff --git a/src/chroot-tools/Makefile b/src/chroot-tools/Makefile index 7f6a7ea..258caea 100644 --- a/src/chroot-tools/Makefile +++ b/src/chroot-tools/Makefile @@ -31,3 +31,6 @@ archroot: %: %.in Makefile @echo "GEN $@" @$(edit) <"$<" >"$@" || { rm -f -- '$@'; false; } @chmod 755 "$@" || { rm -f -- '$@'; false; } + +distcc-tool.pot: distcc-tool + xgettext --omit-header -i --from-code=UTF-8 -L shell --keyword={error,errusage} -o $@ $< diff --git a/src/chroot-tools/chcleanup b/src/chroot-tools/chcleanup index d2d9a70..fa6a572 100755 --- a/src/chroot-tools/chcleanup +++ b/src/chroot-tools/chcleanup @@ -12,18 +12,24 @@ DRYRUN=${DRYRUN:-false} ################################################################################ # Define these here to avoid having dependencies on outside files +if type gettext &>/dev/null; then + _() { gettext "$@"; } +else + _() { echo "$@"; } +fi + msg() { - local mesg=$1; shift + local mesg="$(_ "$1")"; shift printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } msg2() { - local mesg=$1; shift + local mesg="$(_ "$1")"; shift printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } error() { - local mesg=$1; shift + local mesg="$(_ "$1")"; shift printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } diff --git a/src/chroot-tools/distcc-tool b/src/chroot-tools/distcc-tool index 3f7a30f..67bcd2d 100755 --- a/src/chroot-tools/distcc-tool +++ b/src/chroot-tools/distcc-tool @@ -28,35 +28,45 @@ # On Parabola, this means the packages: # bash, coreutils, sed, socat +if ! type gettext &>/dev/null; then + gettext() { echo "$@"; } +fi + panic() { - echo 'panic: malformed call to internal function' >&2 + echo "$(gettext 'panic: malformed call to internal function')" >&2 exit 1 } error() { - fmt=$1; shift - printf "ERROR: $fmt\n" "$@" >&2 + mesg="$(gettext "$1")"; shift + printf "$(gettext 'ERROR:') $mesg\n" "$@" >&2 exit 1 } +print() { + local mesg=$1 + shift + printf -- "$(gettext "$mesg")\n" "$@" +} + usage() { - echo "Usage: $0 COMMAND [COMMAND-ARGS]" - echo "Tool for using distcc within a networkless chroot" + print "Usage: $0 COMMAND [COMMAND-ARGS]" + print "Tool for using distcc within a networkless chroot" echo - echo "Commands:" - echo ' help print this message' - echo ' odaemon CHROOTPATH daemon to run outside of the chroot' - echo ' idaemon DISTCC_HOSTS daemon to run inside of the chroot' - echo ' rewrite DISTCC_HOSTS prints a rewritten version of DISTCC_HOSTS' - echo ' client HOST PORT connects stdio to TCP:$HOST:$PORT' - echo 'Commands: for internal use' - echo ' server counterpart to client; spawned by odaemon' + print "Commands:" + print ' help print this message' + print ' odaemon CHROOTPATH daemon to run outside of the chroot' + print ' idaemon DISTCC_HOSTS daemon to run inside of the chroot' + print ' rewrite DISTCC_HOSTS prints a rewritten version of DISTCC_HOSTS' + print ' client HOST PORT connects stdio to TCP:$HOST:$PORT' + print 'Commands: for internal use' + print ' server counterpart to client; spawned by odaemon' } errusage() { if [[ $# -gt 0 ]]; then - fmt=$1; shift - printf "ERROR: $fmt\n" "$@" >&2 + fmt="$(gettext "$1")"; shift + printf "$(gettext 'ERROR:') $fmt\n" "$@" >&2 fi usage >&2 exit 1 @@ -125,7 +135,7 @@ parse_DISTCC_HOSTS() { ;; # ZEROCONF +zeroconf) - error "$0 does not support the +zeroconf option" + error "%s does not support the +zeroconf option" "$0" exit 1 ;; # TCP_HOST or OLDSTYLE_TCP_HOST diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 91afe3e..e82b18c 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -44,82 +44,81 @@ make_empty_repo() { ln -s "repo.db.tar.gz" "${copydir}/repo/repo.db" } -cmd=${0##*/} usage() { calculate_directories - echo "Usage: $cmd [OPTIONS] COMMAND [ARGS...]" - echo 'Interacts with an archroot (arch chroot).' - echo '' - echo 'This is configured with `chroot.conf`, either in' - echo '`/etc/libretools.d/`, or `$XDG_CONFIG_HOME/libretools/`.' - echo 'The variables you may set are $CHROOTDIR, $CHROOT, and' - echo '$CHROOTEXTRAPKG'. - echo '' - echo 'There may be multiple chroots; they are stored in $CHROOTDIR.' - echo '' - echo 'Each chroot is named; the default is configured with $CHROOT.' - echo '' - echo "Each named chroot has a master clean copy (named 'root'), and any" - echo 'number of other named copies; the copy used by default is the' - echo "current username (or \$SUDO_USER, or 'copy' if root)." - echo '' - echo 'The full path to the chroot copy is "$CHROOTDIR/$CHROOT/$COPY",' - echo 'unless the copy name is manually specified as an absolute path,' - echo 'in which case, that path is used.' - echo '' - echo 'The current settings for the above varibles are:' - echo " CHROOTDIR : ${CHROOTDIR:-ERROR: NO SETTING}" - echo " CHROOT : ${CHROOT:-ERROR: NO SETTING}" - echo " COPY : $COPY" - echo " rootdir : ${rootdir:-ERROR}" - echo " copydir : ${copydir:-ERROR}" - echo '' - echo 'If the chroot, or copy does not exist, it will be created' - echo 'automatically. A chroot by default contains the packages in the' - echo 'group "base-devel", and any packages named in $CHROOTEXTRAPKG.' - echo 'Unless the `-C` or `-M` flags are used, the configuration files' - echo 'that this program installs are the stock versions supplied in the' - echo 'packages, not the versions from your host system. Other tools' - echo '(such as libremakepkg) may alter the configuration.' - echo '' - echo 'This command will make the following configuration changes in' - echo 'the chroot:' - echo ' - overwrite `/etc/libretools.d/chroot.conf`' - echo ' - overwrite `/etc/pacman.d/mirrorlist`' - echo ' - set `CacheDir` in `/etc/pacman.conf`' - echo 'If a new `pacman.conf` is inserted with the `-C` flag, the change' - echo "is made after the file is copied in; the \`-C\` flag doesn't stop" - echo 'the change from being effective.' - echo '' - echo 'Creating a copy, deleting a copy, or syncing a copy can be fairly' - echo 'slow; but are very fast if $CHROOTDIR is on a btrfs partition.' - echo '' - echo 'Options:' - echo ' -n <CHROOT> Name of the chroot to use' - echo ' -l <COPY> Name of, or absolute path to, the copy to use' - echo ' -N Disable networking in the chroot' - echo ' -C <file> Copy this file to `$copydir/etc/pacman.conf`' - echo ' -M <file> Copy this file to `$copydir/etc/makepkg.conf`' - echo '' - echo 'Commands:' - echo ' Create/copy/delete:' - echo ' noop|make Do not do anything, but still creates the' - echo ' chroot copy if it does not exist' - echo " sync Sync the copy with the clean ('root') copy" - echo " delete delete the chroot copy" - echo ' Dealing with packages:' - echo ' install-file FILES... Like `pacman -U FILES...`' - echo ' install-name NAMES... Like `pacman -S NAMES...`' - echo ' update Like `pacman -Syu`' - echo ' clean-pkgs Remove all packages from the chroot copy that' - echo ' are not in base-devel, $CHROOTEXTRAPKG, or' - echo ' named as a dependency in the file' - echo ' `/build/PKGBUILD` in the chroot copy' - echo ' Other:' - echo ' run CMD... Run CMD in the chroot copy' - echo ' enter Enter an interactive shell in the chroot copy' - echo ' clean-repo Clean /repo in the chroot copy' - echo ' help Show this message' + print "Usage: %s [OPTIONS] COMMAND [ARGS...]" "${0##*/}" + print 'Interacts with an archroot (arch chroot).' + echo + prose 'This is configured with `chroot.conf`, either in + `/etc/libretools.d/`, or `$XDG_CONFIG_HOME/libretools/`. + The variables you may set are $CHROOTDIR, $CHROOT, and + $CHROOTEXTRAPKG.' + echo + prose 'There may be multiple chroots; they are stored in $CHROOTDIR.' + echo + prose 'Each chroot is named; the default is configured with $CHROOT.' + echo + prose 'Each named chroot has a master clean copy (named `root`), and any + number of other named copies; the copy used by default is the + current username (or $SUDO_USER, or `copy` if root).' + echo + prose 'The full path to the chroot copy is "$CHROOTDIR/$CHROOT/$COPY", + unless the copy name is manually specified as an absolute path, + in which case, that path is used.' + echo + prose 'The current settings for the above varibles are:' + printf ' CHROOTDIR : %s\n' "${CHROOTDIR:-$(_ 'ERROR: NO SETTING')}" + printf ' CHROOT : %s\n' "${CHROOT:-$(_ 'ERROR: NO SETTING')}" + printf ' COPY : %s\n' "$COPY" + printf ' rootdir : %s\n' "${rootdir:-$(_ 'ERROR')}" + printf ' copydir : %s\n' "${copydir:-$(_ 'ERROR')}" + echo + prose 'If the chroot, or copy does not exist, it will be created + automatically. A chroot by default contains the packages in the + group "base-devel", and any packages named in $CHROOTEXTRAPKG. + Unless the `-C` or `-M` flags are used, the configuration files + that this program installs are the stock versions supplied in the + packages, not the versions from your host system. Other tools + (such as libremakepkg) may alter the configuration.' + echo + prose 'This command will make the following configuration changes in the + chroot:' + bullet 'overwrite `/etc/libretools.d/chroot.conf`' + bullet 'overwrite `/etc/pacman.d/mirrorlist`' + bullet 'set `CacheDir` in `/etc/pacman.conf`' + prose 'If a new `pacman.conf` is inserted with the `-C` flag, the change + is made after the file is copied in; the `-C` flag doesn'\''t + stop the change from being effective.' + echo + prose 'Creating a copy, deleting a copy, or syncing a copy can be fairly + slow; but are very fast if $CHROOTDIR is on a btrfs partition.' + echo + print 'Options:' + flag "-n <$(_ CHROOT)>" 'Name of the chroot to use' + flag "-l <$(_ COPY)>" 'Name of, or absolute path to, the copy to use' + flag '-N' 'Disable networking in the chroot' + flag "-C <$(_ FILE)>" 'Copy this file to `$copydir/etc/pacman.conf`' + flag "-M <$(_ FILE)>" 'Copy this file to `$copydir/etc/makepkg.conf`' + echo + print 'Commands:' + print ' Create/copy/delete:' + flag 'noop|make' 'Do not do anything, but still creates the chroot + copy if it does not exist' + flag 'sync' 'Sync the copy with the clean (`root`) copy' + flag 'delete' 'Delete the chroot copy' + print ' Dealing with packages:' + flag "install-file $(_ FILES...)" 'Like `pacman -U FILES...`' + flag "install-name $(_ NAMES...)" 'Like `pacman -S NAMES...`' + flag 'update' 'Like `pacman -Syu`' + flag 'clean-pkgs' 'Remove all packages from the chroot copy that + are not in base-devel, $CHROOTEXTRAPKG, or named + as a dependency in the file `/build/PKGBUILD` in + the chroot copy' + print ' Other:' + flag "run $(_ CMD...)" 'Run CMD in the chroot copy' + flag 'enter' 'Enter an interactive shell in the chroot copy' + flag 'clean-repo' 'Clean /repo in the chroot copy' + flag 'help' 'Show this message' } commands=( noop make sync delete @@ -177,7 +176,7 @@ main() { fi mode=$1 if ! in_array "$mode" "${commands[@]}"; then - error "Unrecognized command: \`$mode'" + error "Unrecognized command: %s" "$mode" usage >/dev/stderr return 1 fi @@ -203,10 +202,10 @@ main() { # Keep this lock as long as we are running # Note that '9' is the same FD number as in (mk)archroot lock_open_write 9 "$copydir" \ - "Waiting for existing lock on chroot copy to be released: [$COPY]" + "Waiting for existing lock on chroot copy to be released: [%s]" "$COPY" if [[ ! -d $rootdir ]]; then - msg "Creating 'root' copy for chroot [$CHROOT]" + msg "Creating 'root' copy for chroot [%s]" "$CHROOT" set +u # if archroot_args is empty, it counts as unbound archroot "${archroot_args[@]}" -m "$rootdir" base-devel set -u @@ -214,7 +213,7 @@ main() { fi if [[ ! -d $copydir ]] || [[ $mode == sync ]]; then - msg "Syncing copy [$COPY] with root copy" + msg "Syncing copy [%s] with root copy" "$COPY" normshell chroot_sync "$CHROOTDIR/$CHROOT" "$COPY" fi diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index c4a2cc8..a1d30d4 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -1,7 +1,7 @@ #!/bin/bash -euE # libremakepkg -# Copyright 2010 - 2011 Nicolás Reynolds +# Copyright 2010-2011 Nicolás Reynolds # Copyright 2011 Joshua Ismael Haase Hernández # Copyright 2012-2013 Luke Shumaker # @@ -267,37 +267,35 @@ check_pkg() { # The main program ############################################################# -cmd=${0##*/} usage() { - echo "Usage: $cmd [options] [-- makepkg args]" - echo 'This program will build your package.' - echo '' - echo 'If run from outside of a chroot, command will make the following' - echo 'configuration changes in the chroot:' - echo ' - whatever changes `librechroot` makes.' - echo ' - set `PKGDEST` and `SRCDEST` in `/etc/makepkg.conf`' - echo ' - set `PACKAGER` in `/etc/makepkg.conf` to reflect the value' - echo ' outside of the chroot.' - echo ' - (maybe) delete `/build/.makepkg.conf`' - echo ' - (maybe) delete `/build/.ssh/config`' - echo 'If run from inside of a chroot, this command will:' - echo ' - (maybe) delete `~/.makepkg.conf`' - echo ' - (maybe) delete `~/.ssh/config`' - echo "The above 'maybe's happen as part of the workarounds to make" - echo 'distcc work in a network-less environment. They will happen if' - echo 'both `socat` and `distcc` are installed in the chroot.' - echo '' - echo "The \`-n' and \`-l' options behave identically to librechroot," - echo 'see the documentation there.' - echo '' - echo 'Options:' - echo ' -n <CHROOT> Name of the chroot to use' - echo ' -l <COPY> Name of, or absolute path to, the copy to use' - echo " -N Don't disable networking during build() or package()" - echo " PLEASE don't use this unless you have a special" - echo " reason, its use is a violation of Parabola policy." - echo ' -R Repackage contents of the package without rebuilding' - echo ' -h Show this message' + print "Usage: %s [options] [-- makepkg args]" "${0##*/}" + print 'This program will build your package.' + echo + prose 'If run from outside of a chroot, command will make the following + configuration changes in the chroot:' + bullet 'whatever changes `librechroot` makes.' + bullet 'set `PKGDEST` and `SRCDEST` in `/etc/makepkg.conf`' + bullet 'set `PACKAGER` in `/etc/makepkg.conf` to reflect the value + outside of the chroot.' + bullet '(maybe) delete `/build/.makepkg.conf`' + bullet '(maybe) delete `/build/.ssh/config`' + prose 'If run from inside of a chroot, this command will:' + bullet '(maybe) delete `~/.makepkg.conf`' + bullet '(maybe) delete `~/.ssh/config`' + prose 'The above "maybe"s happen as part of the workarounds to make + distcc work in a network-less environment. They will happen if + both `socat` and `distcc` are installed in the chroot.' + echo + prose 'The `-n` and `-l` options behave identically to librechroot, see + the documentation there.' + echo + print 'Options:' + flag "-n <$(_ CHROOT)>" 'Name of the chroot to use' + flag "-l <$(_ COPY)>" 'Name of, or absolute path to, the copy to use' + flag '-N' \ + "Don't disable networking during build() and package(). PLEASE don't use this unless you have a special reason, its use is a violation of Parabola policy." + flag '-R' 'Repackage contents of the package without rebuilding' + flag '-h' 'Show this message' } # Globals: $CHROOTDIR, $CHROOT, $COPY and $copydir @@ -366,7 +364,7 @@ main() { # OK, we're starting now ############################################### $INCHROOT || lock_open_write 9 "$copydir" \ - "Waiting for existing lock on chroot copy to be released: [$COPY]" + "Waiting for existing lock on chroot copy to be released: [%s]" "$COPY" # Set target CARCH as it might be used within the PKGBUILD to select # correct sources |