Re: [pacman-dev] [PATCH v3 1/2] Split check_software() to libmakepkg

2018-11-27 Thread Allan McRae
On 27/11/18 7:23 pm, Que Quotion wrote:
> From: Que Quotion 
> 
> This opens the door for third parties who provide extensions to
> libmakepkg to supply scripts that confirm the presence of their
> dependant executables.
> 
> See makepkg-optimize in the AUR for examples.
> 
> Signed-off-by: Que Quotion 
> ---
> Split v2 patch into two patches as requested.
> First, split check_software() out so that we can split
> prepare_buildenv() out as a separate patch later.
> 

I had reviewed this offline.   A couple of issues crept in while doing
the latest revisions (truncated copyright year, indenting in copyright
notice for one file), but I have fixed these and pulled the patch.

Thanks,
Allan


[pacman-dev] [PATCH v3 1/2] Split check_software() to libmakepkg

2018-11-27 Thread Que Quotion
From: Que Quotion 

This opens the door for third parties who provide extensions to
libmakepkg to supply scripts that confirm the presence of their
dependant executables.

See makepkg-optimize in the AUR for examples.

Signed-off-by: Que Quotion 
---
Split v2 patch into two patches as requested.
First, split check_software() out so that we can split
prepare_buildenv() out as a separate patch later.

 scripts/Makefile.am  |  12 ++
 scripts/libmakepkg/executable.sh.in  |  45 +
 scripts/libmakepkg/executable/ccache.sh.in   |  37 
 scripts/libmakepkg/executable/checksum.sh.in |  42 +
 scripts/libmakepkg/executable/distcc.sh.in   |  37 
 scripts/libmakepkg/executable/fakeroot.sh.in |  37 
 scripts/libmakepkg/executable/gpg.sh.in  |  44 +
 scripts/libmakepkg/executable/gzip.sh.in |  37 
 scripts/libmakepkg/executable/meson.build|  26 +++
 scripts/libmakepkg/executable/pacman.sh.in   |  37 
 scripts/libmakepkg/executable/strip.sh.in|  37 
 scripts/libmakepkg/executable/sudo.sh.in |  36 
 scripts/libmakepkg/executable/vcs.sh.in  | 109 
 scripts/libmakepkg/meson.build   |   1 +
 scripts/makepkg.sh.in| 172 ---
 15 files changed, 537 insertions(+), 172 deletions(-)
 create mode 100644 scripts/libmakepkg/executable.sh.in
 create mode 100644 scripts/libmakepkg/executable/ccache.sh.in
 create mode 100644 scripts/libmakepkg/executable/checksum.sh.in
 create mode 100644 scripts/libmakepkg/executable/distcc.sh.in
 create mode 100644 scripts/libmakepkg/executable/fakeroot.sh.in
 create mode 100644 scripts/libmakepkg/executable/gpg.sh.in
 create mode 100644 scripts/libmakepkg/executable/gzip.sh.in
 create mode 100644 scripts/libmakepkg/executable/meson.build
 create mode 100644 scripts/libmakepkg/executable/pacman.sh.in
 create mode 100644 scripts/libmakepkg/executable/strip.sh.in
 create mode 100644 scripts/libmakepkg/executable/sudo.sh.in
 create mode 100644 scripts/libmakepkg/executable/vcs.sh.in

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index c6b6220e..739aeb36 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -41,6 +41,7 @@ LIBRARY = \
 libmakepkgdir = $(datarootdir)/makepkg

 LIBMAKEPKGDIRS = \
+   executable \
integrity \
lint_config \
lint_package \
@@ -50,6 +51,17 @@ LIBMAKEPKGDIRS = \
util

 LIBMAKEPKG_IN = \
+   libmakepkg/executable.sh \
+   libmakepkg/executable/ccache.sh \
+   libmakepkg/executable/checksum.sh \
+   libmakepkg/executable/distcc.sh \
+   libmakepkg/executable/fakeroot.sh \
+   libmakepkg/executable/gpg.sh \
+   libmakepkg/executable/gzip.sh \
+   libmakepkg/executable/pacman.sh \
+   libmakepkg/executable/strip.sh \
+   libmakepkg/executable/sudo.sh \
+   libmakepkg/executable/vcs.sh \
libmakepkg/integrity.sh \
libmakepkg/integrity/generate_checksum.sh \
libmakepkg/integrity/generate_signature.sh \
diff --git a/scripts/libmakepkg/executable.sh.in 
b/scripts/libmakepkg/executable.sh.in
new file mode 100644
index ..68c48038
--- /dev/null
+++ b/scripts/libmakepkg/executable.sh.in
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+#   executable.sh - confirm presence of dependent executables
+#
+#   Copyright (c) 2011-2018 Pacman Development Team 
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see .
+#
+
+[[ -n "$LIBMAKEPKG_EXECUTABLE_SH" ]] && return
+LIBMAKEPKG_EXECUTABLE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+declare -a executable_functions
+
+for lib in "$LIBRARY/executable/"*.sh; do
+   source "$lib"
+done
+
+readonly -a executable_functions
+
+check_software() {
+   local ret=0
+
+   for func in ${executable_functions[@]}; do
+   $func
+   done
+
+   return $ret
+}
diff --git a/scripts/libmakepkg/executable/ccache.sh.in 
b/scripts/libmakepkg/executable/ccache.sh.in
new file mode 100644
index ..6871d64a
--- /dev/null
+++ b/scripts/libmakepkg/executable/ccache.sh.in
@@ -0,0 +1,37 @@
+#!/usr/bin/bash
+#
+#   ccache.sh - Confirm presence of CCache binary
+#
+#   Copyright (c) 2011-2018 Pacman Development Team 
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General