[pacman-dev] [PATCH 3/5] makepkg: extract parts of the write_pkginfo for use elsewhere
Levente Polyak
anthraxx at archlinux.org
Fri May 12 10:41:21 UTC 2017
Signed-off-by: Allan McRae <allan at archlinux.org>
Signed-off-by: Levente Polyak <anthraxx at archlinux.org>
---
scripts/makepkg.sh.in | 42 ++++++++++++++++++++++++++----------------
1 file changed, 26 insertions(+), 16 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index c302c4ad..7bdf72b9 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -608,6 +608,15 @@ find_libprovides() {
(( ${#libprovides[@]} )) && printf '%s\n' "${libprovides[@]}"
}
+get_packager() {
+ if [[ -n $PACKAGER ]]; then
+ local packager="$PACKAGER"
+ else
+ local packager="Unknown Packager"
+ fi
+ printf "%s\n" "$packager"
+}
+
write_kv_pair() {
local key="$1"
shift
@@ -621,13 +630,22 @@ write_kv_pair() {
done
}
-write_pkginfo() {
- if [[ -n $PACKAGER ]]; then
- local packager="$PACKAGER"
- else
- local packager="Unknown Packager"
+write_kv_pkgname() {
+ write_kv_pair "pkgname" "$pkgname"
+ if (( SPLITPKG )) || [[ "$pkgbase" != "$pkgname" ]]; then
+ write_kv_pair "pkgbase" "$pkgbase"
+ fi
+}
+
+write_kv_pkgver() {
+ local fullver=$(get_full_version)
+ write_kv_pair "pkgver" "$fullver"
+ if [[ "$fullver" != "$basever" ]]; then
+ write_kv_pair "basever" "$basever"
fi
+}
+write_pkginfo() {
local size="$(@DUPATH@ @DUFLAGS@)"
size="$(( ${size%%[^0-9]*} * 1024 ))"
@@ -637,16 +655,8 @@ write_pkginfo() {
printf "# Generated by makepkg %s\n" "$makepkg_version"
printf "# using %s\n" "$(fakeroot -v)"
- write_kv_pair "pkgname" "$pkgname"
- if (( SPLITPKG )) || [[ "$pkgbase" != "$pkgname" ]]; then
- write_kv_pair "pkgbase" "$pkgbase"
- fi
-
- local fullver=$(get_full_version)
- write_kv_pair "pkgver" "$fullver"
- if [[ "$fullver" != "$basever" ]]; then
- write_kv_pair "basever" "$basever"
- fi
+ write_kv_pkgname
+ write_kv_pkgver
# TODO: all fields should have this treatment
local spd="${pkgdesc//+([[:space:]])/ }"
@@ -656,7 +666,7 @@ write_pkginfo() {
write_kv_pair "pkgdesc" "$spd"
write_kv_pair "url" "$url"
write_kv_pair "builddate" "$SOURCE_DATE_EPOCH"
- write_kv_pair "packager" "$packager"
+ write_kv_pair "packager" "$(get_packager)"
write_kv_pair "size" "$size"
write_kv_pair "arch" "$pkgarch"
--
2.12.2
More information about the pacman-dev
mailing list