Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't hardcode /usr/local/plan9 in C source code #532

Merged
merged 4 commits into from
Jul 27, 2022

Conversation

nmeum
Copy link
Contributor

@nmeum nmeum commented Oct 31, 2021

I maintain a plan9port package for Alpine Linux. For this package, plan9port is installed to /usr/lib/plan9 not /usr/local/plan9 in order to comply with our packaging policy. Doing so is supported by plan9port via the PLAN9_TARGET environment variable and the ./INSTALL -r flag. The installation script replaces hardcoded references to /usr/local/plan9 with PLAN9_TARGET in various files via the ./lib/moveplan9.sh script.

A few days ago I was made aware that moveplan9.sh does not replace hardcoded references to /usr/local/plan9 in C source code files since it is invoked after the code has been compiled. The following files have been identified to contain such hardcoded paths:

  1. src/lib9/get9root.c
  2. src/cmd/sam/sam.c
  3. src/cmd/upas/nfs/imap.c

As such, the affected code in these files does not work correctly if plan9port is installed to /usr/lib/plan9. For example, get9root does not work if $PLAN9 is not set (e.g. in a rc(1) login shell). This pull request fixes get9root by falling back to the configured PLAN9_TARGET via a CPP define instead of hardcoding /usr/local/plan9 in get9root.c. The remaining two files have been fixed by either using get9root (sam.c) or using the PLAN9_TARGET CPP define as well (imap.c).

Would be nice to get this merged in order to ease packaging plan9port for Linux distributions.

That is, not only when -r was given. This allows using this veriable in
mkfiles across the code base.
Allows this function to always return the proper path in situations
where the $PLAN9 environment variable is not set, i.e. a rc login shell.
@nmeum nmeum force-pushed the hardcoded-target-path branch 2 times, most recently from 84aaf91 to 8ae7fa2 Compare October 31, 2021 10:45
algitbot pushed a commit to alpinelinux/aports that referenced this pull request Oct 31, 2021
Replace occurrence automatically with find(1), grep(1), and sed(1) in
order to ensure that we don't need to check for new hardcoded paths in
modified files on upgrade. This is also what other Linux distributions
(e.g. Gentoo and Arch Linux) do.

See 9fans/plan9port#532

Fixes #26969
@dancrossnyc dancrossnyc merged commit 45124b2 into 9fans:master Jul 27, 2022
algitbot pushed a commit to alpinelinux/aports that referenced this pull request Jul 28, 2022
9fans/plan9port#532 has been merged upstream
and, as such, it should no longer be necessary to manually fix hardcoded
paths in the C source code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants