Repository: mesonbuild/meson

Issue:
install_man should allow specifying compression type (or none)
Various distros have their own rules for installing compressed man files. For example, gentoo
uses bzip2. One should be able to specify which compression type to use, or none at all, both
in the meson.build file itself or via the meson call (`meson --man-compress=[none|gzip|bzip2|...]`
or the like.


Discussion:
I'm starting to think that the entire compression thing was a mistake. Every distro already has code to compress man pages in the exact way that they want to. There is little point in adding a gazillion toggle switches to Meson then there already is a mechanism that works reliably.
@jpakkane sure, that's valid as well.
@jpakkane yes please, let's remove it. Man page compression is a system integration task, and not a build system task. Every package manager does it slightly different, and it just makes distro work so much harder.
@jpakkane do you need us to make a pull request for this? (it seems relatively simple to do but I might be mistaken)
On Fri, Oct 19, 2018 at 10:51 AM Michał Górny <notifications@github.com> wrote:

> @jpakkane do you need us to make a pull request for this? (it seems relatively simple to do but I might be mistaken)

By all means.


Resolving patch:
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -1083,7 +1083,7 @@ def generate_man_install(self, d):
                 if subdir is None:
                     subdir = os.path.join(manroot, 'man' + num)
                 srcabs = f.absolute_path(self.environment.get_source_dir(), self.environment.get_build_dir())
-                dstabs = os.path.join(subdir, os.path.basename(f.fname) + '.gz')
+                dstabs = os.path.join(subdir, os.path.basename(f.fname))
                 i = [srcabs, dstabs, m.get_custom_install_mode()]
                 d.man.append(i)
 
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -379,17 +379,7 @@ def install_man(self, d):
             outdir = os.path.dirname(outfilename)
             d.dirmaker.makedirs(outdir, exist_ok=True)
             install_mode = m[2]
-            if outfilename.endswith('.gz') and not full_source_filename.endswith('.gz'):
-                with open(outfilename, 'wb') as of:
-                    with open(full_source_filename, 'rb') as sf:
-                        # Set mtime and filename for reproducibility.
-                        with gzip.GzipFile(fileobj=of, mode='wb', filename='', mtime=0) as gz:
-                            gz.write(sf.read())
-                shutil.copystat(full_source_filename, outfilename)
-                print('Installing %s to %s' % (full_source_filename, outdir))
-                append_to_log(self.lf, outfilename)
-            else:
-                self.do_copyfile(full_source_filename, outfilename)
+            self.do_copyfile(full_source_filename, outfilename)
             set_mode(outfilename, install_mode, d.install_umask)
 
     def install_headers(self, d):
diff --git a/run_unittests.py b/run_unittests.py
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -3621,7 +3621,7 @@ def test_installed_modes_extended(self):
                 ('share', 'drwxr-x---'),
                 ('share/man', 'drwxr-x---'),
                 ('share/man/man1', 'drwxr-x---'),
-                ('share/man/man1/foo.1.gz', '-r--r--r-T'),
+                ('share/man/man1/foo.1', '-r--r--r-T'),
                 ('share/sub1', 'drwxr-x---'),
                 ('share/sub1/second.dat', '-rwxr-x--t'),
                 ('subdir', 'drwxr-x---'),
@@ -3694,7 +3694,7 @@ def test_install_umask(self):
                 'include/sample.h',
                 'share/datafile.cat',
                 'share/file.dat',
-                'share/man/man1/prog.1.gz',
+                'share/man/man1/prog.1',
                 'share/subdir/datafile.dog',
         ]:
             f = os.path.join(self.installdir, 'usr', *datafile.split('/'))


Test patch:
diff --git a/test cases/common/10 man install/installed_files.txt b/test cases/common/10 man install/installed_files.txt
--- a/test cases/common/10 man install/installed_files.txt	
+++ b/test cases/common/10 man install/installed_files.txt	
@@ -1,5 +1,5 @@
-usr/share/man/man1/foo.1.gz
-usr/share/man/man2/bar.2.gz
-usr/share/man/man1/vanishing.1.gz
-usr/share/man/man2/vanishing.2.gz
-usr/share/man/man1/baz.1.gz
+usr/share/man/man1/foo.1
+usr/share/man/man2/bar.2
+usr/share/man/man1/vanishing.1
+usr/share/man/man2/vanishing.2
+usr/share/man/man1/baz.1
diff --git a/test cases/common/196 install_mode/installed_files.txt b/test cases/common/196 install_mode/installed_files.txt
--- a/test cases/common/196 install_mode/installed_files.txt	
+++ b/test cases/common/196 install_mode/installed_files.txt	
@@ -4,7 +4,7 @@ usr/bin/trivialprog?exe
 usr/include/config.h
 usr/include/rootdir.h
 usr/libtest/libstat.a
-usr/share/man/man1/foo.1.gz
+usr/share/man/man1/foo.1
 usr/share/sub1/second.dat
 usr/share/sub2/stub
 usr/subdir/data.dat
diff --git a/test cases/common/49 custom install dirs/installed_files.txt b/test cases/common/49 custom install dirs/installed_files.txt
--- a/test cases/common/49 custom install dirs/installed_files.txt	
+++ b/test cases/common/49 custom install dirs/installed_files.txt	
@@ -4,8 +4,8 @@ usr/dib/dab/dub2/prog2?exe
 ?msvc:usr/dib/dab/dub2/prog2.pdb
 usr/some/dir/sample.h
 usr/some/dir2/sample.h
-usr/woman/prog.1.gz
-usr/woman2/prog.1.gz
+usr/woman/prog.1
+usr/woman2/prog.1
 usr/meow/datafile.cat
 usr/meow2/datafile.cat
 usr/woof/subdir/datafile.dog