[virt-tools-list] [PATCH virt-viewer] msi: learn to build a non-privileged per-user installer

Marc-André Lureau marcandre.lureau at gmail.com
Thu Jul 11 19:30:18 UTC 2013


With msitools/wixl 0.93, it is now possible to build per-user
installers.
---
 data/Makefile.am          | 25 ++++++++++++++++++++-----
 data/virt-viewer.wxs.in   | 18 ++++++++++++++----
 mingw-virt-viewer.spec.in |  2 +-
 3 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/data/Makefile.am b/data/Makefile.am
index a43374e..75f3ab5 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -43,12 +43,27 @@ virt-viewer-$(WIXL_ARCH)-$(VERSION).msi: virt-viewer.wxs deps.txt
 	     $< virt-viewer-files.wxs &&				\
 	rm -rf $$DESTDIR virt-viewer-files.wxs
 
-msi: virt-viewer-$(WIXL_ARCH)-$(VERSION).msi
+virt-viewer-$(WIXL_ARCH)-user-$(VERSION).msi: virt-viewer.wxs deps.txt
+	$(AM_V_GEN)DESTDIR=`mktemp -d` &&				\
+	make -C $(top_builddir) install DESTDIR=$$DESTDIR >/dev/null &&	\
+	find $$DESTDIR | wixl-heat -p $$DESTDIR$(prefix)/		\
+	    --component-group CG.virt-viewer --var var.DESTDIR		\
+	    --directory-ref=INSTALLDIR > virt-viewer-files.wxs &&	\
+	MANUFACTURER="$(MANUFACTURER)" wixl -D SourceDir=$(prefix)	\
+             -D DESTDIR=$$DESTDIR$(prefix)				\
+	     -D USER=1							\
+             --arch $(WIXL_ARCH)					\
+             -o $@							\
+	     $< virt-viewer-files.wxs &&				\
+	rm -rf $$DESTDIR virt-viewer-files.wxs
+
+msi: virt-viewer-$(WIXL_ARCH)-$(VERSION).msi virt-viewer-$(WIXL_ARCH)-user-$(VERSION).msi
 
-CLEANFILES +=					\
-	deps.txt				\
-	virt-viewer-$(VERSION).exe		\
-	virt-viewer-$(WIXL_ARCH)-$(VERSION).msi	\
+CLEANFILES +=						\
+	deps.txt					\
+	virt-viewer-$(VERSION).exe			\
+	virt-viewer-$(WIXL_ARCH)-$(VERSION).msi		\
+	virt-viewer-$(WIXL_ARCH)-user-$(VERSION).msi	\
 	$(NULL)
 
 else #!WIN32
diff --git a/data/virt-viewer.wxs.in b/data/virt-viewer.wxs.in
index 9f8973e..c53db4e 100644
--- a/data/virt-viewer.wxs.in
+++ b/data/virt-viewer.wxs.in
@@ -15,6 +15,16 @@
       <?define ArchProgramFilesFolder = "ProgramFilesFolder"?>
       <?define Win64 = "no"?>
   <?endif?>
+  <?if $(var.USER) = "1"?>
+      <?define Scope = "perUser"?>
+      <?define Root = "HKCU"?>
+      <?define ArchProgramFilesFolder = "LocalAppDataFolder"?>
+      <?define UserString = " user"?>
+  <?else?>
+      <?define Scope = "perMachine"?>
+      <?define Root = "HKLM"?>
+      <?define UserString = ""?>
+  <?endif?>
 
   <?require spice-gtk.wxi?>
   <?require gtk-vnc.wxi?>
@@ -22,13 +32,13 @@
 
   <?define UpgradeCode = "5B027138-1A63-49E6-877E-055E5EEC1903"?>
   <Product Id="*"
-           Name="VirtViewer $(var.Version) ($(var.ArchString))"
+           Name="VirtViewer $(var.Version) ($(var.ArchString)$(var.UserString))"
            Manufacturer="$(env.MANUFACTURER)"
            Version="$(var.Version)"
            UpgradeCode="$(var.UpgradeCode)"
            Language="1033">
 
-    <Package InstallerVersion="200" Compressed="yes" Comments="comments"/>
+    <Package InstallerVersion="200" Compressed="yes" InstallScope="$(var.Scope)"/>
     <Media Id="1" Cabinet="cabinet.cab" EmbedCab="yes"/>
 
     <Property Id="ARPHELPLINK" Value="http://www.virt-tools.org"/>
@@ -44,12 +54,12 @@
 
     <DirectoryRef Id="TARGETDIR">
       <Component Id="CRegistryEntries" Guid="*">
-        <RegistryKey Root='HKLM' Key='Software\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{96190E9D-6FBB-64DB-9095-29F6FDE0B897}'>
+        <RegistryKey Root='$(var.Root)' Key='Software\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{96190E9D-6FBB-64DB-9095-29F6FDE0B897}'>
           <RegistryValue Type='string' Name='AppPath' Value='[INSTALLDIR]\bin'/>
           <RegistryValue Type='string' Name='AppName' Value='remote-viewer.exe'/>
           <RegistryValue Type='integer' Name='Policy' Value='3'/>
         </RegistryKey>
-        <RegistryKey Root='HKLM' Key='Software\spice-space.org\spicex'>
+        <RegistryKey Root='$(var.Root)' Key='Software\spice-space.org\spicex'>
           <RegistryValue Type='string' Name='client' Value='[INSTALLDIR]\bin\remote-viewer.exe --spice-controller'/>
         </RegistryKey>
       </Component>
diff --git a/mingw-virt-viewer.spec.in b/mingw-virt-viewer.spec.in
index ca2c540..1069c87 100644
--- a/mingw-virt-viewer.spec.in
+++ b/mingw-virt-viewer.spec.in
@@ -43,7 +43,7 @@ BuildRequires:  icoutils
 BuildRequires:  dos2unix
 BuildRequires:  hicolor-icon-theme
 BuildRequires:  gnome-icon-theme
-BuildRequires:  msitools >= 0.92-2
+BuildRequires:  msitools >= 0.93
 
 BuildArch:      noarch
 
-- 
1.8.3.rc1.49.g8d97506




More information about the virt-tools-list mailing list