cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zasp...@apache.org
Subject [04/37] cordova-ubuntu git commit: bin/build: produce debian source package instead of binary
Date Mon, 15 Dec 2014 13:32:53 GMT
bin/build: produce debian source package instead of binary


Project: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/commit/d896d28c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/tree/d896d28c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/diff/d896d28c

Branch: refs/heads/master
Commit: d896d28c78a1115d84dd5d5443d3c13e898b7b12
Parents: 46a8fa5
Author: Maxim Ermilov <maxim.ermilov@canonical.com>
Authored: Sun Sep 7 02:18:28 2014 +0400
Committer: Maxim Ermilov <maxim.ermilov@canonical.com>
Committed: Sun Sep 7 02:18:28 2014 +0400

----------------------------------------------------------------------
 bin/build/lib/templates/changelog       |  7 +++
 bin/build/lib/templates/compat          |  1 +
 bin/build/lib/templates/control         | 17 +++++++
 bin/build/lib/templates/cordova.desktop |  7 +++
 bin/build/lib/templates/install         |  3 ++
 bin/build/lib/templates/rules           | 27 +++++++++++
 bin/build/lib/ubuntu.js                 | 70 +++++++++++++++++-----------
 bin/check_reqs                          |  2 +-
 8 files changed, 105 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/d896d28c/bin/build/lib/templates/changelog
----------------------------------------------------------------------
diff --git a/bin/build/lib/templates/changelog b/bin/build/lib/templates/changelog
new file mode 100644
index 0000000..ec94655
--- /dev/null
+++ b/bin/build/lib/templates/changelog
@@ -0,0 +1,7 @@
+{PACKAGE_NAME} ({PACKAGE_VERSION}) trusty; urgency=medium
+
+  [ {MAINTAINER_NAME} ]
+  * upstream release
+
+ -- {MAINTAINER_NAME} <{MAINTAINER_EMAIL}>  Thu, 30 Aug 2014 06:06:06 +0000
+

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/d896d28c/bin/build/lib/templates/compat
----------------------------------------------------------------------
diff --git a/bin/build/lib/templates/compat b/bin/build/lib/templates/compat
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/bin/build/lib/templates/compat
@@ -0,0 +1 @@
+9

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/d896d28c/bin/build/lib/templates/control
----------------------------------------------------------------------
diff --git a/bin/build/lib/templates/control b/bin/build/lib/templates/control
new file mode 100644
index 0000000..51fb082
--- /dev/null
+++ b/bin/build/lib/templates/control
@@ -0,0 +1,17 @@
+Source: {PACKAGE_NAME}
+Section: devel
+Priority: optional
+Maintainer: {MAINTAINER_NAME} <{MAINTAINER_EMAIL}>
+Build-Depends: ubuntu-sdk,
+         qtfeedback5-dev,
+         qtmultimedia5-dev,
+         qtpim5-dev,
+         libqt5sensors5-dev,
+         qtsystems5-dev,
+         qtlocation5-dev,
+         libicu-dev
+
+Package: {PACKAGE_NAME}
+Architecture: any
+Description: {PACKAGE_DESCRIPTION}
+Depends: ubuntu-sdk-libs

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/d896d28c/bin/build/lib/templates/cordova.desktop
----------------------------------------------------------------------
diff --git a/bin/build/lib/templates/cordova.desktop b/bin/build/lib/templates/cordova.desktop
new file mode 100644
index 0000000..dee2f44
--- /dev/null
+++ b/bin/build/lib/templates/cordova.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name={PACKAGE_TITLE}
+Exec=/opt/{PACKAGE_NAME}/cordova-ubuntu
+Terminal=false
+Type=Application
+X-Ubuntu-Touch=true
+Icon={PACKAGE_ICON}

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/d896d28c/bin/build/lib/templates/install
----------------------------------------------------------------------
diff --git a/bin/build/lib/templates/install b/bin/build/lib/templates/install
new file mode 100644
index 0000000..c3e51ca
--- /dev/null
+++ b/bin/build/lib/templates/install
@@ -0,0 +1,3 @@
+/opt/{PACKAGE_NAME}
+/usr/share/applications/*
+

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/d896d28c/bin/build/lib/templates/rules
----------------------------------------------------------------------
diff --git a/bin/build/lib/templates/rules b/bin/build/lib/templates/rules
new file mode 100755
index 0000000..27bc587
--- /dev/null
+++ b/bin/build/lib/templates/rules
@@ -0,0 +1,27 @@
+#!/usr/bin/make -f
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+export CFLAGS := $(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
+export CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) $(shell dpkg-buildflags --get
CPPFLAGS)
+export LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) -Wl,--as-needed
+export QT_SELECT := qt5
+
+DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
+
+# -----------------------------------
+
+%:
+	dh $@ --fail-missing
+
+override_dh_auto_configure:
+	dh_auto_configure -- -DCMAKE_INSTALL_PREFIX=/opt/{PACKAGE_NAME}
+
+override_dh_auto_install:
+	dh_auto_install --destdir=debian/tmp
+	cp -R $(CURDIR)/www/* $(CURDIR)/debian/tmp/opt/{PACKAGE_NAME}/www
+	cp -R $(CURDIR)/debian/config.xml $(CURDIR)/debian/tmp/opt/{PACKAGE_NAME}/
+	cp -R $(CURDIR)/qml/* $(CURDIR)/debian/tmp/opt/{PACKAGE_NAME}/qml
+	mkdir -p $(CURDIR)/debian/tmp/usr/share/applications/
+	cp -R $(CURDIR)/debian/cordova.desktop $(CURDIR)/debian/tmp/usr/share/applications/{PACKAGE_NAME}.desktop

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/d896d28c/bin/build/lib/ubuntu.js
----------------------------------------------------------------------
diff --git a/bin/build/lib/ubuntu.js b/bin/build/lib/ubuntu.js
index 400c84a..43e0b22 100644
--- a/bin/build/lib/ubuntu.js
+++ b/bin/build/lib/ubuntu.js
@@ -276,6 +276,15 @@ function buildClickPackage(campoDir, ubuntuDir, nobuild, architecture,
framework
     });
 }
 
+function fillTemplate(source, dest, obj) {
+    var content = fs.readFileSync(source, {encoding: "utf8"});
+    for (var prop in obj) {
+        content = content.replace(new RegExp('{' + prop + '}', 'g'), obj[prop])
+    }
+
+    fs.writeFileSync(dest, content);
+}
+
 function buildNative(campoDir, ubuntuDir, nobuild, debug) {
     var nativeDir = path.join(ubuntuDir, 'native');
     var prefixDir = path.join(nativeDir, 'prefix');
@@ -322,39 +331,44 @@ function buildNative(campoDir, ubuntuDir, nobuild, debug) {
         debDir = path.join(nativeDir, manifest.name);
 
         shell.rm('-rf', debDir);
-        shell.mkdir('-p', path.join(debDir, 'opt', manifest.name));
-        cp(path.join(prefixDir, '*'), path.join(debDir, 'opt', manifest.name));
-
-        var destDir = path.join('/opt', manifest.name);
-        var icon = fs.readFileSync(path.join(ubuntuDir, 'cordova.desktop'), {encoding: "utf8"}).match(/^Icon=(.+)$/m);
-        var desktopFileContent = '[Desktop Entry]\nName=' + manifest.title + '\nExec=' +
path.join(destDir, 'cordova-ubuntu') + ' ' + path.join(destDir, 'www') + '\nTerminal=false\nType=Application\nX-Ubuntu-Touch=true\n';
-        if (icon) {
-            icon = icon[1];
-            desktopFileContent += 'Icon=' + path.join(destDir, icon) + '\n';
-        } else {
-            desktopFileContent += 'Icon=qmlscene\n';
-        }
 
+        shell.mkdir('-p', path.join(debDir, 'debian'));
+        cp(path.join(campoDir, '*'), debDir);
 
-        var debControlContent = 'Package: ' + manifest.name
-            + '\nVersion: ' + manifest.version
-            + '\nMaintainer: ' + manifest.maintainer
-            + '\nArchitecture: ' + manifest.architecture
-            + '\nDescription: ' + manifest.description
-            + '\nDepends: ubuntu-sdk-libs\n';
+        cp(path.join(ubuntuDir, 'config.xml'), path.join(debDir, 'debian'));
+        cp(path.join(ubuntuDir, 'www', '*'), path.join(debDir, 'www'));
+        cp(path.join(ubuntuDir, 'qml', '*'), path.join(debDir, 'qml'));
 
-        shell.mkdir('-p', path.join(debDir, 'usr', 'share', 'applications'));
-        shell.mkdir('-p', path.join(debDir, 'DEBIAN'));
-        fs.writeFileSync(path.join(debDir, 'DEBIAN', 'control'), debControlContent);
-        fs.writeFileSync(path.join(debDir, 'usr', 'share', 'applications', manifest.name
+ '.desktop'), desktopFileContent);
-
-        pushd(nativeDir);
+        var destDir = path.join('/opt', manifest.name);
 
-        return execAsync('dpkg-deb -b "' + manifest.name + '" .');
-    }).then(function () {
-        shell.rm('-rf', debDir);
+        var icon = fs.readFileSync(path.join(ubuntuDir, 'cordova.desktop'), {encoding: "utf8"}).match(/^Icon=(.+)$/m);
+        icon = icon ? '/opt/' + manifest.name + '/' + icon[1] : 'qmlscene';
+
+        var maintainerEmail = manifest.maintainer.match('<.+>$');
+        maintainerEmail = maintainerEmail?maintainerEmail[0]:'';
+        var maintainerName = manifest.maintainer.replace(maintainerEmail, '').trim();
+        maintainerEmail = maintainerEmail.replace('<', '').replace('>', '');
+
+        var props = { PACKAGE_NAME: manifest.name,
+                      PACKAGE_TITLE: manifest.title,
+                      PACKAGE_VERSION: manifest.version,
+                      MAINTAINER_NAME: maintainerName,
+                      MAINTAINER_EMAIL: maintainerEmail,
+                      PACKAGE_DESCRIPTION: manifest.description,
+                      PACKAGE_ICON: icon };
+        var templateDir = path.join(campoDir, 'bin', 'build', 'lib', 'templates');
+        var templates = [{source: path.join(templateDir, 'changelog'), dest: path.join(debDir,
'debian', 'changelog')},
+                         {source: path.join(templateDir, 'compat'), dest: path.join(debDir,
'debian', 'compat')},
+                         {source: path.join(templateDir, 'control'), dest: path.join(debDir,
'debian', 'control')},
+                         {source: path.join(templateDir, 'rules'), dest: path.join(debDir,
'debian', 'rules')},
+                         {source: path.join(templateDir, 'cordova.desktop'), dest: path.join(debDir,
'debian', 'cordova.desktop')},
+                         {source: path.join(templateDir, 'install'), dest: path.join(debDir,
'debian', manifest.name + '.install')}];
+        for (var i = 0; i < templates.length; i++) {
+            fillTemplate(templates[i].source, templates[i].dest, props);
+        }
 
-        popd();
+        console.error('In order to build debian package, execute'.yellow);
+        console.error(('cd ' + debDir + '; ' + 'debuild').yellow);
     });
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/d896d28c/bin/check_reqs
----------------------------------------------------------------------
diff --git a/bin/check_reqs b/bin/check_reqs
index ffa0b35..56b5a6e 100755
--- a/bin/check_reqs
+++ b/bin/check_reqs
@@ -21,7 +21,7 @@
 
 var exec = require('child_process').exec;
 
-var deps = "cmake libicu-dev pkg-config qtbase5-dev qtchooser qtdeclarative5-dev qtfeedback5-dev
qtlocation5-dev qtmultimedia5-dev qtpim5-dev libqt5sensors5-dev qtsystems5-dev";
+var deps = "cmake libicu-dev pkg-config devscripts qtbase5-dev qtchooser qtdeclarative5-dev
qtfeedback5-dev qtlocation5-dev qtmultimedia5-dev qtpim5-dev libqt5sensors5-dev qtsystems5-dev";
 
 exec("dpkg-query -Wf'${db:Status-abbrev}\\n' click " + deps, function(error, stdout, stderr)
{
     if (error || stdout.indexOf('un') !== -1) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message