Skip to content

Commit 750b564

Browse files
committed
no Mac App Bundle and better AppImage support
1 parent 388dc6f commit 750b564

File tree

19 files changed

+141
-476
lines changed

19 files changed

+141
-476
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
src/resources/icon/* linguist-vendored
22
resources/app/bootstrap/* linguist-vendored
33
resources/app/jquery/* linguist-vendored
4-
sdk/lib/* linguist-vendored

CREDITS.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ karaman, sisvenvet and all other members of Hackafe, the hackerspace of Plovdiv,
2525
for being welcoming host of the first public presentation of Perl Executing Browser
2626
on the 2nd of March 2014 and for their helpful proposals.
2727

28-
Thanks to Roderich Schupp and all contributors of the Module::ScanDeps CPAN module.
29-
https://metacpan.org/pod/Module::ScanDeps
30-
31-
Thanks to Daniel Muey and all contributors of the File::Copy::Recursive CPAN module.
32-
https://metacpan.org/pod/File::Copy::Recursive
33-
3428
Thanks to [probonopd](https://github.com/probonopd) for his
3529
knowledgeable instructions and patient cooperation
3630
in the preparation and testing of Perl Executing Browser AppImages
@@ -74,7 +68,6 @@ https://forum.qt.io/topic/3314/qwebelement-set-and-get-attribute
7468

7569
http://www.qtcentre.org/threads/46016-Place-QMessageBox-on-middle-of-screen
7670
http://www.qtcentre.org/threads/18146-String-operations-printing-to-stdout
77-
http://www.qtcentre.org/threads/29363-Problem-with-QDir-cdUp()
7871
http://www.qtcentre.org/threads/10661-QByteArray-to-QString
7972
http://www.qtcentre.org/threads/29104-QMake-DEFINES
8073
http://www.qtcentre.org/threads/48238-Call-a-JavaScript-function-from-C-using-QtWebkit
@@ -172,25 +165,17 @@ https://meta.stackexchange.com/questions/70356/key-stroke-combination-markdown
172165

173166
## Bash
174167

175-
http://tldp.org/LDP/abs/html/fto.html
176-
http://tldp.org/LDP/abs/html/functions.html
177-
178168
https://www.shellcheck.net/
179169

180170
https://stackoverflow.com/questions/13210880/replace-one-substring-for-another-string-in-shell-script
181171
https://stackoverflow.com/questions/4181703/how-to-concatenate-string-variables-in-bash
182172
https://stackoverflow.com/questions/638975/how-do-i-tell-if-a-regular-file-does-not-exist-in-bash
183173
https://stackoverflow.com/questions/10319652/check-if-a-file-is-executable
184174
https://stackoverflow.com/questions/10376206/what-is-the-preferred-bash-shebang
185-
https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
186175
https://stackoverflow.com/questions/2664740/extract-file-basename-without-path-and-extension-in-bash
187176

188-
https://unix.stackexchange.com/questions/312280/split-string-by-delimiter-and-get-n-th-element
189177
https://unix.stackexchange.com/questions/12453/how-to-determine-linux-kernel-architecture
190178

191-
https://www.cyberciti.biz/faq/unix-linux-bsd-appleosx-bash-assign-variable-command-output/
192-
https://www.tutorialspoint.com/unix/unix-regular-expressions.htm
193-
194179
## AppImage
195180

196181
https://standards.freedesktop.org/menu-spec/latest/apa.html

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Perl Executing Browser (PEB) is an HTML5 user interface for [Perl 5](https://www
1717
* [Limitations](#limitations)
1818
* [REQUIREMENTS](./doc/REQUIREMENTS.md)
1919
* [Compile-Time Requirements](./doc/REQUIREMENTS.md#compile-time-requirements)
20-
* [Compile-Time Settings](./doc/REQUIREMENTS.md#compile-time-settings)
2120
* [Runtime Requirements](./doc/REQUIREMENTS.md#runtime-requirements)
2221
* [CONSTANTS](./doc/CONSTANTS.md)
2322
* [Files and Folders](./doc/CONSTANTS.md#files-and-folders)
@@ -30,7 +29,7 @@ Perl Executing Browser (PEB) is an HTML5 user interface for [Perl 5](https://www
3029
* [Requirements for Interactive Perl Scripts](./doc/INTERACTIVE.md#requirements-for-interactive-perl-scripts)
3130
* [Examples of Interactive Perl Scripts](./doc/INTERACTIVE.md#examples-of-interactive-perl-scripts)
3231
* [APPIMAGE SUPPORT](./doc/APPIMAGE.md)
33-
* [PEB AppImage Maker](./doc/APPIMAGE.md#peb-appimage-maker)
32+
* [PEB AppImager](./doc/APPIMAGE.md#peb-appimager)
3433
* [PEB AppImage Configuration Files](./doc/APPIMAGE.md#peb-appimage-configuration-files)
3534
* [PEB AppImage Builder Docker Container](./doc/APPIMAGE.md#peb-appimage-builder-docker-container)
3635
* [AppImageHub](./doc/APPIMAGE.md#appimagehub)

appimager.sh

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env bash
2+
3+
# Version:
4+
export VERSION="1.0.0"
5+
6+
# Architecture check:
7+
if [ ! "$(arch)" == "x86_64" ]; then
8+
printf "\\nAppImage executable can be created only on and for 64-bit Linux distributions.\\n"
9+
exit 1
10+
fi
11+
12+
# Go to to PEB source directory:
13+
cd "$(pwd)/src" || exit
14+
15+
# Remove temporary files:
16+
rm -rf tmp
17+
rm -f .qmake.stash
18+
rm -f Makefile
19+
20+
# Compile PEB:
21+
qmake -qt=qt5
22+
make
23+
24+
# Go back to the PEB root directory:
25+
cd .. || exit
26+
27+
# If no 'linuxdeployqt' is found, it is downloaded from the web:
28+
linuxdeployqt="linuxdeployqt-continuous-$(arch).AppImage"
29+
if [ ! -x "$linuxdeployqt" ]; then
30+
wget --tries=5 --unlink "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
31+
chmod -v a+x "$linuxdeployqt"
32+
fi
33+
34+
# AppImage desktop file is mandatory:
35+
package_desktop_file="$(ls ./resources/app/appimage/*.desktop)"
36+
if [ ! -e "$package_desktop_file" ]; then
37+
printf "\\nPackage .desktop file is missing!\\n"
38+
exit 1
39+
fi
40+
41+
# AppImage name:
42+
appimage_name="$(basename "$package_desktop_file" .desktop)"
43+
44+
# Temporary directory for the creation of the AppImage:
45+
rm -rf "$(pwd)/$appimage_name.app"
46+
mkdir "$(pwd)/$appimage_name.app"
47+
48+
# Main executable:
49+
cp -f "$(pwd)/peb" "$(pwd)/$appimage_name.app/$appimage_name"
50+
51+
# Desktop file:
52+
cp -f "$package_desktop_file" "$(pwd)/$appimage_name.app/$appimage_name.desktop"
53+
54+
# AppImage icon:
55+
if [ -e "$(pwd)/resources/app.png" ]; then
56+
cp -f "$(pwd)/resources/app.png" "$(pwd)/$appimage_name.app/app.png"
57+
fi
58+
59+
# AppImage metadata file:
60+
if [ -e "$(pwd)/resources/app/appimage/$appimage_name.appdata.xml" ]; then
61+
mkdir -p "$(pwd)/$appimage_name.app/usr/share/metainfo"
62+
cp -f "$(pwd)/resources/app/appimage/$appimage_name.appdata.xml" "$(pwd)/$appimage_name.app/usr/share/metainfo/$appimage_name.appdata.xml"
63+
fi
64+
65+
# Documentation:
66+
cp -r "$(pwd)/doc" "$(pwd)/$appimage_name.app/doc"
67+
cp "$(pwd)/CREDITS.md" "$(pwd)/$appimage_name.app/CREDITS.md"
68+
cp "$(pwd)/LICENSE.md" "$(pwd)/$appimage_name.app/LICENSE.md"
69+
cp "$(pwd)/README.md" "$(pwd)/$appimage_name.app/README.md"
70+
71+
# Resources:
72+
cp -r "$(pwd)/resources" "$(pwd)/$appimage_name.app/resources"
73+
74+
# File cleaning:
75+
rm -f "$(pwd)/$appimage_name.app/resources/app/$appimage_name.desktop"
76+
rm -f "$(pwd)/$appimage_name.app/resources/app/$appimage_name.appdata.xml"
77+
78+
# Extraction of the contents of 'linuxdeployqt' tool -
79+
# it is necessary for operation inside the PEB AppImage Builder Docker Container:
80+
if [ -x "$linuxdeployqt" ]; then
81+
"$(pwd)/$linuxdeployqt" "--appimage-extract"
82+
else
83+
printf "\\n$linuxdeployqt is missing!\\n"
84+
exit 1
85+
fi
86+
87+
# AppImage generation:
88+
"$(pwd)/squashfs-root/AppRun" "$(pwd)/$appimage_name.app/$appimage_name" -qmake='qmake -qt=qt5' -no-translations -appimage
89+
90+
# Removal of the temporary directories:
91+
rm -rf "$(pwd)/squashfs-root"
92+
rm -rf "$(pwd)/$appimage_name.app"

doc/APPIMAGE.md

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,43 @@
11
# Perl Executing Browser - AppImage Support
22

3-
## PEB AppImage Maker
3+
## PEB AppImager
44

5-
PEB and any PEB-based application can be easily packed as a 64-bit single-file Linux [AppImage](https://appimage.org/) executable by the [PEB AppImage Maker](https://github.com/ddmitov/perl-executing-browser/blob/master/sdk/appimage-maker.sh) script, which has two modes of operation:
5+
Any PEB-based application with a PEB executable, Qt libraries and a relocatable Perl distribution can be easily packed as a 64-bit single-file Linux [AppImage](https://appimage.org/) executable by the [PEB AppImager](https://github.com/ddmitov/perl-executing-browser/blob/master/appimager.sh) script, which uses the [linuxdeployqt](https://github.com/probonopd/linuxdeployqt/releases/) tool to detect all Qt dependencies of PEB and build an AppImage.
66

7-
* packing a Perl application together with a PEB executable, Qt libraries and a relocatable Perl distribution:
8-
9-
```bash
10-
./appimage-maker.sh --include-resources
11-
```
12-
13-
* packing only a PEB executable and its Qt libraries:
14-
15-
```bash
16-
./appimage-maker.sh --no-resources
17-
```
18-
19-
In this case, a PEB executable from an AppImage will try to find its application files and folders in the directory of the AppImage.
20-
21-
In both modes of operation, the PEB AppImage uses the [linuxdeployqt](https://github.com/probonopd/linuxdeployqt/releases/) tool to detect all Qt dependencies of PEB and build the final image.
22-
23-
The PEB AppImage Maker script must be started from the ``{PEB_executable_directory}/sdk`` directory.
7+
The PEB AppImager must be started from the ``{PEB_executable_directory}``.
248

259
## PEB AppImage Configuration Files
2610

2711
``{PEB_executable_directory}/resources/app/appimage/{application_name}.desktop``
2812
``{PEB_executable_directory}/resources/app/appimage/{application_name}.appdata.xml``
2913

3014
``{PEB_executable_directory}/resources/app/{application_name}.desktop``
31-
is mandatory for any PEB-based application which is to be packed by the PEB AppImage Maker.
32-
A minimal example of а ``.desktop`` file is available [here](https://github.com/ddmitov/perl-executing-browser/blob/master/resources/app/peb-demo.desktop).
15+
is mandatory for any PEB-based application which is to be packed by the PEB AppImager.
16+
A minimal example of а ``.desktop`` file is available [here](https://github.com/ddmitov/perl-executing-browser/blob/master/resources/app/appimage/peb-demo.desktop).
3317
``Icon=app`` in the ``.desktop`` file must not be changed for the proper display of the application icon.
3418
All registered categories in a ``.desktop`` file are available [here](https://standards.freedesktop.org/menu-spec/latest/apa.html).
3519
Any ``.desktop`` file can be validated using the ``desktop-file-validate`` tool from the ``desktop-file-utils`` package in all major Linux distributions.
3620

37-
The [AppStream Generator](http://output.jsbin.com/qoqukof) of [probonopd](https://github.com/probonopd) is the recommended tool for generating AppStream ``.appdata.xml`` files for PEB-based applications. An example AppStream file is available [here](https://github.com/ddmitov/perl-executing-browser/blob/master/resources/app/peb-demo.appdata.xml). An AppStream file is not mandatory, but is highly recommended.
21+
The [AppStream Generator](http://output.jsbin.com/qoqukof) of [probonopd](https://github.com/probonopd) is the recommended tool for generating AppStream ``.appdata.xml`` files for PEB-based applications. An example AppStream file is available [here](https://github.com/ddmitov/perl-executing-browser/blob/master/resources/app/appimage/peb-demo.appdata.xml). An AppStream file is not mandatory, but is highly recommended.
3822

39-
Both PEB AppImage configuration files are put on their places in the AppImage directory tree structure by the [PEB AppImage Maker](https://github.com/ddmitov/perl-executing-browser/blob/master/sdk/appimage-maker.sh) script.
23+
Both PEB AppImage configuration files are put on their places in the AppImage directory tree structure by the [PEB AppImager](https://github.com/ddmitov/perl-executing-browser/blob/master/appimager.sh) script.
4024

4125
## PEB AppImage Builder Docker Container
4226

4327
An easy building environment for PEB AppImage executables is the [PEB AppImage Builder Docker Container](https://github.com/ddmitov/perl-executing-browser/blob/master/sdk/Dockerfile).
44-
To build it, type the following command in the PEB project root directory (the directory of the README.md):
28+
To start it, type the following commands in the ``{PEB_executable_directory}``:
4529

4630
```bash
4731
sudo docker build -t peb-appimage-builder .
48-
```
49-
50-
To start the PEB AppImage Builder Docker Container, type the following command in the PEB project root directory:
51-
52-
```bash
5332
sudo docker container run --rm -it -v $(pwd):/opt --user $(id -u):$(id -g) peb-appimage-builder
5433
```
5534

5635
When PEB AppImage Builder Docker Container is running, type:
5736

5837
```bash
59-
cd /opt/sdk
38+
cd /opt/ && ./appimager.sh && exit
6039
```
6140

62-
To start the PEB AppImage Maker, type either:
63-
64-
```bash
65-
./appimage-maker.sh --no-resources
66-
```
67-
68-
or
69-
70-
```bash
71-
./appimage-maker.sh --include-resources
72-
```
73-
74-
To stop the PEB AppImage Builder Docker Container when AppImage building is complete:
75-
<kbd>Ctrl</kbd> + <kbd>D</kbd>
76-
7741
## AppImageHub
7842

7943
Perl Executing Browser is also listed at the [AppImageHub](https://appimage.github.io/perl-executing-browser/).

doc/CONSTANTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Files and Folders
44

5-
PEB is created to work from any directory without installation and all paths used by PEB are relative to the directory of the PEB executable, labeled as ``{PEB_executable_directory}`` within this documentation. ``{PEB_executable_directory}`` may contain a C++ PEB executable or a Linux [AppImage](https://appimage.org/) with a PEB executable and its Qt libraries all packed in a single file. All names of PEB files and folders are hard-coded in C++ code and they are case-sensitive.
5+
PEB is created to work from any directory without installation and all paths used by PEB are relative to the directory of the PEB executable, labeled as ``{PEB_executable_directory}`` within this documentation. All names of PEB files and folders are hard-coded in C++ code.
66

77
A typical ``{PEB_executable_directory}`` looks like this:
88

doc/INTERACTIVE.md

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Perl Executing Browser - Interactive Perl Scripts
22

3-
PEB interactive Perl scripts are able to receive user input multiple times after the script is already started thus forming a bidirectional connection with PEB. Many interactive scripts can be started simultaneously in one PEB instance. One script may be started in many instances, provided that each of them has a JavaScript settings object with an unique name.
3+
PEB interactive Perl scripts are able to receive user input multiple times after the script is started by waiting for new data coming either on STDIN or in a temporary file. Many interactive scripts can be started simultaneously in one PEB instance. One script may be started in many instances, provided that each of them has a JavaScript settings object with an unique name.
44

55
## Requirements for Interactive Perl Scripts
66

77
* **Event Loop**
8-
Each PEB interactive Perl script must have its own event loop waiting constantly for new data on STDIN or in a temporary file for a bidirectional connection with PEB. ``AnyEvent`` is a popular Perl framework for building different types of event loops.
8+
Each PEB interactive Perl script must have its own event loop waiting constantly for new data on STDIN or in a temporary file. ``AnyEvent`` is a popular Perl framework for building different types of event loops.
99

1010
* **No Buffering**
1111
PEB interactive scripts must run without output buffering, which may prevent output before the script has ended.
@@ -32,44 +32,6 @@ PEB interactive Perl scripts are able to receive user input multiple times after
3232

3333
## Examples of Interactive Perl Scripts
3434

35-
The following code shows how to start a PEB interactive Perl script right after the PEB index page is loaded:
36-
37-
```html
38-
<!DOCTYPE html>
39-
<html>
40-
<head>
41-
<title>Interactive Script Demo</title>
42-
<meta name="viewport" content="width=device-width, initial-scale=1">
43-
<meta charset="utf-8">
44-
45-
<script>
46-
var pebSettings = {};
47-
pebSettings.autoStartScripts = ['interactive_script'];
48-
49-
var interactive_script = {};
50-
interactive_script.scriptRelativePath = 'perl/interactive.pl';
51-
interactive_script.inputData = function() {
52-
return document.getElementById('interactive-script-input').value;
53-
}
54-
55-
interactive_script.stdoutFunction = function (stdout) {
56-
var container = document.getElementById('interactive-script-output');
57-
container.innerText = stdout;
58-
}
59-
</script>
60-
</head>
61-
62-
<body>
63-
<form action="interactive_script.script">
64-
<input type="text" name="input" id="interactive-script-input">
65-
<input type="submit" value="Submit">
66-
</form>
67-
68-
<div id="interactive-script-output"></div>
69-
</body>
70-
</html>
71-
```
72-
7335
The [index.htm of the demo package](https://github.com/ddmitov/perl-executing-browser/blob/master/resources/app/index.html) demonstrates how to start automatically one Perl interactive script based on STDIN input in two instances.
7436

7537
The [interactive.pl script of the demo package](https://github.com/ddmitov/perl-executing-browser/blob/master/resources/app/perl-scripts/interactive.pl) is an example of a Perl interactive script based on STDIN input.

doc/REQUIREMENTS.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
## Compile-Time Requirements
44

55
The only Linux and Mac compile-time requirement of PEB is a Qt development bundle version 5.2 or higher.
6-
76
PEB on Windows can be compiled only with a GCC-based MinGW Qt versions 5.2 to 5.6.
87

98
Compiled and tested successfully using:
@@ -25,27 +24,6 @@ make
2524

2625
Please note that PEB builds using the standard ``QtWebKit`` web engine are single-process applications and they consume less memory than PEB builds using the multiprocess ``QtWebEngine``.
2726

28-
## Compile-Time Settings
29-
30-
PEB compile-time settings can be changed by editing the ``src/peb.pro`` project file according to the following instructions.
31-
32-
* Mac Bundle
33-
To make a bundle-less binary, which is the default setting:
34-
35-
```QMake
36-
BUNDLE = 0
37-
CONFIG -= app_bundle
38-
```
39-
40-
To make a bundled binary (peb.app):
41-
42-
```QMake
43-
BUNDLE = 1
44-
CONFIG += app_bundle
45-
```
46-
47-
To make automatically a bundled binary (peb.app) use the [dmg-maker.sh](sdk/dmg-maker.sh) script by Valcho Nedelchev.
48-
4927
## Runtime Requirements
5028

5129
* Qt 5 libraries.
@@ -56,12 +34,8 @@ PEB compile-time settings can be changed by editing the ``src/peb.pro`` project
5634

5735
Tested successfully using:
5836
Linux 64-bit [Relocatable Perl](https://github.com/skaji/relocatable-perl) versions 5.24.1, 5.26.1
59-
Linux 64-bit [Perlbrew](https://perlbrew.pl/) Perl versions 5.18.4, 5.23.7
6037
Linux 64-bit Perl version 5.22.1
6138
Windows 32-bit [Strawberry Perl](http://strawberryperl.com/) PortableZIP versions 5.12.2.0, 5.16.1.1, 5.20.2.1, 5.30.0.1
6239

63-
To use a Perlbrew Perl with PEB create a symlink at:
64-
``{PEB_executable_directory}/resources/perl/bin/perl``
65-
6640
PEB will use the first Perl on PATH if a relocatable Perl distribution is not found in the
6741
``{PEB_executable_directory}/resources/app/perl`` folder.

doc/SETTINGS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Application Filename
44

5-
The executable binary file of the browser, ``peb``, ``peb.app``, ``peb.dmg`` or ``peb.exe`` by default, can be renamed with no restrictions or additional adjustments. It can take the name of the PEB-based application it is going to run.
5+
The executable binary file of the browser, ``peb`` or ``peb.exe`` by default, can be renamed with no restrictions or additional adjustments. It can take the name of the PEB-based application it is going to run.
66

77
## Global Settings API
88

resources/app/perl-scripts/interactive-windows.pl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66
use Encode qw(decode);
77
use English;
88

9-
use AnyEvent;
109
use File::Temp;
1110
use JSON::PP;
1211

12+
if (eval("require AnyEvent;")) {
13+
require AnyEvent;
14+
AnyEvent->import();
15+
} else {
16+
print "AnyEvent module is missing in this Perl distribution.";
17+
exit 1;
18+
}
19+
1320
# Disable output buffering:
1421
$OUTPUT_AUTOFLUSH = 1;
1522

0 commit comments

Comments
 (0)