Hi,
this is a bit of an OCD thing, but `makepkg --printsrcinfo` usually
generates a file with two newlines at the end.

This logic happens in pacman/scripts/libmakepkg/srcinfo.sh.in
(/usr/share/makepkg/srcinfo.sh)

The relevant functions:

srcinfo_close_section() {
echo
}

srcinfo_write_global() {
...
srcinfo_open_section 'pkgbase' "${pkgbase:-$pkgname}"
srcinfo_write_section_details ''
srcinfo_close_section
}

srcinfo_write_package() {
...
srcinfo_open_section 'pkgname' "$1"
srcinfo_write_section_details "$1"
srcinfo_close_section
}

As you can see, the functions process section details, and then print
out a newline no matter if details printed something or not.

The write_section_details eventually leads to:

srcinfo_write_attr() {
...
printf "\t$attrname = %s\n" "${attrvalues[@]}"
}

Which seems to always print out a newline, so I believe the
srcinfo_close_section function is not needed there and simply
removing it and the two lines that call it would solve this issue, as
per the patchfile in the attachment.

Thanks for taking a look at this,
Marti
--- srcinfo.sh.in.edit	2020-06-26 01:02:38.662489244 +0200
+++ srcinfo.sh.in	2020-06-26 01:02:58.086464001 +0200
@@ -30,9 +30,6 @@
 	printf '%s = %s\n' "$1" "$2"
 }
 
-srcinfo_close_section() {
-	echo
-}
 
 srcinfo_write_attr() {
 	# $1: attr name
@@ -94,7 +91,6 @@
 
 	srcinfo_open_section 'pkgbase' "${pkgbase:-$pkgname}"
 	srcinfo_write_section_details ''
-	srcinfo_close_section
 }
 
 srcinfo_write_package() {
@@ -104,7 +100,6 @@
 
 	srcinfo_open_section 'pkgname' "$1"
 	srcinfo_write_section_details "$1"
-	srcinfo_close_section
 }
 
 write_srcinfo_header() {

Reply via email to