Creating a new Package
A package consists of a package recipe in the form of aPKGBUILD file. See thePKGBUILD file forglibas an example. To have your package included in the official repository it hasto end up in the package git repository via a pull request →https://github.com/msys2/MINGW-packages/pulls
Things to consider before creating a PKGBUILD file
- Does the project you'd like to package support Windows and does it support other compilers than MSVC?
- Is the project you'd like to package already in the repo?
- Are all the runtime and build dependencies of that project already in the repo?
- Does building the project work in an MSYS2 environment?
- Is the project packaged inArch Linux or in theAUR, to help you as a reference for both the build process and finding a package name?
Creating a new PKGBUILD file
Many projects are similar to build and package, so it's easiest to just copy anexisting PKGBUILD file as a starting point. You can either look for a packagewith a similar build system and dependencies in our repository or use one of ourPKGBUILD templates:
- CMake - git:PKGBUILD.CMake-git
- CMake - tarball:PKGBUILD.CMake-tarball
- Autotools - tarball:PKGBUILD.autotools-tarball
- Rust/Cargo - tarball:PKGBUILD.cargo-tarball
- Rust/Cargo-C - tarball:PKGBUILD.cargo-c-tarball
- Meson - tarball:PKGBUILD.meson-tarball
- Python - tarball:PKGBUILD.python
After you have decided on a good starting point:
- Decide on a package name. If the project is already packaged in Arch Linux or the AUR then we prefer the same name.
- Create a directory called
mingw-w64-<package-name> - Move your
PKGBUILDfile into that directory. - Fill out your
PKGBUILDfile- Seehttps://wiki.archlinux.org/title/PKGBUILD for details on the format and the meaning of variables and functions.
- See ourPackage Guidelines for how we expect
PKGBUILDfiles to be structured and how they should behave.
- Run
updpkgsumsto update the source checksums in thePKGBUILDfile. - Build the package...
Building the package
Building a package requires a base set of build related packages to be installedfirst. This only needs to be done once:
pacman-S--neededbase-develTo build the package, start a shell in an environment you want to build for,change the working directory to the directory of thePKGBUILD, and run:
makepkg-mingw--cleanbuild--syncdeps--force--noconfirmThis will download all required build dependencies, build your package, and willresult in a*.pkg.tar.zst package in the same directory, if nothing goeswrong.
To install the package you can run:
pacman-U*.pkg.tar.zstmakepkg-mingw has various other helpful options you can add:
--install- to install the built package right away--rmdeps- to remove all packages again that it installed for building--help- to see more options
Proposing the package to be included in our official repository
Once you are pleased with your package and have tested it sufficiently you cancreate a pull request against our package repository →https://github.com/msys2/MINGW-packages/pulls
Once the PR is opened, our CI system will try to build your package in a freshand clean build environment and will also try to build it for all our supportedtarget environments (mingw64, clang64, etc).
There is a chance that this will uncover some issues in your package, such asunspecified build dependencies, or uncover errors in projects that build withgcc but not with clang for example. If that is the case you can try to fix thefound issues or ask us for assistance.
Differences compared to Arch Linux
If you are already accustomed to building packages for Arch Linux, you mightnotice some differences despite us using the same tools:
- Our
PKGBUILDfiles use environment variables such asMINGW_PACKAGE_PREFIXandMINGW_PREFIXin various places so they can be used to build packages for difference environments using the samePKGBUILDfile. - We use
makepkg-mingwinstead ofmakepkg.makepkg-mingwis just a small wrapper aroundmakepkgwhich sets up the right environment and also allows building the same package multiple times for different environments in one go.