From 089c90004ba8f2af9574e3982b20a4b6cb2ab2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Thu, 22 Jun 2023 23:34:51 +0200 Subject: Produce a basic Windows installer package We're very early adopters of msitools' new UI feature, so this doesn't work on MSYS2 directly yet due to an old version. --- README.adoc | 5 ++-- fiv.wxs.in | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ meson.build | 13 ++++++++++ msys2-configure.sh | 2 +- msys2-package.sh | 30 ++++++++++++++++++++++++ 5 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 fiv.wxs.in create mode 100755 msys2-package.sh diff --git a/README.adoc b/README.adoc index 5923dc0..5c8def4 100644 --- a/README.adoc +++ b/README.adoc @@ -65,14 +65,15 @@ Windows ~~~~~~~ 'fiv' can be cross-compiled for Windows, provided that you install a bunch of dependencies listed at the beginning of 'msys2-configure.sh', -plus rsvg-convert from librsvg2, and icotool from icoutils. +plus rsvg-convert from librsvg2, icotool from icoutils, and msitools ≥ 0.102. Beware that the build will take up about a gigabyte of disk space. $ sh -e msys2-configure.sh builddir $ meson install -C builddir If everything succeeds, you will find a portable build of the application -in the 'builddir/package' subdirectory. No installer is provided yet. +in the 'builddir/package' subdirectory, and a very basic MSI installation +package in 'builddir'. Faster colour management ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/fiv.wxs.in b/fiv.wxs.in new file mode 100644 index 0000000..c81fcbb --- /dev/null +++ b/fiv.wxs.in @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/meson.build b/meson.build index ed3acbe..4a9b411 100644 --- a/meson.build +++ b/meson.build @@ -338,6 +338,19 @@ elif meson.is_cross_build() msys2_root = meson.get_external_property('msys2_root') meson.add_install_script('msys2-install.sh', msys2_root) + # TODO: If we used DESTDIR instead of the prefix, this could probably + # be a custom target that invokes "meson install --destdir $(pwd)/package" + # through "meson compile -C builddir msi". Try it out, also in MSYS2. + meson.add_install_script('msys2-package.sh', host_machine.cpu()) + configure_file( + input : 'fiv.wxs.in', + output : 'fiv.wxs', + configuration : configuration_data({ + 'ProjectName' : meson.project_name(), + 'ProjectVersion' : meson.project_version(), + }), + ) + # This is the minimum to run targets from msys2-configure.sh builds. meson.add_devenv({ 'WINEPATH' : msys2_root / 'bin', diff --git a/msys2-configure.sh b/msys2-configure.sh index 8bc1973..9554e4f 100755 --- a/msys2-configure.sh +++ b/msys2-configure.sh @@ -19,7 +19,7 @@ then wine64() { "$@"; } awk() { command awk -v RS='\r?\n' "$@"; } pacman -S --needed libarchive $pkg-ca-certificates $pkg-gcc $pkg-icoutils \ - $pkg-librsvg $pkg-meson $pkg-pkgconf + $pkg-librsvg $pkg-meson $pkg-msitools $pkg-pkgconf fi status() { diff --git a/msys2-package.sh b/msys2-package.sh new file mode 100755 index 0000000..419ee21 --- /dev/null +++ b/msys2-package.sh @@ -0,0 +1,30 @@ +#!/bin/sh -e +export LC_ALL=C.UTF-8 +cd "$MESON_BUILD_ROOT" + +txt2rtf() { + iconv -f utf-8 -t ascii//translit "$@" | awk 'BEGIN { + print "{\\rtf1\\ansi\\ansicpg1252\\deff0{\\fonttbl{\\f0 Tahoma;}}" + print "\\f0\\fs24{\\pard\\sa240" + } { + gsub(/\\/, "\\\\"); gsub(/{/, "\\{"); gsub(/}/, "\\}") + if (!$0) { print "\\par}{\\pard\\sa240"; prefix = "" } + else { print prefix $0; prefix = " " } + } END { + print "\\par}}" + }' +} + +# We're being passed host_machine.cpu(), which will be either x86 or x86_64. +[ "$1" = "x86" ] && arch=x86 || arch=x64 + +wxs=fiv.wxs files=fiv-files.wxs msi=fiv.msi + +txt2rtf "$MESON_SOURCE_ROOT/LICENSE" > License.rtf +find "$MESON_INSTALL_DESTDIR_PREFIX" -type f \ + | wixl-heat --prefix "$MESON_INSTALL_DESTDIR_PREFIX/" \ + --directory-ref INSTALLDIR --component-group CG.fiv \ + --var var.SourceDir > "$files" + +wixl --verbose --arch "$arch" -D SourceDir="$MESON_INSTALL_DESTDIR_PREFIX" \ + --ext ui --output "$msi" "$wxs" "$files" -- cgit v1.2.3