Skip to content

Commit

Permalink
build: Allow custom app IDs
Browse files Browse the repository at this point in the history
From this time onward, development flatpaks of Bottles will
be suffixed with `.Devel`. This allows us to test Bottles completely
separately from stable releases, making it easier to test without
affecting existing configurations.

Related: bottlesdevs#2921
  • Loading branch information
TheEvilSkeleton committed Dec 9, 2024
1 parent fb5e6d2 commit 1517f2d
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
- uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v6
with:
bundle: bottles.flatpak
manifest-path: build-aux/com.usebottles.bottles.json
manifest-path: build-aux/com.usebottles.bottles.Devel.json
cache-key: flatpak-builder-${{ github.sha }}
4 changes: 2 additions & 2 deletions .github/workflows/update-manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

env:
PR_BRANCH: pr/ci-manifest/${{ github.ref_name }}
FEDC_ARGS: --update --require-important-update --commit-only --never-fork "bottles-repository/build-aux/com.usebottles.bottles.json"
FEDC_ARGS: --update --require-important-update --commit-only --never-fork "bottles-repository/build-aux/com.usebottles.bottles.Devel.json"
UPDATE_PYTHON: false

jobs:
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
run: |
git checkout -B ${{ env.PR_BRANCH }}
git push -f --set-upstream origin ${{ env.PR_BRANCH }}
git diff ${{ github.ref_name }} --exit-code build-aux/com.usebottles.bottles.json
git diff ${{ github.ref_name }} --exit-code build-aux/com.usebottles.bottles.Devel.json
updated=$?
if [ $updated -ne 0 ] || [ "${{ env.UPDATE_PYTHON }}" = true ]; then
gh pr create --title ":robot:: Update manifest (important)" --body ":wrench: One or more modules marked as 'important' have been updated." --head ${{ env.PR_BRANCH }} --base ${{ github.ref_name }}
Expand Down
10 changes: 5 additions & 5 deletions CODING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
#### Build & install

```bash
flatpak-builder --install --user --force-clean ./.flatpak-builder/out ./build-aux/com.usebottles.bottles.json
flatpak-builder --install --user --force-clean ./.flatpak-builder/out ./build-aux/com.usebottles.bottles.Devel.json
```

#### Run

```bash
flatpak run com.usebottles.bottles
flatpak run com.usebottles.bottles.Devel
```

#### Uninstall devel version

```bash
flatpak uninstall com.usebottles.bottles//master
flatpak uninstall com.usebottles.bottles.Devel
```

## Unit Test
Expand Down Expand Up @@ -51,9 +51,9 @@ cat > po/POTFILES <<EOF
EOF
grep -rlP "_\(['\"]" bottles | sort >> po/POTFILES
cat >> po/POTFILES <<EOF
data/com.usebottles.bottles.desktop.in
data/com.usebottles.bottles.desktop.in.in
data/com.usebottles.bottles.gschema.xml
data/com.usebottles.bottles.metainfo.xml.in
data/com.usebottles.bottles.metainfo.xml.in.in
EOF
```

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ There are two methods to build Bottles. The first and longer method is using `or

1. Install [`org.flatpak.Builder`](https://github.com/flathub/org.flatpak.Builder) from Flathub
1. Clone `https://github.com/bottlesdevs/Bottles.git` (or your fork)
1. Run `flatpak run org.flatpak.Builder --install --install-deps-from=flathub --default-branch=master --force-clean build-dir build-aux/com.usebottles.bottles.json` in the terminal from the root of the repository (use `--user` if necessary)
1. Run `flatpak run com.usebottles.bottles//master` to launch it
1. Run `flatpak run org.flatpak.Builder --install --install-deps-from=flathub --default-branch=master --force-clean build-dir build-aux/com.usebottles.bottles.Devel.json` in the terminal from the root of the repository (use `--user` if necessary)
1. Run `flatpak run com.usebottles.bottles.Devel` to launch it

### Meson

Since Bottles is primarily and officially distributed as a Flatpak, we only provide instructions to directly build it inside a Flatpak environment:

1. Download and install the latest build of Bottles: [bottles-x86_64.zip](https://nightly.link/bottlesdevs/Bottles/workflows/build_flatpak/main/bottles-x86_64.zip). Unzip it, and run `flatpak install bottles.flatpak` (use `--user` if necessary)
2. Run `flatpak run -d --filesystem=$PWD --command=bash com.usebottles.bottles//master` from the root of the repository, followed by `./utils/install.sh`. This will build Bottles and install it under the `build/` directory.
2. Run `flatpak run -d --filesystem=$PWD --command=bash com.usebottles.bottles.Devel` from the root of the repository, followed by `./utils/install.sh`. This will build Bottles and install it under the `build/` directory.
3. Run `./build/bin/bottles` to launch Bottles

Due to GNOME Builder limitations, Builder cannot build Bottles for the time being; see [GNOME/gnome-builder#2061](https://gitlab.gnome.org/GNOME/gnome-builder/-/issues/2061) for more context. This is the best workaround we can provide.
Expand Down
3 changes: 2 additions & 1 deletion bottles/backend/params.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
APP_VERSION = "@APP_VERSION@"
APP_ID = "com.usebottles.bottles"
BASE_ID = "@BASE_ID@"
APP_ID = "@APP_ID@"
2 changes: 1 addition & 1 deletion bottles/frontend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Bottles(Adw.Application):

def __init__(self):
super().__init__(
application_id="com.usebottles.bottles",
application_id=APP_ID,
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
register_session=True,
)
Expand Down
3 changes: 2 additions & 1 deletion bottles/frontend/params.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Application details
APP_NAME = "@APP_NAME@"
APP_NAME_LOWER = APP_NAME.lower()
APP_ID = "com.usebottles.bottles"
BASE_ID = "@BASE_ID@"
APP_ID = "@APP_ID@"
APP_VERSION = "@APP_VERSION@"
APP_ICON = "@APP_ID@"
PROFILE = "@PROFILE@"
Expand Down
1 change: 0 additions & 1 deletion bottles/frontend/ui/list.blp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ template $BottleView: Adw.Bin {
}

Adw.StatusPage bottle_status {
icon-name: "com.usebottles.bottles-symbolic";
title: _("Bottles");
hexpand: true;
vexpand: true;
Expand Down
3 changes: 1 addition & 2 deletions bottles/frontend/ui/loading.blp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ template $LoadingView: Adw.Bin {
Box {
orientation: vertical;

Adw.StatusPage {
icon-name: "com.usebottles.bottles";
Adw.StatusPage loading_status_page {
title: _("Starting up…");
hexpand: true;
vexpand: true;
Expand Down
1 change: 0 additions & 1 deletion bottles/frontend/ui/window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ using Adw 1;

template $MainWindow: Adw.ApplicationWindow {
title: "Bottles";
icon-name: "com.usebottles.bottles";
close-request => $on_close_request();

Adw.ToastOverlay toasts {
Expand Down
3 changes: 3 additions & 0 deletions bottles/frontend/views/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from bottles.backend.utils.threading import RunAsync
from bottles.backend.wine.executor import WineExecutor
from bottles.frontend.utils.filters import add_executable_filters, add_all_filters
from bottles.frontend.params import APP_ID


@Gtk.Template(resource_path="/com/usebottles/bottles/list-entry.ui")
Expand Down Expand Up @@ -182,6 +183,8 @@ def __init__(self, window, arg_bottle=None, **kwargs):
Signals.ManagerLocalBottlesLoaded, self.backend_local_bottle_loaded
)

self.bottle_status.set_icon_name(f"{APP_ID}-symbolic")

self.update_bottles()

def __search_bottles(self, widget, event=None, data=None):
Expand Down
3 changes: 3 additions & 0 deletions bottles/frontend/views/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from bottles.backend.models.result import Result
from bottles.backend.state import SignalManager, Signals
from bottles.frontend.utils.gtk import GtkUtils
from bottles.frontend.params import APP_ID


@Gtk.Template(resource_path="/com/usebottles/bottles/loading.ui")
Expand All @@ -33,10 +34,12 @@ class LoadingView(Adw.Bin):
label_fetched = Gtk.Template.Child()
label_downloading = Gtk.Template.Child()
btn_go_offline = Gtk.Template.Child()
loading_status_page = Gtk.Template.Child()
# endregion

def __init__(self, **kwargs):
super().__init__(**kwargs)
self.loading_status_page.set_icon_name(APP_ID)
self.btn_go_offline.connect("clicked", self.go_offline)

@GtkUtils.run_in_main_loop
Expand Down
4 changes: 2 additions & 2 deletions bottles/frontend/windows/bottlepicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from bottles.backend.managers.manager import Manager
from bottles.backend.models.config import BottleConfig
from bottles.frontend.params import APP_ID
from bottles.frontend.params import BASE_ID


class BottleEntry(Adw.ActionRow):
Expand All @@ -36,7 +36,7 @@ class BottlePickerDialog(Adw.ApplicationWindow):
"""This class should not be called from the application GUI, only from CLI."""

__gtype_name__ = "BottlePickerDialog"
settings = Gio.Settings.new(APP_ID)
settings = Gio.Settings.new(BASE_ID)
Adw.init()

# region Widgets
Expand Down
5 changes: 3 additions & 2 deletions bottles/frontend/windows/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class MainWindow(Adw.ApplicationWindow):

# Common variables
previous_page = ""
settings = Gio.Settings.new(APP_ID)
settings = Gio.Settings.new(BASE_ID)
argument_executed = False

def __init__(self, arg_bottle, **kwargs):
Expand All @@ -86,6 +86,7 @@ def __init__(self, arg_bottle, **kwargs):
self.manager = None
self.arg_bottle = arg_bottle
self.app = kwargs.get("application")
self.set_icon_name(APP_ID)

if PROFILE == "development":
self.add_css_class("devel")
Expand Down Expand Up @@ -219,7 +220,7 @@ def set_manager(result: Manager, error=None):

self.stack_main.add_titled(
child=self.page_list, name="page_list", title=_("Bottles")
).set_icon_name("com.usebottles.bottles-symbolic")
).set_icon_name(f"{APP_ID}-symbolic")
self.stack_main.add_titled(
child=self.page_library, name="page_library", title=_("Library")
).set_icon_name("library-symbolic")
Expand Down
1 change: 1 addition & 0 deletions bottles/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ python = import('python')

conf = configuration_data()
conf.set('PYTHON', python.find_installation('python3').full_path())
conf.set('BASE_ID', BASE_ID)
conf.set('APP_ID', APP_ID)
conf.set('APP_NAME', APP_NAME)
conf.set('APP_VERSION', APP_VERSION)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "com.usebottles.bottles",
"id": "com.usebottles.bottles.Devel",
"sdk": "org.gnome.Sdk",
"runtime": "org.gnome.Platform",
"base": "org.winehq.Wine",
Expand Down
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/sh

run_flatpak() {
flatpak-spawn --host flatpak-builder -v build build-aux/com.usebottles.bottles.json --user --install --force-clean && flatpak-spawn --host flatpak run com.usebottles.bottles
flatpak-spawn --host flatpak-builder -v build build-aux/com.usebottles.bottles.Devel.json --user --install --force-clean && flatpak-spawn --host flatpak run com.usebottles.bottles.Devel
}

run_host() {
flatpak-builder build -v build-aux/com.usebottles.bottles.json --user --install --force-clean && flatpak run com.usebottles.bottles
flatpak-builder build -v build-aux/com.usebottles.bottles.Devel.json --user --install --force-clean && flatpak run com.usebottles.bottles.Devel
}

run_container() {
host-spawn flatpak-builder build -v build-aux/com.usebottles.bottles.json --user --install --force-clean && host-spawn flatpak run com.usebottles.bottles
host-spawn flatpak-builder build -v build-aux/com.usebottles.bottles.Devel.json --user --install --force-clean && host-spawn flatpak run com.usebottles.bottles.Devel
}

if [ -x "$(command -v flatpak-spawn)" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<component type="desktop">
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-only</project_license>
<id>com.usebottles.bottles</id>
<launchable type="desktop-id">com.usebottles.bottles.desktop</launchable>
<id>@APP_ID@</id>
<launchable type="desktop-id">@APP_ID@.desktop</launchable>
<name>Bottles</name>
<summary>Run Windows Software</summary>
<developer_name translatable="no">Bottles Contributors</developer_name>
<developer id="com.usebottles">
<developer id="@DEVELOPER_ID@">
<name translatable="no">Bottles Contributors</name>
</developer>
<description>
Expand Down Expand Up @@ -49,7 +49,7 @@
<image>https://raw.githubusercontent.com/bottlesdevs/Bottles/main/data/appstream/5.png</image>
</screenshot>
</screenshots>
<translation type="gettext">com.usebottles.bottles</translation>
<translation type="gettext">@APP_ID@</translation>
<content_rating type="oars-1.1"/>
<url type="homepage">https://usebottles.com</url>
<url type="bugtracker">https://github.com/bottlesdevs/Bottles/issues</url>
Expand Down
25 changes: 15 additions & 10 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
conf = configuration_data()
conf.set('APP_ID', APP_ID)
conf.set('BASE_ID', BASE_ID)
conf.set('APP_NAME', APP_NAME)

desktop_file = configure_file(
input: 'com.usebottles.bottles.desktop.in.in',
output: 'com.usebottles.bottles.desktop.in',
configuration: conf)
conf.set('DEVELOPER_ID', DEVELOPER_ID)

desktop = i18n.merge_file(
input: desktop_file,
output: 'com.usebottles.bottles.desktop',
input: configure_file(
input: BASE_ID + '.desktop.in.in',
output: BASE_ID + '.desktop.in',
configuration: conf
),
output: APP_ID + '.desktop',
type: 'desktop',
po_dir: '../po',
install: true,
Expand All @@ -24,11 +25,15 @@ if desktop_utils.found()
endif

appstream_file = i18n.merge_file(
input: 'com.usebottles.bottles.metainfo.xml.in',
output: 'com.usebottles.bottles.metainfo.xml',
input: configure_file(
input: BASE_ID + '.' + 'metainfo.xml.in.in',
output: BASE_ID + '.' + 'metainfo.xml.in',
configuration: conf
),
output: APP_ID + '.' + 'metainfo.xml',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'metainfo')
install_dir: get_option('datadir') / 'metainfo'
)

appstream_util = find_program('appstream-util', required: false)
Expand Down
4 changes: 3 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ project(


APP_NAME = 'Bottles'
APP_ID = 'com.usebottles.bottles'
DEVELOPER_ID = 'com.usebottles'
BASE_ID = DEVELOPER_ID + '.' + meson.project_name()
APP_ID = BASE_ID
APP_VERSION = meson.project_version()
PROFILE = get_option('profile')

Expand Down

0 comments on commit 1517f2d

Please sign in to comment.