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

Unit files: Use actual installed path for podman #11886

Merged
merged 1 commit into from
Oct 12, 2021

Conversation

edsantiago
Copy link
Member

@edsantiago edsantiago commented Oct 7, 2021

Don't hardcode /usr/bin/podman in unit files: instead, use
template files with a path replaced at install time.

Because 'make' can be invoked repeatedly, with different
PREFIX, do not leave the generated files behind in our
work directory: wipe them immediately after install.

Side note: #7023 made contrib/systemd/user a symlink
to .../system but did not update paths in Makefile.
The unrelated-looking path change you see here is
a belated correction for that.

Fixes: #10787

Signed-off-by: Ed Santiago [email protected]

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 7, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: edsantiago

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 7, 2021
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@mheon
Copy link
Member

mheon commented Oct 7, 2021

Are we going to need to do any packaging work to get this to work? @lsm5

@mheon
Copy link
Member

mheon commented Oct 7, 2021

The RPM task is blowing up, suggesting that we will

@edsantiago
Copy link
Member Author

Sigh. This is the rathole I was trying to avoid.

sed -e "s;@@PODMAN@@;/root/rpmbuild/BUILDROOT/podman-3.3.0-1633619291.gitfe8cc213.fc34.x86_64/usr/bin/podman;g" ...

This means that BINDIR = /root/rpmbuild/.... I was expecting BINDIR = /usr/bin. @lsm5 @cevich do you have any idea what's going on here?

@edsantiago
Copy link
Member Author

I wonder if PREFIX here should be DESTDIR instead?

PODMAN_VERSION=%{version} %{__make} PREFIX=%{buildroot}%{_prefix} ETCDIR=%{buildroot}%{_sysconfdir} \

@cevich
Copy link
Member

cevich commented Oct 7, 2021

Probably better check the podman-release-amd64.tar.gz file, the target for that also depends on install.systemd with a modified DESTDIR and PREFIX.

Clarification: This tarball is produced for each of the 'Build for *' tasks (Fedora and Ubuntu). You'll find the tarball in the Cirrus WebUI under the gosrc artifacts.

@cevich
Copy link
Member

cevich commented Oct 7, 2021

Update: I examined the F34 tarball (in this PR) and surprisingly, the paths look correct (i.e. they don't reference the temp. dir).

Makefile Show resolved Hide resolved
@edsantiago
Copy link
Member Author

I give up. If someone more rpm-savvy wants to take this over, please feel free.

@edsantiago edsantiago closed this Oct 7, 2021
@cevich
Copy link
Member

cevich commented Oct 7, 2021

I give up. If someone more rpm-savvy wants to take this over, please feel free.

In case it helps at all, the podman-release target (I checked tarball earlier) is doing the right thing with it's tempdir (in this PR). The key seems to be running make ... DESTDIR=$(TMPDIR)" "PREFIX=/usr". Did it not work to pass in the rpmbuild root in as DESTDIR?

I should think if it's possible with a simple tarball...surely rpmbuild can be made to do the right thing. Though I too am very much not an expert nor savvy.

@edsantiago
Copy link
Member Author

I've just spent way more hours than I should've trying to debug this. Conclusion: our Makefile is very badly broken. It is doing nasty things with $(PREFIX) that it shouldn't be. Fixing that is way beyond the scope of what I'm able to do.

@cevich
Copy link
Member

cevich commented Oct 8, 2021

Looks like you got it!

@@ -435,7 +435,7 @@ BUILDTAGS=$BUILDTAGS make binaries
%install
install -dp %{buildroot}%{_unitdir}
install -dp %{buildroot}%{_usr}/lib/systemd/user
PODMAN_VERSION=%{version} %{__make} PREFIX=%{buildroot}%{_prefix} ETCDIR=%{buildroot}%{_sysconfdir} \
PODMAN_VERSION=%{version} %{__make} DESTDIR=%{buildroot} PREFIX=/usr ETCDIR=%{_sysconfdir} \
Copy link
Member Author

Choose a reason for hiding this comment

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

@lsm5 PTAVCL (Very Close Look) at this change. I'm highly confident that it is the right thing to do, and that this fixes something that has been broken from Day One... but when I get "confident" is exactly when I need to ask for extra sets of eyes. I don't know who/what else uses this specfile, or what cascading effects this might have.TIA.

Copy link
Member

Choose a reason for hiding this comment

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

@edsantiago can you remind me what exactly was/in broken?

Copy link
Member

Choose a reason for hiding this comment

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

mostly LGTM on this change, that's how it should be. I guess last time we didn't have a DESTDIR variable in makefile or something, is that correct?

If you could change to DESTDIR=%{buildroot} PREFIX=%{_prefix}, even better. %{_prefix} by default evaluates to /usr

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is PREFIX=/usr ? Currently make install installs in /usr/local. The exact problem is, that make install installs in /usr/local/bin/podman, but the service files looked at /usr/bin/podman wihtout /local.

Copy link
Member Author

Choose a reason for hiding this comment

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

can you remind me what exactly was/in broken?

If a user installs into /usr/local for some reason, the systemd unit files will still refer to /usr/bin/podman. See #10787.

last time we didn't have a DESTDIR variable in makefile or something, is that correct?

I doubt it; I think DESTDIR dates back pretty far. I don't know why this was the way it was. It was broken from the beginning, I suspect it was copied from something else.

If you could change to DESTDIR=%{buildroot} PREFIX=%{_prefix}, even better

Done. Thanks for the hint.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why is PREFIX=/usr ?

Because this is a specfile. Specfiles are for installing in a distribution. Distributions install into /usr, never ever ever into /usr/local.

@edsantiago
Copy link
Member Author

@tobwen @dilyanpalauzov PTAL

@dilyanpalauzov
Copy link
Contributor

Because 'make' can be invoked repeatedly, with different DESTDIR, do not leave the generated files behind in our work directory: wipe them immediately after install.

This makes no sense. DESTDIR shall not influence the content of the .service files.

@dilyanpalauzov
Copy link
Contributor

@edsantiago
Copy link
Member Author

You're right, I meant PREFIX (which in turn affects BINDIR). I've updated the commit message, rebased, and pushed. Thank you

Don't hardcode /usr/bin/podman in unit files: instead, use
template files with a path replaced at install time.

Because 'make' can be invoked repeatedly, with different
PREFIX, do not leave the generated files behind in our
work directory: wipe them immediately after install.

To get this to work, fix a longstanding bug in podman.spec.in,
a PREFIX that should've been DESTDIR.

Side note: containers#7023 made contrib/systemd/user a symlink
to .../system but did not update paths in Makefile.
The unrelated-looking path change you see here is
a belated correction for that.

Fixes: containers#10787

Signed-off-by: Ed Santiago <[email protected]>
@edsantiago
Copy link
Member Author

@containers/podman-maintainers I'm calling this ready to merge

@mheon
Copy link
Member

mheon commented Oct 12, 2021

I am not really particularly qualified to review makefile changes, but from my limited knowledge, this LGTM

@rhatdan
Copy link
Member

rhatdan commented Oct 12, 2021

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 12, 2021
@openshift-merge-robot openshift-merge-robot merged commit 65e1564 into containers:main Oct 12, 2021
@cevich
Copy link
Member

cevich commented Oct 12, 2021

Thanks for sticking it out through merge @edsantiago If not for your work, this probably wouldn't have been fixed at all, or worse, fixed in a very bad/broken way. It takes courage to pick something so frustrating like this, back up into play and over the goal line.

@vrothberg
Copy link
Member

💯 !

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

systemd service files contain hardcoded paths
8 participants