Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundling app into Flatpak #72

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

DavidDeSimone
Copy link
Contributor

@DavidDeSimone DavidDeSimone commented Feb 24, 2023

This draft PR is to capture my work to show a prototype of packaging the app as a flatpak.

In order to run this, you must first run
go mod vendor && git add vendor && git commit -m "Running go mod vendor"

From there you can build the flatpak via
flatpak-builder --force-clean --user --install --repo=repo ./build-dir io.cryobyte.cryobyteutilities.yml
and run via
flatpak run io.cryobyte.cryobyteutilities.yml

Comment on lines 18 to 33
- name: golang
buildsystem: simple
sources:
- type: archive
only-arches:
- aarch64
url: https://go.dev/dl/go1.20.1.linux-arm64.tar.gz
sha256: fc0aa29c933cec8d76f5435d859aaf42249aa08c74eb2d154689ae44c08d23b3
- type: archive
only-arches:
- x86_64
url: https://go.dev/dl/go1.20.1.linux-amd64.tar.gz
sha256: 000a5b1fca4f75895f78befeb2eecf10bfff3c428597f3f1e69133b63b911b02
build-commands:
- install -d /app/lib/sdk/golang
- cp -rpv * /app/lib/sdk/golang/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need go 1.20, but the SDK extension was only providing go 1.19. It may be there was something I was missing.

Comment on lines 50 to 53
sources:
- type: git
path: .
branch: relative-homdir
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a trick I use for iterating on builds, but isn't the end solution. If we were to use this "for real", we would want to use a tag/commit hash combination for a release.

@@ -3,4 +3,4 @@ if [ "$(xrandr | grep ' connected' | wc -l)" -eq 1 ]; then
export FYNE_SCALE=0.25
fi

"$HOME"/.cryo_utilities/cryo_utilities gui
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to think of a better way to rectify launching in the flatpak vs. out of the flatpak. It should be an easy thing to solve.

Comment on lines +297 to +317

func setUnitValueWithinFlatpak(param string, value string) error {
hostSpawnCmd := "host-spawn"
hostCommandArgs := []string{"sudo", "sh", "-c"}
shellCmd := fmt.Sprintf("echo %v | tee %v", value, UnitMatrix[param])
hostCommandArgs = append(hostCommandArgs, shellCmd)
fmt.Println("Executing command ", hostSpawnCmd, hostCommandArgs)
cmd := exec.Command(hostSpawnCmd, hostCommandArgs...)
stdin, err := cmd.StdinPipe()
if err != nil {
fmt.Println(err)
return err
}
cmd.Start()
_, err = stdin.Write([]byte(CryoUtils.UserPassword + "\n"))
if err != nil {
fmt.Println(err)
return err
}
return cmd.Wait()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these functions would need to be documented prior to being ready for prime-time.

@@ -0,0 +1,53 @@
app-id: io.github.steamdeckutilities
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a real domain controlled by the project to be listed on flathub. I just made something up for iteration purposes.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I own cryobyte.io, which would be perfect. Does it need to have its own subdomain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Short answer: From my reading of the docs, the project just needs to control the root domain, so controlling io.cryobyte should be sufficient. The third part of the url will just be the project identifier, so my recommendation would be io.cryobyte.steamdeckutilities

Docs: https://docs.flatpak.org/en/latest/conventions.html#application-ids

@CryoByte33
Copy link
Owner

Amazing work! I'll be busy moving for the next few days, but I'll review as I can!

@ajite
Copy link
Contributor

ajite commented Feb 24, 2023

That's very nice indeed. Your createCommand is much cleaner.

It would be great if you could do another PR with the createCommand so we can already start to use it. Should not we rename it to execCommand since the original is exec.Command ?

@DavidDeSimone
Copy link
Contributor Author

That's very nice indeed. Your createCommand is much cleaner.

It would be great if you could do another PR with the createCommand so we can already start to use it. Should not we rename it to execCommand since the original is exec.Command ?

I can spin out createCommand to a separate PR if there is a desire for that. Ideally createCommand should be pretty transparent to the rest of the application though.

Thank you for the feedback - I originally thought of naming it execCommand, but thought that naming would be confusing since createCommand isn't actually executing a command, it's making a *exec.Cmd that you still need to call .Run() or .CombinedOutput(), etc. on to actually run

@DavidDeSimone
Copy link
Contributor Author

My usage of downloading golang manually is a work around for flathub/org.freedesktop.Sdk.Extension.golang#82 - once that is fixed we can just use the SDK extension.

@DavidDeSimone DavidDeSimone changed the title Prototype example of how to bundle the app into a flatpak Bundling app into Flatpak Mar 15, 2023

<developer_name>Cryobyte33</developer_name>

<metadata_license>MIT</metadata_license>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-metadata_license, the metadata license supported does not appear to include GPL. This is not the code/project license, this is strictly the license for this metadata itself. Other options are:

FSFAP
MIT
0BSD
CC0-1.0
CC-BY-3.0
CC-BY-4.0
CC-BY-SA-3.0
CC-BY-SA-4.0
GFDL-1.1
GFDL-1.2
GFDL-1.3
BSL-1.0
FTL
FSFUL

@CryoByte33 Do you have a preference on this, or are you comfortable with MIT?

Comment on lines +27 to +55
<description>
<p>
# Cryobyte Utilities is a game performance enhancher for Linux. This application is designed primarily for the Steam Deck, however it will work on other distributions on a "best-effort" basis.
</p>
<p>
Written by Cryobyte33, this application fine tunes Linux system settings for gaming performance.
</p>
<p>
Key Features:
</p>
<p>
One-click set-to-recommended settings
One-click revert-to-stock settings
Swap Tuner
Swap File Resizer + Recovery
Swappiness Changer
Memory Parameter Tuning
HugePages Toggle
Compaction Proactiveness Changer
HugePage Defragmentation Toggle
Page Lock Unfairness Changer
Shared Memory (shmem) Toggle
Storage Manager
Sync shadercache and compatdata to the same location the game is installed
Delete shadercache and compatdata for whichever games you select
NEW Delete the shadercache and compatdata for all uninstalled games with a single click
Full CLI mode
</p>
</description>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user will see this copy on this discover store - I would like feedback from Cryo and the community. This can be changed on a per-update basis.

Comment on lines +60 to +64
<image>https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/cmd/cryoutilities/Icon.png</image>
</screenshot>
<!-- <screenshot>
<image>@TODO</image>
</screenshot> -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need at least one screenshot for flathub.

- install -D cryo_utilities /app/bin/cryo_utilities
- install -D launcher.sh /app/bin/launcher.sh
- mkdir -p /app/share/applications/
- install -D ./cmd/cryoutilities/Icon.png /app/share/icons/hicolor/512x512/apps/io.cryobyte.cryobyteutilities.png
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CryoByte33 Do you have a 512x512 version of the project icon? Flatpak will auto downsample the image to smaller versions (256x256, 128x128 etc), but our current icon isn't very high res and looks washed out when upscaled to 512x512.

@DavidDeSimone
Copy link
Contributor Author

DavidDeSimone commented Mar 15, 2023

The code work for this is pretty much done. This is mostly admin work, with one code change. The remaining work:

  • Testing, testing, testing. This is going to require a ton of testing, and I would greatly appreciate any help from other contributors.
  • Fix launch.sh to not choke when launching within the flatpak
  • Approval of the copy and images will be displayed on flathub/the discover store
  • Screenshots to be displayed on flathub/ The discover store. I can generate the screenshots myself, unless you already have specific screenshots you want Cryo.
  • A 512x512 icon
  • Documentation - my recommendation is to start with code level commenting, but I would be happy to write a design doc if required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants