Skip to content

Instantly share code, notes, and snippets.

@reishoku
Last active July 19, 2023 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reishoku/72e0fb0c7b655f476923193cdc4c7216 to your computer and use it in GitHub Desktop.
Save reishoku/72e0fb0c7b655f476923193cdc4c7216 to your computer and use it in GitHub Desktop.
linux-man-in-macOS.md

macOSでLinuxのmanを読む方法

ややうろ覚えぎみなのであまり当てにはしないでほしいけれど。

使用シェルは fish

reishoku@Jade ~> sw_vers
ProductName:  macOS
ProductVersion:  13.4.1
ProductVersionExtra: (c)
BuildVersion:  22F770820d

reishoku@Jade ~> uname -m
arm64

cd (mktemp -d)
brew install mandoc man-db gman perl make
curl -sLO "https://linuxjm.osdn.jp/man-pages-ja-20230715.tar.gz"
tar zxf man-pages-ja-20230715.tar.gz
cd man-pages-ja-20230715
# ここのあたりで変更を加える。内容は次のコードブロックにかいてあるdiffのとおり
sudo mkdir -p /opt/share/manpages-linux-ja
sudo chown -R root:wheel /opt/share/manpages-linux-ja
sudo chmod -R g+r /opt/share/manpages-linux-ja
gmake config
sudo gmake install
reishoku@Jade /t/m/o/man-pages-ja-20230715 [1]> diff -ru . ../../man-pages-ja-20230715
diff --color=auto -ru ./Makefile ../../man-pages-ja-20230715/Makefile
--- ./Makefile 2022-06-07 03:35:26
+++ ../../man-pages-ja-20230715/Makefile 2023-07-17 03:25:15
@@ -5,7 +5,7 @@
 all: config

 config: ./script/configure.perl
- perl -w $<
+ /opt/homebrew/bin/perl -w $<

 install: installman.sh
  sh $<
Only in ../../man-pages-ja-20230715: installman.sh
diff --color=auto -ru ./script/configure.perl ../../man-pages-ja-20230715/script/configure.perl
--- ./script/configure.perl 2022-06-07 03:35:26
+++ ../../man-pages-ja-20230715/script/configure.perl 2023-07-17 03:26:08
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 use Env qw (PATH LANG);
 use strict 'vars';
 use Encode qw (decode);
@@ -21,10 +21,11 @@
 print "(just Return if you accept default)\n";

 do{
-    $MANROOT = "/usr/share/man/$LANG";
+  # $LANG = "ja_JP.UTF-8";
+    $MANROOT = "/opt/share/manpages-linux-ja/man/$LANG";
     print "   Install directory   [$MANROOT] ?: ";
-    $ans = <STDIN>; chomp $ans;
-    if ($ans ne "") {$MANROOT = $ans;}
+    $ans = "y"; chomp $ans;
+    # if ($ans ne "") {$MANROOT = $ans;}

     print "   compress manual with..\n";
     for my $i (0 .. $#pack_method){
@@ -41,7 +42,7 @@
     $ans = <STDIN>; chomp $ans;
     if ($ans ne "") {$OWNER = $ans;}

-    $GROUP = "root";
+    $GROUP = "wheel";
     print "   group of page owner [$GROUP] ?: ";
     $ans = <STDIN>; chomp $ans;
     if ($ans ne "") {$GROUP = $ans;}
@@ -93,14 +94,14 @@
     for $i (0 .. $#pl){
  my $qstr = ($main::pw{$pl[$i]} > -1) ? "[Y/n]" : "[y/N]";
  printf "   [%2d/%2d] %-15s %s ?: ", $i, $#pl, $pl[$i], $qstr;
- $ans = <STDIN>; chomp $ans;
+ $ans = "y"; chomp $ans;
  if ($ans =~ /[Yy].*/) { $main::pw{$pl[$i]} = $i;}
  if ($ans =~ /[Nn].*/) { $main::pw{$pl[$i]} = -1;}
     }

     do {
  print "All OK? (Yes, [C]ontinue / No, [R]eselect) : ";
- $ans = <STDIN>; chomp $ans;
+ $ans = "y"; chomp $ans;
     } until ($ans =~ /[yYnNcCrR].*/);

 } until ($ans =~ /^[yYcC]/);
@@ -108,7 +109,7 @@
 #
 # translation_list からインストールすべきファイルを取得.
 #
-open TL, "cat `find manual/ -name translation_list -print` |";
+open TL, "/opt/homebrew/bin/gcat `/opt/homebrew/bin/gfind manual/ -name translation_list -print` |";
 while(<TL>) {
     $_ = decode('utf-8', $_);
     if (/^×/ || /^▲/ || /^△/ || /^●/ || /^※/ || /^$/) { next; }
@@ -194,11 +195,11 @@

 print ISS "#!/bin/sh\n";

-print ISS "mkdir -p $MANROOT;";
-print ISS "chown $OWNER.$GROUP $MANROOT\n";
+print ISS "gmkdir -p $MANROOT;";
+print ISS "gchown $OWNER.$GROUP $MANROOT\n";
 for $i (1..9){
-    print ISS "mkdir -p $MANROOT/man$i;";
-    print ISS "chown $OWNER.$GROUP $MANROOT/man$i\n";
+    print ISS "gmkdir -p $MANROOT/man$i;";
+    print ISS "gchown $OWNER.$GROUP $MANROOT/man$i\n";
 }
 print ISS "\n";

@@ -208,15 +209,15 @@
     my $mansrc = "manual/$pkg/man$sec/$name.$sec";
     my $mandst = "$MANROOT/man$sec";

-    print ISS "echo -n install $pkg: $name.$sec .. \n";
-    print ISS "install -o $OWNER -g $GROUP -m 644 $mansrc $mandst\n";
+    print ISS "gecho -n install $pkg: $name.$sec .. \n";
+    print ISS "ginstall -o $OWNER -g $GROUP -m 644 $mansrc $mandst\n";

     if ($PACK ne "none"){
- print ISS "echo -n $PACK .. \n";
+ print ISS "gecho -n $PACK .. \n";
  print ISS "$PACK -f $mandst/$name.$sec\n";
     }

-    print ISS "echo done.\n\n";
+    print ISS "gecho done.\n\n";
 }
 close(ISS);

diff --color=auto -ru ./script/pkgs.list ../../man-pages-ja-20230715/script/pkgs.list
--- ./script/pkgs.list 2022-11-12 12:33:09
+++ ../../man-pages-ja-20230715/script/pkgs.list 2023-07-17 03:07:16
@@ -18,7 +18,7 @@
 GNU_bison Y
 GNU_diffutils Y
 GNU_ed  Y
-GNU_fileutils N
+GNU_fileutils Y
 GNU_findutils Y
 GNU_gawk Y
 GNU_gcc  Y
@@ -41,7 +41,7 @@
 GNU_sharutils Y
 GNU_tar  Y
 GNU_texinfo Y
-GNU_textutils N
+GNU_textutils Y
 GNU_uucp Y
 GNU_which Y
 LDP_man-pages Y
@@ -94,12 +94,12 @@
 lpr-linux Y
 majordomo Y
 man  Y
-man-db  N
+man-db  Y
 meson  Y
 microcode_ctl Y
 mirrordir Y
 module-init-tools N
-modutils N
+modutils Y
 mpg123  Y
 ncftp  Y
 ncurses  Y
function linux-man --description "Show manpages of Linux softwares" --wraps gman
  set --prepend --function -x MANPATH "/opt/share/manpages-linux-ja/man"
  command /opt/homebrew/bin/gman $argv
end
function man-linux
  linux-man $argv
end

以上

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