LoginSignup
3
1

More than 1 year has passed since last update.

LibreOffice変換コマンドの深掘り: soffice VS. soffice.bin

Last updated at Posted at 2022-08-12

はじめに

LibreOfficeの変換コマンドsofficeを深掘りします。
特に、soffice.binとの関連や違いなど。

LibreOfficeのsofficeコマンドとは

  • LibreOffice

  • sofficeコマンド

    • LibreOfficeに内蔵されたドキュメント変換コマンド

検証環境

  • AlmaLinux 8.6

sofficeコマンドの他に、soffice.binが存在する?

  • sofficeコマンドの配置場所に、soffice.binも存在
$ ls -l /opt/libreoffice7.3/program/

まず、sofficeコマンドの確認から

  • 実体はシェルスクリプト
$ file /opt/libreoffice7.3/program/soffice
/opt/libreoffice7.3/program/soffice: POSIX shell script, ASCII text executable

sofficeをデバッグしてみる

sh -xコマンドでsofficeシェルスクリプトをデバッグ
すると、sofficeからoosplashが呼び出されていることが判明

$ sh -x /opt/libreoffice7.3/program/soffice --headless --convert-to pdf test.xlsx
... ...
+ exec /opt/libreoffice7.3/program/oosplash --headless --convert-to pdf test.xlsx
... ...

つぎ、oosplashを確認

oosplashは、アプリケーション起動処理中に画像を表示するSplashと関係するかも。

  • 実体は、バイナリの実行ファイル
$ file /opt/libreoffice7.3/program/oosplash

/opt/libreoffice7.3/program/oosplash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=f60aed35eb866e2b73386fcbff8b84e8a58a378e, stripped

straceコマンドでトレース採取

$ strace -f -o strace_oosplash.log /opt/libreoffice7.3/program/oosplash --headless --convert-to pdf test.xls

strace_oosplash.logから、oosplash内部でsoffice.binが呼び出されることが判明

...
execve("/opt/libreoffice7.3/program/soffice.bin", ["/opt/libreoffice7.3/program/soffice.bin", "--headless", "--convert-to", "pdf", "test.xlsx"], 0x7ffcc4a53aa8 /* 21 vars */ <unfinished ...>
...

ここまでわかったこと

  • soffice -> oosplash -> soffice.bin の順で呼び出される
  • 変換は実質soffice.binにより行われる、sofficeはそのラッパーにすぎない

sofficeとsoffice.binの違いは?

端末A、端末Bから、同時に同じ変換を実施してみる(同じLibreOfficeユーザプロファイルを使用する前提)

まず、sofficeの挙動を検証

  • 端末A
$ /opt/libreoffice7.3/program/soffice --headless --convert-to pdf test.xls
convert /tmp/test.xls -> /tmp/test.pdf using filter : calc_pdf_Export
Overwriting: /tmp/test.pdf
  • 端末B
$ /opt/libreoffice7.3/program/soffice --headless --convert-to pdf test.xls
convert /tmp/test.xls -> /tmp/test.pdf using filter : calc_pdf_Export
Overwriting: /tmp/test.pdf
  • 結果
    • 端末Aの変換が終わるまで、端末Bは待機(キューイング)
    • 端末Aが終わったら、端末Bの変換がスタートし成功

つぎ、soffice.binの挙動を検証

  • 端末A
$ /opt/libreoffice7.3/program/soffice.bin --headless --convert-to pdf test.xls
convert /tmp/test.xls -> /tmp/test.pdf using filter : calc_pdf_Export
Overwriting: /tmp/test.pdf
  • 端末B
$ /opt/libreoffice7.3/program/soffice.bin --headless --convert-to pdf test.xls
$ echo $?
1
  • 結果
    • 端末Aの変換が実行中のため、端末Bの変換要求はエラーコード1で失敗(待機しない)
    • 端末Aのみ変換成功、端末Bの変換はなかったことに

おわりに

sofficeコマンドとsoffice.binコマンドの差異を検証しました。
目的に応じて、使い分けるとよいかもしれません。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1