Skip to content

Commit 09afdf8

Browse files
committed
better AppImage support
1 parent 6873c98 commit 09afdf8

32 files changed

+1397
-211
lines changed

CREDITS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ http://stackoverflow.com/questions/17680207/qhash-iterator-example-no-match-for-
144144
https://stackoverflow.com/questions/23174393/parse-jsonarray
145145
https://stackoverflow.com/questions/24899558/how-to-check-qt-version-to-include-different-header
146146
https://stackoverflow.com/questions/19822211/qt-parsing-json-using-qjsondocument-qjsonobject-qjsonarray
147+
https://stackoverflow.com/questions/2241808/checking-if-a-folder-exists-and-creating-folders-in-qt-c
147148

148149
http://www.java2s.com/Code/Cpp/Qt/CheckfileexistanceandfilenamewithQFile.htm
149150
http://webkit.sed.hu/content/disabling-cache
@@ -227,6 +228,8 @@ https://stackoverflow.com/questions/10319652/check-if-a-file-is-executable
227228
https://stackoverflow.com/questions/10376206/what-is-the-preferred-bash-shebang
228229

229230
https://unix.stackexchange.com/questions/312280/split-string-by-delimiter-and-get-n-th-element
231+
https://unix.stackexchange.com/questions/12453/how-to-determine-linux-kernel-architecture
232+
230233
https://www.cyberciti.biz/faq/unix-linux-bsd-appleosx-bash-assign-variable-command-output/
231234
https://www.tutorialspoint.com/unix/unix-regular-expressions.htm
232235
http://ryanstutorials.net/bash-scripting-tutorial/bash-functions.php

SETTINGS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ select_file.receiverFunction = function (file) {
216216
Any new directory will be created immediately by PEB.
217217

218218
## Minimal Portable Perl Distribution for PEB
219-
Sometimes it is important to minimize the size of the relocatable (or portable) Perl distribution used by a PEB-based application. [Perl Distribution Compactor](sdk/compactor.pl) is one solution to this problem. It finds all dependencies of all Perl scripts in the ``{PEB_binary_directory}/resources/app`` directory and copies them in a new ``{PEB_binary_directory}/perl/lib`` folder; a new ``{PEB_binary_directory}/perl/bin`` is also created. The original ``bin`` and ``lib`` folders are saved as ``bin-original`` and ``lib-original`` respectively. These directories should be manually archived for future use or removed.
219+
Sometimes it is important to minimize the size of the relocatable (or portable) Perl distribution used by a PEB-based application. [Perl Distribution Compactor](sdk/compactor.pl) is one solution to this problem. It finds all dependencies of all Perl scripts in the ``{PEB_binary_directory}/resources/app`` directory and copies them in a new ``{PEB_binary_directory}/perl/lib`` folder; a new ``{PEB_binary_directory}/perl/bin`` is also created. The original ``bin`` and ``lib`` folders may be saved as ``bin-original`` and ``lib-original`` respectively.
220220

221-
Perl Distribution Compactor should be started from the directory of the browser binary using [compactor.sh](compactor.sh) on a Linux or a Mac machine or [compactor.cmd](compactor.cmd) on a Windows machine to ensure that only the Perl distribution of PEB is used. This is necessary to avoid dependency mismatches with any other Perl on PATH.
221+
Perl Distribution Compactor should be started using [compactor.sh](sdk/compactor.sh) on a Linux or a Mac machine or [compactor.cmd](sdk/compactor.cmd) on a Windows machine to ensure that only the Perl distribution of PEB is used. This is necessary to avoid dependency mismatches with any other Perl on PATH.
222222

223223
Perl Distribution Compactor depends on [Module::ScanDeps](https://metacpan.org/pod/Module::ScanDeps) and [File::Copy::Recursive](https://metacpan.org/pod/File::Copy::Recursive) CPAN modules, which are included in the ``{PEB_binary_directory}/sdk/lib`` folder.
224224

appimage-maker.sh

Lines changed: 0 additions & 57 deletions
This file was deleted.

sdk/appimage-maker.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
cd .. || exit
4+
5+
if [ ! -e ./peb.app ]; then
6+
mkdir ./peb.app
7+
fi
8+
9+
if [ -e ./peb ]; then
10+
cp -f ./peb ./peb.app/peb
11+
else
12+
cd ./src || exit
13+
14+
qmake -qt=qt5
15+
make
16+
17+
cd .. || exit
18+
cp -f ./peb ./peb.app/peb
19+
fi
20+
21+
cp ./sdk/peb.desktop ./peb.app/peb.desktop
22+
cp ./src/resources/icon/camel.png ./peb.app/peb.png
23+
24+
cp -rf ./resources ./peb.app/resources
25+
26+
relocatable_perl="$(pwd)/perl/bin/perl"
27+
compactor_script="$(pwd)/sdk/compactor.pl"
28+
29+
if [ -e "$relocatable_perl" ]; then
30+
printf "\\nGoing to compact the relocatable Perl for this copy of Perl Executing Browser.\\n"
31+
"$relocatable_perl" "$compactor_script" "--AppImage"
32+
else
33+
printf "\\nRelocatable Perl is not found for this copy of Perl Executing Browser.\\n"
34+
fi
35+
36+
linuxdeployqt="linuxdeployqt-continuous-$(arch).AppImage"
37+
38+
if [ ! -x "$linuxdeployqt" ]; then
39+
wget --tries=5 --unlink "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/$linuxdeployqt"
40+
chmod -v a+x "$linuxdeployqt"
41+
fi
42+
43+
"./$linuxdeployqt" ./peb.app/peb -qmake='qmake -qt=qt5' -no-translations -appimage

compactor.cmd renamed to sdk/compactor.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
cd ..
12

23
IF EXIST ./perl/bin/perl.exe (
34
ECHO Going to compact the relocatable Perl for this copy of Perl Executing Browser.

sdk/compactor.pl

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,18 @@
2727
my $app_directory = catdir($root, "resources", "app");
2828
my $perl_directory = catdir($root, "perl");
2929
my $bin_original = catdir($perl_directory, "bin");
30-
my $bin_compacted = catdir($perl_directory, "bin-compacted");
3130
my $lib_original = catdir($perl_directory, "lib");
32-
my $lib_compacted = catdir($perl_directory, "lib-compacted");
31+
32+
my $bin_compacted;
33+
my $lib_compacted;
34+
35+
if ($ARGV[0] and $ARGV[0] =~ /^--AppImage$/) {
36+
$bin_compacted = catdir($root, "peb.app", "perl", "bin");
37+
$lib_compacted = catdir($root, "peb.app", "perl", "lib");
38+
} else {
39+
$bin_compacted = catdir($perl_directory, "bin-compacted");
40+
$lib_compacted = catdir($perl_directory, "lib-compacted");
41+
}
3342

3443
# Copying the Perl interpreter:
3544
if ($Config{osname} !~ "MSWin32") {
@@ -57,7 +66,8 @@
5766
print "Script Nr. $script_counter: $script\n";
5867

5968
my $dependencies_hashref =
60-
scan_deps (files => [$script], recurse => 3, compile => 'true');
69+
scan_deps(files => [$script], recurse => 3,
70+
compile => 'true', warn_missing => 1);
6171

6272
my $module_counter;
6373
while (my($partial_path, $module_name) = each(%{$dependencies_hashref})) {
@@ -77,16 +87,18 @@
7787
}
7888

7989
# Rename Perl directories:
80-
rename $bin_original, catdir($perl_directory, "bin-original");
81-
rename $bin_compacted, catdir($perl_directory, "bin");
90+
if ($ARGV[0] and $ARGV[0] !~ /^--AppImage$/) {
91+
rename $bin_original, catdir($perl_directory, "bin-original");
92+
rename $bin_compacted, catdir($perl_directory, "bin");
8293

83-
rename $lib_original, catdir($perl_directory, "lib-original");
84-
rename $lib_compacted, catdir($perl_directory, "lib");
94+
rename $lib_original, catdir($perl_directory, "lib-original");
95+
rename $lib_compacted, catdir($perl_directory, "lib");
8596

86-
# Remove backup directories if the script is started with the '--nobackup' flag.
87-
if ($ARGV[0] and $ARGV[0] =~ /^--nobackup$/) {
88-
rmtree(catdir($perl_directory, "bin-original"));
89-
rmtree(catdir($perl_directory, "lib-original"));
97+
# Remove backup directories if the script is started with the '--no-backup' flag.
98+
if ($ARGV[0] and $ARGV[0] =~ /^--no-backup$/) {
99+
rmtree(catdir($perl_directory, "bin-original"));
100+
rmtree(catdir($perl_directory, "lib-original"));
101+
}
90102
}
91103

92104
# Perl scripts recursive lister subroutine:

compactor.sh renamed to sdk/compactor.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
cd .. || exit
4+
35
relocatable_perl="./perl/bin/perl"
46

57
if [ -e "$relocatable_perl" ]; then

makedmg.sh renamed to sdk/makedmg.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/sh
22

3+
cd .. || exit 1
4+
35
makedmg_version='v0.3'
46
macdeployqt_bin=$(which macdeployqt)
57
peb_bundle=$1
@@ -12,7 +14,7 @@ require_bundle_config() {
1214
echo "Please, set BUNDLE=1 in $peb_pro file and rebuild project."
1315
echo
1416
echo "Here is one liner to update your configuration: "
15-
echo " perl -pi -e s,BUNDLE=0,BUNDLE=1,g $peb_pro"
17+
echo "perl -pi -e s,BUNDLE=0,BUNDLE=1,g $peb_pro"
1618
echo
1719
exit 1
1820
fi
@@ -35,7 +37,7 @@ require_bundle_config
3537

3638
if [ -z "$macdeployqt_bin" ]
3739
then
38-
echo "No macdeployqt found in PATH"
40+
echo "No macdeployqt found in PATH."
3941
if [ -z "$QTDIR" ]
4042
then
4143
echo "Need to set QTDIR environment variable."
@@ -44,8 +46,8 @@ if [ -z "$macdeployqt_bin" ]
4446
set QTDIR = $qtdirname
4547
if [ -z "$QTDIR" ]
4648
then
47-
echo "No QTDIR was set. I have quit now."
48-
exit
49+
echo "No QTDIR was set. I have to quit now."
50+
exit 1
4951
fi
5052
echo ""
5153
fi

0 commit comments

Comments
 (0)