Skip to content

overlord/snapstate, wrappers: manpages!#8079

Closed
chipaca wants to merge 1 commit intocanonical:masterfrom
chipaca:manpages
Closed

overlord/snapstate, wrappers: manpages!#8079
chipaca wants to merge 1 commit intocanonical:masterfrom
chipaca:manpages

Conversation

@chipaca
Copy link
Copy Markdown
Contributor

@chipaca chipaca commented Feb 2, 2020

This is a rough draft of a first pass at manpages support.

This works by creating a man directory next to the snappy bin
directory (i.e. a /snap/man to go with /snap/bin, in Ubuntu); if
the latter is on your $PATH, then man will pick up manpages that are
in the former.

Right now it only sets things up for files that start with the snap
name. A second pass would be to add also support for aliases. Also it
only considers files, whereas often manpages will be symlinks. We
should support manpages symlinking to other things as long as they are
in the same snap, at least.


It works! But needs a few things before being production-ready:

  • more and better unit tests
  • a spread test

but I'm stopping here. Hopefully this is enough...

This is a rough draft of a first pass at manpages support.

This works by creating a `man` directory next to the snappy `bin`
directory (i.e. a `/snap/man` to go with `/snap/bin`, in Ubuntu); if
the latter is on your `$PATH`, then man will pick up manpages that are
in the former.

Right now it only sets things up for files that start with the snap
name. A second pass would be to add also support for aliases. Also it
only considers files, whereas often manpages will be symlinks. We
should support manpages symlinking to other things as long as they are
in the same snap, at least.

---

It works! But needs a few things before being production-ready:

* more and better unit tests
* a spread test

but I'm stopping here. Hopefully this is enough...
Copy link
Copy Markdown
Contributor

@zyga zyga left a comment

Choose a reason for hiding this comment

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

I have personal desire and use case for this. I'll pick it up (even if it has to be in my weekend spare time).

)

func AddSnapManpages(s *snap.Info) error {
snapManRoot := filepath.Join(s.MountDir(), "meta", "man")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will we have automation in snapcraft to popualte this? i.e. what's the plan (if any) to keep the man-pages in the snapcraft parts and this dir in sync ?

Copy link
Copy Markdown
Contributor

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

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

Some questions

@@ -218,6 +228,19 @@ apps:

info := snaptest.MockSnap(c, yaml, &snap.SideInfo{Revision: snap.R(11)})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's a snapstest.MockSnapWithFiles helper now.

SnapRollbackDir = filepath.Join(rootdir, snappyDir, "rollback")

SnapBinariesDir = filepath.Join(SnapMountDir, "bin")
SnapManpagesDir = filepath.Join(SnapMountDir, "man")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A random, thought, should we block installation of snaps named bin and man like we do for system ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CC @jdstrand for review tools. I think we should do a separate pass of checks in snapd though.

snapManRoot := filepath.Join(s.MountDir(), "meta", "man")
inSnapPrefix := s.SnapName() + "."
onDiskPrefix := s.InstanceName() + "."
return filepath.Walk(snapManRoot, func(path string, info os.FileInfo, err error) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As I understand the first if is suppose to handle the case when there's no man directory inside snap meta, but as a side effect it swallows up all errors. I think it'd be better to have:

if !osutil.DirExists(snapManRoot) {
	return nil
}
return filepath.Walk(snapManRoot, func(path string, info os.FileInfo, err error) error {
	if err != nil {
		return err
	}
	...
}

err := syscall.Unlink(path)
for err == nil {
path = filepath.Dir(path)
if path == stop {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are we sure that stop wa filepath.Clean()'ed?

@ivocavalcante
Copy link
Copy Markdown

Hi guys, passing by just to remind you this is a very welcomed feature. Could you, please, start working on it again?

@mvo5 mvo5 added the Precious but later ❤️ PRs that are precious but can't be worked on right now and should be reopened at a later point label May 20, 2022
@mvo5 mvo5 closed this May 20, 2022
@chipaca
Copy link
Copy Markdown
Contributor Author

chipaca commented May 20, 2022

:-(

@dviererbe
Copy link
Copy Markdown

Hey snapcraft people 👋🏻, because it is the time of the year where teams start planning the Roadmap for the next Cycle, I want to kindly ask: Can you add this issue to the Roadmap of the next cycle?

I totally understand that there are probably always pressing issues to fix and you are busy, but I think this is a low hanging fruit that would make snaps so much better. Having inaccessible documentation is bad UX.

To give some argumentative munition against other issues during planning discussions:

fnordahl added a commit to fnordahl/microovn that referenced this pull request Oct 5, 2023
The upstream OVS and OVN projeccts provide detailed documentation
in their manpages.  It would be a shame to deprieve the user of
this documentation.

There have been efforts to bring man page support to the snap
infrastructure [0][1], but it has unfortunately not come to
fruition.  We need to bring the required components ourself.

Example to view the OVN Architecture documentation:

    microovn.man ovn-architecture

0: https://forum.snapcraft.io/t/support-for-man-pages/2299
1: canonical/snapd#8079
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
fnordahl added a commit to fnordahl/microovn that referenced this pull request Oct 5, 2023
The upstream OVS and OVN projeccts provide detailed documentation
in their manpages.  It would be a shame to deprieve the user of
this documentation.

There have been efforts to bring man page support to the snap
infrastructure [0][1], but it has unfortunately not come to
fruition.  We need to bring the required components ourself.

Example to view the OVN Architecture documentation:

    microovn.man ovn-architecture

0: https://forum.snapcraft.io/t/support-for-man-pages/2299
1: canonical/snapd#8079
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
@yvs2014
Copy link
Copy Markdown

yvs2014 commented Oct 27, 2023

Hello,

is there any updates on this topic (man page support) in 2023 ?
Or any other way to integrate app manual pages in some common directory to add that dir to user MANPATH?

@dviererbe
Copy link
Copy Markdown

Hey snapcraft people 👋🏻, is there any updates on this issue for this cycle?

@dviererbe
Copy link
Copy Markdown

February 2025; this issue is now 5 years old 🎂

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⛔ Blocked Needs Samuele review Needs a review from Samuele before it can land Precious but later ❤️ PRs that are precious but can't be worked on right now and should be reopened at a later point

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants