[pacman-dev] repo-add error in BSD
Dan McGee
dpmcgee at gmail.com
Tue Jun 3 18:37:05 EDT 2008
On Tue, Jun 3, 2008 at 4:53 PM, Antonio Huete Jimenez
<ahuete.devel at gmail.com> wrote:
> repo-add uses readlink -f in linux to find out file's real path. readlink is
> part of coreutils.
> I've found that readlink in BSD don't support -f option so we need to use
> realpath instead.
>
> Attached you can find a mini-patch.
Please use inline patches next time so we can more easily comment
inline, thanks. You may want to even read up on using git-send-email.
I've marked my comments below with **** since I don't have the benefit
of reply markers. Besides what I mention below, I think this patch
looks OK and we can apply this. I would also ask that you add it to
repo-remove and replace the use of readlink there as well with a call
to fullpath.
>From b1142fa6d3b182161d6348bf0942eb3b94f40e3a Mon Sep 17 00:00:00 2001
From: Antonio Huete Jimenez <ahuete.devel at gmail.com>
Date: Tue, 3 Jun 2008 00:26:06 +0200
Subject: [PATCH] Let repo-add to use realpath instead readlink in BSD
environments.
---
po/es.po | 3 +++
scripts/repo-add.sh.in | 18 +++++++++++++++---
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/po/es.po b/po/es.po
index e53b92b..5a98562 100644
--- a/po/es.po
+++ b/po/es.po
@@ -1780,6 +1780,9 @@ msgstr "%s no fue encontrado"
msgid "could not find %s-%s-%s-%s%s - aborting"
msgstr "No se pudo encontrar %s-%s-%s-%s%s - abortando"
+msgid "Couldn't use neither realpath nor readlink to canonicalize."
+msgstr "Fallo al encontrar realpath o readlink."
+
#~ msgid "error: failed to add target '%s' (%s)"
#~ msgstr "error: fallo al procesar '%s' (%s)"
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index e90f0e8..9b77e39 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -31,6 +31,18 @@ REPO_DB_FILE=""
# ensure we have a sane umask set
umask 0022
+fullpath() {
+ if type -p realpath; then
+ realpath "$@"
+ echo soy de realpath
****Hmm? Debugging stuff?
+ elif type -p readlink; then
+ readlink -f "$@"
+ echo soy de readlink
+ else
+ error "$(gettext "Couldn't use neither realpath nor readlink to
canonicalize.")"
***Either the realpath or readlink utility is required!
and probaly also add an exit 1 here?
+ fi
+}
+
msg() {
[ $QUIET -ne 0 ] && return
local mesg=$1; shift
@@ -104,7 +116,7 @@ write_list_entry() {
db_write_delta()
{
# blank out all variables and set deltafile
- local deltafile=$(readlink -f "$1")
+ local deltafile=$(fullpath "$1")
local filename=$(basename "$deltafile")
local deltavars pkgname fromver tover arch csize md5sum
@@ -135,7 +147,7 @@ db_write_delta()
db_write_entry()
{
# blank out all variables and set pkgfile
- local pkgfile=$(readlink -f "$1")
+ local pkgfile=$(fullpath "$1")
local pkgname pkgver pkgdesc url builddate packager csize size \
group depend backup license replaces provides conflict force \
_groups _depends _backups _licenses _replaces _provides _conflicts \
@@ -304,7 +316,7 @@ for arg in "$@"; do
elif [ "$arg" == "--quiet" -o "$arg" == "-q" ]; then
QUIET=1
elif [ -z "$REPO_DB_FILE" ]; then
- REPO_DB_FILE=$(readlink -f "$arg")
+ REPO_DB_FILE=$(fullpath -f "$arg")
**** You left the -f arg in here by accident I'm assuming.
if ! test_repo_db_file; then
error "$(gettext "Repository file '%s' is not a proper pacman
database.")" "$REPO_DB_FILE"
exit 1
--
1.5.5.1
More information about the pacman-dev
mailing list