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

mock shell should change directory to %{_builddir} #693

Open
voxik opened this issue Jan 29, 2021 · 6 comments
Open

mock shell should change directory to %{_builddir} #693

voxik opened this issue Jan 29, 2021 · 6 comments
Labels
enhancement feature request, rfe

Comments

@voxik
Copy link
Contributor

voxik commented Jan 29, 2021

Currently, whenever I do mock shell --unpriv, I endup in root directory and this is typically followed byt cd /builddir/build/BUILD/builddir_of_the_package. Would you consider to do this step automatically? I don't think that being in the root directory is good default.

@praiskup
Copy link
Member

I'm not sure why login shell isn't used, I have to check later. IMO we should switch to $HOME automatically, but this doesn't happen.

I don't think it is wise to go anywhere else than /builddir by default (non-standard behavior, something contrary to what I personally expect - so that would be about preferences). The builddir_of_the_package is variable, hard to guess correctly ... I'd say using shell completion could be enough? Perhaps we could have some option for initial cd path command? I don't think it is worth it...?

@hroncok
Copy link
Contributor

hroncok commented Jan 29, 2021

Maybe have a different shell command or option(s) to do this:

  • su mockbuild
  • cd $HOME
$ mock -r fedora-rawhide-x86_64 --shell --user

Or

$ mock -r fedora-rawhide-x86_64 --usershell

@voxik
Copy link
Contributor Author

voxik commented Jan 29, 2021

IMO we should switch to $HOME automatically

Sorry for confusion, this actually happens. But that is not useful either.

I don't think it is wise to go anywhere else than /builddir by default (non-standard behavior, something contrary to what I personally expect - so that would be about preferences).

You are right, that it would be non-standard, but probably more convenient. There is basically nothing useful what can one do in $HOME in mock.

The builddir_of_the_package is variable, hard to guess correctly

The %{_builddir} is $HOME/rpmbuild/BUILD by default, but if there was chance to even step into the expanded sources directory, that could be nice as well.

Perhaps we could have some option for initial cd path command?

That starts to be more complicated then the explicit cd. But if the default behavior could be configured, that could be helpful.

@jwakely
Copy link
Contributor

jwakely commented Jan 29, 2021

What would be useful is if mock --rebuild (and fedpkg mockbuild) printed a message when they fail, telling you the directory to change to.

Build failed, see /build/rpmbuild/BUILD/foo-1.2.3 in the chroot filesystem.
Alternatively, /var/lib/mock/fedora-rawhide-x86_64/build/rpmbuild/BUILD/foo-1.2.3 in the local filesystem.

Then at least you can just select that with the mouse and paste it into the shell (either mock shell or the host shell). That would be easier than remembering/rediscovering the right paths each time.

A new mock command like --usershell or --user --shell might be useful, but it's one more extra command to remember. I don't mind being root and I don't mind having to cd to the build dir, the only difficulty is knowing the path of that build dir.

@praiskup praiskup added the enhancement feature request, rfe label Apr 26, 2021
@praiskup praiskup changed the title [RFE] mock shell should change directory to %{_builddir} mock shell should change directory to %{_builddir} Apr 26, 2021
xsuchy added a commit to xsuchy/mock that referenced this issue May 20, 2021
Additionally change to `chroothome` when --shell.

Relates: rpm-software-management#693
@xsuchy
Copy link
Member

xsuchy commented May 20, 2021

I created #732 which allows you to use --cwd together with --shell. And which chdir to /builddir if nothing is explicitly specified.

I am not sure about that %{_builddir} because that would be hard to implement (evaluating that in bootstrap?) and hardcoding /build/rpmbuild/BUILD/ will be fragile. Or not?

The other option is to define (yet) another config option, which will allow customization. Comments?

@voxik
Copy link
Contributor Author

voxik commented May 20, 2021

While --cwd might have some utility, I don't think is convenient for my use case. Once in mock shell, I can use at least bash completion to help me writ the path, while it won't work outside of mock. Also cd /some/path is shorter the --cwd /some/path.

praiskup pushed a commit that referenced this issue May 21, 2021
Additionally change to `chroothome` when --shell.

Relates: #693
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request, rfe
Projects
None yet
Development

No branches or pull requests

5 participants