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, 07:46 PM
Dave Reisner
 
Default repo-add: use format_entry for all desc/depends fields

This ranks high on the code readability scale. The same function formats
all of our data and writes to the metadata file at once.
---
scripts/repo-add.sh.in | 52 ++++++++++++++++++++++++-----------------------
1 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index fb1e24a..174efa4 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -294,37 +294,39 @@ 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
- format_entry "GROUPS" "${_groups[@]}" >>"desc"
- [[ -n $csize ]] && echo -e "%CSIZE%
$csize
" >>desc
- [[ -n $size ]] && echo -e "%ISIZE%
$size
" >>desc
-
- # add checksums
- echo -e "%MD5SUM%
$md5sum
" >>desc
- echo -e "%SHA256SUM%
$sha256sum
" >>desc
-
- # add PGP sig
- [[ -n $pgpsig ]] && echo -e "%PGPSIG%
$pgpsig
" >>desc
-
- [[ -n $url ]] && echo -e "%URL%
$url
" >>desc
- format_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
- format_entry "REPLACES" "${_replaces[@]}" >>"desc"
+ {
+ format_entry "FILENAME" "${1##*/}"
+ format_entry "NAME" "$pkgname"
+ format_entry "BASE" "$pkgbase"
+ format_entry "VERSION" "$pkgver"
+ format_entry "DESC" "$pkgdesc"
+ format_entry "GROUPS" "${_groups[@]}"
+ format_entry "CSIZE" "$csize"
+ format_entry "ISIZE" "$size"
+
+ # add checksums
+ format_entry "MD5SUM" "$md5sum"
+ format_entry "SHA256SUM" "$sha256sum"
+
+ # add PGP sig
+ format_entry "PGPSIG" "$pgpsig"
+
+ format_entry "URL" "$url"
+ format_entry "LICENSE" "${_licenses[@]}"
+ format_entry "ARCH" "$arch"
+ format_entry "BUILDDATE" "$builddate"
+ format_entry "PACKAGER" "$packager"
+ format_entry "REPLACES" "${_replaces[@]}"
+ } >>'desc'

# create depends entry
msg2 "$(gettext "Creating '%s' db entry...")" 'depends'
# create the file even if it will remain empty
touch "depends"
{
- format_entry "DEPENDS" "${_depends[@]}"
- format_entry "CONFLICTS" "${_conflicts[@]}"
- format_entry "PROVIDES" "${_provides[@]}"
+ format_entry "DEPENDS" "${_depends[@]}"
+ format_entry "CONFLICTS" "${_conflicts[@]}"
+ format_entry "PROVIDES" "${_provides[@]}"
format_entry "OPTDEPENDS" "${_optdepends[@]}"
} >>'depends'

--
1.7.5.4
 
Old 06-23-2011, 01:00 AM
Dave Reisner
 
Default repo-add: use format_entry for all desc/depends fields

This ranks high on the code readability scale. The same function formats
all of our data and writes to the metadata file at once.

Signed-off-by: Dave Reisner <d@falconindy.com>
---
scripts/repo-add.sh.in | 46 ++++++++++++++++++++++++----------------------
1 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 8350db5..ab97952 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -292,28 +292,30 @@ 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
- format_entry "GROUPS" "${_groups[@]}" >>"desc"
- [[ -n $csize ]] && echo -e "%CSIZE%
$csize
" >>desc
- [[ -n $size ]] && echo -e "%ISIZE%
$size
" >>desc
-
- # add checksums
- echo -e "%MD5SUM%
$md5sum
" >>desc
- echo -e "%SHA256SUM%
$sha256sum
" >>desc
-
- # add PGP sig
- [[ -n $pgpsig ]] && echo -e "%PGPSIG%
$pgpsig
" >>desc
-
- [[ -n $url ]] && echo -e "%URL%
$url
" >>desc
- format_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
- format_entry "REPLACES" "${_replaces[@]}" >>"desc"
+ {
+ format_entry "FILENAME" "${1##*/}"
+ format_entry "NAME" "$pkgname"
+ format_entry "BASE" "$pkgbase"
+ format_entry "VERSION" "$pkgver"
+ format_entry "DESC" "$pkgdesc"
+ format_entry "GROUPS" "${_groups[@]}"
+ format_entry "CSIZE" "$csize"
+ format_entry "ISIZE" "$size"
+
+ # add checksums
+ format_entry "MD5SUM" "$md5sum"
+ format_entry "SHA256SUM" "$sha256sum"
+
+ # add PGP sig
+ format_entry "PGPSIG" "$pgpsig"
+
+ format_entry "URL" "$url"
+ format_entry "LICENSE" "${_licenses[@]}"
+ format_entry "ARCH" "$arch"
+ format_entry "BUILDDATE" "$builddate"
+ format_entry "PACKAGER" "$packager"
+ format_entry "REPLACES" "${_replaces[@]}"
+ } >'desc'

# create depends entry
msg2 "$(gettext "Creating '%s' db entry...")" 'depends'
--
1.7.5.4
 

Thread Tools




All times are GMT. The time now is 06:48 AM.

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