All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ross Burton <ross.burton@intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [RFC PATCH 1/2] podfix: class to remove Pod::Man versions from manpages
Date: Fri, 13 Dec 2019 23:21:55 +0000	[thread overview]
Message-ID: <20191213232156.28367-1-ross.burton@intel.com> (raw)

Manpages generated by Pod::Man contain the version number, which isn't
reproducible if we're using the host Perl to generate manpage.

One option is to always depend on perl-native when generating manpages
but this is a heavy dependency, so instead strip out the versions in
do_install().

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/podfix.bbclass | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 meta/classes/podfix.bbclass

diff --git a/meta/classes/podfix.bbclass b/meta/classes/podfix.bbclass
new file mode 100644
index 00000000000..54fff6a0a23
--- /dev/null
+++ b/meta/classes/podfix.bbclass
@@ -0,0 +1,32 @@
+python pod_strip_version() {
+    import re
+
+    def opener(filename, mode):
+        if filename.endswith(".gz"):
+            import gzip
+            return gzip.open(filename, mode)
+        elif filename.endswith(".bz2"):
+            import bz2
+            return bz2.open(filename, mode)
+        else:
+            return open(filename, mode)
+
+    bad_re = re.compile(rb"Automatically generated by Pod::Man( [0-9]+.+)")
+
+    for root, dirs, files in os.walk(d.expand("${D}${mandir}")):
+        for filename in files:
+            filename = os.path.join(root, filename)
+            with opener(filename, "rb") as manfile:
+                manpage = manfile.read()
+                m = bad_re.search(manpage)
+                if not m:
+                    continue
+
+            bb.note("podfix: stripping version from %s" % filename)
+            os.unlink(filename)
+            with opener(filename, "wb") as manfile:
+                manfile.write(manpage[:m.start(1)])
+                manfile.write(manpage[m.end(1):])
+}
+
+do_install[postfuncs] += "pod_strip_version"
-- 
2.20.1



             reply	other threads:[~2019-12-13 23:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13 23:21 Ross Burton [this message]
2019-12-13 23:21 ` [RFC PATCH 2/2] reproducible_build_simple: inherit podfix Ross Burton
2019-12-16  4:39 ` [RFC PATCH 1/2] podfix: class to remove Pod::Man versions from manpages Khem Raj
2019-12-16 11:20   ` Ross Burton
2019-12-16 15:17     ` Khem Raj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191213232156.28367-1-ross.burton@intel.com \
    --to=ross.burton@intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.