FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 06-20-2011, 06:27 PM
Dan McGee
 
Default repo-add: reuse write_list_entry for desc file

On Mon, Jun 20, 2011 at 1:12 PM, Dave Reisner <d@falconindy.com> wrote:
> Repurpose the write_list_entry function for everything we write to the
> depends and desc files by appending our own extra newline after each
> single line data point.
>
> This also refactors write_list_entry into a single printf statement.
>
> Signed-off-by: Dave Reisner <d@falconindy.com>
> ---
> More repo-add madness. Reusable code, ftw.
>
> dave
>
> *scripts/repo-add.sh.in | * 31 +++++++++++++++----------------
> *1 files changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
> index 14506dc..a23f89e 100644
> --- a/scripts/repo-add.sh.in
> +++ b/scripts/repo-add.sh.in
> @@ -88,8 +88,7 @@ There is NO WARRANTY, to the extent permitted by law.
")"
> *# * * * * * * *arg3 - File to write to
> *write_list_entry() {
> * * * *if [[ -n $2 ]]; then
> - * * * * * * * echo "%$1%" >>$3
> - * * * * * * * echo -e $2 >>$3
> + * * * * * * * printf "%%%s%%
$2
" "$1" >>"$3"
Does it make sense to use both %s and var substitution at the same
time? Why not:
printf "%%%s%%
%s
" "$1" "$2" >>"$3"

> * * * *fi
> *}
>
> @@ -301,27 +300,27 @@ db_write_entry()
>
> * * * *# create desc entry
> * * * *msg2 "$(gettext "Creating '%s' db entry...")" 'desc'
> - * * * echo -e "%FILENAME%
${1##*/}
" >>desc
> - * * * echo -e "%NAME%
$pkgname
" >>desc
> - * * * [[ -n $pkgbase ]] && echo -e "%BASE%
$pkgbase
" >>desc
> - * * * echo -e "%VERSION%
$pkgver
" >>desc
> - * * * [[ -n $pkgdesc ]] && echo -e "%DESC%
$pkgdesc
" >>desc
> + * * * write_list_entry "FILENAME" "${1##*/}
" "desc"
> + * * * write_list_entry "NAME" "$pkgname
" "desc"
> + * * * [[ -n $pkgbase ]] && write_list_entry "BASE" "$pkgbase
" "desc"
It would be cleaner to move the -n bits inside write_list_entry.
Otherwise I like this change to make things a bit more consistent.

> + * * * write_list_entry "VERSION" "$pkgver
" "desc"
> + * * * [[ -n $pkgdesc ]] && write_list_entry "DESC" "$pkgdesc
" "desc"
> * * * *write_list_entry "GROUPS" "$_groups" "desc"
> - * * * [[ -n $csize ]] && echo -e "%CSIZE%
$csize
" >>desc
> - * * * [[ -n $size ]] && echo -e "%ISIZE%
$size
" >>desc
> + * * * [[ -n $csize ]] && write_list_entry "CSIZE" "$csize
" "desc"
> + * * * [[ -n $size ]] && write_list_entry "ISIZE" "$size
" "desc"
>
> * * * *# add checksums
> - * * * echo -e "%MD5SUM%
$md5sum
" >>desc
> - * * * echo -e "%SHA256SUM%
$sha256sum
" >>desc
> + * * * write_list_entry "MD5SUM" "$md5sum
" "desc"
> + * * * write_list_entry "SHA256SUM" "$sha256sum
" "desc"
>
> * * * *# add PGP sig
> - * * * [[ -n $pgpsig ]] && echo -e "%PGPSIG%
$pgpsig
" >>desc
> + * * * [[ -n $pgpsig ]] && write_list_entry "PGPSIG" "$pgpsig
" "desc"
>
> - * * * [[ -n $url ]] && echo -e "%URL%
$url
" >>desc
> + * * * [[ -n $url ]] && write_list_entry "URL" "$url
" "desc"
> * * * *write_list_entry "LICENSE" "$_licenses" "desc"
> - * * * [[ -n $arch ]] && echo -e "%ARCH%
$arch
" >>desc
> - * * * [[ -n $builddate ]] && echo -e "%BUILDDATE%
$builddate
" >>desc
> - * * * [[ -n $packager ]] && echo -e "%PACKAGER%
$packager
" >>desc
> + * * * [[ -n $arch ]] && write_list_entry "ARCH" "$arch
" "desc"
> + * * * [[ -n $builddate ]] && write_list_entry "BUILDDATE" "$builddate
" "desc"
> + * * * [[ -n $packager ]] && write_list_entry "PACKAGER" "$packager
" "desc"
> * * * *write_list_entry "REPLACES" "$_replaces" "desc"
>
> * * * *# create depends entry
> --
> 1.7.5.4
>
>
>
 

Thread Tools




All times are GMT. The time now is 07:48 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org