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

workdir-cd: script to cd to build dir of ebuild #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Schievel1
Copy link

@Schievel1 Schievel1 commented Sep 4, 2023

I was wondering if we can make a similar script to repo-cd, but instead of changing into the ebuilds directory in the repo, we change into to current workdir in /var/tmp/portage or whatever is set as PORTAGE_TMPDIR

We use a similar thing in emacs ebuild-mode, getting the directory from the name of the currently open ebuild:
https://gitweb.gentoo.org/proj/ebuild-mode.git/tree/ebuild-mode.el#n552

This has tons of features that probably no one uses, because it is mostly copied from repo-cd.
I was wondering if we should just leave them in or better remove them.

@Schievel1 Schievel1 marked this pull request as draft September 4, 2023 10:53
@Schievel1
Copy link
Author

To my own suprise this is working quite well already, just by changing the $REPOPATH

found_default="true"
break
fi
done < /etc/portage/make.conf || die "failed to read make.conf"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PORTAGE_TMPDIR is one of the bigger annoyance. Trying to read make.conf is more of a hack, and:

  1. make.conf can be a directory, and have other rules like "source another.conf"
  2. package.env may override PORTAGE_TMPDIR per package and then we just don't know

For 1. could use portageq to get the value, but portageq has meh startup time which is not great for cd
For 2, don't think there's much that can reasonably be done (automatically anyway)

An option could be to just use /var/tmp/portage by default and let the search paths be configurable (users could add extra paths for everything they use).

This aside, not sure if we really need an over-engineered tool (aka things in this project) to cd to workdir, ultimately just cd'ing to the latest timestamp directory in the tmpdir is about all that sounds useful.

Copy link
Author

@Schievel1 Schievel1 Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your fast reply on this.

  1. Yes I was thinking about using portageq instead, but refrained from it because of the startup time.
    If PORTAGE_TMPDIR isn't to be found in make.conf, we could just assume it's /var/tmp/portage. Users can set --path to something different in this case or put it in the config (once that's ready)
  2. If that's the case users can still provide --path. Another option would be to fiddle with the output of emerge --info or something, but that is too slow again. I want this to be snappy and frictionless.

Idk if people really need this. The question if we have something like this came up in the German gentoo Linux meetup. When fiddling with ebuilds (e.g. writing patches) I use to cd into WORKDIR all the time.
I would love to integrate the thing you said, so when you run workdir-cd without a package argument it just goes to the latest work directory in the tmpdir. This would allow for even faster operation.

So if you don't want to have it I'm gonna shamelessly steal your script as a skeleton. I was hoping to get some input from this PR though, because my bash-fu isn't at good as yours

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested performance of portageq and its actually not that bad. So let's use that

@Schievel1 Schievel1 force-pushed the feature-workdir-cd branch 4 times, most recently from 8fe36bb to ae154bf Compare September 7, 2023 08:15
@Schievel1 Schievel1 marked this pull request as ready for review September 7, 2023 08:55
@Schievel1 Schievel1 requested a review from ionenwks September 7, 2023 08:55
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