Re: [gentoo-dev] [PATCH 1/2] cargo.eclass: allow passing additional arguments to cargo

2019-01-06 Thread Ulrich Mueller
> On Mon, 07 Jan 2019, Georgy Yakovlev wrote:

>  cargo_src_compile() {
>   debug-print-function ${FUNCNAME} "$@"
>  
>   export CARGO_HOME="${ECARGO_HOME}"
>  
> - cargo build -j $(makeopts_jobs) $(usex debug "" --release) \
> + cargo build -j $(makeopts_jobs) $(usex debug "" --release) "${@}" \

Keep constistent style, "$@" is without braces just above.

>  cargo_src_install() {
>   debug-print-function ${FUNCNAME} "$@"
> 
> - cargo install -j $(makeopts_jobs) --root="${D}/usr" $(usex debug 
> --debug "") \
> + cargo install -j $(makeopts_jobs) --root="${D}/usr" $(usex debug 
> --debug "") "${@}" \

Ditto.

Ulrich


signature.asc
Description: PGP signature


Re: [gentoo-dev] [PATCH] cargo.eclass: allow passing additional arguments to cargo

2019-01-06 Thread Georgy Yakovlev
On Thursday, January 3, 2019 1:37:20 AM PST Sergei Trofimovich wrote:
> On Wed,  2 Jan 2019 13:58:26 -0800
> 
> Georgy Yakovlev  wrote:
> > +# @CODE
> > +# ECARGO_BUILD_FLAGS="$(usex pcre "--features pcre2" "")"
> > +# @CODE
> 
> You may also want to provide user's hooks as well.
> 

I have something else brewing for cargo, next time I'll include something like 
this.
 it's nice to have, sure. Thanks for suggestion.

> Similar to EXTRA_ECONF and EXTRA_EMAKE those might be
> ECARGO_EXTRA_BUILD_FLAGS
> ECARGO_EXTRA_INSTALL_FLAGS
> 
> That way user would be able to tweak cargo behaviour without
> breaking ebuild behaviour too much via make.conf/package.env, like
> ECARGO_EXTRA_BUILD_FLAGS=--color=never


-- 
Georgy Yakovlev
Gentoo Linux Developer

signature.asc
Description: This is a digitally signed message part.


[gentoo-dev] [PATCH 2/2] cargo.eclass: add standard src_test

2019-01-06 Thread Georgy Yakovlev
But not set IUSE=test by default

Signed-off-by: Georgy Yakovlev 
This is pretty straightforward change, just adds standard src_test for
cargo

---
 eclass/cargo.eclass | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index ee17f2af9d9..c576c8e8066 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -1,142 +1,152 @@
 # Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: cargo.eclass
 # @MAINTAINER:
 # r...@gentoo.org
 # @AUTHOR:
 # Doug Goldstein 
 # @SUPPORTED_EAPIS: 6 7
 # @BLURB: common functions and variables for cargo builds
 
 if [[ -z ${_CARGO_ECLASS} ]]; then
 _CARGO_ECLASS=1
 
 CARGO_DEPEND=""
 [[ ${CATEGORY}/${PN} != dev-util/cargo ]] && CARGO_DEPEND="virtual/cargo"
 
 case ${EAPI} in
6) DEPEND="${CARGO_DEPEND}";;
7) BDEPEND="${CARGO_DEPEND}";;
*) die "EAPI=${EAPI:-0} is not supported" ;;
 esac
 
 inherit multiprocessing
 
-EXPORT_FUNCTIONS src_unpack src_compile src_install
+EXPORT_FUNCTIONS src_unpack src_compile src_install src_test
 
 IUSE="${IUSE} debug"
 
 ECARGO_HOME="${WORKDIR}/cargo_home"
 ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
 
 # @FUNCTION: cargo_crate_uris
 # @DESCRIPTION:
 # Generates the URIs to put in SRC_URI to help fetch dependencies.
 cargo_crate_uris() {
local crate
for crate in "$@"; do
local name version url pretag
name="${crate%-*}"
version="${crate##*-}"
pretag="^[a-zA-Z]+"
if [[ $version =~ $pretag ]]; then
version="${name##*-}-${version}"
name="${name%-*}"
fi

url="https://crates.io/api/v1/crates/${name}/${version}/download -> 
${crate}.crate"
echo "${url}"
done
 }
 
 # @FUNCTION: cargo_src_unpack
 # @DESCRIPTION:
 # Unpacks the package and the cargo registry
 cargo_src_unpack() {
debug-print-function ${FUNCNAME} "$@"
 
mkdir -p "${ECARGO_VENDOR}" || die
mkdir -p "${S}" || die
 
local archive shasum pkg
for archive in ${A}; do
case "${archive}" in
*.crate)
ebegin "Loading ${archive} into Cargo registry"
tar -xf "${DISTDIR}"/${archive} -C 
"${ECARGO_VENDOR}/" || die
# generate sha256sum of the crate itself as 
cargo needs this
shasum=$(sha256sum "${DISTDIR}"/${archive} | 
cut -d ' ' -f 1)
pkg=$(basename ${archive} .crate)
cat <<- EOF > 
${ECARGO_VENDOR}/${pkg}/.cargo-checksum.json
{
"package": "${shasum}",
"files": {}
}
EOF
# if this is our target package we need it in 
${WORKDIR} too
# to make ${S} (and handle any revisions too)
if [[ ${P} == ${pkg}* ]]; then
tar -xf "${DISTDIR}"/${archive} -C 
"${WORKDIR}" || die
fi
eend $?
;;
cargo-snapshot*)
ebegin "Unpacking ${archive}"
mkdir -p "${S}"/target/snapshot
tar -xzf "${DISTDIR}"/${archive} -C 
"${S}"/target/snapshot --strip-components 2 || die
# cargo's makefile needs this otherwise it will 
try to
# download it
touch "${S}"/target/snapshot/bin/cargo || die
eend $?
;;
*)
unpack ${archive}
;;
esac
done
 
cargo_gen_config
 }
 
 # @FUNCTION: cargo_gen_config
 # @DESCRIPTION:
 # Generate the $CARGO_HOME/config necessary to use our local registry
 cargo_gen_config() {
debug-print-function ${FUNCNAME} "$@"
 
cat <<- EOF > "${ECARGO_HOME}/config"
[source.gentoo]
directory = "${ECARGO_VENDOR}"
 
[source.crates-io]
replace-with = "gentoo"
local-registry = "/nonexistant"
EOF
 }
 
 # @FUNCTION: cargo_src_compile
 # @DESCRIPTION:
 # Build the package using cargo build
 cargo_src_compile() {
debug-print-function ${FUNCNAME} "$@"
 
export CARGO_HOME="${ECARGO_HOME}"
 
cargo build -j $(makeopts_jobs) $(usex debug "" --release) "${@}" \
|| die "cargo build failed"
 }
 
 # @FUNCTION: cargo_src_install
 # @DESCRIPT

[gentoo-dev] [PATCH 1/2] cargo.eclass: allow passing additional arguments to cargo

2019-01-06 Thread Georgy Yakovlev
for example:

src_compile() {
cargo_src_compile $(usex pcre "--features pcre2" "")"
}

Signed-off-by: Georgy Yakovlev 
---
Some packages just copy cargo_src_install and add custom arguments.
This change will allow just passing arguments to cargo_src_* instead.

 eclass/cargo.eclass | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 50f7830c51b..ee17f2af9d9 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -1,142 +1,142 @@
-# Copyright 1999-2018 Gentoo Authors
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: cargo.eclass
 # @MAINTAINER:
 # r...@gentoo.org
 # @AUTHOR:
 # Doug Goldstein 
 # @SUPPORTED_EAPIS: 6 7
 # @BLURB: common functions and variables for cargo builds
 
 if [[ -z ${_CARGO_ECLASS} ]]; then
 _CARGO_ECLASS=1
 
 CARGO_DEPEND=""
 [[ ${CATEGORY}/${PN} != dev-util/cargo ]] && CARGO_DEPEND="virtual/cargo"
 
 case ${EAPI} in
6) DEPEND="${CARGO_DEPEND}";;
7) BDEPEND="${CARGO_DEPEND}";;
*) die "EAPI=${EAPI:-0} is not supported" ;;
 esac
 
 inherit multiprocessing
 
 EXPORT_FUNCTIONS src_unpack src_compile src_install
 
 IUSE="${IUSE} debug"
 
 ECARGO_HOME="${WORKDIR}/cargo_home"
 ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
 
 # @FUNCTION: cargo_crate_uris
 # @DESCRIPTION:
 # Generates the URIs to put in SRC_URI to help fetch dependencies.
 cargo_crate_uris() {
local crate
for crate in "$@"; do
local name version url pretag
name="${crate%-*}"
version="${crate##*-}"
pretag="^[a-zA-Z]+"
if [[ $version =~ $pretag ]]; then
version="${name##*-}-${version}"
name="${name%-*}"
fi

url="https://crates.io/api/v1/crates/${name}/${version}/download -> 
${crate}.crate"
echo "${url}"
done
 }
 
 # @FUNCTION: cargo_src_unpack
 # @DESCRIPTION:
 # Unpacks the package and the cargo registry
 cargo_src_unpack() {
debug-print-function ${FUNCNAME} "$@"
 
mkdir -p "${ECARGO_VENDOR}" || die
mkdir -p "${S}" || die
 
local archive shasum pkg
for archive in ${A}; do
case "${archive}" in
*.crate)
ebegin "Loading ${archive} into Cargo registry"
tar -xf "${DISTDIR}"/${archive} -C 
"${ECARGO_VENDOR}/" || die
# generate sha256sum of the crate itself as 
cargo needs this
shasum=$(sha256sum "${DISTDIR}"/${archive} | 
cut -d ' ' -f 1)
pkg=$(basename ${archive} .crate)
cat <<- EOF > 
${ECARGO_VENDOR}/${pkg}/.cargo-checksum.json
{
"package": "${shasum}",
"files": {}
}
EOF
# if this is our target package we need it in 
${WORKDIR} too
# to make ${S} (and handle any revisions too)
if [[ ${P} == ${pkg}* ]]; then
tar -xf "${DISTDIR}"/${archive} -C 
"${WORKDIR}" || die
fi
eend $?
;;
cargo-snapshot*)
ebegin "Unpacking ${archive}"
mkdir -p "${S}"/target/snapshot
tar -xzf "${DISTDIR}"/${archive} -C 
"${S}"/target/snapshot --strip-components 2 || die
# cargo's makefile needs this otherwise it will 
try to
# download it
touch "${S}"/target/snapshot/bin/cargo || die
eend $?
;;
*)
unpack ${archive}
;;
esac
done
 
cargo_gen_config
 }
 
 # @FUNCTION: cargo_gen_config
 # @DESCRIPTION:
 # Generate the $CARGO_HOME/config necessary to use our local registry
 cargo_gen_config() {
debug-print-function ${FUNCNAME} "$@"
 
cat <<- EOF > "${ECARGO_HOME}/config"
[source.gentoo]
directory = "${ECARGO_VENDOR}"
 
[source.crates-io]
replace-with = "gentoo"
local-registry = "/nonexistant"
EOF
 }
 
 # @FUNCTION: cargo_src_compile
 # @DESCRIPTION:
 # Build the package using cargo build
 cargo_src_compile() {
debug-print-function ${FUNCNAME} "$@"
 
export CARGO_HOME="${ECARGO_HOME}"
 
-   cargo build -j $(makeopts_jobs) $(usex debug "" --release) \
+   c

[gentoo-dev] Automated Package Removal and Addition Tracker, for the week ending 2019-01-06 23:59 UTC

2019-01-06 Thread Robin H. Johnson
The attached list notes all of the packages that were added or removed
from the tree, for the week ending 2019-01-06 23:59 UTC.

Removals:
kde-apps/syndication  20181231-21:03 asturm   79aa1bb932e
lxqt-base/lxqt-common 20181231-21:04 asturm   eee81925e7e

Additions:
app-admin/terraform   20190104-16:42 gyakovlev78b3d9a3093
app-crypt/nitrocli20190102-20:47 gyakovlevc1f7eca883e
app-crypt/tpm2-abrmd  20181231-22:02 alonbl   7a8bbaf6fbc
app-office/calligraplan   20190101-16:17 asturm   8637d093d5b
app-office/moneyguru  20190102-21:21 vdupras  0f10a1e24dc
dev-libs/stb  20181208-22:09 amynka   d1d9eec5390
dev-perl/B-Debug  20190104-01:25 kentnl   28a92fd152e
dev-perl/B-Flags  20190104-01:02 kentnl   395b0e55a50
dev-util/bingrep  20190106-09:37 gyakovlevc8deb35e7d0
dev-util/packer   20190105-12:01 gyakovlev70311e8fba3
media-libs/libldac20190104-12:14 zx2c4830bdae60e3
media-sound/pulseaudio-modules-bt 20190104-13:01 zx2c4b25bccc8453
sys-apps/bat  20190106-09:02 gyakovlev7881c6e3155
sys-apps/lsd  20190106-08:36 gyakovlev88c437e7f5a
x11-misc/unclutter-xfixes 20190106-08:06 radhermit82513359c2a
x11-themes/icewm-extra-themes 20190102-11:55 polynomial-c 9108947054d

--
Robin Hugh Johnson
Gentoo Linux Developer
E-Mail : robb...@gentoo.org
GnuPG FP   : 11AC BA4F 4778 E3F6 E4ED  F38E B27B 944E 3488 4E85
Removed Packages:
lxqt-base/lxqt-common,removed,asturm,20181231-21:04,eee81925e7e
kde-apps/syndication,removed,asturm,20181231-21:03,79aa1bb932e
Added Packages:
dev-util/packer,added,gyakovlev,20190105-12:01,70311e8fba3
dev-util/bingrep,added,gyakovlev,20190106-09:37,c8deb35e7d0
sys-apps/bat,added,gyakovlev,20190106-09:02,7881c6e3155
sys-apps/lsd,added,gyakovlev,20190106-08:36,88c437e7f5a
x11-misc/unclutter-xfixes,added,radhermit,20190106-08:06,82513359c2a
app-admin/terraform,added,gyakovlev,20190104-16:42,78b3d9a3093
media-sound/pulseaudio-modules-bt,added,zx2c4,20190104-13:01,b25bccc8453
media-libs/libldac,added,zx2c4,20190104-12:14,830bdae60e3
dev-perl/B-Debug,added,kentnl,20190104-01:25,28a92fd152e
dev-perl/B-Flags,added,kentnl,20190104-01:02,395b0e55a50
app-crypt/nitrocli,added,gyakovlev,20190102-20:47,c1f7eca883e
dev-libs/stb,added,amynka,20181208-22:09,d1d9eec5390
app-office/moneyguru,added,vdupras,20190102-21:21,0f10a1e24dc
x11-themes/icewm-extra-themes,added,polynomial-c,20190102-11:55,9108947054d
app-office/calligraplan,added,asturm,20190101-16:17,8637d093d5b
app-crypt/tpm2-abrmd,added,alonbl,20181231-22:02,7a8bbaf6fbc

Done.

Re: [gentoo-dev] [PATCH 02/12] python-utils-r1.eclass: New python_fix_shebang approach

2019-01-06 Thread James Le Cuirot
On Fri, 04 Jan 2019 07:02:40 +0100
Michał Górny  wrote:

> On Thu, 2019-01-03 at 21:39 +, James Le Cuirot wrote:
> > The previous approach would erroneously match foopython. The new
> > approach requires the match to start the string or be preceeded by a
> > slash, the only two cases we actually want. It does this with slightly
> > less code and allows the replacement of whole path strings that would
> > be problematic when passed to sed. This will be needed when
> > cross-compiling is addressed.
> > 
> > Signed-off-by: James Le Cuirot 
> > ---
> >  eclass/python-utils-r1.eclass | 78 ++-
> >  1 file changed, 31 insertions(+), 47 deletions(-)
> > 
> > diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
> > index da76a755fb34..1eca0764a202 100644
> > --- a/eclass/python-utils-r1.eclass
> > +++ b/eclass/python-utils-r1.eclass
> > @@ -1165,8 +1165,7 @@ python_fix_shebang() {
> > [[ -d ${path} ]] && is_recursive=1
> >  
> > while IFS= read -r -d '' f; do
> > -   local shebang i
> > -   local error= from=
> > +   local shebang i= error= fix=
> >  
> > # note: we can't ||die here since read will fail if file
> > # has no newline characters
> > @@ -1175,65 +1174,56 @@ python_fix_shebang() {
> > # First, check if it's shebang at all...
> > if [[ ${shebang} == '#!'* ]]; then
> > local split_shebang=()
> > -   read -r -a split_shebang <<<${shebang} || die
> > +   read -r -a split_shebang <<<${shebang#\#\!} || 
> > die  
> 
> Does '!' really need to be escaped?

Seemingly only in an interactive shell.

> >  
> > # Match left-to-right in a loop, to avoid 
> > matching random
> > # repetitions like 'python2.7 python2'.
> > -   for i in "${split_shebang[@]}"; do
> > -   case "${i}" in
> > -   *"${EPYTHON}")
> > +   for i in $(seq 0 $((${#split_shebang[@]} - 
> > 1))); do  
> 
> for i in "${!split_shebang[@]}"; do

Interesting, didn't know about that.

> > +   case "/${split_shebang[${i}]}" in  
> 
> case "/${split_shebang[i]}" in

...or that.

> Also below.
> 
> > +   */${EPYTHON})
> > debug-print 
> > "${FUNCNAME}: in file ${f#${D%/}}"
> > debug-print 
> > "${FUNCNAME}: shebang matches EPYTHON: ${shebang}"
> >  
> > # Nothing to do, move 
> > along.
> > any_correct=1
> > -   from=${EPYTHON}
> > +   continue 2
> > +   ;;
> > +   */python)
> > +   fix=1
> > break
> > ;;
> > -   *python|*python[23])
> > -   debug-print 
> > "${FUNCNAME}: in file ${f#${D%/}}"
> > -   debug-print 
> > "${FUNCNAME}: rewriting shebang: ${shebang}"
> > -
> > -   if [[ ${i} == *python2 
> > ]]; then
> > -   from=python2
> > -   if [[ ! 
> > ${force} ]]; then
> > -   
> > python_is_python3 "${EPYTHON}" && error=1
> > -   fi
> > -   elif [[ ${i} == 
> > *python3 ]]; then
> > -   from=python3
> > -   if [[ ! 
> > ${force} ]]; then
> > -   
> > python_is_python3 "${EPYTHON}" || error=1
> > -   fi
> > -   else
> > -   from=python
> > +   */python2)
> > +   if [[ ! ${force} ]]; 
> > then
> > +   
> > python_is_python3 "${EPYTHON}" && error=1
> >   

Re: [gentoo-dev] [PATCH 06/12] python-utils-r1.eclass: Don't die in python_fix_shebang if all fixed

2019-01-06 Thread James Le Cuirot
On Sat, 05 Jan 2019 22:42:27 +0100
Michał Górny  wrote:

> On Sat, 2019-01-05 at 21:38 +, James Le Cuirot wrote:
> > On Fri, 04 Jan 2019 19:26:34 +0100
> > Michał Górny  wrote:
> >   
> > > On Fri, 2019-01-04 at 13:10 -0500, Mike Gilbert wrote:  
> > > > On Fri, Jan 4, 2019 at 10:55 AM Michał Górny  wrote: 
> > > >
> > > > > 
> > > > > On Thu, 2019-01-03 at 21:39 +, James Le Cuirot wrote:
> > > > > > Shebangs may need fixing on prefix systems or when cross-building 
> > > > > > but
> > > > > > not at other times.
> > > > > > 
> > > > > > Signed-off-by: James Le Cuirot 
> > > > > > ---
> > > > > >  eclass/python-utils-r1.eclass | 8 ++--
> > > > > >  1 file changed, 2 insertions(+), 6 deletions(-)
> > > > > > 
> > > > > > diff --git a/eclass/python-utils-r1.eclass 
> > > > > > b/eclass/python-utils-r1.eclass
> > > > > > index 19cfaf2798ab..91e457f3cf14 100644
> > > > > > --- a/eclass/python-utils-r1.eclass
> > > > > > +++ b/eclass/python-utils-r1.eclass
> > > > > > @@ -1328,16 +1328,12 @@ python_fix_shebang() {
> > > > > >   fi
> > > > > >   done < <(find -H "${path}" -type f -print0 || die)
> > > > > > 
> > > > > > - if [[ ! ${any_fixed} ]]; then
> > > > > > + if [[ ! ${any_fixed} && ! ${any_correct} ]]; then
> > > > > >   local cmd=eerror
> > > > > >   [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn
> > > > > > 
> > > > > >   "${cmd}" "QA warning: ${FUNCNAME}, 
> > > > > > ${path#${D%/}} did not match any fixable files."
> > > > > > - if [[ ${any_correct} ]]; then
> > > > > > - "${cmd}" "All files have ${EPYTHON} 
> > > > > > shebang already."
> > > > > > - else
> > > > > > - "${cmd}" "There are no Python files 
> > > > > > in specified directory."
> > > > > > - fi
> > > > > > + "${cmd}" "There are no Python files in 
> > > > > > specified directory."
> > > > > > 
> > > > > >   [[ ${cmd} == eerror ]] && die "${FUNCNAME} 
> > > > > > did not match any fixable files (QA warning fatal in EAPI ${EAPI})"
> > > > > >   fi
> > > > > 
> > > > > Sounds like you're introducing breakage, then abusing a function to 
> > > > > fix
> > > > > your breakage, then killing a useful diagnostic because you've just
> > > > > broken it.
> > > > 
> > > > I'm unable to make sense of what you are trying to say here. Is there
> > > > something wrong with this patch, or are you making a general comment
> > > > on the patch series?
> > > > 
> > > 
> > > Original usage: rewrite 'python' to 'pythonX.Y', etc. on static files. 
> > > Throws an error if you try to use for files that have correct shebang
> > > already.
> > > 
> > > Now:
> > > 
> > > 1. Due to PYTHON override, generated files frequently have wrong
> > > shebangs.
> > > 
> > > 2. python_fix_shebang is modified to fix this -- orthogonal
> > > behavior is introduced.
> > > 
> > > 3. Now diagnostic on files with correct shebang is gone because it
> > > conflicts with the orthogonal behavior added here.  
> > 
> > The diagnostic is a problem even without my changes.
> > 
> > It's quite likely upstream could hardcode a shebang like
> > #!/usr/bin/python2.7, which does not need to be modified on normal
> > systems but does on prefixed systems.   
> 
> Fixing prefix was never the goal.

And fixing prefix is a bad thing? The prefix team does seem interested
in this work. There is a good deal of overlap here and in making sure I
wasn't making prefix worse, I had to stop and consider how this would
help them too.

> > What about hardcoding #!/usr/bin/python3.6? This would need correcting
> > against 3.7 but would fall foul of the diagnostic when using 3.6.  
> 
> No, it would fail as mismatched shebang.  By design.

Okay, I only thought of this case while writing the mail, having
forgotten the precise logic since working on it. It doesn't take
anything away from the point above though.

> python_fix_shebang is meant to fix common cases of generic shebangs
> in a safe way, not serve as a generic shebang replacement tool.

Allow me to suggest some options for a compromise. We can't just make
the diagnostic conditional on cross/prefix cases as it is the other
cases where it would blow up. This leaves us with:

(a) In cross/prefix cases only, call python_fix_shebang on all files
that look like they have a Python-like shebang in pkg_postinst.
Unfortunately the Python eclasses don't currently export a pkg_postinst
phase function so existing ebuilds using other eclasses may need
fixing. These files could be efficiently found with help from awk using
something along the lines of this:

find "${D}" -type f -exec awk '/^#!.*python/ {print FILENAME} {nextfile}' {} +

(b) Same as (a) but I'll invoke this from cross-boss using bashrc
instead of relying on the eclasses. Prefix would need to d