util: Added a 'common.sh' for some common stuff and removed add_tar.sh

This commit is contained in:
Yorhel 2012-07-25 15:27:23 +02:00
parent 181cf4ae69
commit 36301e1ffd
5 changed files with 30 additions and 33 deletions

24
util/common.sh Normal file
View file

@ -0,0 +1,24 @@
CURL="curl -fSs -A manual-page-crawler,info@manned.org --limit-rate 500k"
PSQL="psql -U manned -Awtq"
TMP=`mktemp -d manned.XXXXXX`
# bash-ism, remove the working directory when we're done.
trap "rm -rf $TMP" EXIT
# Usage: add_tar <file> <pkgid> <flags>
# Requires a recent GNU tar for compression autodetect and xz support.
# TODO: tar throws an error if there are no man pages, but this isn't really an
# error.
add_tar() {
DIR=`mktemp -d "$TMP/tar.XXXXXXX"`
tar --warning=no-unknown-keyword -C "$DIR" $3 -xf "$1" --wildcards '*/man/*'\
&& ./add_dir.pl "$DIR" "$2"
RET=$?
rm -rf "$DIR"
return $RET
}