Skip to contentSkip to conversation

man/info: fix not support xz/bz2 compression

PATCH Superseded Hongxu Jia 2 participants 9 messages Sep 24, 2014

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Hongxu Jia

author
#0 lore raw

v2 cover man/info: fix not support xz/bz2 compression

Changed in V2:
- Conditionally add 'gzip/bzip2/xz' to man/info's RDEPENDS rather than modify busybox's defconfig.

- Refer Ubuntu to add a script to postinst_intercept to run it after all packages have been installed at build time.

Test Case:

vim local.conf
..
IMAGE_INSTALL_append = " man man-doc texinfo texinfo-doc info info-doc" INHERIT += "compress_doc"
DOC_COMPRESS = "xz" or DOC_COMPRESS = "bz2"
..

bitbake core-image-minimal

runqemu qemux86

On target,
...

root@qemux86:~# man man
root@qemux86:~# info info
...

//Hongxu

The following changes since commit 8ac8eca2e3bd8c78e2b31ea974930ed0243258a3:

build-appliance-image: Update to dizzy head revision (2014-09-23 22:10:26 +0100)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib hongxu/fix-doc
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=hongxu/fix-doc

Hongxu Jia (4):
scripts/postinst-intercepts: add update_info_dir
texinfo: fix QA Error while doc compress enabled
texinfo: fix info not work
man/texinfo: conditionally add gzip/bzip2/xz to RDEPENDS

 meta/recipes-extended/man/man_1.6g.bb        | 13 +++++
 meta/recipes-extended/texinfo/texinfo_5.2.bb | 68 +++++++++++++++++++++-
 scripts/postinst-intercepts/update_info_dir  | 84 ++++++++++++++++++++++++++++
 3 files changed, 164 insertions(+), 1 deletion(-)
 create mode 100755 scripts/postinst-intercepts/update_info_dir
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v2 1/4 scripts/postinst-intercepts: add update_info_dir

We need to run it after all packages have been installed. Here is details:

NAME
update_info_dir - update or create index file from all installed info files in directory

SYNOPSIS
update_info_dir [options] [directory]

DESCRIPTION
Update, or create, the index file dir of available documentation in $D/${infodir} (the default) or in given DIRECTORY. The index file info is the directory is usually presented by info browsers on startup.

OPTIONS
-h,--help
Display help and exit.

SEE ALSO
emacs(1) info(1) install-info(1)

AUTHOR
This manual page was written by Norbert Preining <[email protected]>, for the Debian GNU/Linux system (but may be used by others). This manual page was written for the Debian GNU/Linux distribution because the original script was designed for Debian packaging system.

Backport update-info-dir from ubuntu 1404, and add xz/bz2 compression support

[YOCTO #6751]

---
 scripts/postinst-intercepts/update_info_dir | 84 +++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100755 scripts/postinst-intercepts/update_info_dir
scripts/postinst-intercepts/update_info_dir new file +84 -0
new file mode 100755
index 0000000..8ef55ec
@@ -0,0 +1,84 @@
+#!/bin/bash
+# update-info-dir
+# create a dir file from all installed info files
+# Copyright 2009 Norbert Preining
+# GPLv2
+
+INFODIR=$D${infodir}
+
+set -e
+
+#
+# since user's environment is taken over into root account when sudo-ing
+# we don't want that one's user LANGUAGE setting changes the messages in
+# the dir file. Unset LANGUAGE and reload /etc/environment to get
+# the system wide settings. See bug #536476
+unset LANGUAGE
+unset LANG
+if [ -r /etc/environment ] ; then
+  . /etc/environment
+fi
+if [ -r /etc/default/locale ] ; then
+  . /etc/default/locale
+fi
+
+Help ()
+{
+    echo "\
+SYNOPSIS: update-info-dir [-h,--help] [info-directory]
+
+(re-)creates the index of available documentation in info format
+(the file /usr/share/info/dir) which is usually presented by info browsers
+on startup."
+
+    exit 0
+}
+
+
+if [ "$1" = "-h" ] || [ "$1" == "--help" ]; then
+    Help
+fi
+
+if [ -n "$1" ] ; then
+  INFODIR="$1"
+fi
+
+if [ ! -d "$INFODIR" ] ; then
+  echo "Not a directory: $INFODIR." >&2
+  exit 1
+fi
+
+if [ -r "$INFODIR/dir" ] ; then
+  rm -f "$INFODIR/dir.old"
+  cp $INFODIR/dir $INFODIR/dir.old
+fi
+
+# we have to remove the dir file not make ginstall-info being surprised
+rm -f "$INFODIR/dir"
+
+errors=0
+find "$INFODIR" -type f | while read file ; do
+  case $file in
+    */dir|*/dir.old| \
+    *-[0-9]|*-[0-9].gz|*-[0-9].xz|*-[0-9].bz2| \
+    *-[1-9][0-9]|*-[1-9][0-9].gz|*-[1-9][0-9].xz|*-[1-9][0-9].bz2| \
+    *.png)
+      # these files are ignored
+      continue
+      ;;
+    *)
+      ${STAGING_BINDIR_NATIVE}/install-info "$file" "$INFODIR/dir" || {
+        errors=$[errors+1]
+      }
+      ;;
+  esac
+done
+
+if [ $errors -gt 0 ] ; then
+  echo "Updating the index of info documentation produced $errors errors."
+  exit 1
+fi
+
+exit 0
+
+# vim:set expandtab tabstop=2: #
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH 1/4] scripts/postinst-intercepts: add update_info_dir

scripts/postinst-intercepts/update_info_dir line 23

Quoted 12 lines · Hongxu Jia
scripts/postinst-intercepts/update_info_dir new file +12 -0
+# since user's environment is taken over into root account when sudo-ing
+# we don't want that one's user LANGUAGE setting changes the messages in
+# the dir file. Unset LANGUAGE and reload /etc/environment to get
+# the system wide settings. See bug #536476
+unset LANGUAGE
+unset LANG
+if [ -r /etc/environment ] ; then
+  . /etc/environment
+fi
+if [ -r /etc/default/locale ] ; then
+  . /etc/default/locale
+fi

Isn't this Debian-specific, and also pushing the build host's environment settings onto the target? We should use whatever default locale is configured for the image, or easier just force it to C.

Ross

author
#3 lore raw

Re: [PATCH 1/4] scripts/postinst-intercepts: add update_info_dir

Quoted 16 lines · Ross

scripts/postinst-intercepts/update_info_dir line 23

Quoted 12 lines · Hongxu Jia
scripts/postinst-intercepts/update_info_dir new file +12 -0
+# since user's environment is taken over into root account when sudo-ing
+# we don't want that one's user LANGUAGE setting changes the messages in
+# the dir file. Unset LANGUAGE and reload /etc/environment to get
+# the system wide settings. See bug #536476
+unset LANGUAGE
+unset LANG
+if [ -r /etc/environment ] ; then
+  . /etc/environment
+fi
+if [ -r /etc/default/locale ] ; then
+  . /etc/default/locale
+fi

Isn't this Debian-specific, and also pushing the build host's environment settings onto the target? We should use whatever default locale is configured for the image, or easier just force it to C.

Okay, I will just force it to C.

//Hongxu

Quoted 1 line

Ross

author
#4 lore raw

PATCH v2 2/4 texinfo: fix QA Error while doc compress enabled

In reply to Hongxu Jia

While doc compress enabled, ther is a QA issue:
...
ERROR: QA Issue: texinfo: Files/directories were installed but not shipped
/usr/share/info/info.info.bz2 /usr/share/info/info-stnd.info.bz2 [installed-vs-shipped]
...

---
 meta/recipes-extended/texinfo/texinfo_5.2.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-extended/texinfo/texinfo_5.2.bb +1 -1
index be90aba..7b5a11a 100644
@@ -51,7 +51,7 @@ do_install_append_class-native() {
 PACKAGES += "info info-doc"
 
 FILES_info = "${bindir}/info ${bindir}/infokey ${bindir}/install-info"
-FILES_info-doc = "${infodir}/info.info ${infodir}/dir ${infodir}/info-*.info \
+FILES_info-doc = "${infodir}/info.info* ${infodir}/dir ${infodir}/info-*.info* \
                   ${mandir}/man1/info.1* ${mandir}/man5/info.5* \
                   ${mandir}/man1/infokey.1* ${mandir}/man1/install-info.1*"
 
Signature · 1 line
1.9.1
author
#5 lore raw

PATCH v2 3/4 texinfo: fix info not work

In reply to Hongxu Jia

In texinfo, we didn't have info/dir entries, which caused info not work.
...

root@qemux86:~# info info
info: dir: No such file or directory
...

Refer ubuntu/debian to invoke install-info to create info/dir entries in pkg_postinst_info.

[YOCTO #6751]

---
 meta/recipes-extended/texinfo/texinfo_5.2.bb | 53 ++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
meta/recipes-extended/texinfo/texinfo_5.2.bb +53 -0
index 7b5a11a..cdcb37b 100644
@@ -61,4 +61,57 @@ FILES_${PN}-doc = "${infodir}/texinfo* \
                    ${datadir}/${tex_texinfo} \
                    ${mandir}/man1 ${mandir}/man5"
 
+pkg_postinst_info () {
+if [ "x$D" != "x" ]; then
+    $INTERCEPT_DIR/postinst_intercept update_info_dir ${PKG} \
+        mlprefix=${MLPREFIX} infodir=${infodir} STAGING_BINDIR_NATIVE=${STAGING_BINDIR_NATIVE}
+else
+    errors=0
+    find "${infodir}" -type f | while read file ; do
+        case $file in
+        */dir| */dir.old| \
+        *-[0-9]|*-[0-9].gz|*-[0-9].xz|*-[0-9].bz2| \
+        *-[1-9][0-9]|*-[1-9][0-9].gz|*-[1-9][0-9].xz|*-[1-9][0-9].bz2| \
+        *.png)
+            # these files are ignored
+            continue
+            ;;
+        *)
+            install-info "$file" "${infodir}/dir" || {
+                errors=$[errors+1]
+            }
+            ;;
+        esac
+    done
+    if [ $errors -gt 0 ] ; then
+        echo "Updating the index of info documentation produced $errors errors."
+        exit 1
+    fi
+fi
+}
+
+pkg_prerm_info () {
+errors=0
+find "$D${infodir}" -type f | while read file ; do
+    case $file in
+    */dir|*/dir.old| \
+    *-[0-9]|*-[0-9].gz|*-[0-9].xz|*-[0-9].bz2| \
+    *-[1-9][0-9]|*-[1-9][0-9].gz|*-[1-9][0-9].xz|*-[1-9][0-9].bz2| \
+    *.png)
+        # these files are ignored
+        continue
+        ;;
+    *)
+        install-info --delete "$file" "$D${infodir}/dir" || {
+            errors=$[errors+1]
+        }
+        ;;
+    esac
+done
+
+if [ $errors -gt 0 ] ; then
+    echo "Cleaning the index of info documentation produced $errors errors."
+fi
+}
+
 BBCLASSEXTEND = "native"
Signature · 1 line
1.9.1
author
#6 lore raw

PATCH v2 4/4 man/texinfo: conditionally add gzip/bzip2/xz to RDEPENDS

In reply to Hongxu Jia

Conditionally add 'xz/bz2/gzip' to info/man's RDEPENDS according to DOC_COMPRESS.

[YOCTO #6750]
[YOCTO #6751]

---
 meta/recipes-extended/man/man_1.6g.bb        | 13 +++++++++++++
 meta/recipes-extended/texinfo/texinfo_5.2.bb | 13 +++++++++++++
 2 files changed, 26 insertions(+)
meta/recipes-extended/man/man_1.6g.bb +13 -0
index a66e01c..2a0868f 100644
@@ -9,6 +9,19 @@ PR = "r1"
 
 DEPENDS = "groff less"
 
+def compress_pkg(d):
+    if "compress_doc" in d.getVar("INHERIT", True):
+         compress = d.getVar("DOC_COMPRESS", True)
+         if compress == "gz":
+             return "gzip"
+         elif compress == "bz2":
+             return "bzip2"
+         elif compress == "xz":
+             return "xz"
+    return ""
+
+RDEPENDS_${PN} += "${@compress_pkg(d)}"
+
 SRC_URI = "http://primates.ximian.com/~flucifredi/${BPN}/${BPN}-${PV}.tar.gz \
            file://man-1.5k-confpath.patch;striplevel=0 \
            file://man-1.5h1-make.patch \
meta/recipes-extended/texinfo/texinfo_5.2.bb +13 -0
index cdcb37b..0ea5d54 100644
@@ -9,6 +9,19 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
 
 PROVIDES_append_class-native = " texinfo-replacement-native"
 
+def compress_pkg(d):
+    if "compress_doc" in d.getVar("INHERIT", True):
+         compress = d.getVar("DOC_COMPRESS", True)
+         if compress == "gz":
+             return "gzip"
+         elif compress == "bz2":
+             return "bzip2"
+         elif compress == "xz":
+             return "xz"
+    return ""
+
+RDEPENDS_info += "${@compress_pkg(d)}"
+
 DEPENDS = "zlib ncurses texinfo-replacement-native"
 DEPENDS_class-native = "zlib-native ncurses-native"
 
Signature · 1 line
1.9.1
#7 lore raw

Re: [PATCH 4/4] man/texinfo: conditionally add gzip/bzip2/xz to RDEPENDS

Quoted 1 line · Hongxu Jia

+ if "compress_doc" in d.getVar("INHERIT", True):

You'll want to split() the INHERIT variable so you're searching for a member and not a substring:

if "compress_doc" in d.getVar("INHERIT", True).split()

Without splitting, an inherited class called decompress_docker will trigger your code.

Ross

author
#8 lore raw

Re: [PATCH 4/4] man/texinfo: conditionally add gzip/bzip2/xz to RDEPENDS

Quoted 9 lines · Ross
Quoted 1 line · Hongxu Jia

+ if "compress_doc" in d.getVar("INHERIT", True):

You'll want to split() the INHERIT variable so you're searching for a member and not a substring:

if "compress_doc" in d.getVar("INHERIT", True).split()

Without splitting, an inherited class called decompress_docker will trigger your code.

Yes, I will fix that, thanks for figuring that out

//Hongxu

Quoted 2 lines

Ross