Skip to content

Source tree symlink for cowthink.1 man page#27

Closed
ndim wants to merge 3 commits intocowsay-org:mainfrom
ndim:source-tree-symlink-for-cowthink.1-man-page
Closed

Source tree symlink for cowthink.1 man page#27
ndim wants to merge 3 commits intocowsay-org:mainfrom
ndim:source-tree-symlink-for-cowthink.1-man-page

Conversation

@ndim
Copy link
Copy Markdown
Contributor

@ndim ndim commented Sep 11, 2022

This makes the source tree cowthink.1 a symlink to the cowsay.1 file just like cowthink already is a symlink to the cowsay script file.

This avoids the need to revert the cowthink.1 file to not have the man1/ part in the reference to cowsay.1, which you need to do every time a2x has re-built the man page from cowsay.1.adoc.

This consists of two commits which cannot be squashed. Update: This appears to be untrue after all. Some research needed.

This builds on PR 26, so for reviewing this, you only need to consider the last two commits in the series of commits.

  • Remove regular file cowthink.1 (preparing for symlink)

    It appears git cannot change a source tree file from regular file to symlink within a single commit, so this is the first part which removes the regular file. Update: Is this just limitation of git gui and git can actually handle this?

    Adding the symlink will be in the next commit.

  • Make source tree cowthink.1 a symlink to cowsay.1

    As the source tree is already using symlinks for the cowthink script, we can assume working symlinks and therefore can use them for the cowthink.1 man page as well.

    This has the advantage that when the man page is updated, no special treatment is required for the man1/cowthink.1 reference inside the cowthink.1 file produced by a2x.

    Note that due to an apparent limitation of the git tool, an earlier commit must remove the regular file cowthink.1 before this commit can add a symlink called cowthink.1.

@ndim ndim force-pushed the source-tree-symlink-for-cowthink.1-man-page branch 2 times, most recently from ccc4db2 to aecc8c0 Compare September 11, 2022 12:44
Copy link
Copy Markdown
Collaborator

@apjanke apjanke left a comment

Choose a reason for hiding this comment

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

This sounds smart. Let's do it.

Maybe a MKDIR_P Makefile variable?

I'm delaying merging this until #26 is merged, because this PR is "stacked" on top of its commits.

Comment thread Makefile Outdated
$(A2X) --format manpage ./cowsay.1.adoc
set -ex; \
mantmpdir="mantmp-$$$$"; \
mkdir -p "$$mantmpdir"; \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we do a MKDIR_P Makefile variable like GNU seems to do? Here's what GNU coreutils 9.1 does, at least after I run ./configure on my macOS 10.14 box:

MKDIR_P = /opt/local/bin/gmkdir -p
[...]
  $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \

I figure a regular mkdir -p would be a good enough default, instead of detecting a GNU-specific mkdir.

The GNU Makefile Conventions say "don't use mkdir -p, because it's not supported everywhere", but I think we can disregard that since we're not trying to be super-portable to old or exotic systems.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can we do a MKDIR_P Makefile variable like GNU seems to do?

Good idea. Sorry for missing that.

I figure a regular mkdir -p would be a good enough default, instead of detecting a GNU-specific mkdir.

The GNU Makefile Conventions say "don't use mkdir -p, because it's not supported everywhere", but I think we can disregard that since we're not trying to be super-portable to old or exotic systems.

And for those old and/or exotic systems, the user overridable MKDIR_P will rise and shine.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

And for those old and/or exotic systems, the user overridable MKDIR_P will rise and shine.

Bingo, I guess that's what it's there for. :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unless... we just run mkdir "$$mantmpdir" without the -p. That should be quite portable, should it not?

OTOH, we could switch to mktemp. :-)

@apjanke
Copy link
Copy Markdown
Collaborator

apjanke commented Sep 12, 2022

Oh, sorry if I was unclear in my PR review comment: yep, everything you said in the PR's main description makes sense, including the commit history arrangement. After #26 is merged, we'll roll this right in.

And I'll play around with the git CLI and see if I can get them into a single commit. I don't know enough about Git's internal data model to know if that should be possible or not.

@apjanke
Copy link
Copy Markdown
Collaborator

apjanke commented Sep 12, 2022

Hey check it out, I think I was able to do the regular file to symlink conversion in a single commit: https://github.com/cowsay-org/cowsay/commits/apj/WIP/ndim-cowthink-symlink-in-one-comit

Haven't figured out how to do it using regular commit actions (the git add operations seem tricky), but I copied your branch, did a git rebase -i master and made the last commit a fixup to merge it into the prior one, and that seemed to work just fine.

What do you think?

@ndim
Copy link
Copy Markdown
Contributor Author

ndim commented Sep 12, 2022

Hey check it out, I think I was able to do the regular file to symlink conversion in a single commit: https://github.com/cowsay-org/cowsay/commits/apj/WIP/ndim-cowthink-symlink-in-one-comit

I managed to do that as well, but...

Haven't figured out how to do it using regular commit actions (the git add operations seem tricky), but I copied your branch, did a git rebase -i master and made the last commit a fixup to merge it into the prior one, and that seemed to work just fine.

What do you think?

As the git user interface is that weird around this (and I have found reports on gitlab bugs around the similar thing of the web UI did not show properly when a symlink was replaced by a regular file), I would err on the side of caution and compatibility by keeping this PR as two separate commits, possibly held together by one --no-ff merge commit.

@apjanke
Copy link
Copy Markdown
Collaborator

apjanke commented Sep 12, 2022

I would err on the side of caution and compatibility by keeping this PR as two separate commits

Works for me; there's no real impact to that.

@ndim ndim force-pushed the source-tree-symlink-for-cowthink.1-man-page branch 2 times, most recently from b521fd5 to 4a72180 Compare September 14, 2022 22:20
This makes the Makefile a bit more conforming to the GNU Makefile
conventions, more robust and more flexible.

  * Fix: "make uninstall" removes the cows/ dir from its actual location
  * Fix: Allow repeated "make install" runs to succeed instead of
    failing to create a symlink which already exists.
  * Add a standard "all" target
  * "make uninstall" remove only the cow files we "make install", i.e.
    stop removing files we did not install
  * "make uninstall" removes all cowsay specific directories (if empty)
  * Define and use make variables for definitions used more than
    once like e.g. $(cowsdir) $(sitecowsdir)
  * Use make variables for tools like e.g. $(LN_S) $(A2X) $(INSTALL_DIRS)
  * Only install cow files called *.cow. Prevents e.g. editor backup
    files like *.cow~ or unsupported (as of yet) *.pm format cow files
    from being installed.
  * Install empty %{sysconfdir}/cowsay/cowpath.d directory
  * Use "install -c" for backwards compatibility with ancient "install"
It appears git cannot change a source tree file from regular file to
symlink within a single commit, so this is the first part which
removes the regular file.

Adding the symlink will be in the next commit.
As the source tree is already using symlinks for the cowthink script,
we can assume working symlinks and therefore can use them for the
cowthink.1 man page as well.

This has the advantage that when the man page is updated, no special
treatment is required for the "man1/cowthink.1" reference inside
the cowthink.1 file produced by a2x.

Note that due to an apparent limitation of the git tool, an earlier
commit must remove the regular file "cowthink.1" before this commit
can add a symlink called "cowthink.1".
@ndim ndim force-pushed the source-tree-symlink-for-cowthink.1-man-page branch from 4a72180 to 3dcfce5 Compare September 14, 2022 22:40
@ndim
Copy link
Copy Markdown
Contributor Author

ndim commented Aug 8, 2024

This PR appears to have been made obsolete by the switch from a2x to asciidoctor: asciidoctor generates the cowthink.1 file without the man1/ prefix, so the original problem does not present itself any more.

@ndim ndim closed this Aug 8, 2024
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