Here is a basic POC for what I had in mind. Please let me know what you think. 


>From e7f9293f42d8d069b7a57165b25e79e248abd680 Mon Sep 17 00:00:00 2001
From: Dustin Falgout <[email protected]>
Date: Sat, 22 Apr 2017 19:54:51 -0500
Subject: [PATCH] [POC] makepkg :: Configurable pkgbuild attributes

Signed-off-by: Dustin Falgout <[email protected]>
---
 scripts/libmakepkg/conf/attributes-march.multi |  0
 scripts/libmakepkg/conf/attributes.multi       |  0
 scripts/libmakepkg/conf/attributes.single      |  0
 scripts/libmakepkg/srcinfo.sh.in               | 61 +++++++++++++++++++++-----
 4 files changed, 49 insertions(+), 12 deletions(-)
 create mode 100644 scripts/libmakepkg/conf/attributes-march.multi
 create mode 100644 scripts/libmakepkg/conf/attributes.multi
 create mode 100644 scripts/libmakepkg/conf/attributes.single

diff --git a/scripts/libmakepkg/conf/attributes-march.multi 
b/scripts/libmakepkg/conf/attributes-march.multi
new file mode 100644
index 00000000..e69de29b
diff --git a/scripts/libmakepkg/conf/attributes.multi 
b/scripts/libmakepkg/conf/attributes.multi
new file mode 100644
index 00000000..e69de29b
diff --git a/scripts/libmakepkg/conf/attributes.single 
b/scripts/libmakepkg/conf/attributes.single
new file mode 100644
index 00000000..e69de29b
diff --git a/scripts/libmakepkg/srcinfo.sh.in b/scripts/libmakepkg/srcinfo.sh.in
index 99f5628a..96783850 100644
--- a/scripts/libmakepkg/srcinfo.sh.in
+++ b/scripts/libmakepkg/srcinfo.sh.in
@@ -23,8 +23,53 @@ LIBMAKEPKG_SRCINFO_SH=1
 
 LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 
+SINGLE_VALUED_ATTRS=
+MULTI_VALUED_ATTRS=
+MARCH_MULTI_VALUED_ATTRS=
+
 source "$LIBRARY/util/pkgbuild.sh"
 
+set_attributes() {
+       local makepkgd="${confdir}/makepkg.d"
+       local singlevalued_default= multivalued_default= singlevalued= 
multivalued=
+       local tmparray=()
+
+       mapfile -t singlevalued_default < "${LIBRARY}/conf/attributes.single"
+       mapfile -t multivalued_default < "${LIBRARY}/conf/attributes.multi"
+
+       [[ -f "${makepkgd}/attributes.single" ]] && mapfile -t singlevalued < 
"${makepkgd}/attributes.single"
+       [[ -f "${makepkgd}/attributes.multi" ]] && mapfile -t multivalued < 
"${makepkgd}/attributes.multi"
+
+       for key in "${singlevalued_default[@]}" "${singlevalued[@]}"; do
+               [[ -n "${key}" ]] && tmparray["${key}"]=1
+       done
+
+       SINGLE_VALUED_ATTRS=("${!tmparray[@]}")
+
+       tmparray=()
+
+       for key in "${multivalued_default[@]}" "${multivalued[@]}"; do
+               [[ -n "${key}" ]] && tmparray["${key}"]=1
+       done
+
+       MULTI_VALUED_ATTRS=("${!tmparray[@]}")
+}
+
+set_march_attributes() {
+       local makepkgd="${confdir}/makepkg.d"
+       local multivalued_default= multivalued=
+
+       mapfile -t multivalued_default < "${LIBRARY}/conf/attributes.multi"
+
+       [[ -f "${makepkgd}/attributes-march.multi" ]] && mapfile -t multivalued 
< "${makepkgd}/attributes-march.multi"
+
+       for key in "${multivalued_default[@]}" "${multivalued[@]}"; do
+               [[ -n "${key}" ]] && tmparray["${key}"]=1
+       done
+
+       MARCH_MULTI_VALUED_ATTRS=("${!tmparray[@]}")
+}
+
 srcinfo_open_section() {
        printf '%s = %s\n' "$1" "$2"
 }
@@ -61,15 +106,12 @@ pkgbuild_extract_to_srcinfo() {
 
 srcinfo_write_section_details() {
        local attr package_arch a
-       local multivalued_arch_attrs=(source provides conflicts depends replaces
-                                     optdepends makedepends checkdepends
-                                     {md5,sha{1,224,256,384,512}}sums)
 
-       for attr in "${singlevalued[@]}"; do
+       for attr in "${SINGLE_VALUED_ATTRS[@]}"; do
                pkgbuild_extract_to_srcinfo "$1" "$attr" 0
        done
 
-       for attr in "${multivalued[@]}"; do
+       for attr in "${MULTI_VALUED_ATTRS[@]}"; do
                pkgbuild_extract_to_srcinfo "$1" "$attr" 1
        done
 
@@ -78,19 +120,14 @@ srcinfo_write_section_details() {
                # 'any' is special. there's no support for, e.g. depends_any.
                [[ $a = any ]] && continue
 
-               for attr in "${multivalued_arch_attrs[@]}"; do
+               for attr in "${MARCH_MULTI_VALUED_ATTRS[@]}"; do
                        pkgbuild_extract_to_srcinfo "$1" "${attr}_$a" 1
                done
        done
 }
 
 srcinfo_write_global() {
-       local singlevalued=(pkgdesc pkgver pkgrel epoch url install changelog)
-       local multivalued=(arch groups license checkdepends makedepends
-                          depends optdepends provides conflicts replaces
-                          noextract options backup
-                          source validpgpkeys {md5,sha{1,224,256,384,512}}sums)
-
+       set_attributes
        srcinfo_open_section 'pkgbase' "${pkgbase:-$pkgname}"
        srcinfo_write_section_details ''
        srcinfo_close_section
-- 
2.12.2
 
     




From: pacman-dev <[email protected]> on behalf of Dustin Falgout 
<[email protected]>
Sent: Saturday, April 22, 2017 7:03 PM
To: Discussion list for pacman development
Subject: Re: [pacman-dev] [RFC] Make PKGBUILD attributes configurable
    
Sure, no problem. Currently, our build server uses some custom attributes in 
the PKGBUILD for additional metadata needed for things like release monitoring. 
I would like to start using .SRCINFO files on the server because they are 
easier  to parse and also because it would be better convention-wise.  Here's 
an example[1].

[1]  
https://github.com/Antergos/antergos-packages/blob/master/antergos/mate/mate-desktop/PKGBUILD

--
Dustin Falgout 

E-mail: [email protected]
Github: lots0logs




From: pacman-dev <[email protected]> on behalf of Allan McRae 
<[email protected]>
Sent: Saturday, April 22, 2017 6:51 PM
To: Discussion list for pacman development
Subject: Re: [pacman-dev] [RFC] Make PKGBUILD attributes configurable
    
On 23/04/17 09:36, Dustin Falgout wrote:
> I would like a way to include custom attributes from the PKGBUILD in the 
> output of the --printsrcinfo option. So basically, this...
> 
> pkgbase = pacman
>        pkgdesc = A library-based package manager with dependency support
>        pkgver = 5.0.1
>        pkgrel = 4
>        url = http://www.archlinux.org/pacman/
>        arch = i686
>        arch = x86_64
>        ...
>        _custom_attribute1 = some value
>        _custom_attribute2 = some value
>        _custom_attribute3 = some value
>        ...
> 
> pkgname = pacman
> 

Bringing the mailing list back into this  (seems our reply field is
broken...)

Can you give an example of what a custom attribute would be?   Your
example is still to vague to judge whether this would be something we
wish to support.

Thanks,
Allan
        

Reply via email to