Skip to content

Instantly share code, notes, and snippets.

@Thesola10
Last active November 25, 2022 21:30
Show Gist options
  • Save Thesola10/0c89552488ef37b3c49fd75f1000d597 to your computer and use it in GitHub Desktop.
Save Thesola10/0c89552488ef37b3c49fd75f1000d597 to your computer and use it in GitHub Desktop.
Patch to build a Flatpak from Dweller's Empty Path game folder
diff --color -ruN "Dwellers Empty Path/io.itch.tuyoki.DwellersEmptyPath.yaml" DwellerNew/io.itch.tuyoki.DwellersEmptyPath.yaml
--- "Dwellers Empty Path/io.itch.tuyoki.DwellersEmptyPath.yaml" 1970-01-01 01:00:00.000000000 +0100
+++ DwellerNew/io.itch.tuyoki.DwellersEmptyPath.yaml 2020-08-08 21:08:21.619488035 +0200
@@ -0,0 +1,47 @@
+app-id: "io.itch.tuyoki.DwellersEmptyPath"
+runtime: org.freedesktop.Platform
+runtime-version: '19.08'
+sdk: org.freedesktop.Sdk
+command: "/app/bin/Dweller"
+
+finish-args:
+ - "--share=ipc"
+ - "--socket=x11"
+ - "--socket=wayland"
+ - "--socket=pulseaudio"
+ - "--device=dri"
+ - "--persist=save"
+
+sdk-extensions:
+ - 'org.freedesktop.Sdk.Extension.node12'
+
+add-extensions:
+ 'org.freedesktop.Platform.openh264':
+ directory: "lib"
+ version: '19.08'
+
+modules:
+ - name: "nodejs"
+ buildsystem: simple
+ build-commands:
+ - "/usr/lib/sdk/node12/install.sh"
+ - "mkdir -p /app/bin"
+ - "mv /app/node/bin/node /app/bin/node"
+ - name: "game"
+ buildsystem: simple
+ build-commands:
+ - "patch share/game/js/rpg_managers.js rpg_managers.js.patch"
+ - "ln -s fonts share/game/Fonts"
+ - "mkdir -p /app/lib"
+ - "cp -r share /app/"
+ - "install -D -m 755 share/run.sh /app/bin/Dweller"
+ - "install -D share/game/icon/icon.png /app/share/icons/hicolor/128x128/apps/io.itch.tuyoki.DwellersEmptyPath.png"
+ sources:
+ - type: dir
+ path: "static/linux"
+ dest: "share"
+ - type: dir
+ path: "www"
+ dest: "share/game"
+ - type: file
+ path: "rpg_managers.js.patch"
diff --color -ruN "Dwellers Empty Path/package.json" DwellerNew/package.json
--- "Dwellers Empty Path/package.json" 2018-10-25 15:10:48.000000000 +0200
+++ DwellerNew/package.json 2020-08-08 21:36:41.928939488 +0200
@@ -1,12 +1,18 @@
{
- "name": "",
+ "name": "dwellers_empty_path",
"main": "www/index.html",
"js-flags": "--expose-gc",
"window": {
- "title": "",
+ "title": "Dweller's Empty Path",
"toolbar": false,
"width": 816,
"height": 624,
"icon": "www/icon/icon.png"
+ },
+ "dependencies": {
+ "nw": "^0.47.2"
+ },
+ "scripts": {
+ "start": "nw"
}
}
diff --color -ruN "Dwellers Empty Path/rpg_managers.js.patch" DwellerNew/rpg_managers.js.patch
--- "Dwellers Empty Path/rpg_managers.js.patch" 1970-01-01 01:00:00.000000000 +0100
+++ DwellerNew/rpg_managers.js.patch 2020-08-08 21:07:02.872213246 +0200
@@ -0,0 +1,11 @@
+--- www/js/rpg_managers.js 2020-08-07 18:54:46.931909235 +0200
++++ rpg_managers.js 2020-08-07 18:58:29.999573577 +0200
+@@ -755,7 +755,7 @@
+ StorageManager.localFileDirectoryPath = function() {
+ var path = require('path');
+
+- var base = path.dirname(process.mainModule.filename);
++ var base = require('os').homedir();
+ return path.join(base, 'save/');
+ };
+
diff --color -ruN "Dwellers Empty Path/static/linux/applications/io.itch.tuyoki.DwellersEmptyPath.desktop" DwellerNew/static/linux/applications/io.itch.tuyoki.DwellersEmptyPath.desktop
--- "Dwellers Empty Path/static/linux/applications/io.itch.tuyoki.DwellersEmptyPath.desktop" 1970-01-01 01:00:00.000000000 +0100
+++ DwellerNew/static/linux/applications/io.itch.tuyoki.DwellersEmptyPath.desktop 2020-08-08 21:11:04.841172719 +0200
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=Dweller's Empty Path
+Comment=A small RPGMaker game exploring the life of a lost being from another world.
+Exec=/app/bin/Dweller
+Icon=io.itch.tuyoki.DwellersEmptyPath
+Categories=Game
+Type=Application
diff --color -ruN "Dwellers Empty Path/static/linux/metainfo/io.itch.tuyoki.DwellersEmptyPath.metainfo.xml" DwellerNew/static/linux/metainfo/io.itch.tuyoki.DwellersEmptyPath.metainfo.xml
--- "Dwellers Empty Path/static/linux/metainfo/io.itch.tuyoki.DwellersEmptyPath.metainfo.xml" 1970-01-01 01:00:00.000000000 +0100
+++ DwellerNew/static/linux/metainfo/io.itch.tuyoki.DwellersEmptyPath.metainfo.xml 2020-08-08 21:13:20.063530217 +0200
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<component type="desktop-application">
+ <name>Dweller's Empty Path</name>
+ <id>io.itch.tuyoki.DwellersEmptyPath</id>
+ <launchable type="desktop-id">io.itch.tuyoki.DwellersEmptyPath.desktop</launchable>
+ <metadata_license>CC0-1.0</metadata_license>
+ <project_license>LicenseRef-proprietary</project_license>
+ <summary>A small RPGMaker game exploring the life of a lost being from another world.</summary>
+
+ <description>
+ <p>Yoki wakes up from a nightmare and has some difficulty falling back asleep, so she decides to go on a short walk to clear her mind.</p>
+ <p>As you play as Yoki, you can choose to end the game at any time by returning to her bed and attempt another shot at getting some much needed rest.</p>
+ </description>
+
+ <url type="homepage">https://tuyoki.itch.io/dwellers-empty-path</url>
+
+ <developer_name>Temmie Chang</developer_name>
+
+ <provides>
+ <binary>Dweller</binary>
+ </provides>
+ <releases>
+ <release version="1.0" date="2020-07-14"/>
+ </releases>
+</component>
diff --color -ruN "Dwellers Empty Path/static/linux/run.sh" DwellerNew/static/linux/run.sh
--- "Dwellers Empty Path/static/linux/run.sh" 1970-01-01 01:00:00.000000000 +0100
+++ DwellerNew/static/linux/run.sh 2020-08-08 21:06:55.432601443 +0200
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec /app/share/game/node_modules/nw/bin/nw /app/share/game
diff --color -ruN "Dwellers Empty Path/www/package.json" DwellerNew/www/package.json
--- "Dwellers Empty Path/www/package.json" 2019-10-08 13:29:54.000000000 +0200
+++ DwellerNew/www/package.json 2020-08-08 21:36:50.028221303 +0200
@@ -1,12 +1,18 @@
{
- "name": "",
+ "name": "dwellers_empty_path",
"main": "index.html",
"js-flags": "--expose-gc",
"window": {
- "title": "",
+ "title": "Dweller's Empty Path",
"toolbar": false,
"width": 816,
"height": 624,
"icon": "icon/icon.png"
+ },
+ "dependencies": {
+ "nw": "^0.47.2"
+ },
+ "scripts": {
+ "start": "nw"
}
}

Steps to build a flatpak from Dweller's Empty Path

Right, before you begin:

This diff applies to the Dwellers Empty Path folder within the archive, referred to as the "game folder" here. Yes, you can indeed apply a diff to an entire directory. Cool, huh?

Prerequisites

  • Dweller's Empty Path for Windows (whichever version)
  • Node.js and npm
  • Flatpak (duh) and flatpak-builder
  • From Flathub, org.freedesktop.Sdk and org.freedesktop.Sdk.Extension.node12

How to

  • Run dos2unix package.json in the game directory to apply the patch properly.
  • Run patch -p1 -ui dweller.patch in the game directory, usually Dwellers Empty Path.
  • Run npm install in the www directory. We need the node_modules in there.
  • Run dos2unix www/js/rpg_managers.js to change the line endings in that file, we'll need to patch it. You'll get an error otherwise.
  • Then, run flatpak-builder build mybuilddir io.itch.tuyoki.DwellersEmptyPath.yaml.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment