Bug 245536 - PREFIX-safety of cargo-using ports
Summary: PREFIX-safety of cargo-using ports
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Jan Beich
URL:
Keywords: needs-patch, needs-qa
Depends on:
Blocks:
 
Reported: 2020-04-11 15:34 UTC by Mikhail Teterin
Modified: 2020-04-11 16:27 UTC (History)
1 user (show)

See Also:
jbeich: merge-quarterly+


Attachments
Append --prefix to CARGO_BUILD_ARGS, unless already set (395 bytes, patch)
2020-04-11 15:34 UTC, Mikhail Teterin
tobik: maintainer-approval-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Teterin freebsd_committer freebsd_triage 2020-04-11 15:34:41 UTC
Created attachment 213290 [details]
Append --prefix to CARGO_BUILD_ARGS, unless already set

My PREFIX is set to /opt and multimedia/librav1e failed to stage overnight:

...
===>  Staging for librav1e-0.3.1_3
===>   Generating temporary packing list
    Finished release [optimized + debuginfo] target(s) in 0.16s
    Building pkg-config file
  Installing pkg-config file
  Installing header file
  Installing static library
  Installing shared library
strip: open /spare/usr/ports/multimedia/librav1e/work/stage/opt/lib/*.so failed: No such file or directory
*** Error code 1

Indeed, instead of ${STAGEDIR}/opt, the port installed under ${STAGEDIR}/usr/local ... Maybe, some day, our wonderful automated build-tools will learn to catch these errors too.

Though adding `--prefix ${PREFIX}` to the port is easy, I think, this fix belongs to Mk/Uses/cargo.mk -- for all cargo-using ports.
Comment 1 Jan Beich freebsd_committer freebsd_triage 2020-04-11 15:54:51 UTC
Mk/Uses/cargo.mk is maintained by rust@, not portmgr@.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2020-04-11 15:57:31 UTC
Comment on attachment 213290 [details]
Append --prefix to CARGO_BUILD_ARGS, unless already set

> +.if ! ${CARGO_BUILD_ARGS:M--prefix*}
> +CARGO_BUILD_ARGS+=	--prefix ${PREFIX:Q}
> +.endif

--prefix is not supported by "cargo build" unlike "cargo cbuild". What fixed multimedia/librav1e now breaks multimedia/rav1e:

=======================<phase: build          >============================
===>  Building for rav1e-0.3.1_2
error: Found argument '--prefix' which wasn't expected, or isn't valid in this context

USAGE:
    cargo build --manifest-path <PATH> --release --verbose

For more information try --help
*** Error code 1
Comment 3 Tobias Kortkamp freebsd_committer freebsd_triage 2020-04-11 15:59:25 UTC
USES=cargo ports are already PREFIX-safe unless they are doing
something special.

Anyway `cargo build` does not take a --prefix argument (Jan has already
posted the error), so this patch is nonsense and rejected since it
would break every USES=cargo port.

librav1e is abusing CARGO_BUILD_ARGS for `cargo cinstall` and should be
fixed instead to not use CARGO_BUILD_ARGS or pass --prefix itself.
Comment 4 commit-hook freebsd_committer freebsd_triage 2020-04-11 16:18:25 UTC
A commit references this bug:

Author: jbeich
Date: Sat Apr 11 16:18:18 UTC 2020
New revision: 531433
URL: https://svnweb.freebsd.org/changeset/ports/531433

Log:
  multimedia/librav1e: unbreak PREFIX != LOCALBASE

  $ poudriere testport -Pj 113i386 multimedia/librav1e
  [...]
  strip: open /wrkdirs/usr/ports/multimedia/librav1e/work/stage/prefix/librav1e-0.3.1_3/lib/*.so failed: No such file or directory

  PR:		245536
  Reported by:	mi

Changes:
  head/multimedia/librav1e/Makefile
Comment 5 commit-hook freebsd_committer freebsd_triage 2020-04-11 16:19:26 UTC
A commit references this bug:

Author: jbeich
Date: Sat Apr 11 16:19:19 UTC 2020
New revision: 531434
URL: https://svnweb.freebsd.org/changeset/ports/531434

Log:
  MFH: r531433

  multimedia/librav1e: unbreak PREFIX != LOCALBASE

  $ poudriere testport -Pj 113i386 multimedia/librav1e
  [...]
  strip: open /wrkdirs/usr/ports/multimedia/librav1e/work/stage/prefix/librav1e-0.3.1_3/lib/*.so failed: No such file or directory

  PR:		245536
  Reported by:	mi
  Approved by:	ports-secteam blanket

Changes:
_U  branches/2020Q2/
  branches/2020Q2/multimedia/librav1e/Makefile
Comment 6 Jan Beich freebsd_committer freebsd_triage 2020-04-11 16:20:10 UTC
(In reply to Tobias Kortkamp from comment #3)
> librav1e is abusing CARGO_BUILD_ARGS for `cargo cinstall` and should be
> fixed instead to not use CARGO_BUILD_ARGS or pass --prefix itself.

This is intentional. librav1e needs USES=cargo while "cargo cbuild" shares "cargo build" flags e.g.,
- --release dependeding on WITH_DEBUG
- --features, --all-features, --no-default-features depending on CARGO_FEATURES

Discrepancy in flags is either due to bugs in cargo-c or historical raisins in cargo (e.g., --release default).
Comment 7 Mikhail Teterin freebsd_committer freebsd_triage 2020-04-11 16:27:13 UTC
(In reply to commit-hook from comment #4)
>  multimedia/librav1e: unbreak PREFIX != LOCALBASE

This is not quite accurate, for the record. LOCALBASE is also /opt on the system, where the error manifested.

Thanks for the prompt fix!