[pacman-dev] [PATCH v5 1/4] libmakepkg: move checkdepends to the correct array
Signed-off-by: morganamilo <morganamilo@gmail.com> --- scripts/libmakepkg/lint_pkgbuild/variable.sh.in | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in index d19c95bc..a975b024 100644 --- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in @@ -31,11 +31,10 @@ lint_pkgbuild_functions+=('lint_variable') lint_variable() { # TODO: refactor - similar arrays are used elsewhere - local array=(arch backup checkdepends groups license noextract options - validpgpkeys) - local arch_array=(conflicts depends makedepends md5sums optdepends provides - replaces sha1sums sha224sums sha256sums sha384sums sha512sums - source) + local array=(arch backup groups license noextract options validpgpkeys) + local arch_array=(checkdepends conflicts depends makedepends md5sums + optdepends provides replaces sha1sums sha224sums + sha256sums sha384sums sha512sums source) local string=(changelog epoch install pkgbase pkgdesc pkgrel pkgver url) local i a pkg out bad ret=0 -- 2.20.1
This helpers functions allows checking for the existence of a package variable without worrying if it is an array or not. Signed-off-by: morganamilo <morganamilo@gmail.com> --- scripts/libmakepkg/util/pkgbuild.sh.in | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in index b29229a3..f9fc440b 100644 --- a/scripts/libmakepkg/util/pkgbuild.sh.in +++ b/scripts/libmakepkg/util/pkgbuild.sh.in @@ -98,6 +98,15 @@ extract_function_variable() { return $r } +exists_function_variable() { + # $1: function name + # $2: variable name + + local funcname=$1 attr=$2 out + extract_function_variable "$funcname" "$attr" 0 out || \ + extract_function_variable "$funcname" "$attr" 1 out +} + get_pkgbuild_attribute() { # $1: package name # $2: attribute name -- 2.20.1
On Mon, Jan 21, 2019 at 11:59:30PM +0000, morganamilo wrote:
This helpers functions allows checking for the existence of a package variable without worrying if it is an array or not.
Seems reasonable, but where would this be used? Is this meant to consolidate existing cases of redundant code? Under what circumstances do we care about the variable existing without needing to know if it's an array or not?
Signed-off-by: morganamilo <morganamilo@gmail.com> --- scripts/libmakepkg/util/pkgbuild.sh.in | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in index b29229a3..f9fc440b 100644 --- a/scripts/libmakepkg/util/pkgbuild.sh.in +++ b/scripts/libmakepkg/util/pkgbuild.sh.in @@ -98,6 +98,15 @@ extract_function_variable() { return $r }
+exists_function_variable() { + # $1: function name + # $2: variable name + + local funcname=$1 attr=$2 out + extract_function_variable "$funcname" "$attr" 0 out || \
The explicit line continuation isn't needed here -- || at the end of the line indicates a compound command that needs more tokens to be lexed before bash can complete the input.
+ extract_function_variable "$funcname" "$attr" 1 out +} + get_pkgbuild_attribute() { # $1: package name # $2: attribute name -- 2.20.1
On Mon, Jan 21, 2019 at 07:40:14PM -0500, Dave Reisner wrote:
On Mon, Jan 21, 2019 at 11:59:30PM +0000, morganamilo wrote:
This helpers functions allows checking for the existence of a package variable without worrying if it is an array or not.
Seems reasonable, but where would this be used? Is this meant to consolidate existing cases of redundant code? Under what circumstances do we care about the variable existing without needing to know if it's an array or not?
Ok, I see the followup patch where this is used. IMO, the patch using this function for the first time ought to be also responsible for defining it.
Signed-off-by: morganamilo <morganamilo@gmail.com> --- scripts/libmakepkg/util/pkgbuild.sh.in | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in index b29229a3..f9fc440b 100644 --- a/scripts/libmakepkg/util/pkgbuild.sh.in +++ b/scripts/libmakepkg/util/pkgbuild.sh.in @@ -98,6 +98,15 @@ extract_function_variable() { return $r }
+exists_function_variable() { + # $1: function name + # $2: variable name + + local funcname=$1 attr=$2 out + extract_function_variable "$funcname" "$attr" 0 out || \
The explicit line continuation isn't needed here -- || at the end of the line indicates a compound command that needs more tokens to be lexed before bash can complete the input.
+ extract_function_variable "$funcname" "$attr" 1 out +} + get_pkgbuild_attribute() { # $1: package name # $2: attribute name -- 2.20.1
On Tue, 22 Jan 2019 at 00:45, Dave Reisner <d@falconindy.com> wrote:
On Mon, Jan 21, 2019 at 07:40:14PM -0500, Dave Reisner wrote:
On Mon, Jan 21, 2019 at 11:59:30PM +0000, morganamilo wrote:
This helpers functions allows checking for the existence of a package variable without worrying if it is an array or not.
Seems reasonable, but where would this be used? Is this meant to consolidate existing cases of redundant code? Under what circumstances do we care about the variable existing without needing to know if it's an array or not?
Ok, I see the followup patch where this is used. IMO, the patch using this function for the first time ought to be also responsible for defining it.
Signed-off-by: morganamilo <morganamilo@gmail.com> --- scripts/libmakepkg/util/pkgbuild.sh.in | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in index b29229a3..f9fc440b 100644 --- a/scripts/libmakepkg/util/pkgbuild.sh.in +++ b/scripts/libmakepkg/util/pkgbuild.sh.in @@ -98,6 +98,15 @@ extract_function_variable() { return $r }
+exists_function_variable() { + # $1: function name + # $2: variable name + + local funcname=$1 attr=$2 out + extract_function_variable "$funcname" "$attr" 0 out || \
The explicit line continuation isn't needed here -- || at the end of the line indicates a compound command that needs more tokens to be lexed before bash can complete the input.
+ extract_function_variable "$funcname" "$attr" 1 out +} + get_pkgbuild_attribute() { # $1: package name # $2: attribute name -- 2.20.1
Thanks for the tips. I'll remove the \ and squash it with the next patch once the set has been reviewed.
participants (3)
-
Dave Reisner
-
Morgan Adamiec
-
morganamilo