Add gettext/i18n to most of the currently-used scripts

Signed-off-by: Giovanni Scafora <linuxmania@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Giovanni Scafora 2007-06-04 01:21:14 -04:00 committed by Dan McGee
parent d0679da4f3
commit ecb594107e
7 changed files with 151 additions and 132 deletions

View file

@ -21,6 +21,10 @@
# USA. # USA.
# #
# gettext initialization
export TEXTDOMAIN='pacman'
export TEXTDOMAINDIR='@localedir@'
myver='@PACKAGE_VERSION@' myver='@PACKAGE_VERSION@'
CONFDIR="@sysconfdir@/abs" CONFDIR="@sysconfdir@/abs"
CONNMODE="m" CONNMODE="m"
@ -31,14 +35,16 @@ CONNMODE="m"
[ -f ~/.abs.conf ] && source ~/.abs.conf [ -f ~/.abs.conf ] && source ~/.abs.conf
usage() { usage() {
echo "Arch Build System -- synchronization utility" printf "abs (pacman) %s\n" "$myver"
echo "usage: $0 [-p] [repository1 [repository2 ...]]" echo
printf "$(gettext "Usage: %s [-p] [repository1 [repository2 ...]]")\n" "$0"
echo
printf "$(gettext "abs will synchronize PKGBUILD scripts from the CVS repository")\n"
printf "$(gettext "into %s. You can follow different package trees by")\n" "$ABSROOT"
printf "$(gettext "editing %s files. If no argument is given, abs")\n" "$CONFDIR/supfile.*"
printf "$(gettext "will synchronize from supfiles specified in %s.")\n" "$CONFDIR/abs.conf"
printf "$(gettext "If -p is specified, the connection is opened in passive mode.")\n"
echo echo
echo "abs will synchronize PKGBUILD scripts from the CVS repository"
echo "into $ABSROOT. You can follow different package trees by"
echo "editing @SYSCONFDIR@/abs/supfile.* files. If no argument is given, abs "
echo "will synchronize from supfiles specified in @SYSCONFDIR@/abs/abs.conf."
echo "If -p is specified, the connection is opened in passive mode."
} }
version() { version() {
@ -79,11 +85,11 @@ if [ "$1" = "-V" -o "$1" = "--version" ]; then
fi fi
if [ ! -d "$ABSROOT" ]; then if [ ! -d "$ABSROOT" ]; then
echo "abs: $ABSROOT does not exist (or is not a directory)" echo "$(gettext "abs: %s does not exist (or is not a directory).")" "$ABSROOT"
exit 1 exit 1
fi fi
if [ ! -w "$ABSROOT" ]; then if [ ! -w "$ABSROOT" ]; then
echo "abs: no write permissions in $ABSROOT" echo "$(gettext "abs: no write permissions in %s.")" "$ABSROOT"
exit 1 exit 1
fi fi
@ -92,7 +98,7 @@ if [ "$(type -p cvsup)" ]; then
elif [ "$(type -p csup)" ]; then elif [ "$(type -p csup)" ]; then
CVSUP="csup" CVSUP="csup"
else else
echo "abs: missing CVS synchronization utility. Install cvsup or csup." echo "$(gettext "abs: missing CVS synchronization utility. Install cvsup or csup.")"
exit 1 exit 1
fi fi

View file

@ -21,29 +21,33 @@
# USA. # USA.
# #
# gettext initialization
export TEXTDOMAIN='pacman'
export TEXTDOMAINDIR='@localedir@'
myver='@PACKAGE_VERSION@' myver='@PACKAGE_VERSION@'
# functions # functions
usage() { usage() {
echo "gensync $myver" printf "gensync (pacman) %s\n" "$myver"
echo "usage: $0 <root> <destfile> [package_directory]"
echo echo
echo "gensync will generate a sync database by reading all PKGBUILD files" printf "$(gettext "Usage: %s <root> <destfile> [package_directory]")\n" "$0"
echo "from <root>. gensync builds the database in a temporary directory"
echo "and then compresses it to <destfile>."
echo echo
echo "gensync will calculate md5sums of packages in the same directory as" echo "$(gettext "gensync will generate a sync database by reading all PKGBUILD files")"
echo "<destfile>, unless an alternate [package_directory] is specified." echo "$(gettext "from <root>. gensync builds the database in a temporary directory")"
echo "$(gettext "and then compresses it to <destfile>.")"
echo echo
echo "note: The <destfile> name is important. It must be of the form" echo "$(gettext "gensync will calculate md5sums of packages in the same directory as")"
echo " {treename}.db.tar.gz where {treename} is the name of the custom" echo "$(gettext "<destfile>, unless an alternate [package_directory] is specified.")"
echo " package repository you configured in @sysconfdir@/pacman.conf. The"
echo " generated database must reside in the same directory as your"
echo " custom packages (also configured in @sysconfdir@/pacman.conf)"
echo echo
echo "example: gensync /var/abs/local /home/mypkgs/custom.db.tar.gz" echo "$(gettext "note: The <destfile> name is important. It must be of the form")"
echo "$(gettext " {treename}.db.tar.gz where {treename} is the name of the custom")"
echo "$(gettext " package repository you configured in /etc/pacman.conf. The")"
echo "$(gettext " generated database must reside in the same directory as your")"
echo "$(gettext " custom packages (also configured in /etc/pacman.conf)")"
echo echo
echo "$(gettext "example: gensync /var/abs/local /home/mypkgs/custom.db.tar.gz")"
echo echo
exit 0 exit 0
} }
@ -58,7 +62,8 @@ version() {
} }
error () { error () {
echo "==> ERROR: $*" >&2 local mesg=$1; shift
printf "==> ERROR: ${mesg}\n" "$@" >&2
} }
die () { die () {
@ -98,8 +103,7 @@ fi
if [ -r @sysconfdir@/makepkg.conf ]; then if [ -r @sysconfdir@/makepkg.conf ]; then
source @sysconfdir@/makepkg.conf source @sysconfdir@/makepkg.conf
else else
echo "ERROR: @sysconfdir@/makepkg.conf not found. Can not continue." >&2 die "$(gettext "%s not found. Can not continue.")" "@sysconfdir@/makepkg.conf"
exit 1 # $E_CONFIG_ERROR # TODO: error codes
fi fi
if [ -r ~/.makepkg.conf ]; then if [ -r ~/.makepkg.conf ]; then
@ -117,9 +121,9 @@ if [ "$3" != "" ]; then
pkgdir="$3" pkgdir="$3"
fi fi
[ ! -d "$rootdir" ] && die "invalid root dir: $rootdir" [ ! -d "$rootdir" ] && die "$(gettext "invalid root dir: %s")" $rootdir
echo "gensync: building database entries, generating md5sums..." >&2 echo "$(gettext "gensync: building database entries, generating md5sums...")" >&2
cd "$destdir" cd "$destdir"
pkgs="" pkgs=""
@ -128,7 +132,7 @@ forcepkgs=""
for file in $(find "$rootdir"/* -name "$BUILDSCRIPT"); do for file in $(find "$rootdir"/* -name "$BUILDSCRIPT"); do
unset pkgname pkgver pkgrel options unset pkgname pkgver pkgrel options
source $file || die "failed to parse parse $file" source $file || die "$(gettext "failed to parse parse %s")" $file
if [ "$pkgdir" != "" ]; then if [ "$pkgdir" != "" ]; then
pkgfile="$pkgdir/$pkgname-$pkgver-$pkgrel-$CARCH.$PKGEXT" pkgfile="$pkgdir/$pkgname-$pkgver-$pkgrel-$CARCH.$PKGEXT"
else else
@ -136,7 +140,7 @@ for file in $(find "$rootdir"/* -name "$BUILDSCRIPT"); do
fi fi
if [ ! -f "$pkgfile" ]; then if [ ! -f "$pkgfile" ]; then
error "could not find $pkgname-$pkgver-$pkgrel-$CARCH.$PKGEXT - skipping" error "$(gettext "could not find %s-%s-%s-%s.%s - skipping")" $pkgname $pkgver $pkgrel $CARCH $PKGEXT
else else
if check_force; then if check_force; then
forcepkgs="$forcepkgs $pkgfile" forcepkgs="$forcepkgs $pkgfile"
@ -146,7 +150,7 @@ for file in $(find "$rootdir"/* -name "$BUILDSCRIPT"); do
fi fi
done done
echo "creating repo DB..." echo "$(gettext "creating repo DB...")"
# we'll trim the output just a tad, as gensync may be used on large repos # we'll trim the output just a tad, as gensync may be used on large repos
repo-add $destfile $pkgs --force $force_pkgs \ repo-add $destfile $pkgs --force $force_pkgs \

View file

@ -920,7 +920,7 @@ install_package() {
} }
usage() { usage() {
printf "$(gettext "makepkg (pacman) %s")\n" "$myver" printf "makepkg (pacman) %s\n" "$myver"
echo echo
printf "$(gettext "Usage: %s [options]")\n" "$0" printf "$(gettext "Usage: %s [options]")\n" "$0"
echo echo

View file

@ -21,35 +21,39 @@
# USA. # USA.
# #
# gettext initialization
export TEXTDOMAIN='pacman'
export TEXTDOMAINDIR='@localedir@'
myver='@PACKAGE_VERSION@' myver='@PACKAGE_VERSION@'
# TODO fix these paths
dbroot='@ROOTDIR@@DBPATH@' dbroot='@ROOTDIR@@DBPATH@'
lockfile='@ROOTDIR@@LOCKFILE@' lockfile='@ROOTDIR@@LOCKFILE@'
error() { msg() {
if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then local mesg=$1; shift
echo -e "\033[1;31m:: ERROR:\033[1;0m \033[1;1m$@\033[1;0m" >&2 printf "==> ${mesg}\n" "$@" >&2
else
echo ":: ERROR: $@" >&2
fi
} }
# determine current USECOLOR setting error () {
[ -f "/etc/rc.conf" ] && source /etc/rc.conf local mesg=$1; shift
[ -f "/etc/rc.d/functions" ] && source /etc/rc.d/functions printf "==> ERROR: ${mesg}\n" "$@" >&2
}
usage() { usage() {
echo "pacman-optimize (pacman) $myver" printf "pacman-optimize (pacman) %s\n" "$myver"
echo "usage: $0 [pacman_db_root]"
echo echo
echo "pacman-optimize is a little hack that should improve the performance" printf "$(gettext "Usage: %s[pacman_db_root]")\n" "$0"
echo "of pacman when reading/writing to its filesystem-based database."
echo echo
echo "Because pacman uses many small files to keep track of packages," echo "$(gettext "pacman-optimize is a little hack that should improve the performance")"
echo "there is a tendency for these files to become fragmented over time." echo "$(gettext "of pacman when reading/writing to its filesystem-based database.")"
echo "This script attempts to relocate these small files into one" echo
echo "continuous location on your hard drive. The result is that the hard" echo "$(gettext "Because pacman uses many small files to keep track of packages,")"
echo "drive should be able to read them faster, since the hard drive head" echo "$(gettext "there is a tendency for these files to become fragmented over time.")"
echo "does not have to move around the disk as much." echo "$(gettext "This script attempts to relocate these small files into one")"
echo "$(gettext "continuous location on your hard drive. The result is that the hard")"
echo "$(gettext "drive should be able to read them faster, since the hard drive head")"
echo "$(gettext "does not have to move around the disk as much.")"
echo echo
} }
@ -88,73 +92,66 @@ fi
# make sure pacman isn't running # make sure pacman isn't running
if [ -f $lockfile ]; then if [ -f $lockfile ]; then
die "Pacman lockfile was found. Cannot run while pacman is running." die "$(gettext "Pacman lockfile was found. Cannot run while pacman is running.")"
fi fi
if [ ! -d "$dbroot" ]; then if [ ! -d "$dbroot" ]; then
die "$dbroot does not exist or is not a directory" die "$(gettext "%s does not exist or is not a directory.")" "$dbroot"
fi fi
if [ ! -w "$dbroot" ]; then if [ ! -w "$dbroot" ]; then
die "You must have correct permissions to optimize the database" die "$(gettext "You must have correct permissions to optimize the database.")"
fi fi
# do not let pacman run while we do this # do not let pacman run while we do this
touch $lockfile touch $lockfile
# step 1: sum the old db # step 1: sum the old db
stat_busy "Md5sum'ing the old database" msg "$(gettext "MD5sum'ing the old database...")"
find $dbroot -type f | sort | xargs md5sum > /tmp/pacsums.old find $dbroot -type f | sort | xargs md5sum > /tmp/pacsums.old
stat_done
# step 2: tar it up # step 2: tar it up
stat_busy "Tar'ing up $dbroot" msg "$(gettext "Tar'ing up %s...")" "$dbroot"
cd $dbroot cd $dbroot
tar -czf /tmp/pacmanDB.tgz ./ tar -czf /tmp/pacmanDB.tgz ./
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
stat_fail
rm -f /tmp/pacmanDB.tgz /tmp/pacsums.old rm -f /tmp/pacmanDB.tgz /tmp/pacsums.old
die_r "tar'ing up $dbroot failed" die_r "$(gettext "Tar'ing up %s failed.")" "$dbroot"
fi fi
stat_done
# step 3: make and sum the new db # step 3: make and sum the new db
stat_busy "Making and md5sum'ing the new db" msg "$(gettext "Making and MD5sum'ing the new db...")"
mkdir $dbroot.new mkdir $dbroot.new
tar -zxpf /tmp/pacmanDB.tgz -C $dbroot.new/ tar -zxpf /tmp/pacmanDB.tgz -C $dbroot.new/
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
rm -f /tmp/pacmanDB.tgz /tmp/pacsums.old rm -f /tmp/pacmanDB.tgz /tmp/pacsums.old
rm -rf "$dbroot.new" rm -rf "$dbroot.new"
die_r "untar'ing $dbroot failed" die_r "$(gettext "Untar'ing $dbroot failed.")"
fi fi
find "$dbroot.new" -type f | sort | sed -e 's/pacman.new/pacman/g' |\ find "$dbroot.new" -type f | sort | sed -e 's/pacman.new/pacman/g' | \
xargs md5sum > /tmp/pacsums.new xargs md5sum > /tmp/pacsums.new
stat_done
# step 4: compare the sums # step 4: compare the sums
stat_busy "Checking integrity" msg "$(gettext "Checking integrity...")"
diff /tmp/pacsums.old /tmp/pacsums.new >/dev/null 2>&1 diff /tmp/pacsums.old /tmp/pacsums.new >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
# failed # failed
stat_fail
# leave /tmp/pacsums.old and .new for checking to see what doesn't match up # leave /tmp/pacsums.old and .new for checking to see what doesn't match up
rm -rf "$dbroot.new" $lockfile /tmp/pacmanDB.tgz rm -rf "$dbroot.new" $lockfile /tmp/pacmanDB.tgz
die_r "integrity check FAILED, reverting to old database" die_r "$(gettext "integrity check FAILED, reverting to old database.")"
fi fi
stat_done
# step 5: remove the new temporary database and the old one # step 5: remove the new temporary database and the old one
# and use the .tgz to replace the old one # and use the .tgz to replace the old one
stat_busy "Putting the new database in place" msg "$(gettext "Putting the new database in place...")"
rm -rf "$dbroot.new" "$dbroot"/* rm -rf "$dbroot.new" "$dbroot"/*
tar -zxpf /tmp/pacmanDB.tgz -C "$dbroot"/ tar -zxpf /tmp/pacmanDB.tgz -C "$dbroot"/
stat_done
# remove the lock file, sum files, and .tgz of database # remove the lock file, sum files, and .tgz of database
rm -f $lockfile /tmp/pacsums.old /tmp/pacsums.new /tmp/pacmanDB.tgz rm -f $lockfile /tmp/pacsums.old /tmp/pacsums.new /tmp/pacmanDB.tgz
echo echo
echo "Finished. Your pacman database has been optimized." echo "$(gettext "Finished. Your pacman database has been optimized.")"
echo echo
exit 0 exit 0

View file

@ -20,6 +20,10 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA. # USA.
# gettext initialization
export TEXTDOMAIN='pacman'
export TEXTDOMAINDIR='@localedir@'
myver='@PACKAGE_VERSION@' myver='@PACKAGE_VERSION@'
FORCE=0 FORCE=0
@ -28,19 +32,19 @@ TMP_DIR=""
# print usage instructions # print usage instructions
usage() { usage() {
echo "repo-add $myver" printf "repo-add (pacman) %s\n" "$myver"
echo echo
echo "usage: repo-add <path-to-db> [--force] <package> ..." echo "$(gettext "usage: repo-add <path-to-db> [--force] <package> ...")"
echo echo
echo "repo-add will update a package database by reading a package file." echo "$(gettext "repo-add will update a package database by reading a package file.")"
echo "Multiple packages to add can be specified on the command line." echo "$(gettext "Multiple packages to add can be specified on the command line.")"
echo echo
echo "The --force flag will add a 'force' entry to the sync database, which" echo "$(gettext "The --force flag will add a 'force' entry to the sync database, which")"
echo "tells pacman to skip its internal version number checking and update" echo "$(gettext "tells pacman to skip its internal version number checking and update")"
echo "the package regardless." echo "$(gettext "the package regardless.")"
echo echo
echo "Example:" echo "$(gettext "Example:")"
echo " repo-add /path/to/repo.db.tar.gz pacman-3.0.0.pkg.tar.gz" echo "$(gettext " repo-add /path/to/repo.db.tar.gz pacman-3.0.0.pkg.tar.gz")"
echo echo
} }
@ -137,14 +141,14 @@ db_write_entry()
# ensure $pkgname and $pkgver variables were found # ensure $pkgname and $pkgver variables were found
if [ -z "$pkgname" -o -z "$pkgver" ]; then if [ -z "$pkgname" -o -z "$pkgver" ]; then
echo " error: invalid package file" echo "$(gettext " error: invalid package file")"
return 1 return 1
fi fi
# remove any other package in the DB with same name # remove any other package in the DB with same name
for existing in *; do for existing in *; do
if [ "${existing%-*-*}" = "$pkgname" ]; then if [ "${existing%-*-*}" = "$pkgname" ]; then
echo ":: removing existing package '$existing'" echo "$(gettext ":: removing existing package '%s'")" $existing
rm -rf $existing rm -rf $existing
fi fi
done done
@ -154,7 +158,7 @@ db_write_entry()
cd "$pkgname-$pkgver" cd "$pkgname-$pkgver"
# create desc entry # create desc entry
echo ":: creating 'desc' db entry" echo "$(gettext ":: creating 'desc' db entry")"
echo -e "%FILENAME%\n$(basename $1)\n" >>desc echo -e "%FILENAME%\n$(basename $1)\n" >>desc
echo -e "%NAME%\n$pkgname\n" >>desc echo -e "%NAME%\n$pkgname\n" >>desc
echo -e "%VERSION%\n$pkgver\n" >>desc echo -e "%VERSION%\n$pkgver\n" >>desc
@ -172,7 +176,7 @@ db_write_entry()
# compute checksums # compute checksums
for chk in ${DB_CHECKSUMS[@]}; do for chk in ${DB_CHECKSUMS[@]}; do
name="$(checksum_name $chk)" name="$(checksum_name $chk)"
echo ":: computing $name checksums" echo "$(gettext ":: computing %s checksums")" $name
if [ -n "$name" ]; then if [ -n "$name" ]; then
echo -e "%$name%\n$(get_checksum $chk $pkgfile)\n" >>desc echo -e "%$name%\n$(get_checksum $chk $pkgfile)\n" >>desc
fi fi
@ -241,8 +245,8 @@ fi
if [ -r @sysconfdir@/makepkg.conf ]; then if [ -r @sysconfdir@/makepkg.conf ]; then
source @sysconfdir@/makepkg.conf source @sysconfdir@/makepkg.conf
else else
echo "ERROR: /etc/makepkg.conf not found. Can not continue." >&2 echo "$(gettext "ERROR: /etc/makepkg.conf not found. Can not continue.")" >&2
exit 1 # $E_CONFIG_ERROR # TODO: error codes exit 1 # $E_CONFIG_ERROR
fi fi
if [ -r ~/.makepkg.conf ]; then if [ -r ~/.makepkg.conf ]; then
@ -252,7 +256,7 @@ fi
# main routine # main routine
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then
gstmpdir=$(mktemp -d /tmp/gensync.XXXXXXXXXX) || (\ gstmpdir=$(mktemp -d /tmp/gensync.XXXXXXXXXX) || (\
echo "cannot create temp directory for database building"; \ echo "$(gettext "cannot create temp directory for database building")"; \
exit 1) exit 1)
success=0 success=0
@ -263,18 +267,18 @@ if [ $# -gt 1 ]; then
elif [ -z "$REPO_DB_FILE" ]; then elif [ -z "$REPO_DB_FILE" ]; then
REPO_DB_FILE="$(readlink -f $arg)" REPO_DB_FILE="$(readlink -f $arg)"
if ! test_repo_db_file; then if ! test_repo_db_file; then
echo "error: repository file '$REPO_DB_FILE' is not a proper pacman db" echo "$(gettext "error: repository file '%s' is not a proper pacman db")" $REPO_DB_FILE
exit 1 exit 1
elif [ -f "$REPO_DB_FILE" ]; then elif [ -f "$REPO_DB_FILE" ]; then
echo ":: extracting database to a temporary location" echo "$(gettext ":: extracting database to a temporary location")"
tar xf "$REPO_DB_FILE" -C "$gstmpdir" tar xf "$REPO_DB_FILE" -C "$gstmpdir"
fi fi
else else
if [ -f "$arg" ]; then if [ -f "$arg" ]; then
if ! tar tf "$arg" .PKGINFO 2>&1 >/dev/null; then if ! tar tf "$arg" .PKGINFO 2>&1 >/dev/null; then
echo "error: '$arg' is not a package file, skipping" echo "$(gettext "error: '%s' is not a package file, skipping")" $arg
else else
echo ":: adding package '$arg'" echo "$(gettext ":: adding package '%s'")" $arg
this_dir="$(pwd)" this_dir="$(pwd)"
if db_write_entry "$arg"; then if db_write_entry "$arg"; then
@ -283,14 +287,14 @@ if [ $# -gt 1 ]; then
cd $this_dir cd $this_dir
fi fi
else else
echo "error: package '$arg' not found" echo "$(gettext "error: package '%s' not found")" $arg
fi fi
fi fi
done done
# if all operations were a success, rezip database # if all operations were a success, rezip database
if [ "$success" = "1" ]; then if [ "$success" = "1" ]; then
echo ":: creating updated database file ${REPO_DB_FILE}" echo "$(gettext ":: creating updated database file %s")" ${REPO_DB_FILE}
cd $gstmpdir cd $gstmpdir
if [ -n "$(ls)" ]; then if [ -n "$(ls)" ]; then
[ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old" [ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old"
@ -298,12 +302,12 @@ if [ $# -gt 1 ]; then
case "$DB_COMPRESSION" in case "$DB_COMPRESSION" in
gz) tar c * | gzip -9 >$REPO_DB_FILE ;; gz) tar c * | gzip -9 >$REPO_DB_FILE ;;
bz2) tar c * | bzip2 -9 >$REPO_DB_FILE ;; bz2) tar c * | bzip2 -9 >$REPO_DB_FILE ;;
*) echo "warning: no compression set" *) echo "$(gettext "warning: no compression set")"
tar c * >$REPO_DB_FILE;; tar c * >$REPO_DB_FILE;;
esac esac
fi fi
else else
echo ":: no packages modified, nothing to do" echo "$(gettext ":: no packages modified, nothing to do")"
fi fi
fi fi

View file

@ -20,6 +20,10 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA. # USA.
# gettext initialization
export TEXTDOMAIN='pacman'
export TEXTDOMAINDIR='@localedir@'
myver='@PACKAGE_VERSION@' myver='@PACKAGE_VERSION@'
FORCE=0 FORCE=0
@ -28,16 +32,16 @@ TMP_DIR=""
# print usage instructions # print usage instructions
usage() { usage() {
echo "repo-remove $myver" echo "$(gettext "repo-remove %s")" $myver
echo echo
echo "usage: repo-remove <path-to-db> <packagename> ..." echo "$(gettext "usage: repo-remove <path-to-db> <packagename> ...")"
echo echo
echo "repo-remove will update a package database by removing the package name" echo "$(gettext "repo-remove will update a package database by removing the package name")"
echo "specified on the command line from the given repo database. Multiple" echo "$(gettext "specified on the command line from the given repo database. Multiple")"
echo "packages to remove can be specified on the command line." echo "$(gettext "packages to remove can be specified on the command line.")"
echo echo
echo "Example:" echo "$(gettext "Example:")"
echo " repo-remove /path/to/repo.db.tar.gz kernel26" echo "$(gettext " repo-remove /path/to/repo.db.tar.gz kernel26")"
echo echo
} }
@ -67,7 +71,7 @@ db_remove_entry()
# remove any other package in the DB with same name # remove any other package in the DB with same name
for existing in *; do for existing in *; do
if [ "${existing%-*-*}" = "$1" ]; then if [ "${existing%-*-*}" = "$1" ]; then
echo ":: removing existing package '$existing'" echo "$(gettext ":: removing existing package '%s'")" $existing
rm -rf $existing rm -rf $existing
fi fi
done done
@ -97,8 +101,8 @@ fi
if [ -r @sysconfdir@/makepkg.conf ]; then if [ -r @sysconfdir@/makepkg.conf ]; then
source @sysconfdir@/makepkg.conf source @sysconfdir@/makepkg.conf
else else
echo "ERROR: /etc/makepkg.conf not found. Can not continue." >&2 echo "$(gettext "ERROR: /etc/makepkg.conf not found. Can not continue.")" >&2
exit 1 # $E_CONFIG_ERROR # TODO: error codes exit 1 # $E_CONFIG_ERROR
fi fi
if [ -r ~/.makepkg.conf ]; then if [ -r ~/.makepkg.conf ]; then
@ -108,7 +112,7 @@ fi
# main routine # main routine
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then
gstmpdir=$(mktemp -d /tmp/gensync.XXXXXXXXXX) || (\ gstmpdir=$(mktemp -d /tmp/gensync.XXXXXXXXXX) || (\
echo "cannot create temp directory for database building"; \ echo "$(gettext "cannot create temp directory for database building")"; \
exit 1) exit 1)
success=0 success=0
@ -117,20 +121,20 @@ if [ $# -gt 1 ]; then
if [ -z "$REPO_DB_FILE" ]; then if [ -z "$REPO_DB_FILE" ]; then
REPO_DB_FILE="$(readlink -f $arg)" REPO_DB_FILE="$(readlink -f $arg)"
if ! test_repo_db_file; then if ! test_repo_db_file; then
echo "error: repository file '$REPO_DB_FILE' is not a proper pacman db" echo "$(gettext "error: repository file '%s' is not a proper pacman db")" $REPO_DB_FILE
exit 1 exit 1
elif [ -f "$REPO_DB_FILE" ]; then elif [ -f "$REPO_DB_FILE" ]; then
echo ":: extracting database to a temporary location" echo "$(gettext ":: extracting database to a temporary location")"
tar xf "$REPO_DB_FILE" -C "$gstmpdir" tar xf "$REPO_DB_FILE" -C "$gstmpdir"
fi fi
else else
echo ":: searching for package '$arg'" echo "$(gettext ":: searching for package '%s'")"
this_dir="$(pwd)" this_dir="$(pwd)"
if db_remove_entry "$arg"; then if db_remove_entry "$arg"; then
success=1 success=1
else else
echo "error: package matching '$arg' not found" echo "$(gettext "error: package matching '%s' not found")" $arg
fi fi
cd $this_dir cd $this_dir
fi fi
@ -138,7 +142,7 @@ if [ $# -gt 1 ]; then
# if all operations were a success, rezip database # if all operations were a success, rezip database
if [ "$success" = "1" ]; then if [ "$success" = "1" ]; then
echo ":: creating updated database file ${REPO_DB_FILE}" echo "$(gettext ":: creating updated database file %s")" ${REPO_DB_FILE}
cd $gstmpdir cd $gstmpdir
if [ -n "$(ls)" ]; then if [ -n "$(ls)" ]; then
[ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old" [ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old"
@ -146,12 +150,12 @@ if [ $# -gt 1 ]; then
case "$DB_COMPRESSION" in case "$DB_COMPRESSION" in
gz) tar c * | gzip -9 >$REPO_DB_FILE ;; gz) tar c * | gzip -9 >$REPO_DB_FILE ;;
bz2) tar c * | bzip2 -9 >$REPO_DB_FILE ;; bz2) tar c * | bzip2 -9 >$REPO_DB_FILE ;;
*) echo "warning: no compression set" *) echo "$(gettext "warning: no compression set")"
tar c * >$REPO_DB_FILE;; tar c * >$REPO_DB_FILE;;
esac esac
fi fi
else else
echo ":: no packages modified, nothing to do" echo "$(gettext ":: no packages modified, nothing to do")"
fi fi
fi fi

View file

@ -22,30 +22,34 @@
# USA. # USA.
# #
# gettext initialization
export TEXTDOMAIN='pacman'
export TEXTDOMAINDIR='@localedir@'
myver='@PACKAGE_VERSION@' myver='@PACKAGE_VERSION@'
# functions # functions
usage() { usage() {
echo "updatesync $myver" printf "updatesync (pacman) %s\n" "$myver"
echo "usage: $0 <action> <destfile> <option> [package_directory]"
echo echo
echo "updatesync will update a sync database by reading a PKGBUILD and" printf "$(gettext "Usage: %s <action> <destfile> <option> [package_directory]")\n" "$0"
echo "modifying the destfile. updatesync updates the database in a temporary"
echo "directory and then compresses it to <destfile>."
echo echo
echo "There are two types of actions:" echo "$(gettext "updatesync will update a sync database by reading a PKGBUILD and")"
echo "$(gettext "modifying the destfile. updatesync updates the database in a temporary")"
echo "$(gettext "directory and then compresses it to <destfile>.")"
echo echo
echo "upd - Will update a package's entry or create it if it doesn't exist." echo "$(gettext "There are two types of actions:")"
echo " It takes the package's PKGBUILD as an option."
echo "del - Will remove a package's entry from the db."
echo " It takes the package's name as an option."
echo echo
echo "updatesync will calculate md5sums of packages in the same directory as" echo "$(gettext "upd - Will update a package's entry or create it if it doesn't exist.")"
echo "<destfile>, unless an alternate [package_directory] is specified." echo "$(gettext " It takes the package's PKGBUILD as an option.")"
echo "$(gettext "del - Will remove a package's entry from the db.")"
echo "$(gettext " It takes the package's name as an option.")"
echo echo
echo "example: updatesync upd /home/mypkgs/custom.db.tar.gz PKGBUILD" echo "$(gettext "updatesync will calculate md5sums of packages in the same directory as")"
echo "$(gettext "<destfile>, unless an alternate [package_directory] is specified.")"
echo echo
echo "$(gettext "example: updatesync upd /home/mypkgs/custom.db.tar.gz PKGBUILD")"
echo echo
exit 0 exit 0
} }
@ -60,7 +64,8 @@ version() {
} }
error () { error () {
echo "==> ERROR: $*" >&2 local mesg=$1; shift
printf "==> ERROR: ${mesg}\n" "$@" >&2
} }
die () { die () {
@ -100,8 +105,7 @@ fi
if [ -r @sysconfdir@/makepkg.conf ]; then if [ -r @sysconfdir@/makepkg.conf ]; then
source @sysconfdir@/makepkg.conf source @sysconfdir@/makepkg.conf
else else
echo "ERROR: /etc/makepkg.conf not found. Can not continue." >&2 die "$(gettext "%s not found. Can not continue.")" "@sysconfdir@/makepkg.conf"
exit 1 # $E_CONFIG_ERROR # TODO: error codes
fi fi
if [ -r ~/.makepkg.conf ]; then if [ -r ~/.makepkg.conf ]; then
@ -123,17 +127,17 @@ fi
opt_force="" opt_force=""
if [ ! -f "$option" ]; then if [ ! -f "$option" ]; then
die "$option not found" die "$(gettext "%s not found")" $option
fi fi
if [ "$action" = "upd" ]; then # INSERT / UPDATE if [ "$action" = "upd" ]; then # INSERT / UPDATE
unset pkgname pkgver pkgrel options unset pkgname pkgver pkgrel options
source $option || die "failed to parse $option" source $option || die "$(gettext "failed to parse %s")" $option
pkgfile="$pkgdir/$pkgname-$pkgver-$pkgrel-$CARCH.$PKGEXT" pkgfile="$pkgdir/$pkgname-$pkgver-$pkgrel-$CARCH.$PKGEXT"
if [ ! -f "$pkgfile" ]; then if [ ! -f "$pkgfile" ]; then
die "could not find $pkgname-$pkgver-$pkgrel-$CARCH.$PKGEXT - aborting" die "$(gettext "could not find %s-%s-%s-%s.%s - aborting")" $pkgname $pkgver $pkgrel $CARCH $PKGEXT
fi fi
if check_force; then if check_force; then