CentOS: how to build pandoc from source


Method 1: use stack

Step 1: install stack

curl -sSL https://get.haskellstack.org/ | sh

...
  Verifying  : libquadmath-devel-4.8.5-36.el7_6.2.x86_64                                                                                                              42/47
  Verifying  : xz-devel-5.2.2-1.el7.x86_64                                                                                                                            43/47
  Verifying  : libffi-3.0.13-18.el7.x86_64                                                                                                                            44/47
  Verifying  : libgcc-4.8.5-36.el7_6.2.x86_64                                                                                                                         45/47
  Verifying  : libquadmath-4.8.5-36.el7_6.2.x86_64                                                                                                                    46/47
  Verifying  : cpp-4.8.5-36.el7_6.2.x86_64                                                                                                                            47/47

Installed:
  gmp-devel.x86_64 1:6.0.0-15.el7

Updated:
  gcc.x86_64 0:4.8.5-44.el7          gcc-c++.x86_64 0:4.8.5-44.el7     git.x86_64 0:1.8.3.1-25.el7_9     libffi.x86_64 0:3.0.13-19.el7     make.x86_64 1:3.82-24.el7
  perl.x86_64 4:5.16.3-299.el7_9     xz.x86_64 0:5.2.2-2.el7_9         zlib.x86_64 0:1.2.7-21.el7_9

Dependency Updated:
  cpp.x86_64 0:4.8.5-44.el7              gcc-gfortran.x86_64 0:4.8.5-44.el7         libffi-devel.x86_64 0:3.0.13-19.el7      libgcc.x86_64 0:4.8.5-44.el7
  libgfortran.x86_64 0:4.8.5-44.el7      libgomp.x86_64 0:4.8.5-44.el7              libquadmath.x86_64 0:4.8.5-44.el7        libquadmath-devel.x86_64 0:4.8.5-44.el7
  libstdc++.x86_64 0:4.8.5-44.el7        libstdc++-devel.x86_64 0:4.8.5-44.el7      perl-Git.noarch 0:1.8.3.1-25.el7_9       perl-libs.x86_64 4:5.16.3-299.el7_9
  xz-devel.x86_64 0:5.2.2-2.el7_9        xz-libs.x86_64 0:5.2.2-2.el7_9             zlib-devel.x86_64 0:1.2.7-21.el7_9

Complete!

Using generic bindist...

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   116  100   116    0     0    480      0 --:--:-- --:--:-- --:--:--   481
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 20.5M  100 20.5M    0     0  18.5M      0  0:00:01  0:00:01 --:--:-- 31.0M
Installing Stack to: /usr/local/bin/stack...

-------------------------------------------------------------------------------

Stack has been installed to: /usr/local/bin/stack

WARNING: '/root/.local/bin' is not on your PATH.
    Stack will place the binaries it builds in '/root/.local/bin' so
    for best results, please add it to the beginning of PATH in your profile.

Step 2: download source of pandoc

[root@tutorialspots ~]# git clone https://github.com/jgm/pandoc
Cloning into ‘pandoc’…
remote: Enumerating objects: 126152, done.
remote: Counting objects: 100% (2880/2880), done.
remote: Compressing objects: 100% (1105/1105), done.
remote: Total 126152 (delta 1785), reused 2581 (delta 1585), pack-reused 123272
Receiving objects: 100% (126152/126152), 61.85 MiB | 28.44 MiB/s, done.
Resolving deltas: 100% (80388/80388), done.

Step 3: change dir to pandoc

cd pandoc

Step 4: build

Wait about 1 hour

[root@tutorialspots pandoc]# stack install
Cloning 926d1c60c80cc9f205e31b7f070835665c2817dd from https://github.com/jgm/typst-hs
Cloning a22c43333930dfe59a9be97ab0516aef5338959c from https://github.com/jgm/texmath
Cabal file info not found for lpeg-1.1.0, updating
Selected mirror https://hackage.haskell.org/
Downloading root
Waiting to acquire cache lock on /root/.stack/pantry/hackage/hackage-security-lock
Acquired cache lock on /root/.stack/pantry/hackage/hackage-security-lock
Released cache lock on /root/.stack/pantry/hackage/hackage-security-lock
Selected mirror https://hackage.haskell.org/
Downloading timestamp
Downloading snapshot
Downloading mirrors
Cannot update index (no local copy)
Downloading index
Waiting to acquire cache lock on /root/.stack/pantry/hackage/hackage-security-lock
Acquired cache lock on /root/.stack/pantry/hackage/hackage-security-lock
Released cache lock on /root/.stack/pantry/hackage/hackage-security-lock
Updated package index downloaded
Calculating hashes to check for hackage-security rebases or filesystem changes
No old cache found, populating cache from scratch
Populating cache from file size 899847680, hash c732d92d2b97e140f1f2786f4d831baffa8aae5e5cfc4929dd9032033247c1c6
Populating package index cache ...
...
pandoc-lua-engine                > [30 of 31] Compiling Text.Pandoc.Lua.Custom
pandoc-lua-engine                > [31 of 31] Compiling Text.Pandoc.Lua
pandoc-lua-engine                > /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/./ghc-9.6.4: /lib64/libtinfo.so.5: no version information available (required by /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/../lib/x86_64-linux-ghc-9.6.4/libHShaskeline-0.8.2.1-ghc9.6.4.so)
pandoc-lua-engine                > /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/./ghc-9.6.4: /lib64/libtinfo.so.5: no version information available (required by /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/../lib/x86_64-linux-ghc-9.6.4/libHSterminfo-0.4.1.6-ghc9.6.4.so)
pandoc-lua-engine                > copy/register
pandoc-lua-engine                > Installing library in /root/pdf/pandoc/.stack-work/install/x86_64-linux/da98b9879bae0870035551ce3ec2b21a9269ee5c485b5ae327d8072247bbc7df/9.6.4/lib/x86_64-linux-ghc-9.6.4/pandoc-lua-engine-0.2.1.3-3wh7QuSI0wVD9NsCtLLoWc
pandoc-lua-engine                > Registering library for pandoc-lua-engine-0.2.1.3..
pandoc-cli                       > configure (exe)
pandoc-cli                       > Configuring pandoc-cli-3.1.12.3...
pandoc-cli                       > /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/./ghc-9.6.4: /lib64/libtinfo.so.5: no version information available (required by /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/../lib/x86_64-linux-ghc-9.6.4/libHShaskeline-0.8.2.1-ghc9.6.4.so)
pandoc-cli                       > /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/./ghc-9.6.4: /lib64/libtinfo.so.5: no version information available (required by /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/../lib/x86_64-linux-ghc-9.6.4/libHSterminfo-0.4.1.6-ghc9.6.4.so)
pandoc-cli                       > build (exe) with ghc-9.6.4
pandoc-cli                       > Preprocessing executable 'pandoc' for pandoc-cli-3.1.12.3..
pandoc-cli                       > Building executable 'pandoc' for pandoc-cli-3.1.12.3..
pandoc-cli                       > /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/./ghc-9.6.4: /lib64/libtinfo.so.5: no version information available (required by /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/../lib/x86_64-linux-ghc-9.6.4/libHShaskeline-0.8.2.1-ghc9.6.4.so)
pandoc-cli                       > /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/./ghc-9.6.4: /lib64/libtinfo.so.5: no version information available (required by /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/../lib/x86_64-linux-ghc-9.6.4/libHSterminfo-0.4.1.6-ghc9.6.4.so)
pandoc-cli                       > [1 of 3] Compiling PandocCLI.Lua
pandoc-cli                       > [2 of 3] Compiling PandocCLI.Server
pandoc-cli                       > [3 of 3] Compiling Main
pandoc-cli                       > /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/./ghc-9.6.4: /lib64/libtinfo.so.5: no version information available (required by /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/../lib/x86_64-linux-ghc-9.6.4/libHShaskeline-0.8.2.1-ghc9.6.4.so)
pandoc-cli                       > /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/./ghc-9.6.4: /lib64/libtinfo.so.5: no version information available (required by /root/.stack/programs/x86_64-linux/ghc-9.6.4/lib/ghc-9.6.4/bin/../lib/x86_64-linux-ghc-9.6.4/libHSterminfo-0.4.1.6-ghc9.6.4.so)
pandoc-cli                       > [4 of 4] Linking .stack-work/dist/x86_64-linux/ghc-9.6.4/build/pandoc/pandoc
pandoc-cli                       > copy/register
pandoc-cli                       > Installing executable pandoc in /root/pdf/pandoc/.stack-work/install/x86_64-linux/da98b9879bae0870035551ce3ec2b21a9269ee5c485b5ae327d8072247bbc7df/9.6.4/bin
Completed 227 action(s).
Copying from /root/pdf/pandoc/.stack-work/install/x86_64-linux/da98b9879bae0870035551ce3ec2b21a9269ee5c485b5ae327d8072247bbc7df/9.6.4/bin/pandoc to /root/.local/bin/pandoc.
Copied executables to /root/.local/bin/:
* pandoc

Warning: Installation path /root/.local/bin not found on the PATH environment variable.

Step 5: make symlink:

ln -s /root/.local/bin/pandoc /usr/bin/pandoc

Check:

[root@tutorialspots pandoc]# pandoc -v
pandoc 3.1.12.3
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /root/.local/share/pandoc
Copyright (C) 2006-2023 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.

Method 2: use cabal

Step 1: install ghcup

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

… Continuing …

Leave a Reply