Bug 85214 - libreoffice fails to build properly when /bin/sh is not bash
Summary: libreoffice fails to build properly when /bin/sh is not bash
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
4.3.1.2 release
Hardware: x86-64 (AMD64) Linux (All)
: low normal
Assignee: Not Assigned
URL:
Whiteboard: target:4.5.0
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-20 04:43 UTC by Jonathan Callen
Modified: 2015-01-05 12:40 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Remove bashisms from configure.ac (561 bytes, patch)
2014-12-28 10:13 UTC, Rémi Cardona
Details
configure.ac: remove bashisms, see fdo#85214 (1.00 KB, patch)
2014-12-28 12:14 UTC, Rémi Cardona
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Callen 2014-10-20 04:43:15 UTC
The ./configure script used to buid libreoffice contains bashisms, causing build failures when called using a /bin/sh that is not bash.
Comment 1 Julien Nabet 2014-10-20 05:58:05 UTC
Jonathan: could you be more specific? Which sources are you trying to build? (master sources, 4.3, other?) which bashism have you found?
Did you follow https://wiki.documentfoundation.org/Development/BuildingOnLinux ?
Comment 2 Evan Langlois 2014-11-05 07:47:09 UTC
I'm finding the same issue.  I haven't gone into a huge amount of investigation, but I tend to keep /bin/sh as a symlink to /bin/dash because its faster and is 100% posix/bourne compatible.  My login shell is /bin/bash for the extra features, but I use that interactively.

Compiling LibreOffice 4.3.2.2 from source fails.  I reset the /bin/sh symlink to bash and it compiles.  Its still compiling since it was successfule so it could be quite some time before it finishes and I can rebreak it to give some output.  I will attach whatever logs I can that will bring about some help as to where the bug is.

Incidently, to prevent these issues, I pass SHELL=/bin/bash to the configure script as that sometimes will fix these issues.  It didn't.
Comment 3 Julien Nabet 2014-11-05 21:19:49 UTC
Evan: thank you for having given the version but could you put the error logs?
Comment 4 Evan Langlois 2014-11-06 07:03:13 UTC
s/successfule/successful/

Here is a snippet of configure failing:

checking for building the Barcode extension... no
checking for building the ConvertTextToNumber extension... no
checking for building the Numbertext extension... no
checking for building the Hungarian Cross-reference Toolbar extension... no
checking for building the Typography Toolbar extension... no
checking for building the Google Docs extension... no
checking for building the NLPSolver extension... no
checking for building the LanguageTool extension... no
checking for Sun Professional Template Pack integration (only supported languages displayed)... no integration
checking whether to include third-party fonts... no
checking for fc-match... /usr/bin/fc-match
checking font mapping for 'Calibri'... ./configure: 38799: shift: can't shift that many


And that's where it dies.  The line is actually 38799 in the usage of shift.
Bash will silently ignore shift if it runs out of variables to shift.  Bourne shell gives the above error.  And .. one other way bash and bourne differ is that bourne shell exits if any built-in fails.  So .. since shift is a built-in and it ran out of arguments .. the configure script dies.

Maybe you could test how many arguments you have with $# before calling shift.  Notice exit status clause of shift in http://pubs.opengroup.org/onlinepubs/009695399/utilities/shift.html
Comment 5 Julien Nabet 2014-11-06 20:54:37 UTC
Jonathan/Evan: which branch do you use? (master, 4.3, 4.2?)
Would it be possible you attach your autogen.input? (or give params provided for autogen.sh)

Indeed, taking example of Evan's case, I downloaded and installed Calibri (+ regenerated font cache), used dash instead of bash (even put SHELL=/bin/dash) but I don't get the lines:
hecking for fc-match... /usr/bin/fc-match
checking font mapping for 'Calibri'

Here's my output:
...
checking whether to include third-party fonts... yes
checking whether to include extra galleries... yes
checking whether to include extra templates... yes
checking whether to include extra samples... yes
checking whether to include extra fonts... no
checking whether to enable online update... yes
checking whether to create MSI with LIMITUI=1 (silent install)... no
checking whether and how to use Xinerama... yes, with dynamic linking
checking X11/extensions/Xinerama.h usability... yes
checking X11/extensions/Xinerama.h presence... yes
...
Comment 6 Jonathan Callen 2014-11-06 23:54:21 UTC
In my case, I'm using Gentoo's build scripts, which do not run autogen.sh.

I am building version 4.3.1.2, and have explicitly set --with-external-tar=; not setting that causes the build to work further than setting it does.

The complete configure command line is:

./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --disable-dependency-tracking --libdir=/usr/lib64 --docdir=/usr/share/doc/libreoffice-4.3.1.2/ --with-system-headers --with-system-libs --with-system-jars --with-system-dicts --enable-cairo-canvas --enable-graphite --enable-largefile --enable-neon --enable-python=system --enable-randr --enable-randr-link --enable-release-build --disable-hardlink-deliver --disable-ccache --disable-crashdump --disable-dependency-tracking --disable-epm --disable-fetch-external --disable-gnome-vfs --disable-gstreamer-0-10 --disable-report-builder --disable-kdeab --disable-kde --disable-mergelibs --disable-online-update --disable-systray --with-alloc=system --with-build-version="Gentoo official package" --enable-extension-integration --with-external-dict-dir=/usr/share/myspell --with-external-hyph-dir=/usr/share/myspell --with-external-thes-dir=/usr/share/myspell --with-external-tar=/tmp/portage/app-office/libreoffice-4.3.1.2/distdir --with-lang= --with-parallelism=16 --with-system-ucpp --with-vendor="Gentoo Foundation" --with-x --without-fonts --without-myspell-dicts --without-help --with-helppack-integration --without-sun-templates --enable-sdremote-bluetooth --disable-coinmp --disable-collada --enable-cups --disable-debug --enable-dbus --disable-evolution2 --disable-firebird-sdbc --disable-gltf --disable-gconf --disable-gio --disable-lockdown --enable-gstreamer --enable-gtk --disable-gtk3 --enable-kde4 --disable-ext-mariadb-connector --disable-odk --enable-opengl --disable-postgresql-sdbc --disable-telepathy --enable-vba --disable-vlc --without-system-coinmp --without-system-libgltf --without-java --without-system-mysql-cppconn --without-doxygen --without-system-sane --without-system-vigra --disable-ext-nlpsolver --disable-scripting-beanshell --disable-scripting-javascript --disable-ext-wiki-publisher

This fails when the AbsolutePath function attempts to run the following line (line 75 of configure.ac):

  cd - &> /dev/null

This code did not work in dash, as "&>" is not valid in POSIX sh.  It ended up causing the code following to run in the external tar directory, which is not writable by the user running the build under this build system (instead of in the source directory, which is).

After updating dash to a later version, dash now parses that line as two commands:
  cd - &
  > /dev/null

This is valid, but does not send the output to /dev/null as expected.
Comment 7 Evan Langlois 2014-11-07 01:29:52 UTC
Jonathan: Still not valid as its treating it as if & meant to run it in the background as part of an asynchronous list.   Its supposed to read it as
cd - >/dev/null 2>&1

It's bash shorthand.  I'm surprised dash supported "cd -" as I don't think that's posix.

Julien: I'm running Gentoo's sister, funtoo.  At the moment, I'm doing a full system recompile (not world, just system tools for now) to make sure there are no mistakes on this end, and upgrading to a slightly newer GCC.  This means all the automake tools and such will all be rebuilt.  Once this is done, I'll try libreoffice again without changing the shell (still dash), and see if I can track down which ./configure flags are causing the issue.  

I don't believe Gentoo systems normally run automake, but its quite possible that running it to rebuild the configure script could help.  I think configure is already made upstream, so Gentoo doesn't tinker with it, but I think autogen may actually be the issue after researching this.  I think if autogen is run with a shell that excepts bashism, it generates a configure that does as well.  I have to confirm this.  The recompile may take quite awhile, but I keep you posted as to what I can find out so that you have all the information you need to track this down.
Comment 8 Julien Nabet 2014-11-07 06:50:28 UTC
Thank you for your feedback both of you. I put it at NEW

Bjoern/Michael: Jonathan and Evan indicated bashisms, one for you?
Comment 9 Michael Stahl (allotropia) 2014-11-07 11:34:03 UTC
configure should run on any /bin/sh, please submit patches against master

https://wiki.documentfoundation.org/Development/gerrit
Comment 10 Julien Nabet 2014-11-09 09:33:31 UTC
I tried comment 6 but had this:
configure: error: Package requirements (libe-book-0.1 >= 0.1.1) were not met:

No package 'libe-book-0.1' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables EBOOK_CFLAGS
and EBOOK_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

However, libe-book is installed, since I've got this:
Package: libe-book-0.1-1
Source: libe-book
Version: 0.1.1-2

I checked PKG_CONFIG_PATH and EBOOK_CFLAGS, they're empty.

So I did "export PKG_CONFIG_PATH=/usr/lib" (since libe-book-0.1.so.1 and libe-book-0.1.so.1.0.1 are there) but no result.

It seems Gentoo and related are quite different from Debian.
Comment 11 Jonathan Callen 2014-11-09 20:26:00 UTC
(In reply to Julien Nabet from comment #10)
> I tried comment 6 but had this:
> configure: error: Package requirements (libe-book-0.1 >= 0.1.1) were not met:
> 
> No package 'libe-book-0.1' found
> 
> Consider adjusting the PKG_CONFIG_PATH environment variable if you
> installed software in a non-standard prefix.
> 
> Alternatively, you may set the environment variables EBOOK_CFLAGS
> and EBOOK_LIBS to avoid the need to call pkg-config.
> See the pkg-config man page for more details.
> 
> However, libe-book is installed, since I've got this:
> Package: libe-book-0.1-1
> Source: libe-book
> Version: 0.1.1-2
> 
> I checked PKG_CONFIG_PATH and EBOOK_CFLAGS, they're empty.
> 
> So I did "export PKG_CONFIG_PATH=/usr/lib" (since libe-book-0.1.so.1 and
> libe-book-0.1.so.1.0.1 are there) but no result.
> 
> It seems Gentoo and related are quite different from Debian.

You have a different issue.  You probaby need to install the package "libe-book-dev".  The build system is looking for the file "libe-book-0.1.pc", which is in the -dev package.
Comment 12 Julien Nabet 2014-11-09 22:01:49 UTC
(In reply to Jonathan Callen from comment #11)
> (In reply to Julien Nabet from comment #10)
> > I tried comment 6 but had this:
> > configure: error: Package requirements (libe-book-0.1 >= 0.1.1) were not met:
> > 
> > No package 'libe-book-0.1' found
> > ...
> 
> You have a different issue.  You probaby need to install the package
> "libe-book-dev".  The build system is looking for the file
> "libe-book-0.1.pc", which is in the -dev package.
It worked indeed.
Now it complains with this:
No package 'libetonyek-0.1' found

I changed a bit the options to have this:
./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --disable-dependency-tracking --libdir=/usr/lib64  --enable-cairo-canvas --enable-graphite --enable-largefile --enable-neon --enable-python=system --enable-randr --enable-randr-link --enable-release-build --disable-hardlink-deliver --disable-ccache --disable-crashdump --disable-dependency-tracking --disable-epm --disable-fetch-external --disable-gnome-vfs --disable-gstreamer-0-10 --disable-report-builder --disable-kdeab --disable-kde --disable-mergelibs --disable-online-update --disable-systray --with-alloc=system --with-build-version="Gentoo official package" --enable-extension-integration --with-external-dict-dir=/usr/share/myspell --with-external-hyph-dir=/usr/share/myspell --with-external-thes-dir=/usr/share/myspell --with-lang= --with-parallelism=16 --with-system-ucpp --with-vendor="Gentoo Foundation" --with-x --without-fonts --without-myspell-dicts --without-help --with-helppack-integration --without-sun-templates --enable-sdremote-bluetooth --disable-coinmp --disable-collada --enable-cups --disable-debug --enable-dbus --disable-evolution2 --disable-firebird-sdbc --disable-gltf --disable-gconf --disable-gio --disable-lockdown --enable-gstreamer --enable-gtk --disable-gtk3 --disable-ext-mariadb-connector --disable-odk --enable-opengl --disable-postgresql-sdbc --disable-telepathy --enable-vba --disable-vlc --without-system-coinmp --without-system-libgltf --without-java --without-system-mysql-cppconn --without-doxygen --without-system-sane --without-system-vigra --disable-ext-nlpsolver --disable-scripting-beanshell --disable-scripting-javascript --disable-ext-wiki-publisher --enable-python=internal

I removed kde4 + system libs + add python internal

It's ok fo me.

It seems, I won't be of any help here.
Comment 13 Julien Nabet 2014-12-25 19:20:05 UTC
I found this link which may help:
http://www.shellcheck.net
Comment 14 Rémi Cardona 2014-12-28 10:12:01 UTC
(In reply to Julien Nabet from comment #5)
> SHELL=/bin/dash) but I don't get the lines:
> hecking for fc-match... /usr/bin/fc-match
> checking font mapping for 'Calibri'

Autoconf checks if /bin/sh is POSIXy enough before continuing. If it isn't, configure automatically reruns itself with /bin/bash. Debian devs wanted to make dash fully POSIX-compliant but this caused too many headaches[1], so they disabled the one feature Autoconf checks to detect shells' POSIX-ness: LINENO support. Bottom line, if you want to run ./configure with dash you need to set the following environment variable: CONFIG_SHELL=/bin/dash.

(In reply to Evan Langlois from comment #4)
> checking font mapping for 'Calibri'... ./configure: 38799: shift: can't
> shift that many

I hit the same issue. Patch coming up.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=582952
Comment 15 Rémi Cardona 2014-12-28 10:13:13 UTC
Created attachment 111420 [details]
Remove bashisms from configure.ac
Comment 16 Rémi Cardona 2014-12-28 12:14:28 UTC
Created attachment 111424 [details]
configure.ac: remove bashisms, see fdo#85214

Here's a properly crafted git patch that applies on today's master head.
Comment 18 Adolfo Jayme 2015-01-05 12:40:26 UTC
Closing the report assuming that the above commit fixes the reported issue.