简体   繁体   中英

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 meson , but manually copies the executables after the meson install step; so maybe I'm supposed to manually copy the executables here as well??)

OK, it seems, that I had misunderstood what is the actual package file produced by makepkg , which eventually gets installed by pacman .

So far, I was quite persuaded, that it is the tio-1.37.tar.xz file - which, as seen in the OP, does not have the "built"/"executable" files.

However, after re-reading the docs, I noticed https://wiki.archlinux.org/title/makepkg :

Once all dependencies are satisfied and the package builds successfully, a package file ( pkgname-pkgver.pkg.tar.zst ) will be created in the working directory. To install, use -i/--install (same as pacman -U pkgname-pkgver.pkg.tar.zst )

So, the final built package file is actually tio-1.37-1-x86_64.pkg.tar.zst : And if I try to inspect its contents:

$ tar tf tio-1.37-1-x86_64.pkg.tar.zst
.BUILDINFO
.MTREE
.PKGINFO
usr/
usr/bin/
usr/bin/tio.exe
usr/share/
usr/share/bash-completion/
usr/share/bash-completion/completions/
usr/share/bash-completion/completions/tio
usr/share/man/
usr/share/man/man1/
usr/share/man/man1/tio.1.gz

... indeed, it appears that all of the "executable" files are there!

So, first let's check the previously installed version of package tio by pacman :

$ pacman -Qi tio
Name            : tio
Version         : 1.32-1
Description     : A simple TTY terminal I/O application
Architecture    : x86_64
URL             : https://tio.github.io/
Licenses        : GPL
Groups          : None
Provides        : None
Depends On      : None
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 47.00 KiB
Packager        : Alexey Pavlov <alexpux@gmail.com>
Build Date      : Mon, Nov 26, 2018 7:33:50 AM
Install Date    : Thu, Feb 14, 2019 3:53:15 PM
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

$ pacman -Ql tio
tio /usr/
tio /usr/bin/
tio /usr/bin/tio.exe
tio /usr/share/
tio /usr/share/bash-completion/
tio /usr/share/bash-completion/completions/
tio /usr/share/bash-completion/completions/tio
tio /usr/share/licenses/
tio /usr/share/licenses/tio/
tio /usr/share/licenses/tio/COPYING
tio /usr/share/man/
tio /usr/share/man/man1/
tio /usr/share/man/man1/tio.1.gz

$ tio --version | head -2
tio v1.32
Copyright (c) 2014-2018 Martin Lund

... and a quick check of the newly built.zst file, too:

$ pacman -Qi --file tio-1.37-1-x86_64.pkg.tar.zst
Name            : tio
Version         : 1.37-1
Description     : A simple TTY terminal I/O application
Architecture    : x86_64
URL             : https://tio.github.io/
Licenses        : GPL
Groups          : None
Provides        : None
Depends On      : None
Optional Deps   : None
Conflicts With  : None
Replaces        : None
Compressed Size : 24.63 KiB
Installed Size  : 42.12 KiB
Packager        : Unknown Packager
Build Date      : Fri, Apr 29, 2022 4:08:19 PM
Install Script  : No
Validated By    : None
Signatures      : None

... and finally, we can try to install - or rather, upgrade, since the old version is already installed - the newly built package with pacman :

$ pacman -U tio-1.37-1-x86_64.pkg.tar.zst
loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (1) tio-1.37-1

Total Installed Size:  0.04 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring                                           [#######################################] 100%
(1/1) checking package integrity                                         [#######################################] 100%
(1/1) loading package files                                              [#######################################] 100%
(1/1) checking for file conflicts                                        [#######################################] 100%
(1/1) checking available disk space                                      [#######################################] 100%
:: Processing package changes...
(1/1) upgrading tio                                                      [#######################################] 100%

$ tio --version | head -2
tio v1.37
Copyright (c) 2014-2022 Martin Lund

Well, that's great - everything had, in fact, built fine - and it installs fine as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM