Skip to contentSkip to conversation

build windows installers in ci

PATCH In review Gerd Hoffmann 2 participants 5 messages Jul 26, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v2 cover build windows installers in ci

With 8619b5ddb56f ("ci: build & store windows installer") merged at least patch 1/3 should go into 6.1 too so the installers created by CI do actually work.

Patches 2+3 are for the guest agent installer.

Gerd Hoffmann (3):
nsis.py: create dlldir automatically
ci: build & store guest agent msi
qemu-ga/msi: fix w32 libgcc name

 scripts/nsis.py                               | 27 ++++++++++++++++---
 .gitlab-ci.d/crossbuild-template.yml          |  3 ++-
 .gitlab-ci.d/crossbuilds.yml                  |  2 ++
 meson.build                                   |  1 +
 qga/installer/qemu-ga.wxs                     |  2 +-
 .../dockerfiles/fedora-win32-cross.docker     |  1 +
 .../dockerfiles/fedora-win64-cross.docker     |  1 +
 7 files changed, 31 insertions(+), 6 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 1/3 nsis.py: create dlldir automatically

Use objdump do figure which dlls are needed. Copy them to a temporary dlldir and pass that directory to makensis.

This patch removes the need to manually copy dlls to $srcdir/dll/w{32,64} to get functional windows installers via "make installer".

---
 scripts/nsis.py | 27 +++++++++++++++++++++++----
 meson.build     |  1 +
 2 files changed, 24 insertions(+), 4 deletions(-)
scripts/nsis.py +23 -4
index 5135a0583167..5a3cc7c09628 100644
@@ -7,6 +7,7 @@
 import argparse
 import glob
 import os
+import sys
 import shutil
 import subprocess
 import tempfile
@@ -19,16 +20,35 @@ def signcode(path):
     subprocess.run([cmd, path])
 
 
+def copydlls(binary, srcdir, dstdir):
+    cmdline = [ "objdump", "-p", binary ]
+    result = subprocess.run(cmdline, stdout = subprocess.PIPE,
+                            universal_newlines = True)
+    if result.returncode != 0:
+        sys.exit(result.returncode)
+    for line in result.stdout.split('\n'):
+        if line.find('DLL Name') != -1:
+            dll = line.split()[2]
+            src = os.path.join(srcdir, dll)
+            dst = os.path.join(dstdir, dll)
+            if os.path.isfile(src) and not os.path.isfile(dst):
+                print("nsis.py: copy " + src)
+                shutil.copyfile(src, dst)
+                copydlls(src, srcdir, dstdir)
+
+
 def main():
     parser = argparse.ArgumentParser(description="QEMU NSIS build helper.")
     parser.add_argument("outfile")
     parser.add_argument("prefix")
     parser.add_argument("srcdir")
     parser.add_argument("cpu")
+    parser.add_argument("dllsrc")
     parser.add_argument("nsisargs", nargs="*")
     args = parser.parse_args()
 
     destdir = tempfile.mkdtemp()
+    dlldir = tempfile.mkdtemp()
     try:
         subprocess.run(["make", "install", "DESTDIR=" + destdir + os.path.sep])
         with open(
@@ -52,6 +72,7 @@ def main():
 
         for exe in glob.glob(os.path.join(destdir + args.prefix, "*.exe")):
             signcode(exe)
+            copydlls(exe, args.dllsrc, dlldir)
 
         makensis = [
             "makensis",
@@ -59,19 +80,17 @@ def main():
             "-NOCD",
             "-DSRCDIR=" + args.srcdir,
             "-DBINDIR=" + destdir + args.prefix,
+            "-DDLLDIR=" + dlldir,
         ]
-        dlldir = "w32"
         if args.cpu == "x86_64":
-            dlldir = "w64"
             makensis += ["-DW64"]
-        if os.path.exists(os.path.join(args.srcdir, "dll")):
-            makensis += ["-DDLLDIR={0}/dll/{1}".format(args.srcdir, dlldir)]
 
         makensis += ["-DOUTFILE=" + args.outfile] + args.nsisargs
         subprocess.run(makensis)
         signcode(args.outfile)
     finally:
         shutil.rmtree(destdir)
+        shutil.rmtree(dlldir)
 
 
 if __name__ == "__main__":
meson.build +1 -0
index f2e148eaf98e..4a2d54fbae3f 100644
@@ -2790,6 +2790,7 @@ if host_machine.system() == 'windows'
     get_option('prefix'),
     meson.current_source_dir(),
     host_machine.cpu(),
+    config_host['QEMU_GA_MSI_MINGW_DLL_PATH'],
     '--',
     '-DDISPLAYVERSION=' + meson.project_version(),
   ]
Signature · 1 line
2.31.1
#2 lore raw

PATCH v2 2/3 ci: build & store guest agent msi

In reply to Gerd Hoffmann

Build guest agent windows msi install package in gitlab CI, store the result as artifact.

---
 .gitlab-ci.d/crossbuild-template.yml               | 3 ++-
 .gitlab-ci.d/crossbuilds.yml                       | 2 ++
 tests/docker/dockerfiles/fedora-win32-cross.docker | 1 +
 tests/docker/dockerfiles/fedora-win64-cross.docker | 1 +
 4 files changed, 6 insertions(+), 1 deletion(-)
.gitlab-ci.d/crossbuild-template.yml +2 -1
index 7d3ad00a1eb9..12f78e81de0d 100644
@@ -12,9 +12,10 @@
           mips64-softmmu ppc-softmmu sh4-softmmu xtensa-softmmu"
     - make -j$(expr $(nproc) + 1) all check-build $MAKE_CHECK_ARGS
     - if grep -q "EXESUF=.exe" config-host.mak;
-      then make installer;
+      then make installer msi;
       version="$(git describe --match v[0-9]*)";
       mv -v qemu-setup*.exe qemu-setup-${version}.exe;
+      mv -v qga/*.msi $(basename qga/*.msi .msi)-${version}.msi;
       fi
 
 # Job to cross-build specific accelerators.
.gitlab-ci.d/crossbuilds.yml +2 -0
index 4ff3aa3cfcdd..fc14a1cf5c10 100644
@@ -163,6 +163,7 @@ cross-win32-system:
   artifacts:
     paths:
       - build/qemu-setup*.exe
+      - build/qemu-ga*.msi
 
 cross-win64-system:
   extends: .cross_system_build_job
@@ -173,6 +174,7 @@ cross-win64-system:
   artifacts:
     paths:
       - build/qemu-setup*.exe
+      - build/qemu-ga*.msi
 
 cross-amd64-xen-only:
   extends: .cross_accel_build_job
tests/docker/dockerfiles/fedora-win32-cross.docker +1 -0
index 5a03e1af43ac..f198927ef56b 100644
@@ -28,6 +28,7 @@ ENV PACKAGES \
     mingw32-pixman \
     mingw32-pkg-config \
     mingw32-SDL2 \
+    msitools \
     perl \
     perl-Test-Harness \
     python3 \
tests/docker/dockerfiles/fedora-win64-cross.docker +1 -0
index d3f13666e82e..fc0b3bf02eff 100644
@@ -25,6 +25,7 @@ ENV PACKAGES \
     mingw64-libtasn1 \
     mingw64-pixman \
     mingw64-pkg-config \
+    msitools \
     perl \
     perl-Test-Harness \
     python3 \
Signature · 1 line
2.31.1
#3 lore raw

PATCH v2 3/3 qemu-ga/msi: fix w32 libgcc name

In reply to Gerd Hoffmann

This is what I find on my Fedora 34 mingw install.

---
 qga/installer/qemu-ga.wxs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qga/installer/qemu-ga.wxs +1 -1
index 9cb4c3d73302..ce7b25b5e16f 100644
@@ -31,7 +31,7 @@
   <?endif?>
 
   <?if $(var.Arch) = "32"?>
-    <?define ArchLib=libgcc_s_sjlj-1.dll?>
+    <?define ArchLib=libgcc_s_dw2-1.dll?>
     <?define GaProgramFilesFolder="ProgramFilesFolder" ?>
   <?endif?>
 
Signature · 1 line
2.31.1
#4 lore raw

Re: [PATCH v2 3/3] qemu-ga/msi: fix w32 libgcc name

Hi

Quoted 13 lines · Gerd Hoffmann

This is what I find on my Fedora 34 mingw install.

---
 qga/installer/qemu-ga.wxs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qga/installer/qemu-ga.wxs +0 -0
index 9cb4c3d73302..ce7b25b5e16f 100644

qga/installer/qemu-ga.wxs line 37

Quoted 8 lines
qga/installer/qemu-ga.wxs +1 -1
@@ -31,7 +31,7 @@
   <?endif?>
 
   <?if $(var.Arch) = "32"?>
-    <?define ArchLib=libgcc_s_sjlj-1.dll?>
+    <?define ArchLib=libgcc_s_dw2-1.dll?>
     <?define GaProgramFilesFolder="ProgramFilesFolder" ?>
   <?endif?>
 

msitools/wixl has Fedora WXI (wxs includes files) for that
https://gitlab.gnome.org/GNOME/msitools/-/blob/master/data/wixl/gcc.wxi

In theory, all you need is: "<?require $DEP.wxi?>" at the top level, and reference the component group "<ComponentGroupRef Id="CG.$DEP"/>"

That's how we handle the dozens for dependencies in virt-viewer/spice.

Signature · 1 line
Marc-André Lureau