#!/bin/sh -uex # Based on byhand-tags # Contributions from aj # Tarball to unpack TBALL="${1:?"Usage: ${0} "}" # Where to extract the Translation files DESTDIR=./tmp/ umask 002 is_name_okay () { local f f="$1" f="${f#./}" # trime leading ./ if present c="${f%%/*}" # component should appear first if [ "x$c" != "xmain" -a "x$c" != "xcontrib" -a "x$c" != "xnon-free" ] then return 1 fi f="${f#*/}" if [ "x$f" = "x" ]; then return 2; fi # directory name, ignore it # i18n/ should appear next if [ "${f#i18n/}" = "$f" ]; then return 1 fi f="${f#*/}" if [ "x$f" = "x" ]; then return 2; fi # directory name, ignore it case "$f" in Translation-[a-z][a-z][a-z]_[A-Z][A-Z]) return 0 ;; Translation-[a-z][a-z]_[A-Z][A-Z]) return 0 ;; Translation-[a-z][a-z][a-z]) return 0 ;; Translation-[a-z][a-z]) return 0 ;; esac return 1 } tar tzf "${TBALL}" | while read f; do if ! is_name_okay "$f" && [ "$?" -ne 2 ]; then true else echo "Bad name in tarball: $f" exit 1 fi done tar tzf "${TBALL}" | while read f; do if is_name_okay "$f"; then tar -C "${DESTDIR}" -xzf "${TBALL}" "$f" fi done trap - EXIT exit 0