[pacman-dev] [PATCH-v2] Clarify that build_options only apply during build()

2019-03-12 Thread Que Quotion
From: Que Quotion 

Signed-off-by: Que Quotion 
---
The word 'build' can be vague: as a verb in can be used to describe
the entire process of rendering a package tarball from a PKGBUILD,
while on these lines it refers to a specific PKGBUILD function.

We need to more effectively discourage packagers from doing things
like generating makefiles in prepare(), where the scripts these
options trigger are not called to set or unset their flags.

 doc/PKGBUILD.5.asciidoc | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/PKGBUILD.5.asciidoc b/doc/PKGBUILD.5.asciidoc
index e8ce691f..7d6f3271 100644
--- a/doc/PKGBUILD.5.asciidoc
+++ b/doc/PKGBUILD.5.asciidoc
@@ -296,23 +296,23 @@ underscore and the architecture name e.g., 
'replaces_x86_64=()'.
Compress man and info pages with gzip.
 
*ccache*;;
-   Allow the use of ccache during build. More useful in its 
negative
+   Allow the use of ccache during `build()`. More useful in its 
negative
form `!ccache` with select packages that have problems building
with ccache.
 
*distcc*;;
-   Allow the use of distcc during build. More useful in its 
negative
+   Allow the use of distcc during `build()`. More useful in its 
negative
form `!distcc` with select packages that have problems building
with distcc.
 
*buildflags*;;
Allow the use of user-specific buildflags (CPPFLAGS, CFLAGS, 
CXXFLAGS,
-   LDFLAGS) during build as specified in linkman:makepkg.conf[5]. 
More
+   LDFLAGS) during `build()` as specified in 
linkman:makepkg.conf[5]. More
useful in its negative form `!buildflags` with select packages 
that
have problems building with custom buildflags.
 
*makeflags*;;
-   Allow the use of user-specific makeflags during build as 
specified
+   Allow the use of user-specific makeflags during `build()` as 
specified
in linkman:makepkg.conf[5]. More useful in its negative form
`!makeflags` with select packages that have problems building 
with
custom makeflags such as `-j2` (or higher).
-- 
2.21.0


[pacman-dev] [PATCH] Clarify that build_options only apply during build()

2019-03-12 Thread Que Quotion
From: Que Quotion 

The word 'build' can be vague: as a verb in can be used to describe
the entire process of rendering a package tarball from a PKGBUILD,
while on these lines it refers to a specific PKGBUILD function.

We need to more effectively discourage packagers from doing things
like generating makefiles in prepare(), where the scripts these
options trigger are not called to set or unset their flags.

Signed-off-by: Que Quotion 
---
 doc/PKGBUILD.5.asciidoc | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/PKGBUILD.5.asciidoc b/doc/PKGBUILD.5.asciidoc
index e8ce691f..416a86a7 100644
--- a/doc/PKGBUILD.5.asciidoc
+++ b/doc/PKGBUILD.5.asciidoc
@@ -296,23 +296,23 @@ underscore and the architecture name e.g., 
'replaces_x86_64=()'.
Compress man and info pages with gzip.
 
*ccache*;;
-   Allow the use of ccache during build. More useful in its 
negative
+   Allow the use of ccache during build(). More useful in its 
negative
form `!ccache` with select packages that have problems building
with ccache.
 
*distcc*;;
-   Allow the use of distcc during build. More useful in its 
negative
+   Allow the use of distcc during build(). More useful in its 
negative
form `!distcc` with select packages that have problems building
with distcc.
 
*buildflags*;;
Allow the use of user-specific buildflags (CPPFLAGS, CFLAGS, 
CXXFLAGS,
-   LDFLAGS) during build as specified in linkman:makepkg.conf[5]. 
More
+   LDFLAGS) during build() as specified in 
linkman:makepkg.conf[5]. More
useful in its negative form `!buildflags` with select packages 
that
have problems building with custom buildflags.
 
*makeflags*;;
-   Allow the use of user-specific makeflags during build as 
specified
+   Allow the use of user-specific makeflags during build() as 
specified
in linkman:makepkg.conf[5]. More useful in its negative form
`!makeflags` with select packages that have problems building 
with
custom makeflags such as `-j2` (or higher).
-- 
2.21.0


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

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

Thank you for the assistance, and the merges.

I triple checked these patches before sending them.

I might have extremely early onset Alzheimer's. ¯\_(ツ)_/¯


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

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

This opens the door for third parties to provide libmakepkg
extentions for the purpose of altering the build environment.

See makepkg-optimize in the AUR for examples.

Signed-off-by: Que Quotion 
---
 scripts/Makefile.am  |  6 +++
 scripts/libmakepkg/buildenv.sh.in| 47 +
 scripts/libmakepkg/buildenv/buildflags.sh.in | 35 +
 scripts/libmakepkg/buildenv/compiler.sh.in   | 55 
 scripts/libmakepkg/buildenv/debugflags.sh.in | 38 ++
 scripts/libmakepkg/buildenv/makeflags.sh.in  | 35 +
 scripts/libmakepkg/buildenv/meson.build  | 20 +++
 scripts/libmakepkg/meson.build   |  1 +
 scripts/makepkg.sh.in| 44 +---
 9 files changed, 238 insertions(+), 43 deletions(-)
 create mode 100644 scripts/libmakepkg/buildenv.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/buildflags.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/compiler.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/debugflags.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/makeflags.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/meson.build

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

 LIBMAKEPKGDIRS = \
+   buildenv \
executable \
integrity \
lint_config \
@@ -62,6 +63,11 @@ LIBMAKEPKG_IN = \
libmakepkg/executable/strip.sh \
libmakepkg/executable/sudo.sh \
libmakepkg/executable/vcs.sh \
+   libmakepkg/buildenv.sh \
+   libmakepkg/buildenv/buildflags.sh \
+   libmakepkg/buildenv/compiler.sh \
+   libmakepkg/buildenv/debugflags.sh \
+   libmakepkg/buildenv/makeflags.sh \
libmakepkg/integrity.sh \
libmakepkg/integrity/generate_checksum.sh \
libmakepkg/integrity/generate_signature.sh \
diff --git a/scripts/libmakepkg/buildenv.sh.in 
b/scripts/libmakepkg/buildenv.sh.in
new file mode 100644
index ..3126e94c
--- /dev/null
+++ b/scripts/libmakepkg/buildenv.sh.in
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+#   buildenv.sh - functions for altering the build environment before
+#   compiliation
+#
+#   Copyright (c) 2016-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 <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_BUILDENV_SH" ]] && return
+LIBMAKEPKG_BUILDENV_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+
+
+declare -a buildenv_functions build_options
+
+for lib in "$LIBRARY/buildenv/"*.sh; do
+   source "$lib"
+done
+
+readonly -a buildenv_functions build_options
+
+prepare_buildenv() {
+   for func in ${buildenv_functions[@]}; do
+   $func
+   done
+
+   # ensure all necessary build variables are exported
+   export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
+}
diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in 
b/scripts/libmakepkg/buildenv/buildflags.sh.in
new file mode 100644
index ..ac207fd3
--- /dev/null
+++ b/scripts/libmakepkg/buildenv/buildflags.sh.in
@@ -0,0 +1,35 @@
+#!/usr/bin/bash
+#
+#   buildflags.sh - Clear user-specified buildflags if requested
+#
+#   Copyright (c) 2016-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 <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_BUILDENV_BUILDFLAGS_SH" ]] && return
+LIBMAKEPKG_BUILDENV_BUILDFLAGS_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/option.sh"
+
+build_options+=('buildflags')
+buildenv_functions+=('

[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 <http://www.gnu.org/licenses/>.
+#
+
+[[ -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 an

[pacman-dev] [PATCH] Remove message; pollutes .SCRINFO files

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

Signed-off-by: Que Quotion 
---
 scripts/libmakepkg/executable.sh.in | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/scripts/libmakepkg/executable.sh.in 
b/scripts/libmakepkg/executable.sh.in
index 57953600..6328effc 100644
--- a/scripts/libmakepkg/executable.sh.in
+++ b/scripts/libmakepkg/executable.sh.in
@@ -36,8 +36,6 @@ done
 readonly -a executable_functions
 
 check_software() {
-   msg "$(gettext "Checking for needed software...")"
-
local ret=0
 
for func in ${executable_functions[@]}; do
@@ -45,5 +43,4 @@ check_software() {
done
 
return $ret
-
 }
-- 
2.19.1


[pacman-dev] [PATCH 10/10] revert using_ccache to non-local

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

Caused makepkg to fail to run.

Signed-off-by: Que Quotion 
---
 scripts/libmakepkg/buildenv/compiler.sh.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in 
b/scripts/libmakepkg/buildenv/compiler.sh.in
index e2b31916..c5cd9b4f 100644
--- a/scripts/libmakepkg/buildenv/compiler.sh.in
+++ b/scripts/libmakepkg/buildenv/compiler.sh.in
@@ -30,7 +30,7 @@ source "$LIBRARY/util/option.sh"
 build_options+=('ccache' 'distcc')
 buildenv_functions+=('buildenv_ccache' 'buildenv_distcc')
 
-local using_ccache=0
+using_ccache=0
 
 buildenv_ccache() {
if check_buildoption "ccache" "y"; then
-- 
2.19.1


[pacman-dev] [PATCH] [PATCH 9/9] relocalize using_ccache

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

Should have done this a when putting the two functions together

Signed-off-by: Que Quotion 
---
 scripts/libmakepkg/buildenv/compiler.sh.in | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in 
b/scripts/libmakepkg/buildenv/compiler.sh.in
index 38399269..e2b31916 100644
--- a/scripts/libmakepkg/buildenv/compiler.sh.in
+++ b/scripts/libmakepkg/buildenv/compiler.sh.in
@@ -25,13 +25,12 @@ LIBMAKEPKG_BUILDENV_COMPILER_SH=1
 
 LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 
-source "$LIBRARY/util/message.sh"
 source "$LIBRARY/util/option.sh"
 
 build_options+=('ccache' 'distcc')
 buildenv_functions+=('buildenv_ccache' 'buildenv_distcc')
 
-using_ccache=0
+local using_ccache=0
 
 buildenv_ccache() {
if check_buildoption "ccache" "y"; then
-- 
2.19.1


[pacman-dev] [PATCH 8/8] grouping requires semicolons

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

Signed-off-by: Que Quotion 
---
 scripts/libmakepkg/executable/gpg.sh.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/libmakepkg/executable/gpg.sh.in 
b/scripts/libmakepkg/executable/gpg.sh.in
index f53f186d..8b6b8aa2 100644
--- a/scripts/libmakepkg/executable/gpg.sh.in
+++ b/scripts/libmakepkg/executable/gpg.sh.in
@@ -28,8 +28,8 @@ source "$LIBRARY/util/option.sh"
 executable_functions+=('executable_gpg')
 
 executable_gpg() {
-   if { [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv 
"sign" "y"; } } || \
-   { (( ! SKIPPGPCHECK )) && source_has_signatures }; then
+   if { [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv 
"sign" "y"; }; } || \
+   { (( ! SKIPPGPCHECK )) && source_has_signatures; }; then
if ! type -p gpg >/dev/null; then
error "$(gettext "Cannot find the %s binary required 
for signing packages.")" "gpg"
ret=1
-- 
2.19.1


[pacman-dev] [PATCH] [PATCH 7/7] Report on all found or not found executables

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

also restore check for pacman!

Signed-off-by: Que Quotion 
---
 scripts/Makefile.am  |  2 ++
 scripts/libmakepkg/executable.sh.in  |  7 +++-
 scripts/libmakepkg/executable/ccache.sh.in   |  2 +-
 scripts/libmakepkg/executable/distcc.sh.in   |  2 +-
 scripts/libmakepkg/executable/fakeroot.sh.in |  2 +-
 scripts/libmakepkg/executable/gpg.sh.in  |  2 +-
 scripts/libmakepkg/executable/gzip.sh.in |  2 +-
 scripts/libmakepkg/executable/meson.build|  1 +
 scripts/libmakepkg/executable/pacman.sh.in   | 37 
 scripts/libmakepkg/executable/strip.sh.in|  2 +-
 scripts/libmakepkg/executable/vcs.sh.in  | 12 ---
 11 files changed, 59 insertions(+), 12 deletions(-)
 create mode 100644 scripts/libmakepkg/executable/pacman.sh.in

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 02188e9f..6e47c1a1 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -42,6 +42,7 @@ libmakepkgdir = $(datarootdir)/makepkg
 
 LIBMAKEPKGDIRS = \
buildenv \
+   executable \
integrity \
lint_config \
lint_package \
@@ -58,6 +59,7 @@ LIBMAKEPKG_IN = \
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 \
diff --git a/scripts/libmakepkg/executable.sh.in 
b/scripts/libmakepkg/executable.sh.in
index 06ed86e2..57953600 100644
--- a/scripts/libmakepkg/executable.sh.in
+++ b/scripts/libmakepkg/executable.sh.in
@@ -36,9 +36,14 @@ done
 readonly -a executable_functions
 
 check_software() {
-msg "$(gettext "Checking for needed software...")"
+   msg "$(gettext "Checking for needed 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
index f31a2014..a745be79 100644
--- a/scripts/libmakepkg/executable/ccache.sh.in
+++ b/scripts/libmakepkg/executable/ccache.sh.in
@@ -31,7 +31,7 @@ executable_ccache() {
if check_buildoption "ccache" "y"; then
if ! type -p ccache >/dev/null; then
error "$(gettext "Cannot find the %s binary required 
for compiler cache usage.")" "ccache"
-   return 1
+   ret=1
fi
fi
 }
diff --git a/scripts/libmakepkg/executable/distcc.sh.in 
b/scripts/libmakepkg/executable/distcc.sh.in
index e794d51a..b47a8915 100644
--- a/scripts/libmakepkg/executable/distcc.sh.in
+++ b/scripts/libmakepkg/executable/distcc.sh.in
@@ -31,7 +31,7 @@ executable_distcc() {
if check_buildoption "distcc" "y"; then
if ! type -p distcc >/dev/null; then
error "$(gettext "Cannot find the %s binary required 
for distributed compilation.")" "distcc"
-   return 1
+   ret=1
fi
fi
 }
diff --git a/scripts/libmakepkg/executable/fakeroot.sh.in 
b/scripts/libmakepkg/executable/fakeroot.sh.in
index 7c03ebeb..83c7a0f6 100644
--- a/scripts/libmakepkg/executable/fakeroot.sh.in
+++ b/scripts/libmakepkg/executable/fakeroot.sh.in
@@ -31,7 +31,7 @@ executable_fakeroot() {
if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then
if ! type -p fakeroot >/dev/null; then
error "$(gettext "Cannot find the %s binary.")" 
"fakeroot"
-   return 1
+   ret=1
fi
fi
 }
diff --git a/scripts/libmakepkg/executable/gpg.sh.in 
b/scripts/libmakepkg/executable/gpg.sh.in
index 0c198473..f53f186d 100644
--- a/scripts/libmakepkg/executable/gpg.sh.in
+++ b/scripts/libmakepkg/executable/gpg.sh.in
@@ -32,7 +32,7 @@ executable_gpg() {
{ (( ! SKIPPGPCHECK )) && source_has_signatures }; then
if ! type -p gpg >/dev/null; then
error "$(gettext "Cannot find the %s binary required 
for signing packages.")" "gpg"
-   return 1
+   ret=1
fi
fi
 }
diff --git a/scripts/libmakepkg/executable/gzip.sh.in 
b/scripts/libmakepkg/executable/gzip.sh.in
index 6d90369e..222c5a47 100644
--- a/scripts/libmakepkg/executable/gzip.sh.in
+++ b/scripts/libmakepkg/executable/gzip.sh.in
@@ -31,7 +31,7 @@ executable_gzip() {
if check_option "zipman" "y"; then
if ! type -p gzip >/dev/null; then
error &qu

[pacman-dev] [PATCH] [PATCH 6/6] Also split out check_software() to libmakepkg

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

Drop-ins for finding executables

Signed-off-by: Que Quotion 
---
 scripts/Makefile.am  |  10 ++
 scripts/libmakepkg/buildenv.sh.in|   1 -
 scripts/libmakepkg/buildenv/buildflags.sh.in |   1 +
 scripts/libmakepkg/buildenv/compiler.sh.in   |  19 +--
 scripts/libmakepkg/buildenv/makeflags.sh.in  |   1 +
 scripts/libmakepkg/executable.sh.in  |  44 ++
 scripts/libmakepkg/executable/ccache.sh.in   |  37 +
 scripts/libmakepkg/executable/checksum.sh.in |  43 +
 scripts/libmakepkg/executable/distcc.sh.in   |  37 +
 scripts/libmakepkg/executable/fakeroot.sh.in |  37 +
 scripts/libmakepkg/executable/gpg.sh.in  |  38 +
 scripts/libmakepkg/executable/gzip.sh.in |  37 +
 scripts/libmakepkg/executable/meson.build|  25 +++
 scripts/libmakepkg/executable/strip.sh.in|  37 +
 scripts/libmakepkg/executable/sudo.sh.in |  36 +
 scripts/libmakepkg/executable/vcs.sh.in  | 107 +
 scripts/libmakepkg/meson.build   |   1 +
 scripts/makepkg.sh.in| 156 ---
 18 files changed, 497 insertions(+), 170 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/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 adced908..02188e9f 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -51,6 +51,16 @@ 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/strip.sh \
+   libmakepkg/executable/sudo.sh \
+   libmakepkg/executable/vcs.sh \
libmakepkg/buildenv.sh \
libmakepkg/buildenv/buildflags.sh \
libmakepkg/buildenv/compiler.sh \
diff --git a/scripts/libmakepkg/buildenv.sh.in 
b/scripts/libmakepkg/buildenv.sh.in
index b49b24bf..c3442c42 100644
--- a/scripts/libmakepkg/buildenv.sh.in
+++ b/scripts/libmakepkg/buildenv.sh.in
@@ -25,7 +25,6 @@ LIBMAKEPKG_BUILDENV_SH=1
 LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 
 source "$LIBRARY/util/message.sh"
-source "$LIBRARY/util/option.sh"
 
 
 declare -a buildenv_functions
diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in 
b/scripts/libmakepkg/buildenv/buildflags.sh.in
index 4bdfd6a1..ac207fd3 100644
--- a/scripts/libmakepkg/buildenv/buildflags.sh.in
+++ b/scripts/libmakepkg/buildenv/buildflags.sh.in
@@ -25,6 +25,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 
 source "$LIBRARY/util/option.sh"
 
+build_options+=('buildflags')
 buildenv_functions+=('buildenv_buildflags')
 
 buildenv_buildflags() {
diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in 
b/scripts/libmakepkg/buildenv/compiler.sh.in
index 384b94da..38399269 100644
--- a/scripts/libmakepkg/buildenv/compiler.sh.in
+++ b/scripts/libmakepkg/buildenv/compiler.sh.in
@@ -1,6 +1,8 @@
 #!/usr/bin/bash
 #
-#   ccache.sh - Cache compiliations and recycle them to save time on 
repititions
+#   compiler.sh - CCache and DistCC compilation
+#   ccache - Cache compiliations and recycle them to save time on repititions
+#   distcc - Distribute compliation to reduce compilation time
 #
 #   Copyright (c) 2018 Pacman Development Team 
 #
@@ -18,25 +20,21 @@
 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-[[ -n "$LIBMAKEPKG_BUILDENV_CCACHE_SH" ]] && return
-LIBMAKEPKG_BUILDENV_CCACHE_SH=1
+[[ -n "$LIBMAKEPKG_BUILDENV_COMPILER_SH" ]] && return
+LIBMAKEPKG_BUILDENV_COMPILER_SH=1
 
 LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 
 source "$LIBRARY/util/message.sh"
 source "$LIBRARY/util/option.sh"
 
+build_options+=('ccache' 'distcc')
 buildenv_functions+=('buildenv_ccache' 'buildenv_distcc')
 
 using_ccache=0
 
 buildenv_ccache() {
if check_buildoption "ccache" "y"; then
-   if ! type -p ccache >/dev/null; then
-   error "$(gettext "Cannot find the %s binary required 
for compiler cache usage.")" "ccache"
-   return 1
-   fi
-
if [ -d /

[pacman-dev] [PATCH 4/4] Split prepare_buildenv() to libmakepkg scripts

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

Signed-off-by: Que Quotion 
---
 scripts/libmakepkg/buildenv.sh.in| 6 +++---
 scripts/libmakepkg/buildenv/buildflags.sh.in | 5 ++---
 scripts/libmakepkg/buildenv/compiler.sh.in   | 7 +++
 scripts/libmakepkg/buildenv/debugflags.sh.in | 4 ++--
 scripts/libmakepkg/buildenv/makeflags.sh.in  | 5 ++---
 5 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/scripts/libmakepkg/buildenv.sh.in 
b/scripts/libmakepkg/buildenv.sh.in
index 9c1f02f4..91e99780 100644
--- a/scripts/libmakepkg/buildenv.sh.in
+++ b/scripts/libmakepkg/buildenv.sh.in
@@ -28,18 +28,18 @@ source "$LIBRARY/util/message.sh"
 source "$LIBRARY/util/option.sh"
 
 
-declare -a build_options build_macros
+declare -a buildenv_options
 
 for lib in "$LIBRARY/buildenv/"*.sh; do
source "$lib"
 done
 
-readonly -a build_options build_macros
+readonly -a buildenv_options
 
 prepare_buildenv() {
msg "$(gettext "Preparing build environment...")"
 
-   for func in ${build_macros[@]}; do
+   for func in ${buildenv_options[@]}; do
$func
done
 
diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in 
b/scripts/libmakepkg/buildenv/buildflags.sh.in
index 55d7fbce..1a21241d 100644
--- a/scripts/libmakepkg/buildenv/buildflags.sh.in
+++ b/scripts/libmakepkg/buildenv/buildflags.sh.in
@@ -25,10 +25,9 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 
 source "$LIBRARY/util/option.sh"
 
-build_options+=('buildflags')
-build_macros+=('buildflags')
+buildenv_options+=('buildenv_buildflags')
 
-buildflags() {
+buildenv_buildflags() {
if check_option "buildflags" "n"; then
unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS
fi
diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in 
b/scripts/libmakepkg/buildenv/compiler.sh.in
index dec19ac8..b7bb1d65 100644
--- a/scripts/libmakepkg/buildenv/compiler.sh.in
+++ b/scripts/libmakepkg/buildenv/compiler.sh.in
@@ -26,12 +26,11 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 source "$LIBRARY/util/message.sh"
 source "$LIBRARY/util/option.sh"
 
-build_options+=('ccache' 'distcc')
-build_macros+=('use_ccache' 'use_distcc')
+buildenv_options+=('buildenv_ccache' 'buildenv_distcc')
 
 using_ccache=0
 
-use_ccache() {
+buildenv_ccache() {
if check_buildoption "ccache" "y"; then
if ! type -p ccache >/dev/null; then
error "$(gettext "Cannot find the %s binary required 
for compiler cache usage.")" "ccache"
@@ -45,7 +44,7 @@ use_ccache() {
fi
 }
 
-use_distcc() {
+buildenv_distcc() {
if check_buildoption "distcc" "y"; then
if ! type -p distcc >/dev/null; then
error "$(gettext "Cannot find the %s binary required 
for distributed compilation.")" "distcc"
diff --git a/scripts/libmakepkg/buildenv/debugflags.sh.in 
b/scripts/libmakepkg/buildenv/debugflags.sh.in
index 1ad2ad8b..ac5f76db 100644
--- a/scripts/libmakepkg/buildenv/debugflags.sh.in
+++ b/scripts/libmakepkg/buildenv/debugflags.sh.in
@@ -26,9 +26,9 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 
 source "$LIBRARY/util/option.sh"
 
-build_macros+=('debugflags')
+buildenv_options+=('buildenv_debugflags')
 
-debugflags() {
+buildenv_debugflags() {
if check_option "debug" "y"; then
DEBUG_CFLAGS+=" 
-fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
DEBUG_CXXFLAGS+=" 
-fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
diff --git a/scripts/libmakepkg/buildenv/makeflags.sh.in 
b/scripts/libmakepkg/buildenv/makeflags.sh.in
index b0c438d2..0e5bb36b 100644
--- a/scripts/libmakepkg/buildenv/makeflags.sh.in
+++ b/scripts/libmakepkg/buildenv/makeflags.sh.in
@@ -25,10 +25,9 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 
 source "$LIBRARY/util/option.sh"
 
-build_options+=('makeflags')
-build_macros+=('makeflags')
+buildenv_options+=('buildenv_makeflags')
 
-makeflags() {
+buildenv_makeflags() {
if check_option "makeflags" "n"; then
unset MAKEFLAGS
fi
-- 
2.19.1


[pacman-dev] [PATCH 3/3] Missed this copypasta!

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

Signed-off-by: Que Quotion 
---
 scripts/libmakepkg/buildenv/debugflags.sh.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/libmakepkg/buildenv/debugflags.sh.in 
b/scripts/libmakepkg/buildenv/debugflags.sh.in
index 8627e242..1ad2ad8b 100644
--- a/scripts/libmakepkg/buildenv/debugflags.sh.in
+++ b/scripts/libmakepkg/buildenv/debugflags.sh.in
@@ -19,8 +19,8 @@
 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-[[ -n "$LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH" ]] && return
-LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH=1
+[[ -n "$LIBMAKEPKG_BUILDENV_DEBUGFLAGS_SH" ]] && return
+LIBMAKEPKG_BUILDENV_DEBUGFLAGS_SH=1
 
 LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 
-- 
2.19.1


[pacman-dev] [PATCH 2/2] Split prepare_buildenv() to libmakepkg scripts

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

Being misled by git's documentation, my attempt to attach this patch
to the previous mail was foiled. That's really, really frustrating.

Signed-off-by: Que Quotion 
---
 scripts/Makefile.am   |  4 +--
 scripts/libmakepkg/buildenv.sh.in | 13 ++--
 scripts/libmakepkg/buildenv/buildflags.sh.in  |  1 +
 .../buildenv/{ccache.sh.in => compiler.sh.in} | 27 +---
 .../{distcc.sh.in => debugflags.sh.in}| 31 +++
 scripts/libmakepkg/buildenv/makeflags.sh.in   |  1 +
 scripts/libmakepkg/buildenv/meson.build   |  4 +--
 7 files changed, 43 insertions(+), 38 deletions(-)
 rename scripts/libmakepkg/buildenv/{ccache.sh.in => compiler.sh.in} (69%)
 rename scripts/libmakepkg/buildenv/{distcc.sh.in => debugflags.sh.in} (56%)

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 8e669f71..adced908 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -53,8 +53,8 @@ LIBMAKEPKGDIRS = \
 LIBMAKEPKG_IN = \
libmakepkg/buildenv.sh \
libmakepkg/buildenv/buildflags.sh \
-   libmakepkg/buildenv/ccache.sh \
-   libmakepkg/buildenv/distcc.sh \
+   libmakepkg/buildenv/compiler.sh \
+   libmakepkg/buildenv/debugflags.sh \
libmakepkg/buildenv/makeflags.sh \
libmakepkg/integrity.sh \
libmakepkg/integrity/generate_checksum.sh \
diff --git a/scripts/libmakepkg/buildenv.sh.in 
b/scripts/libmakepkg/buildenv.sh.in
index a14a3a9a..9c1f02f4 100644
--- a/scripts/libmakepkg/buildenv.sh.in
+++ b/scripts/libmakepkg/buildenv.sh.in
@@ -28,28 +28,21 @@ source "$LIBRARY/util/message.sh"
 source "$LIBRARY/util/option.sh"
 
 
-declare -a build_options
+declare -a build_options build_macros
 
 for lib in "$LIBRARY/buildenv/"*.sh; do
source "$lib"
 done
 
-readonly -a build_options
+readonly -a build_options build_macros
 
 prepare_buildenv() {
msg "$(gettext "Preparing build environment...")"
 
-   for func in ${build_options[@]}; do
+   for func in ${build_macros[@]}; do
$func
done
 
-   if check_option "debug" "y"; then
-   DEBUG_CFLAGS+=" 
-fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
-   DEBUG_CXXFLAGS+=" 
-fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
-   CFLAGS+=" $DEBUG_CFLAGS"
-   CXXFLAGS+=" $DEBUG_CXXFLAGS"
-   fi
-
# ensure all necessary build variables are exported
export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
 }
diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in 
b/scripts/libmakepkg/buildenv/buildflags.sh.in
index fb49a85c..55d7fbce 100644
--- a/scripts/libmakepkg/buildenv/buildflags.sh.in
+++ b/scripts/libmakepkg/buildenv/buildflags.sh.in
@@ -26,6 +26,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 source "$LIBRARY/util/option.sh"
 
 build_options+=('buildflags')
+build_macros+=('buildflags')
 
 buildflags() {
if check_option "buildflags" "n"; then
diff --git a/scripts/libmakepkg/buildenv/ccache.sh.in 
b/scripts/libmakepkg/buildenv/compiler.sh.in
similarity index 69%
rename from scripts/libmakepkg/buildenv/ccache.sh.in
rename to scripts/libmakepkg/buildenv/compiler.sh.in
index 122033a9..dec19ac8 100644
--- a/scripts/libmakepkg/buildenv/ccache.sh.in
+++ b/scripts/libmakepkg/buildenv/compiler.sh.in
@@ -26,11 +26,12 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
 source "$LIBRARY/util/message.sh"
 source "$LIBRARY/util/option.sh"
 
-build_options+=('ccache')
+build_options+=('ccache' 'distcc')
+build_macros+=('use_ccache' 'use_distcc')
 
-local ccache=0
+using_ccache=0
 
-ccache() {
+use_ccache() {
if check_buildoption "ccache" "y"; then
if ! type -p ccache >/dev/null; then
error "$(gettext "Cannot find the %s binary required 
for compiler cache usage.")" "ccache"
@@ -39,7 +40,25 @@ ccache() {
 
if [ -d /usr/lib/ccache/bin ]; then
export PATH="/usr/lib/ccache/bin:$PATH"
-   ccache=1
+   using_ccache=1
fi
fi
 }
+
+use_distcc() {
+   if check_buildoption "distcc" "y"; then
+   if ! type -p distcc >/dev/null; then
+   error "$(gettext "Cannot find the %s binary required 
for distributed compilation.")" "distcc"
+   return 1
+   fi
+
+   if (( using_ccache )); then
+   export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX 
}distcc"
+   export CCACHE_BASEDIR="$srcdir"
+   elif [[ -d /usr/lib/distcc/bin ]]; then
+

[pacman-dev] [PATCH 2/2] Split prepare_buildenv() to libmakepkg scripts

2018-11-04 Thread Que Quotion
>> +if check_option "debug" "y"; then
>> +DEBUG_CFLAGS+=" 
>> -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
>> +DEBUG_CXXFLAGS+=" 
>> -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
>> +CFLAGS+=" $DEBUG_CFLAGS"
>> +CXXFLAGS+=" $DEBUG_CXXFLAGS"
>> +fi
>> +
>> +# ensure all necessary build variables are exported
>> +export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
>> +}
>
>Why is this on its own, not in a dropin?

I needed feedback on this; since the debugflags don't have a corresponding 
build_option I wasn't sure what to do with them. Your feedback on the 
ccache/distcc section 
gave me an idea.

>> +build_options+=('buildflags')
>
>If you look at the way we do this in other sections, this should
>probably be namespaced as buildenv_buildflags

I've kept the name as it was in the original implementation to avoid upsetting 
anyone who might be using this flag in a PKGBUILD or makepkg.conf.

>> +ccache() {
>> +if check_buildoption "ccache" "y"; then
>> +if ! type -p ccache >/dev/null; then
>> +error "$(gettext "Cannot find the %s binary required 
>> for compiler cache usage.")" "ccache"
>> +return 1
>> +fi
>> +
>> +if [ -d /usr/lib/ccache/bin ]; then
>> +export PATH="/usr/lib/ccache/bin:$PATH"
>> +ccache=1
>> +fi
>> +fi
>> +}
>
>ccache is now both a function name and a variable name...
>
>And the variable is declared as local, but outside of a function --
>instead, it's relying on the fact that libmakepkg typically sources this
>file while inside another function. I don't know whether we should be
>doing this...
>
>I'm inclined to think that at least ccache and distcc should be in the
>same dropin file and parsed as the same buildenv function as a result.
>Maybe buildenv_compiler.

I'd rather have them separate, as they may be used separately, but then I don't 
know how to ensure the ccache macro would be called before the distcc macro, so 
I put 
them into compiler.sh.in

Attached patch is succesive, and should be applied after the previous. I can 
resubmit if you want a single patch.


[pacman-dev] [PATCH 1/1] Split prepare_buildenv() to libmakepkg scripts

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

As Eli Schwartz has pointed out:
https://lists.archlinux.org/pipermail/pacman-dev/2018-May/022501.html

It would be beneficial to makepkg to have this function ported
to libmakepkg and split into individual scripts.

Supersedes: https://patchwork.archlinux.org/patch/540/

Signed-off-by: Que Quotion 
---
 scripts/Makefile.am  |  6 ++
 scripts/libmakepkg/buildenv.sh.in| 55 ++
 scripts/libmakepkg/buildenv/buildflags.sh.in | 34 +++
 scripts/libmakepkg/buildenv/ccache.sh.in | 45 +++
 scripts/libmakepkg/buildenv/distcc.sh.in | 47 +++
 scripts/libmakepkg/buildenv/makeflags.sh.in  | 34 +++
 scripts/libmakepkg/buildenv/meson.build  | 20 +++
 scripts/libmakepkg/meson.build   |  1 +
 scripts/makepkg.sh.in| 60 +---
 9 files changed, 243 insertions(+), 59 deletions(-)
 create mode 100644 scripts/libmakepkg/buildenv.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/buildflags.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/ccache.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/distcc.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/makeflags.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/meson.build

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index c6b6220e..8e669f71 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -41,6 +41,7 @@ LIBRARY = \
 libmakepkgdir = $(datarootdir)/makepkg
 
 LIBMAKEPKGDIRS = \
+   buildenv \
integrity \
lint_config \
lint_package \
@@ -50,6 +51,11 @@ LIBMAKEPKGDIRS = \
util
 
 LIBMAKEPKG_IN = \
+   libmakepkg/buildenv.sh \
+   libmakepkg/buildenv/buildflags.sh \
+   libmakepkg/buildenv/ccache.sh \
+   libmakepkg/buildenv/distcc.sh \
+   libmakepkg/buildenv/makeflags.sh \
libmakepkg/integrity.sh \
libmakepkg/integrity/generate_checksum.sh \
libmakepkg/integrity/generate_signature.sh \
diff --git a/scripts/libmakepkg/buildenv.sh.in 
b/scripts/libmakepkg/buildenv.sh.in
new file mode 100644
index ..a14a3a9a
--- /dev/null
+++ b/scripts/libmakepkg/buildenv.sh.in
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+#   buildenv.sh - functions for altering the build environment before
+#   compiliation
+#
+#   Copyright (c) 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 <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_BUILDENV_SH" ]] && return
+LIBMAKEPKG_BUILDENV_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+declare -a build_options
+
+for lib in "$LIBRARY/buildenv/"*.sh; do
+   source "$lib"
+done
+
+readonly -a build_options
+
+prepare_buildenv() {
+   msg "$(gettext "Preparing build environment...")"
+
+   for func in ${build_options[@]}; do
+   $func
+   done
+
+   if check_option "debug" "y"; then
+   DEBUG_CFLAGS+=" 
-fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
+   DEBUG_CXXFLAGS+=" 
-fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
+   CFLAGS+=" $DEBUG_CFLAGS"
+   CXXFLAGS+=" $DEBUG_CXXFLAGS"
+   fi
+
+   # ensure all necessary build variables are exported
+   export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
+}
diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in 
b/scripts/libmakepkg/buildenv/buildflags.sh.in
new file mode 100644
index ..fb49a85c
--- /dev/null
+++ b/scripts/libmakepkg/buildenv/buildflags.sh.in
@@ -0,0 +1,34 @@
+#!/usr/bin/bash
+#
+#   buildflags.sh - Clear user-specified buildflags if requested
+#
+#   Copyright (c) 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

[pacman-dev] [PATCH] Extend BUILDENV: Allow for supplemental scripts that enable build-time optimizations.

2018-05-22 Thread Que Quotion
Signed-off-by: Que Quotion <quequot...@bugmenot.com>
---
 scripts/Makefile.am   |  2 ++
 scripts/libmakepkg/buildenv_ext.sh.in | 43 +++
 scripts/makepkg.sh.in |  3 ++
 3 files changed, 48 insertions(+)
 create mode 100644 scripts/libmakepkg/buildenv_ext.sh.in

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 448057dc..094bca48 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -48,6 +48,7 @@ LIBMAKEPKGDIRS = \
lint_pkgbuild \
source \
tidy \
+   buildenv_ext \
util
 
 LIBMAKEPKG_IN = \
@@ -93,6 +94,7 @@ LIBMAKEPKG_IN = \
libmakepkg/tidy/staticlibs.sh \
libmakepkg/tidy/strip.sh \
libmakepkg/tidy/zipman.sh \
+   libmakepkg/buildenv_ext.sh \
libmakepkg/util.sh \
libmakepkg/util/message.sh \
libmakepkg/util/option.sh \
diff --git a/scripts/libmakepkg/buildenv_ext.sh.in 
b/scripts/libmakepkg/buildenv_ext.sh.in
new file mode 100644
index ..72d5948a
--- /dev/null
+++ b/scripts/libmakepkg/buildenv_ext.sh.in
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+#   buildenv_ext.sh - addional functions for altering the build environment
+#   before compiliation
+#
+#   Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+#
+#   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 <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_BUILDENV_EXT_SH" ]] && return
+LIBMAKEPKG_BUILDENV_EXT_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+declare -a extra_buildopts
+
+for lib in "$LIBRARY/buildenv_ext/"*.sh; do
+   source "$lib"
+done
+
+readonly -a extra_buildopts
+
+
+buildenv_ext() {
+
+   # options that alter compilation parameters
+   for func in ${extra_buildopts[@]}; do
+   $func
+   done
+
+}
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 02398cf8..8f4110f8 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -395,6 +395,9 @@ prepare_buildenv() {
fi
export DISTCC_HOSTS
fi
+
+   # Check for BUILDENV extensions, use any that are requested (check 
buildenv and PKGBUILD opts)
+   buildenv_ext
 }
 
 run_function_safe() {
-- 
2.17.0


[pacman-dev] Any final changes?

2018-05-22 Thread Que Quotion

>where were you a couple of weeks ago?

Somewhere between (still) scouring the Internet for an email client that 
is actually capable of replying to mailing lists, holding out that Allan 
was working on his own approach and that the patches I submitted before 
were still visible somewhere that mattered.


>the next point release

That's fine. I'll post a new version of the patch for consideration 
after this.


>you're the one who wants it

I can't be the only one who wants this.


Re: [pacman-dev] Open up a place for BUILDENV extensions

2016-04-01 Thread Que Quotion

>Allan
Thank you for your consideration; it is encouraging.

I don't mean to be pushy, and I don't mind who gets the thing done or 
when--I really just want to see the idea implemented one way or another.


>Reisner
My reply to you went off thread again; I'm trying to get the hang of it.


Re: [pacman-dev] Open up a place for BUILDENV extensions

2016-04-01 Thread Que Quotion
Sorry to double-post. This will be my second attempt to get this right, 
with yet another email client (gmail can't; geary failed; thunderbird?).


>How exactly is this related to BUILDENV? This seems to be allowing
arbitrary code to run before executing the build() function.

You can use the word "arbitrary" to make it sound like a bad idea if
you like, but it very simply does for BUILDENV exactly what tidy.sh
does for OPTIONS: allow for supplemental scripts to add to makepkg's
functionality at this stage.

In fact, it does it in exactly the same way--because nearly all of this
code was copied and pasted from tidy.sh.

Just as tidy.sh allows any kind of anything to be run, it could allow
any bash script to be run here--but the intention is for scripts that
serve build-environment altering functions to be run here (as the
intention for tidy.sh is to run cleanup and compression scripts).

Your concern about cleanup seems misplaced. It will be up to the
authors of supplemental scripts to make sure they work properly, and
users who trust them to install and enable those features. This
patch--in and of itself--will not cause the problems you are worried
about.

 >This line does nothing, even if correctly spelled.

What is misspelled? This is intended to serve the same purpose as the
same line serves in tidy.sh:

declare -a packaging_options tidy_remove tidy_modify

The tidy scripts have names like upx.sh, the buildenv_ext scripts will
have names like pgo.sh; these variables store the names of those
options as they will be known in makepkg(-optimize).conf (upx, pgo).

 >Since nullglob isn't set, an empty directory will cause this to throw
an error about a missing file (as the glob will turn into a literal). As
there's no "buildenv_ext" files provided by makepkg, this means we error
by default.

That could be fixed very easily, but again: copy pasta from tidy.sh. If
you have a problem with this code--you should have a problem with that
code too. Furthermore, as I have suggested in the forum (and posted a
patch for), the first thing I would do with this if it were up to me is
move ccache and distcc out of makepkg and ship them as builenv_ext
scripts. Then you'd be shipping something that makes this unsafe code
work just the way the same unsafe code works in tidy.sh.

 >quoting

Sure, no problem. That also needs to be fixed in tidy.sh


[pacman-dev] Open up a place for BUILDENV extensions

2016-04-01 Thread Que Quotion
>How exactly is this related to BUILDENV? This seems to be allowing 
arbitrary code to run before executing the build() function.


You can use the word "arbitrary" to make it sound like a bad idea if 
you like, but it very simply does for BUILDENV exactly what tidy.sh 
does for OPTIONS: allow for supplemental scripts to add to makepkg's 
functionality at this stage.


In fact, it does it in exactly the same way--because nearly all of this 
code was copied and pasted from tidy.sh.


Just as tidy.sh allows any kind of anything to be run, it could allow 
any bash script to be run here--but the intention is for scripts that 
serve build-environment altering functions to be run here (as the 
intention for tidy.sh is to run cleanup and compression scripts).


Your concern about cleanup seems misplaced. It will be up to the 
authors of supplemental scripts to make sure they work properly, and 
users who trust them to install and enable those features. This 
patch--in and of itself--will not cause the problems you are worried 
about.


>This line does nothing, even if correctly spelled.

What is misspelled? This is intended to serve the same purpose as the 
same line serves in tidy.sh:


declare -a packaging_options tidy_remove tidy_modify

The tidy scripts have names like upx.sh, the buildenv_ext scripts will 
have names like svgo.sh; these variables store the names of those 
options as they will be known in makepkg(-optimize).conf.


>Since nullglob isn't set, an empty directory will cause this to throw
an error about a missing file (as the glob will turn into a literal). As
there's no "buildenv_ext" files provided by makepkg, this means we error
by default.

That could be fixed very easily, but again: copy pasta from tidy.sh. If 
you have a problem with this code--you should have a problem with that 
code too. Furthermore, as I have suggested in the forum (and posted a 
patch for), the first thing I would do with this if it were up to me is 
move ccache and distcc out of makepkg and ship them as builenv_ext 
scripts. Then you'd be shipping something that makes this unsafe code 
work just the way the same unsafe code works in tidy.sh.


>quoting

Sure, no problem. That also needs to be fixed in tidy.sh.


Re: [pacman-dev] [PATCH] libmakepkg: extension for additional BUILDENV options

2016-04-01 Thread Que Quotion
>>apg

Until a very few moments ago, I was not subscribed to this mailing list. I
do not intend to be subscribed after this is resolved. There is no other
issue on the mailing list for which it is necessary for me to subscribe and
I care very much when unnecessary email comes to my inbox.

There's no way to get header information without being a subscriber, so I'm
never going to get the Message-ID for any past messages. As a result, I'm
left with no choice but to post my patches (with all the appropriate
git-format bells and whistles) as either a new thread or a reply to this
one.

I'm going with new thread, since it is apparently standard practice to
indicate patch version numbers in the subject line and--last week--I did
bump the patch to v2.


Re: [pacman-dev] [PATCH] libmakepkg: extension for additional BUILDENV options

2016-04-01 Thread Que Quotion
On Sat, Apr 2, 2016 at 1:31 AM, Que Quotion <quequot...@gmail.com> wrote:

> >>apg
>
> I was not aware that there is any such patch submission procedure. I will 
> resubmit the patch shortly.
>
>
> Actually, this has proven to be exceedingly difficult. The pacman-dev
archive does not offer header information, so it will not be possible for
me to reply to any specific Message-ID (the best I can do, even with git
send-email, is "Re: this discussion subject line"). In fact, I did submit a
properly formatted patch over a week ago but it has been ignored long
enough to be in last month's discussion archive.

Please look at my properly formatted patch under the same heading in last
month's (last week's) discussion. Resubmitting this patch would be
redundant.


Re: [pacman-dev] [PATCH] libmakepkg: extension for additional BUILDENV options

2016-04-01 Thread Que Quotion
>>apg

I was not aware that there is any such patch submission procedure. I
will resubmit the patch shortly.


Re: [pacman-dev] [PATCH] libmakepkg: extension for additional BUILDENV options

2016-04-01 Thread Que Quotion
Any response is welcome.

I recently proved this works even with makechrootpkg:
https://bbs.archlinux.org/viewtopic.php?pid=1616677


Re: [pacman-dev] [PATCH] libmakepkg: extension for additional BUILDENV options

2016-03-22 Thread Que Quotion
It didn't break anything, but it is unnecessary to use build_options here
(and avoids a warning about it being readonly). extra_buildopts alone will
suffice.

buildenv_ext v2 (final)

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 6f9abb8..a633827 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -45,6 +45,7 @@ LIBMAKEPKGDIRS = \
 lint_pkgbuild \
 source \
 tidy \
+buildenv_ext \
 util

 LIBMAKEPKG = \
@@ -82,6 +83,7 @@ LIBMAKEPKG_IN = \
 libmakepkg/source/local.sh \
 libmakepkg/source/svn.sh \
 libmakepkg/tidy.sh \
+libmakepkg/buildenv_ext.sh \
 libmakepkg/tidy/docs.sh \
 libmakepkg/tidy/emptydirs.sh \
 libmakepkg/tidy/libtool.sh \
diff --git a/scripts/libmakepkg/buildenv_ext.sh.in b/scripts/libmakepkg/
buildenv_ext.sh.in
new file mode 100644
index 000..a877b87
--- /dev/null
+++ b/scripts/libmakepkg/buildenv_ext.sh.in
@@ -0,0 +1,42 @@
+#!/usr/bin/bash
+#
+#   buildenv_ext.sh - addional functions for altering the build environment
+#   before compiliation
+#
+#   Copyright (c) 2015-2016 Pacman Development Team <
pacman-dev@archlinux.org>
+#
+#   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_BUILDENV_EXT_SH" ]] && return
+LIBMAKEPKG_BUILDENV_EXT_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+declare -a  exta_buildopts
+
+for lib in "$LIBRARY/buildenv_ext/"*.sh; do
+source "$lib"
+done
+
+readonly -a extra_buildopts
+
+buildenv_ext() {
+
+# options that alter compilation parameters
+for func in ${extra_buildopts[@]}; do
+$func
+done
+
+}
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 2efcc98..aafec5d 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -866,6 +866,9 @@ run_build() {
 export DISTCC_HOSTS
 fi

+# Check for BUILDENV extensions, use any that are requested (check
buildenv and PKGBUILD opts)
+buildenv_ext
+
 run_function_safe "build"
 }


[pacman-dev] [PATCH] libmakepkg: extension for additional BUILDENV options

2016-03-22 Thread Que Quotion
Sorry for the double post; didn't expect a text attachment to be scrubbed
and the title needed improvement.

This patch makes it possible to create scripts to be used as addiional BUILDENV
options. It does not include any such scripts itself, which would be up to
users to install as supplemental packages.

buildenv_ext.sh is based on tidy.sh; doing exactly the same thing for
BUILDENV that tidy.sh does for OPTIONS.

I have tested this, it does work, but if there's anything you'd like to
change, go right ahead.

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 6f9abb8..a633827 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -45,6 +45,7 @@ LIBMAKEPKGDIRS = \
  lint_pkgbuild \
  source \
  tidy \
+ buildenv_ext \
  util

 LIBMAKEPKG = \
@@ -82,6 +83,7 @@ LIBMAKEPKG_IN = \
  libmakepkg/source/local.sh \
  libmakepkg/source/svn.sh \
  libmakepkg/tidy.sh \
+ libmakepkg/buildenv_ext.sh \
  libmakepkg/tidy/docs.sh \
  libmakepkg/tidy/emptydirs.sh \
  libmakepkg/tidy/libtool.sh \
diff --git a/scripts/libmakepkg/buildenv_ext.sh.in b/scripts/libmakepkg/
buildenv_ext.sh.in
new file mode 100644
index 000..a877b87
--- /dev/null
+++ b/scripts/libmakepkg/buildenv_ext.sh.in
@@ -0,0 +1,42 @@
+#!/usr/bin/bash
+#
+#   buildenv_ext.sh - addional functions for altering the build environment
+#   before compiliation
+#
+#   Copyright (c) 2015-2016 Pacman Development Team <
pacman-dev@archlinux.org>
+#
+#   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_BUILDENV_EXT_SH" ]] && return
+LIBMAKEPKG_BUILDENV_EXT_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+declare -a  build_options exta_buildopts
+
+for lib in "$LIBRARY/buildenv_ext/"*.sh; do
+ source "$lib"
+done
+
+readonly -a build_options extra_buildopts
+
+buildenv_ext() {
+
+ # options that alter compilation parameters
+ for func in ${extra_buildopts[@]}; do
+ $func
+ done
+
+}
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 2efcc98..aafec5d 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -866,6 +866,9 @@ run_build() {
  export DISTCC_HOSTS
  fi

+ # Check for BUILDENV extensions, use any that are requested (check
buildenv and PKGBUILD opts)
+ buildenv_ext
+
  run_function_safe "build"
 }


Re: [pacman-dev] LTO and PGO build options

2016-03-20 Thread Que Quotion
Oh, you're talking about CFLAGS *in makepkg.conf* as I've pointed out, that
won't always work when it should.

On Sun, Mar 20, 2016 at 7:16 PM, Que Quotion <quequot...@gmail.com> wrote:

> >Adding -flto to CFLAGS and forgetting also is fine.  Remove it when the
> software is broken with LTO.
>
> The only way this makes logical sense is if you mean for *packagers* to do 
> so, but I have never known any to do so. I don't think it's any more 
> appropriate to distribute PKGBUILDs with optimizations enabled by default. 
> Much better to leave that to users; much too troublesome to ask them to edit 
> each PKGBUILD they want to optimize. Doing this in makepkg works better than 
> a wrapper script, and involves less work for both users and packagers--who 
> would also have the opportunity to specify packages that must not use LTO.
>
> >Add -flto to CFLAGS, report broken software upstream.  I am not adding
> this to makepkg.
>
> That's dissapointing. There's practically no downside to having LTO available 
> in makepkg.>I was talking about the patch you provided being untested.  You 
> appear
> to have understood that as you have fixed it
>
> Yeah, and you were right--but you came to that conclusion on a whim.
>
> >upx is dropped. optipng is dropped.
>
> Oh, I see. Sorry to hear about that. makepkg's automated (opt-in) 
> optimization of packages is one of the features I considered vastly superior 
> to other package creation tools.
>
> >I am not adding an option to makepkg that does non-deterministic
> optimisation.
>
> It always would have been an option for users to choose, not a policy, ie 
> "enable at your own (negligible) risk".
>
> I don't think I have the constitution to maintain a makepkg fork for extra 
> optimization features, but its sounding like a good idea.
>
>


Re: [pacman-dev] LTO and PGO build options

2016-03-20 Thread Que Quotion
>Adding -flto to CFLAGS and forgetting also is fine.  Remove it when the
software is broken with LTO.

The only way this makes logical sense is if you mean for *packagers*
to do so, but I have never known any to do so. I don't think it's any
more appropriate to distribute PKGBUILDs with optimizations enabled by
default. Much better to leave that to users; much too troublesome to
ask them to edit each PKGBUILD they want to optimize. Doing this in
makepkg works better than a wrapper script, and involves less work for
both users and packagers--who would also have the opportunity to
specify packages that must not use LTO.

>Add -flto to CFLAGS, report broken software upstream.  I am not adding
this to makepkg.

That's dissapointing. There's practically no downside to having LTO
available in makepkg.>I was talking about the patch you provided being
untested.  You appear
to have understood that as you have fixed it

Yeah, and you were right--but you came to that conclusion on a whim.

>upx is dropped. optipng is dropped.

Oh, I see. Sorry to hear about that. makepkg's automated (opt-in)
optimization of packages is one of the features I considered vastly
superior to other package creation tools.

>I am not adding an option to makepkg that does non-deterministic
optimisation.

It always would have been an option for users to choose, not a policy,
ie "enable at your own (negligible) risk".

I don't think I have the constitution to maintain a makepkg fork for
extra optimization features, but its sounding like a good idea.


Re: [pacman-dev] LTO and PGO build options

2016-03-20 Thread Que Quotion
>What is the advantage to all this beyond people adding "-flto" to their
CFLAGS if they want LTO?

The advantage is not having to do that. Theoretically, the compiler
devs expect LTO to always work and want reports when it does not. We
should be able to enable LTO for every build, but my experience is
that--occasionally--the linker fails.

Users so inclined could "set it and forget it" most of the time, and
occasionally disable it if a package does not build. I find this more
efficient than modifying the PKGBUILD of each package that could
benefit from LTO.

>All modern builds should handle the rest by themselves.

Should, but don't last time I checked. A number of builds failed for
not having {AR,RANLIB,NM}FLAGS set when attempting LTO. I see the
complexity as another reason to have this built into makepkg instead
of having to do all this tediousness on a per-package basis.

The less anyone has to edit PKGBUILDs for generic things like
optimization, the better I think.

>I'm guessing this is untested...

That's kinda like.. not testing it, yeah?

I've been using this for quite some time. Nearly everything compiles
successfully with pgo. There were a couple of wrapper leftovers to fix
in my initial post, see below. The problem with only me doing the
testing is no one will ever beleive my success. I have been
successful, believe it--or try it for yourself.

>Anyway, I don't think PGO has a place in makepkg itself

Why not, specifically? We have other cflag stuff in there; besides, it
should be disabled by default so users could opt-in when they feel
ready. Do you know you can PGO just about any package in the
repositories? It's still takes two build steps, but this macro saves a
lot of tediousness over editing the individual PKGBUILDS. I don't see
how it's any more or less worthy than ccache, upx, etc.

As for the particular cflags I've used for PGO and LTO, these are
*known to work* but may not be the only options, might be overkill, or
there could even be a few more minor flags worth setting. I'd
appreciate some commentary on this matter, and some tests to prove or
disprove which flags are required.

"-fwhopr" might be a safter idea than "-flto", to avoid the compiler
running out of memory and crashing while compiling large programs.

New patchset:

In makepkg, "-Wl,-option" must be at the end of LDFLAGS:

--- makepkg 2016-02-23 11:52:34.0 +0900
+++ makepkg 2016-03-20 16:57:07.260935565 +0900
@@ -866,6 +866,32 @@
export DISTCC_HOSTS
fi

+
+   # Use lto if it is requested (check buildenv and PKGBUILD opts)
+   if check_buildoption "lto" "y" && [[ -f "$(gcc -print-search-dirs |
grep install | awk '{print $2 "liblto_plugin.so"}')" ]]; then
+   CFLAGS+=" -flto=$(getconf _NPROCESSORS_ONLN)"
+   CXXFLAGS+=" -flto=$(getconf _NPROCESSORS_ONLN)"
+   LDFLAGS+=" $CFLAGS $CXXFLAGS -Wl,-fuse-linker-plugin"
+   LTOPLUGIN="$(gcc -print-search-dirs | grep install | awk 
'{print $2
"liblto_plugin.so"}')"
+   ARFLAGS+=" --plugin $LTOPLUGIN"
+   RANLIBFLAGS+=" --plugin $LTOPLUGIN"
+   NMFLAGS+=" --plugin $LTOPLUGIN"
+   fi
+
+   # Generate or utilize pgo if it is requested (check buildenv and
PKGBUILD opts)
+   if check_buildoption "pgo" "y"; then
+   if [ ! -d "$PROFDEST/$pkgbase.gen" ]; then
+   mkdir "$PROFDEST/$pkgbase.gen"
+   CFLAGS+=" -fprofile-generate 
-fprofile-dir=$PROFDEST/$pkgbase.gen"
+   CXXFLAGS+=" -fprofile-generate 
-fprofile-dir=$PROFDEST/$pkgbase.gen"
+   LDFLAGS+=" -Wl,-lgcov"
+   elif [ ! -d "$PROFDEST/$pkgbase.used" ]; then
+   mv "$PROFDEST/$pkgbase.gen" "$PROFDEST/$pkgbase.used"
+   CFLAGS+=" -fprofile-correction -fprofile-use
-fprofile-dir=$PROFDEST/$pkgbase.used"
+   CXXFLAGS+=" -fprofile-correction -fprofile-use
-fprofile-dir=$PROFDEST/$pkgbase.used"
+   fi
+   fi
+
run_function_safe "build"
 }

@@ -1865,6 +2028,7 @@
 [[ -n ${PKGDEST} ]] && _PKGDEST=$(canonicalize_path ${PKGDEST})
 [[ -n ${SRCDEST} ]] && _SRCDEST=$(canonicalize_path ${SRCDEST})
 [[ -n ${SRCPKGDEST} ]] && _SRCPKGDEST=$(canonicalize_path ${SRCPKGDEST})
+[[ -n ${PROFDEST} ]] && _PROFDEST=$(canonicalize_path ${PROFDEST})
 [[ -n ${LOGDEST} ]] && _LOGDEST=$(canonicalize_path ${LOGDEST})
 [[ -n ${BUILDDIR} ]] && _BUILDDIR=$(canonicalize_path ${BUILDDIR})
 [[ -n ${PKGEXT} ]] && _PKGEXT=${PKGEXT}
@@ -1961,6 +2125,14 @@
IGNOREARCH=1
 fi

+PROFDEST=${_PROFDEST:-$PROFDEST}
+PROFDEST=${PROFDEST:-$startdir} #default to $startdir if undefined
+if [[ ! -w $PROFDEST ]] ; then
+   error "$(gettext "You do not have write permission to store profiles
in %s.")" "$PROFDEST"
+   plain "$(gettext "Aborting...")"
+   exit 1
+fi
+
 LOGDEST=${_LOGDEST:-$LOGDEST}
 LOGDEST=${LOGDEST:-$startdir} #default to 

Re: [pacman-dev] LTO and PGO build options

2016-03-19 Thread Que Quotion
The section @@ -48,7 +48,7 @@ above is probably unnecessary; I
misunderstood the purpose of that line.

Also, some changes to makepkg.conf to fit with the changes to makepkg:

--- /etc/makepkg.conf 2016-01-09 02:34:08.007565594 +0900
+++ ./makepkg.conf.qq 2016-03-19 04:19:46.655963264 +0900
@@ -110,6 +110,8 @@
 #-- purge:  Remove files specified by PURGE_TARGETS
 #-- upx:Compress binary executable files using UPX
 #-- debug:  Add debugging flags as specified in DEBUG_* variables
+#-- lto:Use link-time optimization to reduce compiled binary size
and possibly improve performance
+#-- pgo:Generate or use profile guided optimization to reduce
compile binary size and improve performance
 #
 OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge upx !debug)

@@ -142,6 +144,8 @@
 #SRCDEST=/home/sources
 #-- Source packages: specify a fixed directory where all src packages will
be placed
 #SRCPKGDEST=/home/srcpackages
+#-- Profile cache: specify a fixed directory where profiles will be stored
+#PROFDEST=/home/sources
 #-- Log files: specify a fixed directory where all log files will be placed
 #LOGDEST=/home/makepkglogs
 #-- Packager: name/email of the person or organization building packages


Re: [pacman-dev] [PATCH] makepkg: remove ability to build individual packages

2015-09-22 Thread Que Quotion
>there can silently exist package order dependencies between package
functions

I find it hilarious that Dave Reisner points this out, because it is his
packages that are full of this problem: one package function putting files
in place for another, such that all the functions have to be done, and be
done in the order he expects them to be done or packging will fail.

Anyway it looks like the issue is settled...

On Tue, Sep 22, 2015 at 11:57 PM, Que Quotion <quequot...@gmail.com> wrote:

> Case in point, I had some trouble pakaging several packages today.
>
> One was libsystemd, which I've already submitted a patch for.
> https://bugs.archlinux.org/task/46382
>
> Another was libutil-lnux, which will need a little more help.
> https://bugs.archlinux.org/task/46383
>
> In both cases $pkgname was used where $pkgbase should be (fixed in an
> earlier report for systemd) and then both packages use one
> package_something() function to put files in place for another
> package_somethingelse() function--both by moving files from $pkgdir into
> $srcdir. This seems like bad practice to me, isn't necessary, and could be
> done better: My proposal for systemd shortens the PKGBUILD by a few lines
> and doesn't touch $srcdir.
>
> Removing the "--pkg" feature of makepkg will only allow more bad practice
> that will be harder to undo should we change our minds down the line.
>
> On Tue, Sep 22, 2015 at 11:40 PM, Que Quotion <quequot...@gmail.com>
> wrote:
>
>> In other words, rather than fix the packages to be safer and more
>> logical, go ahead and let people write sloppy PKGBUILDs?
>>
>> For what it's worth, I think this is a bad idea.
>>
>> The changes needed to fix the packages are small, and this would reduce
>> the ability of users to automate upgrading from ABS.
>>
>> On Tue, Sep 22, 2015 at 11:33 PM, Allan McRae <al...@archlinux.org>
>> wrote:
>>
>>> On 23/09/15 00:20, Pierre Neidhardt wrote:
>>> > I might have missed something in the previous messages, but is there
>>> any
>>> > rationale on this, beside debatable worthiness?
>>> >
>>>
>>> Many packages break when using this.
>>>
>>> Some are because assumptions made on build() about the value of $pkgname
>>> which changes when --pkg was used.  These should use $pkgbase anyway...
>>>
>>> Also, there are quite a few split packages that rely on the first first
>>> split-package being packaged for the rest of the package functions to
>>> work.   This will become more prevalent when a way to do a "make
>>> install" followed by moving files into different packages becomes
>>> available (i.e. rpm packaging style - I am working on this).
>>>
>>> So...  essentially, it is (debatably) broken and will become more broken
>>> in the future
>>>
>>
>>
>


Re: [pacman-dev] [PATCH] makepkg: remove ability to build individual packages

2015-09-22 Thread Que Quotion
Case in point, I had some trouble pakaging several packages today.

One was libsystemd, which I've already submitted a patch for.
https://bugs.archlinux.org/task/46382

Another was libutil-lnux, which will need a little more help.
https://bugs.archlinux.org/task/46383

In both cases $pkgname was used where $pkgbase should be (fixed in an
earlier report for systemd) and then both packages use one
package_something() function to put files in place for another
package_somethingelse() function--both by moving files from $pkgdir into
$srcdir. This seems like bad practice to me, isn't necessary, and could be
done better: My proposal for systemd shortens the PKGBUILD by a few lines
and doesn't touch $srcdir.

Removing the "--pkg" feature of makepkg will only allow more bad practice
that will be harder to undo should we change our minds down the line.

On Tue, Sep 22, 2015 at 11:40 PM, Que Quotion <quequot...@gmail.com> wrote:

> In other words, rather than fix the packages to be safer and more logical,
> go ahead and let people write sloppy PKGBUILDs?
>
> For what it's worth, I think this is a bad idea.
>
> The changes needed to fix the packages are small, and this would reduce
> the ability of users to automate upgrading from ABS.
>
> On Tue, Sep 22, 2015 at 11:33 PM, Allan McRae <al...@archlinux.org> wrote:
>
>> On 23/09/15 00:20, Pierre Neidhardt wrote:
>> > I might have missed something in the previous messages, but is there any
>> > rationale on this, beside debatable worthiness?
>> >
>>
>> Many packages break when using this.
>>
>> Some are because assumptions made on build() about the value of $pkgname
>> which changes when --pkg was used.  These should use $pkgbase anyway...
>>
>> Also, there are quite a few split packages that rely on the first first
>> split-package being packaged for the rest of the package functions to
>> work.   This will become more prevalent when a way to do a "make
>> install" followed by moving files into different packages becomes
>> available (i.e. rpm packaging style - I am working on this).
>>
>> So...  essentially, it is (debatably) broken and will become more broken
>> in the future
>>
>
>


Re: [pacman-dev] [PATCH] makepkg: remove ability to build individual packages

2015-09-22 Thread Que Quotion
In other words, rather than fix the packages to be safer and more logical,
go ahead and let people write sloppy PKGBUILDs?

For what it's worth, I think this is a bad idea.

The changes needed to fix the packages are small, and this would reduce the
ability of users to automate upgrading from ABS.

On Tue, Sep 22, 2015 at 11:33 PM, Allan McRae  wrote:

> On 23/09/15 00:20, Pierre Neidhardt wrote:
> > I might have missed something in the previous messages, but is there any
> > rationale on this, beside debatable worthiness?
> >
>
> Many packages break when using this.
>
> Some are because assumptions made on build() about the value of $pkgname
> which changes when --pkg was used.  These should use $pkgbase anyway...
>
> Also, there are quite a few split packages that rely on the first first
> split-package being packaged for the rest of the package functions to
> work.   This will become more prevalent when a way to do a "make
> install" followed by moving files into different packages becomes
> available (i.e. rpm packaging style - I am working on this).
>
> So...  essentially, it is (debatably) broken and will become more broken
> in the future
>