Skip to content

Commit db71586

Browse files
authored
Merge pull request #2 from speed47/webos3
Webos3
2 parents 08ca0b3 + 0da2960 commit db71586

File tree

4 files changed

+66
-8
lines changed

4 files changed

+66
-8
lines changed

.github/workflows/package.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: package
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
- main
10+
11+
jobs:
12+
package:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v5
16+
with:
17+
persist-credentials: false
18+
- name: apt-get install
19+
env:
20+
DEBIAN_FRONTEND: noninteractive
21+
run: sudo apt-get update && sudo apt-get dist-upgrade -y && sudo apt-get install -y npm
22+
- name: npm install
23+
run: npm install
24+
- name: npm build
25+
run: npm run build
26+
- name: npm package
27+
run: npm run package
28+
- name: get ipk artifact name
29+
id: ipk
30+
run: |
31+
GIT_COMMIT=$(git rev-parse --short HEAD)
32+
PREFIX=$(basename $(ls -1 *.ipk) .ipk)
33+
echo "zip=$PREFIX-$GIT_COMMIT.zip" >> "$GITHUB_OUTPUT"
34+
- uses: actions/upload-artifact@v4
35+
with:
36+
name: ${{ steps.ipk.outputs.zip }}
37+
path: '*.ipk'
38+
retention-days: 30

frontend/index.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,35 @@ function log(s) {
3737

3838
(async () => {
3939
try {
40-
log('Registering input app...');
40+
// register the app in the real /var/lib/eim
41+
log('Registering ourselves as input app if not already done...');
4142
await lunaCall('luna://com.webos.service.eim/addDevice', {
4243
appId: 'org.webosbrew.autostart',
4344
pigImage: '',
4445
mvpdIcon: '',
46+
type: 'MVPD_IP', // can be either MVPD_IP or MVPD_RF, required for webOS 3.x
47+
label: 'Autostart', // required for webOS 3.x
48+
description: 'webosbrew autostart', // required for webOS 3.x
4549
});
50+
} catch (err) {
51+
const errData = JSON.parse(err.message);
52+
if (errData.errorCode === 'EIM.105') { // input app already registered
53+
log('Already registered, good, carrying on...');
54+
}
55+
else {
56+
log(`An error occured:\n${err.stack}`);
57+
return;
58+
}
59+
}
4660

61+
try {
4762
await retry(3, async () => {
63+
// now setup an eim overlay so that any changes done later don't erase our own app
64+
// if /var/lib/webosbrew/eim already exists, keep it that way, changes done in previous
65+
// sessions will live here, so just bind mount it, otherwise create it from the /var/lib/eim contents
4866
log('Setting up eim overlay...');
4967
const res = await lunaCall('luna://org.webosbrew.hbchannel.service/exec', {
50-
command: 'if [[ ! -d /var/lib/webosbrew/eim ]]; then cp -r /var/lib/eim /var/lib/webosbrew/eim; fi ; if ! findmnt /var/lib/eim; then mount --bind /var/lib/webosbrew/eim /var/lib/eim ; fi',
68+
command: 'if [[ ! -d /var/lib/webosbrew/eim ]]; then cp -r /var/lib/eim /var/lib/webosbrew/eim && echo cp ok || echo cp failed; fi ; if ! findmnt /var/lib/eim; then mount --bind /var/lib/webosbrew/eim /var/lib/eim && echo mount overlay ok || echo mount overlay failed; fi',
5169
});
5270
log(`Result: ${res.stdoutString} ${res.stderrString}`);
5371
});
@@ -56,7 +74,9 @@ function log(s) {
5674
const res2 = await lunaCall('luna://org.webosbrew.hbchannel.service/autostart', {});
5775
log(`Result: ${res2.message}`);
5876

59-
log("Removing input app...");
77+
// this just removes ourselves from the overlay, but we still live in the real /var/lib/eim,
78+
// which guarantees that we'll survive on the next reboot
79+
log("Removing our own input app from eim overlay...");
6080
await lunaCall('luna://com.webos.service.eim/deleteDevice', {
6181
appId: 'org.webosbrew.autostart',
6282
});
@@ -70,7 +90,7 @@ function log(s) {
7090
if (lastinputPayload.appId) {
7191
log(`Last input app: ${lastinputPayload.appId}`);
7292
if (lastinputPayload.appId !== 'org.webosbrew.autostart') {
73-
log("Relaunching...");
93+
log("Relaunching this app...");
7494
await lunaCall('luna://com.webos.service.applicationManager/launch', {
7595
id: lastinputPayload.appId,
7696
});
@@ -79,6 +99,6 @@ function log(s) {
7999
}
80100
log("Done.");
81101
} catch (err) {
82-
log(`An error occured: ${err.stack}`);
102+
log(`An error occured:\n${err.stack}`);
83103
}
84104
})();

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "org.webosbrew.autostart",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "Autostart test application",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)