aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-06-22 23:34:51 +0200
committerPřemysl Eric Janouch <p@janouch.name>2023-06-26 02:10:31 +0200
commit089c90004ba8f2af9574e3982b20a4b6cb2ab2f1 (patch)
treeb10b84635ec98c89f1c0656be01d70e494366fda
parent19913a5e4880503dd06a73c03584e77d3cf504a0 (diff)
downloadfiv-089c90004ba8f2af9574e3982b20a4b6cb2ab2f1.tar.gz
fiv-089c90004ba8f2af9574e3982b20a4b6cb2ab2f1.tar.xz
fiv-089c90004ba8f2af9574e3982b20a4b6cb2ab2f1.zip
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.
-rw-r--r--README.adoc5
-rw-r--r--fiv.wxs.in69
-rw-r--r--meson.build13
-rwxr-xr-xmsys2-configure.sh2
-rwxr-xr-xmsys2-package.sh30
5 files changed, 116 insertions, 3 deletions
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 @@
+<?xml version='1.0' encoding='utf-8'?>
+<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
+ <?define FullName = "@ProjectName@ @ProjectVersion@" ?>
+ <?if $(sys.BUILDARCH) = x64 ?>
+ <?define ProgramFilesFolder = "ProgramFiles64Folder" ?>
+ <?else?>
+ <?define ProgramFilesFolder = "ProgramFilesFolder" ?>
+ <?endif?>
+
+ <Product Id='*'
+ Name='$(var.FullName)'
+ UpgradeCode='a3e64e2d-4310-4c5f-8562-bb0e0b3e0a53'
+ Language='1033'
+ Codepage='1252'
+ Version='@ProjectVersion@'
+ Manufacturer='Premysl Eric Janouch'>
+
+ <Package Id='*'
+ Keywords='Installer,Image,Viewer'
+ Description='$(var.FullName) Installer'
+ Manufacturer='Premysl Eric Janouch'
+ InstallerVersion='200'
+ Compressed='yes'
+ Languages='1033'
+ SummaryCodepage='1252' />
+
+ <Media Id='1' Cabinet='data.cab' EmbedCab='yes' />
+ <Icon Id='fiv.ico' SourceFile='fiv.ico' />
+ <Property Id='ARPPRODUCTICON' Value='fiv.ico' />
+ <Property Id='ARPURLINFOABOUT' Value='https://git.janouch.name/p/fiv' />
+
+ <UIRef Id='WixUI_Minimal' />
+ <!-- This isn't supported by msitools, but is necessary for WiX.
+ <WixVariable Id='WixUILicenseRtf' Value='License.rtf' />
+ -->
+
+ <Directory Id='TARGETDIR' Name='SourceDir'>
+ <Directory Id='$(var.ProgramFilesFolder)' Name='Files'>
+ <Directory Id='INSTALLDIR' Name='$(var.FullName)' />
+ </Directory>
+
+ <Directory Id='ProgramMenuFolder' Name='Programs'>
+ <Directory Id='ProgramMenuDir' Name='$(var.FullName)'>
+ <Component Id='ProgramMenuDir' Guid='*'>
+ <Shortcut Id='ProgramsMenuShortcut'
+ Name='@ProjectName@'
+ Target='[INSTALLDIR]\fiv.exe'
+ WorkingDirectory='INSTALLDIR'
+ Arguments='"%USERPROFILE%"'
+ Icon='fiv.ico' />
+ <RemoveFolder Id='ProgramMenuDir' On='uninstall' />
+ <RegistryValue Root='HKCU'
+ Key='Software\[Manufacturer]\[ProductName]'
+ Type='string'
+ Value=''
+ KeyPath='yes' />
+ </Component>
+ </Directory>
+ </Directory>
+
+ <Directory Id='DesktopFolder' Name='Desktop' />
+ </Directory>
+
+ <Feature Id='Complete' Level='1'>
+ <ComponentGroupRef Id='CG.fiv' />
+ <ComponentRef Id='ProgramMenuDir' />
+ </Feature>
+ </Product>
+</Wix>
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"