repo-add error in BSD
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. Cheers, Antonio Huete _______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev |
repo-add error in BSD
On Tue, Jun 3, 2008 at 4:53 PM, Antonio Huete Jimenez
<ahuete.devel@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@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 _______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev |
repo-add error in BSD
On Tue, Jun 3, 2008 at 11:53 PM, Antonio Huete Jimenez
<ahuete.devel@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. > Can anyone explain why we need readlink at all? Otherwise, it is used in repo-remove too but repo-add and repo-remove should be combined. _______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev |
repo-add error in BSD
Xavier escribió:
> On Tue, Jun 3, 2008 at 11:53 PM, Antonio Huete Jimenez > <ahuete.devel@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. >> >> > > Can anyone explain why we need readlink at all? > > Otherwise, it is used in repo-remove too but repo-add and repo-remove > should be combined. > Ooops! I forgot this. Should I still submit the full patch? > _______________________________________________ > pacman-dev mailing list > pacman-dev@archlinux.org > http://archlinux.org/mailman/listinfo/pacman-dev > _______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev |
repo-add error in BSD
Antonio Huete Jimenez wrote:
> Xavier escribió: >> On Tue, Jun 3, 2008 at 11:53 PM, Antonio Huete Jimenez >> <ahuete.devel@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. >>> >>> >> Can anyone explain why we need readlink at all? >> >> Otherwise, it is used in repo-remove too but repo-add and repo-remove >> should be combined. >> > Ooops! I forgot this. Should I still submit the full patch? Not before the above question is answered : what do we need readlink for? _______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev |
repo-add error in BSD
>>>>
>>>> >>> Can anyone explain why we need readlink at all? >>> >>> Otherwise, it is used in repo-remove too but repo-add and repo-remove >>> should be combined. >>> >>> >> Ooops! I forgot this. Should I still submit the full patch? >> > > Not before the above question is answered : what do we need readlink for? > In repo-add/repo-remove, readlink is used to calculate the full path of a file (canonicalize with option -f). But in BSD there's no such option in readlink, so you have to use realpath instead _______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev |
repo-add error in BSD
On Thu, Jun 12, 2008 at 10:47 AM, Antonio Huete Jimenez
<ahuete.devel@gmail.com> wrote: > In repo-add/repo-remove, readlink is used to calculate the full path of > a file (canonicalize with option -f). But in BSD there's no such option > in readlink, so you have to use realpath instead > Sorry, I didn't realize my question was that obscure, let me rephrase it : Why the hell do we need to calculate the full path of these files? If I ask that question, it is because I am personally not able to answer it myself after looking at this repo-add script. If someone can explain why this is necessary, then we will have to use your readlink/realpath patch. If no one can, then it is probably useless so we can remove readlink usage altogether and solve this portability problem in a much simpler way. _______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev |
repo-add error in BSD
On Thu, Jun 12, 2008 at 3:58 AM, Xavier <shiningxc@gmail.com> wrote:
> On Thu, Jun 12, 2008 at 10:47 AM, Antonio Huete Jimenez > <ahuete.devel@gmail.com> wrote: >> In repo-add/repo-remove, readlink is used to calculate the full path of >> a file (canonicalize with option -f). But in BSD there's no such option >> in readlink, so you have to use realpath instead >> > > Sorry, I didn't realize my question was that obscure, let me rephrase it : > Why the hell do we need to calculate the full path of these files? > > If I ask that question, it is because I am personally not able to > answer it myself after looking at this repo-add script. > If someone can explain why this is necessary, then we will have to use > your readlink/realpath patch. > If no one can, then it is probably useless so we can remove readlink > usage altogether and solve this portability problem in a much simpler > way. Without looking at the script, I imagine it has to do with calculating the path used in %FILENAME% in the db entries. it *does* support full paths: %FILENAME% foo/bar/somepkg-1.0.pkg.tar.gz _______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev |
repo-add error in BSD
On Thu, Jun 12, 2008 at 5:03 PM, Aaron Griffin <aaronmgriffin@gmail.com> wrote:
> > Without looking at the script, I imagine it has to do with calculating > the path used in %FILENAME% in the db entries. it *does* support full > paths: > %FILENAME% > foo/bar/somepkg-1.0.pkg.tar.gz > Actually, I didn't check that carefully, but here is how filename is generated by repo-add : echo -e "%FILENAME% $(basename "$1") " >>desc And at the beginning of db_write_entry function : local pkgfile=$(readlink -f "$1") So that means readlink is not used for the FILENAME, and only the basename of the file is put there, so not the full path. _______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev |
repo-add error in BSD
On Thu, Jun 12, 2008 at 10:03 AM, Aaron Griffin <aaronmgriffin@gmail.com> wrote:
> On Thu, Jun 12, 2008 at 3:58 AM, Xavier <shiningxc@gmail.com> wrote: >> On Thu, Jun 12, 2008 at 10:47 AM, Antonio Huete Jimenez >> <ahuete.devel@gmail.com> wrote: >>> In repo-add/repo-remove, readlink is used to calculate the full path of >>> a file (canonicalize with option -f). But in BSD there's no such option >>> in readlink, so you have to use realpath instead >>> >> >> Sorry, I didn't realize my question was that obscure, let me rephrase it : >> Why the hell do we need to calculate the full path of these files? >> >> If I ask that question, it is because I am personally not able to >> answer it myself after looking at this repo-add script. >> If someone can explain why this is necessary, then we will have to use >> your readlink/realpath patch. >> If no one can, then it is probably useless so we can remove readlink >> usage altogether and solve this portability problem in a much simpler >> way. > > Without looking at the script, I imagine it has to do with calculating > the path used in %FILENAME% in the db entries. it *does* support full > paths: > %FILENAME% > foo/bar/somepkg-1.0.pkg.tar.gz That doesn't even use the result of readlink, haha: local pkgfile=$(readlink -f "$1") ..... echo -e "%FILENAME% $(basename "$1") " >>desc So FILENAME doesn't support any full paths- this has come up on the list before. I really see little need for this readlink usage, but Aaron, you did include it originally. If you get a chance to look closer, let us know what you think it may have been for. -Dan _______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev |
| All times are GMT. The time now is 10:19 AM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.