[pve-devel] [PATCH novnc v2 7/7] build from prebuilt app.js and add 'from-source' make target

Dominik Csapak d.csapak at proxmox.com
Wed May 17 09:29:46 CEST 2017


this patch changes the 'deb' target so that it builds the package from
the included, prebuilt app.js, and it adds a new target 'from-source'
which uses npm/node to build the app.js (using the build script from
novnc; it also autobuilds the package when using this)

when npm is not installed, you get an error saying you have to install
nodejs from the nodejs repositories

then we have to introduce a new patch to change the <script> tag to make
use of this new file

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 Makefile                                  | 30 +++++++++++++++------
 debian/install                            |  6 +----
 debian/patches/0010-use-only-app.js.patch | 44 +++++++++++++++++++++++++++++++
 debian/patches/series                     |  1 +
 4 files changed, 68 insertions(+), 13 deletions(-)
 create mode 100644 debian/patches/0010-use-only-app.js.patch

diff --git a/Makefile b/Makefile
index 4ac049f..1547689 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,7 @@ VER=0.6
 PKGREL=1
 
 SRCDIR=novnc
+BUILTDIR=built
 
 ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
 GITVERSION:=$(shell cat .git/refs/heads/master)
@@ -14,18 +15,31 @@ all: ${DEB}
 
 .PHONY: deb
 deb: ${DEB}
-${DEB}: | submodule
-	rm -rf ${SRCDIR}.tmp
-	cp -rpa ${SRCDIR} ${SRCDIR}.tmp
-	cp -a debian ${SRCDIR}.tmp/debian
-	echo "git clone git://git.proxmox.com/git/novnc-pve.git\\ngit checkout ${GITVERSION}" > ${SRCDIR}.tmp/debian/SOURCE
-	cd ${SRCDIR}.tmp; dpkg-buildpackage -rfakeroot -b -uc -us
+${DEB}: ${BUILTDIR} | submodule
+	rm -rf ${BUILTDIR}.tmp
+	cp -rpa ${BUILTDIR} ${BUILTDIR}.tmp
+	cp -a debian ${BUILTDIR}.tmp/debian
+	cp -a ${SRCDIR}/* ${BUILTDIR}.tmp/
+	echo "git clone git://git.proxmox.com/git/novnc-pve.git\\ngit checkout ${GITVERSION}" > ${BUILTDIR}.tmp/debian/SOURCE
+	cd ${BUILTDIR}.tmp; dpkg-buildpackage -rfakeroot -b -uc -us
 	lintian ${DEB}
 	@echo ${DEB}
 
+.PHONY: from-source
+from-source: | submodule
+	@npm --version || (echo "Please install nodejs/npm from nodejs.org"; false)
+	rm -rf ${SRCDIR}.tmp
+	cp -rpa ${SRCDIR} ${SRCDIR}.tmp
+	cp -a debian/patches ${SRCDIR}.tmp/patches
+	cd ${SRCDIR}.tmp; quilt push -a
+	cd ${SRCDIR}.tmp; npm install
+	cd ${SRCDIR}.tmp; node ./utils/use_require.js --with-app --as commonjs
+	cp -rpa ${SRCDIR}.tmp/build/app.js ./${BUILTDIR}
+	${MAKE} deb
+
 .PHONY: submodule
 submodule:
-	test -f "${SRCDIR}/vnc.html" || git submodule update --init
+	@test -f "${SRCDIR}/vnc.html" || git submodule update --init
 
 .PHONY: download
 download ${SRCDIR}:
@@ -40,7 +54,7 @@ distclean: clean
 
 .PHONY: clean
 clean:
-	rm -rf *~ debian/*~ *_${ARCH}.deb ${SRCDIR}.tmp *_all.deb *.changes *.dsc *.buildinfo
+	rm -rf *~ debian/*~ *_${ARCH}.deb ${BUILTDIR}.tmp ${SRCDIR}.tmp *_all.deb *.changes *.dsc *.buildinfo
 
 .PHONY: dinstall
 dinstall: deb
diff --git a/debian/install b/debian/install
index 37f355f..8113943 100644
--- a/debian/install
+++ b/debian/install
@@ -1,7 +1,3 @@
 app usr/share/novnc-pve
-core usr/share/novnc-pve
-docs usr/share/novnc-pve
-po usr/share/novnc-pve
-utils usr/share/novnc-pve
-vendor usr/share/novnc-pve
+app.js usr/share/novnc-pve
 index.html.tpl usr/share/novnc-pve
diff --git a/debian/patches/0010-use-only-app.js.patch b/debian/patches/0010-use-only-app.js.patch
new file mode 100644
index 0000000..e225250
--- /dev/null
+++ b/debian/patches/0010-use-only-app.js.patch
@@ -0,0 +1,44 @@
+From 6d3945c7c0b680a871d789215659f04e42acd6e7 Mon Sep 17 00:00:00 2001
+From: Dominik Csapak <d.csapak at proxmox.com>
+Date: Tue, 16 May 2017 10:36:15 +0200
+Subject: [PATCH 10/10] use only app.js
+
+because we will use the commonjs version,
+we only need to use the generated app.js
+
+Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
+---
+ vnc.html | 17 +----------------
+ 1 file changed, 1 insertion(+), 16 deletions(-)
+
+diff --git a/vnc.html b/vnc.html
+index ff70e0c..40c726b 100644
+--- a/vnc.html
++++ b/vnc.html
+@@ -46,22 +46,7 @@
+     </script>
+ 
+     <!-- begin scripts -->
+-    <!-- promise polyfills promises for IE11 -->
+-    <script src="/novnc/vendor/promise.js"></script>
+-    <!-- ES2015/ES6 modules polyfill -->
+-    <script type="module">
+-        window._noVNC_has_module_support = true;
+-    </script>
+-    <script>
+-        window.addEventListener("load", function() {
+-            if (window._noVNC_has_module_support) return;
+-            var loader = document.createElement("script");
+-            loader.src = "/novnc/vendor/browser-es-module-loader/dist/browser-es-module-loader.js";
+-            document.head.appendChild(loader);
+-        });
+-    </script>
+-    <!-- actual script modules -->
+-    <script type="module" src="/novnc/app/ui.js"></script>
++    <script src="/novnc/app.js"></script>
+     <!-- end scripts -->
+ </head>
+ 
+-- 
+2.11.0
+
diff --git a/debian/patches/series b/debian/patches/series
index f528c37..086ff43 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -7,3 +7,4 @@
 0007-add-replaceable-snippets-in-vnc.html.patch
 0008-focus-canvas-after-load.patch
 0009-decrease-animation-time.patch
+0010-use-only-app.js.patch
-- 
2.11.0





More information about the pve-devel mailing list