File: 1001-Support-building-without-clickable.patch

package info (click to toggle)
lomiri-cloudsync-app 0.8.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,420 kB
  • sloc: cpp: 1,053; python: 67; javascript: 25; makefile: 19; sh: 9
file content (587 lines) | stat: -rw-r--r-- 20,086 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
From: Guido Berhoerster <guido+debian@berhoerster.name>
Date: Tue, 12 Nov 2024 09:03:07 +0100
Subject: Support building without clickable

Use system qwebdavlib.
Add customizable installation paths.
Fix hardcoded paths.
Add compatibility layer for i18n.

diff --git a/OwncloudSync/OwncloudSync.pro b/OwncloudSync/OwncloudSync.pro
--- a/OwncloudSync/OwncloudSync.pro
+++ b/OwncloudSync/OwncloudSync.pro
@@ -3,7 +3,9 @@ TARGET = OwncloudSync
 QT += qml quick dbus xml network
 CONFIG += qt plugin c++11
 
-load(ubuntu-click)
+include($$PWD/../common-install.pri)
+
+click:load(ubuntu-click)
 
 TARGET = $$qtLibraryTarget($$TARGET)
 
@@ -33,13 +35,21 @@ OTHER_FILES = qmldir
 }
 
 qmldir.files = qmldir
-installPath = $${UBUNTU_CLICK_PLUGIN_PATH}/OwncloudSync
+
+click {
+    INCLUDEPATH += $$PWD/../qwebdavlib
+    DEPENDPATH += $$PWD/../qwebdavlib
+
+    LIBS += -L$$OUT_PWD/../qwebdavlib/ -lqwebdav
+
+    installPath = $${UBUNTU_CLICK_PLUGIN_PATH}/OwncloudSync
+} else {
+    CONFIG += link_pkgconfig
+    PKGCONFIG += qwebdav-qt5
+
+    installPath = $${INSTALL_QML}/OwncloudSync
+}
+
 qmldir.path = $$installPath
 target.path = $$installPath
 INSTALLS += target qmldir
-
-INCLUDEPATH += $$PWD/../qwebdavlib
-DEPENDPATH += $$PWD/../qwebdavlib
-
-#LIBS += -L$$OUT_PWD/../qwebdavlib/ -lqwebdav
-LIBS += -L$$OUT_PWD/../qwebdavlib/ -lqwebdav
diff --git a/OwncloudSync/servicecontrol.cpp b/OwncloudSync/servicecontrol.cpp
--- a/OwncloudSync/servicecontrol.cpp
+++ b/OwncloudSync/servicecontrol.cpp
@@ -65,12 +65,11 @@ bool ServiceControl::installServiceFile()
     f.write("[Service]\n");
     f.write("Type=simple\n");
     f.write("WorkingDirectory=%h/.config/ubsync\n");
-#if INTPTR_MAX == INT64_MAX
-    f.write("Environment=\"LD_LIBRARY_PATH=/opt/click.ubuntu.com/ubsync/current/lib/aarch64-linux-gnu/\"\n");
-    f.write("ExecStart=/opt/click.ubuntu.com/ubsync/current/lib/aarch64-linux-gnu/bin/" + m_serviceName.toUtf8() + "\n");
+#if defined(CLICK_LIB_PATH) && defined(CLICK_BIN_PATH)
+    f.write("Environment=\"LD_LIBRARY_PATH=" CLICK_LIB_PATH "\"\n");
+    f.write("ExecStart=" CLICK_BIN_PATH "" + m_serviceName.toUtf8() + "\n");
 #else
-    f.write("Environment=\"LD_LIBRARY_PATH=/opt/click.ubuntu.com/ubsync/current/lib/arm-linux-gnueabihf/\"\n");
-    f.write("ExecStart=/opt/click.ubuntu.com/ubsync/current/lib/arm-linux-gnueabihf/bin/" + m_serviceName.toUtf8() + "\n");
+    f.write("ExecStart=/usr/bin/" + m_serviceName.toUtf8() + "\n");
 #endif
     f.write("\n");
     f.write("[Install]\n");
diff --git a/OwncloudSyncd/OwncloudSyncd.pro b/OwncloudSyncd/OwncloudSyncd.pro
--- a/OwncloudSyncd/OwncloudSyncd.pro
+++ b/OwncloudSyncd/OwncloudSyncd.pro
@@ -5,10 +5,9 @@ TARGET = OwncloudSyncd
 CONFIG += console
 CONFIG -= app_bundle
 
-INCLUDEPATH += /usr/include/accounts-qt5
-INCLUDEPATH += /usr/include/signon-qt5
+include($$PWD/../common-install.pri)
 
-load(ubuntu-click)
+click:load(ubuntu-click)
 
 TEMPLATE = app
 
@@ -18,12 +17,29 @@ SOURCES += main.cpp \
 HEADERS += \
     owncloudsyncd.h
 
-# Default rules for deployment.
-target.path = $${UBUNTU_CLICK_BINARY_PATH}
-INSTALLS+=target
+click {
+    INCLUDEPATH += /usr/include/accounts-qt5
+    INCLUDEPATH += /usr/include/signon-qt5
+
+    LIBS += -laccounts-qt5
+    LIBS += -lsignon-qt5
+
+    target.path = $${UBUNTU_CLICK_BINARY_PATH}
 
-LIBS += -laccounts-qt5
-LIBS += -lsignon-qt5
+    arch_triplet = $$system(dpkg-architecture -qDEB_HOST_MULTIARCH)
+    click_lib_path = /opt/click.ubuntu.com/ubsync/current/lib/$${arch_triplet}
+    click_bin_path = $${click_lib_path}/bin
+    DEFINES += \
+        CLICK_LIB_PATH=\\\"$${click_lib_path}\\\" \
+        CLICK_BIN_PATH=\\\"$${click_bin_path}\\\"
+} else {
+    CONFIG += link_pkgconfig
+    PKGCONFIG += \
+        accounts-qt5 \
+        libsignon-qt5 \
+        qwebdav-qt5
 
-#unix: CONFIG += link_pkgconfig
-#unix: PKGCONFIG += accounts-qt5
+    target.path = $${INSTALL_BINS}
+}
+
+INSTALLS+=target
diff --git a/OwncloudSyncd/owncloudsyncd.cpp b/OwncloudSyncd/owncloudsyncd.cpp
--- a/OwncloudSyncd/owncloudsyncd.cpp
+++ b/OwncloudSyncd/owncloudsyncd.cpp
@@ -169,26 +169,12 @@ QStringList OwncloudSyncd::getLastSync(){
  * @return owncloudcmd PATH
  */
 QString OwncloudSyncd::getOwncloudCmd(){
-
-    QString owncloudcmd;
-
-#if INTPTR_MAX == INT64_MAX
-    qDebug() << "Arm64";
-    if( QFile("/opt/click.ubuntu.com/ubsync/current/lib/aarch64-linux-gnu/bin/owncloudcmd").exists()){
-        owncloudcmd = "/opt/click.ubuntu.com/ubsync/current/lib/aarch64-linux-gnu/bin/owncloudcmd";
-#else
-    qDebug() << "Arm32";
-    if( QFile("/opt/click.ubuntu.com/ubsync/current/lib/arm-linux-gnueabihf/bin/owncloudcmd").exists()){
-        owncloudcmd = "/opt/click.ubuntu.com/ubsync/current/lib/arm-linux-gnueabihf/bin/owncloudcmd";
+    QString owncloudcmd =
+#ifdef CLICK_BIN_PATH
+        CLICK_BIN_PATH "/"
 #endif
-        qDebug() << "Using Arm owncloudcmd Binary - Mobile";
-    } else{
-        owncloudcmd = "owncloudcmd";
-        qDebug() << "Using System owncloudcmd Binary - Desktop";
-    }
-
+        "owncloudcmd";
     return owncloudcmd;
-
 }
 
 
diff --git a/UBsync-ui/UBsync-ui.pro b/UBsync-ui/UBsync-ui.pro
--- a/UBsync-ui/UBsync-ui.pro
+++ b/UBsync-ui/UBsync-ui.pro
@@ -1,14 +1,15 @@
 TEMPLATE = aux
 TARGET = UBsync-ui
 
+include($$PWD/../common-install.pri)
+
 RESOURCES += UBsync-ui.qrc
 
 QML_FILES += $$files(*.qml,true) \
              $$files(*.js,true)
 
 CONF_FILES +=  UBsync.apparmor \
-               UBsync.accounts \
-               UBsync.png
+               UBsync.accounts
 
 AP_TEST_FILES += tests/autopilot/run \
                  $$files(tests/*.py,true)
@@ -16,38 +17,66 @@ AP_TEST_FILES += tests/autopilot/run \
 OTHER_FILES += $${CONF_FILES} \
                $${QML_FILES} \
                $${AP_TEST_FILES} \
+               UBsync.png \
+               UBsync.svg \
                UBsync.desktop
 
+click {
+    desktop_path = /UBsync-ui
+    desktop_icon = UBsync-ui/UBsync.png
+    icon_path = /UBsync-ui
+} else {
+    desktop_path = $${INSTALL_DATA}/applications
+    desktop_icon = UBsync
+    icon_path = $${INSTALL_DATA}/pixmaps
+}
 
 #specify where the qml/js files are installed to
-qml_files.path = /UBsync-ui
+qml_files.path = $${INSTALL_DATA}/UBsync-ui
 qml_files.files += *.qml #$${QML_FILES}
 
 #specify where the ui qml/js files are installed to
-ui_files.path = /UBsync-ui/ui
+ui_files.path = $${INSTALL_DATA}/UBsync-ui/ui
 ui_files.files += ui/*.qml ui/*.js
 
+asset_files.path = $${qml_files.path}
+asset_files.files += UBsync.svg
+
 #specify where the component qml/js files are installed to
-component_files.path = /UBsync-ui/components
+component_files.path = $${INSTALL_DATA}/UBsync-ui/components
 component_files.files += components/*.qml
 
-#specify where the config files are installed to
-config_files.path = /UBsync-ui
-config_files.files += $${CONF_FILES}
-
-owncloud_files.path = /lib/
-owncloud_files.files += aarch64-linux-gnu/bin/*
-owncloud_files.files += aarch64-linux-gnu/lib/*
-owncloud_files.files += arm-linux-gnueabihf/bin/*
-owncloud_files.files += arm-linux-gnueabihf/lib/*
+#specify where the icon file is installed to
+icon_file.path = $${icon_path}
+icon_file.files = UBsync.png
 
 #install the desktop file, a translated version is
 #automatically created in the build directory
-desktop_file.path = /UBsync-ui
+desktop_file.path = $${desktop_path}
 desktop_file.files = $$OUT_PWD/UBsync.desktop
 desktop_file.CONFIG += no_check_exist
 
-INSTALLS+=config_files qml_files desktop_file owncloud_files ui_files component_files
+click {
+    #specify where the config files are installed to
+    config_files.path = $${INSTALL_DATA}/UBsync-ui
+    config_files.files += $${CONF_FILES}
+    INSTALLS += config_files
+
+    owncloud_files.path = /lib/
+    owncloud_files.files += aarch64-linux-gnu/bin/*
+    owncloud_files.files += aarch64-linux-gnu/lib/*
+    owncloud_files.files += arm-linux-gnueabihf/bin/*
+    owncloud_files.files += arm-linux-gnueabihf/lib/*
+    INSTALLS += owncloud_files
+}
+
+INSTALLS += \
+    qml_files \
+    asset_files \
+    icon_file \
+    desktop_file \
+    ui_files \
+    component_files
 
 DISTFILES += \
     ui/AboutPage.qml \
diff --git a/UBsync-ui/UBsync.desktop b/UBsync-ui/UBsync.desktop
deleted file mode 100644
--- a/UBsync-ui/UBsync.desktop
+++ /dev/null
@@ -1,8 +0,0 @@
-[Desktop Entry]
-_Name=UBsync
-Exec=qmlscene %U UBsync-ui/Main.qml
-Icon=UBsync-ui/UBsync.png
-Terminal=false
-Type=Application
-X-Ubuntu-Touch=true
-
diff --git a/UBsync-ui/UBsync.desktop.in b/UBsync-ui/UBsync.desktop.in
new file mode 100644
--- /dev/null
+++ b/UBsync-ui/UBsync.desktop.in
@@ -0,0 +1,8 @@
+[Desktop Entry]
+_Name=UBsync
+Exec=qmlscene %U UBsync-ui/Main.qml
+Icon=UBsync-ui/UBsync.png
+Terminal=false
+Type=Application
+X-Ubuntu-Touch=true
+
diff --git a/UBsync-ui/ui/AboutPage.qml b/UBsync-ui/ui/AboutPage.qml
--- a/UBsync-ui/ui/AboutPage.qml
+++ b/UBsync-ui/ui/AboutPage.qml
@@ -47,7 +47,7 @@ Page {
                 height: width
                 anchors.horizontalCenter: parent.horizontalCenter
                 source: Image {
-                   source: "../UBsync.png"
+                   source: "../UBsync.svg"
                 }
 
                 MouseArea{
diff --git a/UBsync.pro b/UBsync.pro
--- a/UBsync.pro
+++ b/UBsync.pro
@@ -5,16 +5,23 @@ TEMPLATE = subdirs
 
 CONFIG += -std=gnu++11
 
-#load Ubuntu specific features
-load(ubuntu-click)
+SUBDIRS += \
+    UBsync-ui \
+    OwncloudSync \
+    OwncloudSyncd
 
-SUBDIRS += qwebdavlib \
-           UBsync-ui \
-           OwncloudSync \
-           OwncloudSyncd
+click {
+    #load Ubuntu specific features
+    load(ubuntu-click)
+
+    SUBDIRS += qwebdavlib
+
+    # what subproject depends on others
+    OwncloudSync.depends = qwebdavlib
+} else {
+    SUBDIRS += accounts
+}
 
-# what subproject depends on others
-OwncloudSync.depends = qwebdavlib
 # specify the manifest file, this file is required for click
 # packaging and for the IDE to create runconfigurations
 UBUNTU_MANIFEST_FILE=manifest.json.in
@@ -30,12 +37,14 @@ UBUNTU_TRANSLATION_DOMAIN="ubsync"
 UBUNTU_TRANSLATION_SOURCES+= \
     $$files(*.qml,true) \
     $$files(*.js,true) \
-    $$files(*.desktop,true)
+    $$files(*.desktop.in,true)
 
 # specifies all translations files and makes sure they are
 # compiled and installed into the right place in the click package
 UBUNTU_PO_FILES+=$$files(po/*.po)
 
+include(ubuntu-translations-compat.pri)
+
 aptest.target   = autopilot
 aptest.commands = bash $$PWD/UBsync-ui/tests/autopilot/run
 aptest.depends  = sub-Owncloud-Sync
@@ -45,7 +54,3 @@ unittest.commands = /usr/bin/qmltestrunner -input $$PWD/UBsync-ui/tests/unit
 unittest.depends  = sub-Owncloud-Sync
 
 QMAKE_EXTRA_TARGETS += aptest unittest
-
-DISTFILES += \
-
-
diff --git a/accounts/accounts.pro b/accounts/accounts.pro
new file mode 100644
--- /dev/null
+++ b/accounts/accounts.pro
@@ -0,0 +1,16 @@
+TEMPLATE = aux
+TARGET = accounts
+
+include($$PWD/../common-install.pri)
+
+application_files.path = $${INSTALL_DATA}/accounts/applications
+application_files.files = *.application
+INSTALLS += application_files
+
+service_files.path = $${INSTALL_DATA}/accounts/services/lomiri
+service_files.files = *.service
+INSTALLS += service_files
+
+DISTFILES += \
+    $${application_files.files} \
+    $${service_files.files}
diff --git a/accounts/ubsync_UBsync.application b/accounts/ubsync_UBsync.application
new file mode 100644
--- /dev/null
+++ b/accounts/ubsync_UBsync.application
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<application id="ubsync_UBsync">
+  <description>Cloud Synchronization</description>
+  <desktop-entry>UBsync.desktop</desktop-entry>
+  <translations>UBsync</translations>
+  <profile>ubsync_UBsync</profile>
+  <services>
+    <service id="ubsync_UBsync_nextcloud">
+      <description>NextCloud Synchronization</description>
+    </service>
+    <service id="ubsync_UBsync_owncloud">
+      <description>OwnCloud Synchronization</description>
+    </service>
+  </services>
+</application>
diff --git a/accounts/ubsync_UBsync_nextcloud.service b/accounts/ubsync_UBsync_nextcloud.service
new file mode 100644
--- /dev/null
+++ b/accounts/ubsync_UBsync_nextcloud.service
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service id="ubsync_UBsync_nextcloud">
+  <type>ubsync_UBsync</type>
+  <provider>nextcloud</provider>
+  <name>Nextcloud</name>
+  <profile>ubsync_UBsync</profile>
+  <translations>UBsync</translations>
+</service>
diff --git a/accounts/ubsync_UBsync_owncloud.service b/accounts/ubsync_UBsync_owncloud.service
new file mode 100644
--- /dev/null
+++ b/accounts/ubsync_UBsync_owncloud.service
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service id="ubsync_UBsync_owncloud">
+  <type>ubsync_UBsync</type>
+  <provider>owncloud</provider>
+  <name>Owncloud</name>
+  <profile>ubsync_UBsync</profile>
+  <translations>UBsync</translations>
+</service>
diff --git a/common-install.pri b/common-install.pri
new file mode 100644
--- /dev/null
+++ b/common-install.pri
@@ -0,0 +1,26 @@
+!click {
+    INSTALL_PREFIX = $$[QT_INSTALL_PREFIX]
+    !isEmpty(PREFIX) {
+        INSTALL_PREFIX = $${PREFIX}
+    }
+    INSTALL_BINS = $$[QT_INSTALL_BINS]
+    !isEmpty(BINDIR) {
+        INSTALL_BINS = $${BINDIR}
+    }
+    INSTALL_LIBS = $$[QT_INSTALL_LIBS]
+    !isEmpty(LIBDIR) {
+        INSTALL_LIBS = $${LIBDIR}
+    }
+    INSTALL_HEADERS = $$[QT_INSTALL_HEADERS]
+    !isEmpty(HEADERDIR) {
+        INSTALL_HEADERS = $${HEADERDIR}
+    }
+    INSTALL_DATA = $$[QT_INSTALL_DATA]
+    !isEmpty(DATADIR) {
+        INSTALL_DATA = $${DATADIR}
+    }
+    INSTALL_QML = $$[QT_INSTALL_QML]
+    !isEmpty(QMLDIR) {
+        INSTALL_QML = $${QMLDIR}
+    }
+}
diff --git a/ubuntu-translations-compat.pri b/ubuntu-translations-compat.pri
new file mode 100644
--- /dev/null
+++ b/ubuntu-translations-compat.pri
@@ -0,0 +1,126 @@
+isEmpty(INSTALL_DATA):include(common-install.pri)
+# compatibility with the Clickable Ubuntu SDK image, code imported from
+# https://gitlab.com/clickable/clickable-docker-images/-/blob/a3ae87bc690014e68ccf19c3e2ee10d37458c6c4/ubuntu-sdk/20.04-cross-build/ubuntu-click-tools.prf
+!click {
+    defineTest(ubuntuAddPreTargetDep) {
+        equals(TEMPLATE,subdirs) {
+            #this hack adds a extra "first" target dependency
+            #because subdirs can not handle build dependencies
+            isEmpty(target_first.target){
+                target_first.target = first
+                QMAKE_EXTRA_TARGETS += target_first
+                export(QMAKE_EXTRA_TARGETS)
+            }
+            target_first.depends += $$1
+
+            export(target_first)
+            export(target_first.target)
+            export(target_first.depends)
+        } else {
+            PRE_TARGETDEPS+=$$1
+            export(PRE_TARGETDEPS)
+        }
+    }
+
+    !isEmpty(UBUNTU_TRANSLATION_SOURCES){
+        isEmpty(UBUNTU_TRANSLATION_DOMAIN):error("UBUNTU_TRANSLATION_DOMAIN not defined")
+
+        # iterate over all QML/JS files and create a basic translation template
+        template_pot.target=$$_PRO_FILE_PWD_/po/$${UBUNTU_TRANSLATION_DOMAIN}.pot
+        for(filelist, UBUNTU_TRANSLATION_SOURCES) {
+            resolved_filelist = $$absolute_path($$filelist,$$_PRO_FILE_PWD_)
+            resolved_filelist = $$files($$resolved_filelist)
+
+            for(file,resolved_filelist) {
+                RESULT = $$find(file, "\\.desktop(\\.in)?$")
+                count(RESULT, 1) {
+                    # extract the strings from the desktop file, and feed them to xgettext
+                    target_file = "$$shadowed($$_PRO_FILE_PWD_)/$$relative_path($$file,$$_PRO_FILE_PWD_).h"
+                    target_dir  = $$dirname(target_file)
+                    target_name = $$replace(target_file,"[/.-]","_")
+
+                    $${target_name}.target=$$target_file
+                    $${target_name}.commands=mkdir -p $$target_dir && cd $$target_dir && intltool-extract --type="gettext/ini" --update --srcdir=$$dirname(file) $$basename(file)
+                    $${target_name}.depends+=$$file
+                    QMAKE_EXTRA_TARGETS+=$$target_name
+
+                    template_pot.depends+=$$target_file
+                    QMAKE_CLEAN += $$target_file
+
+                    translated_desktop_files+=$$file
+                } else {
+                    template_pot.depends+=$$file
+                }
+            }
+        }
+
+        !isEmpty(template_pot.depends) {
+            template_pot.commands=mkdir -p $$_PRO_FILE_PWD_/po && xgettext -o $$template_pot.target --qt --c++ --from-code=UTF-8 --add-comments=TRANSLATORS --keyword=tr --keyword=tr:1,2 --keyword=N_ $$template_pot.depends
+
+            QMAKE_EXTRA_TARGETS+=template_pot
+            ubuntuAddPreTargetDep($${template_pot.target})
+        }
+
+        !isEmpty(UBUNTU_PO_FILES){
+            # compile the mo files into po files
+            for(filelist, UBUNTU_PO_FILES) {
+                resolved_filelist = $$absolute_path($$filelist,$$_PRO_FILE_PWD_)
+                resolved_filelist = $$files($$resolved_filelist)
+                for(file,resolved_filelist) {
+                    lang=$$basename(file)
+                    lang=$$split(lang, .)
+                    lang=$$first(lang)
+
+                    # add a target that automatically updates the po files from the template
+                    update_target_file = $$shadowed($$_PRO_FILE_PWD_)/po/$$basename(file).updated
+
+                    target_name=update_po_target_$$lang
+                    $${target_name}.target = $${update_target_file}
+                    $${target_name}.commands =mkdir -p $$shadowed($$_PRO_FILE_PWD_)/po/ && cd $$_PRO_FILE_PWD_/po && LC_ALL=C intltool-update -d $$lang -g $${UBUNTU_TRANSLATION_DOMAIN} -x && touch $${update_target_file}
+                    $${target_name}.depends+=$${template_pot.target}
+
+                    QMAKE_EXTRA_TARGETS+=$$target_name
+                    QMAKE_CLEAN += $$update_target_file
+                    ubuntuAddPreTargetDep($${update_target_file})
+
+                    # build the .mo files
+                    target_name=mo_target_$$lang
+                    target_file=$$shadowed($$_PRO_FILE_PWD_)/po/$${lang}/$${UBUNTU_TRANSLATION_DOMAIN}.mo
+
+                    $${target_name}.target=$$target_file
+                    $${target_name}.commands=mkdir -p po/$${lang} && LC_ALL=C msgfmt -o $${target_file} $$absolute_path($$file,$$_PRO_FILE_PWD_)
+                    $${target_name}.depends+=$$absolute_path($$file,$$_PRO_FILE_PWD_) $${update_target_file}
+
+                    $${target_name}_inst.path = $${INSTALL_DATA}/locale/$${lang}/LC_MESSAGES
+                    $${target_name}_inst.CONFIG +=no_check_exist
+                    $${target_name}_inst.files=$$target_file
+
+                    registered_po_files+=$$absolute_path($$file,$$_PRO_FILE_PWD_)
+                    QMAKE_EXTRA_TARGETS+=$$target_name
+                    QMAKE_CLEAN += $$target_file
+                    ubuntuAddPreTargetDep($${target_file})
+
+                    INSTALLS += $${target_name}_inst
+                }
+            }
+        }
+
+        !isEmpty(translated_desktop_files) {
+            #merge the translations into the desktop files
+            for(file, translated_desktop_files) {
+                target_file = $$shadowed($$_PRO_FILE_PWD_)/$$relative_path($$file,$$_PRO_FILE_PWD_)
+                target_file = $$replace(target_file,"\\.in$","")
+
+                target_name = $$replace(target_file,"[/.-]","_")
+                $${target_name}.target=$$target_file
+                $${target_name}.commands=LC_ALL=C intltool-merge -d -u $$_PRO_FILE_PWD_/po $$file $$target_file > /dev/null
+                $${target_name}.depends+=$$registered_po_files \
+                                         $$file
+
+                QMAKE_EXTRA_TARGETS+=$$target_name
+                QMAKE_CLEAN += $$target_file
+                ubuntuAddPreTargetDep($${target_file})
+            }
+        }
+    }
+}