MSYS2 makepkg PKGBUILD with meson – which directory is used in package()?

In MSYS2, there is already a package for tio, version 1.32; This package is built through a PKGBUILD file, which can be seen here:

I wanted to build the latest version of tio, which is currently 1.37, for MSYS2 (I use it on Windows 10). One of the main differences is that whereas tio 1.32 used configure.ac and a Makefile for building, tio 1.37 uses the meson build system.

So, I tried to convert the existing PKGBUILD for tio 1.32, into PKGBUILD that would use meson for 1.37; I’ve put related files in this gist:

First off, I have a C:src directory, and there I create a new directory for building, using the MSYS2 bash shell, where I retrieve the edited file (from the gist) – and finally, I issue the makepkg command (found in https://www.msys2.org/wiki/Creating-Packages/)

$ mkdir tio_msys2
$ cd tio_msys2
$ wget https://gist.githubusercontent.com/sdbbs/77ce5e0bfa59cdabda5fad5596ab9ccd/raw/462234c53bb1cfcdbe0d6323afbef4845231cab2/01_PKGBUILD -O PKGBUILD
$ makepkg -sCLf

In short, the PKGBUILD file looks like this:

pkgname=tio
pkgver=1.37
pkgrel=1
pkgdesc="A simple TTY terminal I/O application"
arch=('i686' 'x86_64')
url="https://tio.github.io/"
license=('GPL')
makedepends=('autotools' 'gcc' 'meson' 'ninja')
source=(https://github.com/tio/tio/releases/download/v${pkgver}/tio-${pkgver}.tar.xz)
sha256sums=('a54cd09baeaabd306fdea486b8161eea6ea75bb970b27cae0e8e407fb2dd7181')
validpgpkeys=('101BAC1C15B216DBE07A3EEA2BDB4A0944FA00B1') # Martin Lund

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  meson --prefix=/usr --buildtype=plain build
  meson compile -C build
}

package() {
  echo "srcdir ${srcdir} pkgname ${pkgname} pkgver ${pkgver} destdir ${destdir}"
  
  cd "${srcdir}/${pkgname}-${pkgver}"
  meson install -C build --destdir "$pkgdir"
}

The build succeeds – you can see the full build log in 02_makepkg.log, but the relevant thing is that tio.exe does get generated:

$ find . -name '*.exe'
./pkg/tio/usr/bin/tio.exe
./src/tio-1.37/build/meson-private/sanitycheckc.exe
./src/tio-1.37/build/meson-private/sanitycheckcpp.exe
./src/tio-1.37/build/meson-private/__CMake_compiler_info__/CMakeFiles/3.22.1/CompilerIdC/a.exe
./src/tio-1.37/build/src/tio.exe

Also, a pkg directory gets generated (that is, /c/src/tio_msys2/pkg), probably in the package() step (probably as a result of the meson install ... command) — which does look like a “packaged” tree, as we expect to see it in an installation package:

$ tree -a pkg
pkg
└── tio
    ├── .BUILDINFO
    ├── .MTREE
    ├── .PKGINFO
    └── usr
        ├── bin
        │   └── tio.exe
        └── share
            ├── bash-completion
            │   └── completions
            │       └── tio
            └── man
                └── man1
                    └── tio.1.gz

8 directories, 6 files

(you can also see the full tree listing of /c/src/tio_msys2/ in 03_files_after_makepkg.log)

HOWEVER, when I inspect the final package file (the one that actually gets installed by the package manager/pacman), which (I think) is tio-1.37.tar.xz – I see no .exe whatsoever?

$ tar tJvf tio-1.37.tar.xz
drwxrwxr-x lundmar/lundmar   0 2022-04-13 18:01 tio-1.37/
drwxrwxr-x lundmar/lundmar   0 2022-04-13 18:00 tio-1.37/.circleci/
-rw-rw-r-- lundmar/lundmar 1112 2022-04-13 18:00 tio-1.37/.circleci/config.yml
-rw-rw-r-- lundmar/lundmar   34 2022-04-13 18:00 tio-1.37/.gitignore
-rw-rw-r-- lundmar/lundmar 1150 2022-04-13 18:00 tio-1.37/AUTHORS
-rw-rw-r-- lundmar/lundmar 21770 2022-04-13 18:00 tio-1.37/ChangeLog
-rw-rw-r-- lundmar/lundmar   709 2022-04-13 18:00 tio-1.37/LICENSE
-rw-rw-r-- lundmar/lundmar  3988 2022-04-13 18:00 tio-1.37/README.md
drwxrwxr-x lundmar/lundmar     0 2022-04-13 18:00 tio-1.37/images/
-rw-rw-r-- lundmar/lundmar 12344 2022-04-13 18:00 tio-1.37/images/paypal.png
-rw-rw-r-- lundmar/lundmar 1846157 2022-04-13 18:00 tio-1.37/images/tio-demo.gif
drwxrwxr-x lundmar/lundmar       0 2022-04-13 18:00 tio-1.37/man/
-rw-rw-r-- lundmar/lundmar     375 2022-04-13 18:00 tio-1.37/man/meson.build
-rw-rw-r-- lundmar/lundmar    6022 2022-04-13 18:00 tio-1.37/man/tio.1.in
-rw-rw-r-- lundmar/lundmar    1578 2022-04-13 18:00 tio-1.37/meson.build
-rw-rw-r-- lundmar/lundmar     130 2022-04-13 18:00 tio-1.37/meson_options.txt
drwxrwxr-x lundmar/lundmar       0 2022-04-13 18:00 tio-1.37/src/
drwxrwxr-x lundmar/lundmar       0 2022-04-13 18:00 tio-1.37/src/bash-completion/
-rw-rw-r-- lundmar/lundmar     647 2022-04-13 18:00 tio-1.37/src/bash-completion/meson.build
-rw-rw-r-- lundmar/lundmar    3017 2022-04-13 18:00 tio-1.37/src/bash-completion/tio.in
-rw-rw-r-- lundmar/lundmar    6650 2022-04-13 18:00 tio-1.37/src/configfile.c
-rw-rw-r-- lundmar/lundmar    1130 2022-04-13 18:00 tio-1.37/src/configfile.h
-rw-rw-r-- lundmar/lundmar    1251 2022-04-13 18:00 tio-1.37/src/error.c
-rw-rw-r-- lundmar/lundmar     929 2022-04-13 18:00 tio-1.37/src/error.h
-rw-rw-r-- lundmar/lundmar     962 2022-04-13 18:00 tio-1.37/src/iossiospeed.c
-rw-rw-r-- lundmar/lundmar    2394 2022-04-13 18:00 tio-1.37/src/log.c
-rw-rw-r-- lundmar/lundmar     936 2022-04-13 18:00 tio-1.37/src/log.h
-rw-rw-r-- lundmar/lundmar    2313 2022-04-13 18:00 tio-1.37/src/main.c
-rw-rw-r-- lundmar/lundmar     880 2022-04-13 18:00 tio-1.37/src/meson.build
-rw-rw-r-- lundmar/lundmar    2955 2022-04-13 18:00 tio-1.37/src/misc.c
-rw-rw-r-- lundmar/lundmar     967 2022-04-13 18:00 tio-1.37/src/misc.h
-rw-rw-r-- lundmar/lundmar    9897 2022-04-13 18:00 tio-1.37/src/options.c
-rw-rw-r-- lundmar/lundmar    1611 2022-04-13 18:00 tio-1.37/src/options.h
-rw-rw-r-- lundmar/lundmar    1434 2022-04-13 18:00 tio-1.37/src/print.c
-rw-rw-r-- lundmar/lundmar    2113 2022-04-13 18:00 tio-1.37/src/print.h
-rw-rw-r-- lundmar/lundmar    1295 2022-04-13 18:00 tio-1.37/src/setspeed2.c
-rw-rw-r-- lundmar/lundmar    1174 2022-04-13 18:00 tio-1.37/src/signals.c
-rw-rw-r-- lundmar/lundmar     859 2022-04-13 18:00 tio-1.37/src/signals.h
-rw-rw-r-- lundmar/lundmar   24490 2022-04-13 18:00 tio-1.37/src/tty.c
-rw-rw-r-- lundmar/lundmar    1397 2022-04-13 18:00 tio-1.37/src/tty.h
drwxrwxr-x lundmar/lundmar       0 2022-04-13 18:00 tio-1.37/subprojects/
-rw-rw-r-- lundmar/lundmar      82 2022-04-13 18:00 tio-1.37/subprojects/libinih.wrap

In fact, it looks like, only the src, man, images and subprojects subdirectories of the src/tio-1.37 (that is, /c/src/tio_msys2/src/tio-1.37) directory are included (but not the build subdirectory) ?! For reference, this is what this directory lists:

$ ls -1 /c/src/tio_msys2/src/tio-1.37
build/
images/
man/
src/
subprojects/
AUTHORS
ChangeLog
LICENSE
meson.build
meson_options.txt
README.md

So, for some reason, makepkg running on this PKGBUILD file, includes the sources only, but not the packaged output files (that is, the executables)?!

So my question is: where am I going wrong, and how can I have the actual compiled binary executable file (or rather, the package prepared files in the pkg subdirectory) included in the final package file?

(Sidenote: I have also found this PKGBUILD https://github.com/msys2/MSYS2-packages/blob/5391c11/pkgconf/PKGBUILD from MSYS2, which also uses mesonbut manually copies the executables after the meson install step; so maybe I’m supposed to manually copy the executables here as well??)

Leave a Comment