Skip to content

Commit

Permalink
feat: Add support for installing additional Flatpak references like S…
Browse files Browse the repository at this point in the history
…DKs and base apps through `hydrapp.yaml`

Signed-off-by: Felicitas Pojtinger <felicitas@pojtinger.com>
  • Loading branch information
pojntfx committed Oct 8, 2024
1 parent 22c8dc1 commit dccd4cc
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ dmg:
# flatpak:
# - path: flatpak/x86_64
# architecture: amd64
# packages: []
msi:
- path: msi/x86_64
architecture: amd64
Expand All @@ -620,7 +621,7 @@ rpm:
# packages: []
```
Note that while the DEB and RPM builds automatically include these packages as dependencies, for DMG and MSI builds, you must still ensure that the necessary runtime libraries are installed on your users' systems unless you manually set up static linking.
For a real-world example of this, check out [Connmapper](/~https://github.com/pojntfx/connmapper). Note that while the DEB and RPM builds automatically include these packages as dependencies, for DMG and MSI builds, you must still ensure that the necessary runtime libraries are installed on your users' systems unless you manually set up static linking.
### How can I provide a tagged, alpha, beta, insider etc. channel/edition/version of my app?
Expand Down
2 changes: 2 additions & 0 deletions hydrapp-example-react-panrpc/hydrapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ dmg:
flatpak:
- path: flatpak/x86_64
architecture: amd64
packages: []
- path: flatpak/aarch64
architecture: arm64
packages: []
msi:
- path: msi/x86_64
architecture: amd64
Expand Down
2 changes: 2 additions & 0 deletions hydrapp-example-vanillajs-forms/hydrapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ dmg:
flatpak:
- path: flatpak/x86_64
architecture: amd64
packages: []
- path: flatpak/aarch64
architecture: arm64
packages: []
msi:
- path: msi/x86_64
architecture: amd64
Expand Down
2 changes: 2 additions & 0 deletions hydrapp-example-vanillajs-rest/hydrapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ dmg:
flatpak:
- path: flatpak/x86_64
architecture: amd64
packages: []
- path: flatpak/aarch64
architecture: arm64
packages: []
msi:
- path: msi/x86_64
architecture: amd64
Expand Down
1 change: 1 addition & 0 deletions hydrapp/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ var buildCmd = &cobra.Command{
cfg.App.License,
cfg.App.Homepage,
cfg.App.Git,
c.Packages,
cfg.Releases,
viper.GetBool(overwriteFlag),
branchID,
Expand Down
1 change: 1 addition & 0 deletions hydrapp/cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ var newCmd = &cobra.Command{
flatpaks = append(flatpaks, config.Flatpak{
Path: path.Join("flatpak", utils.GetArchIdentifier(arch)),
Architecture: arch,
Packages: []rpm.Package{},
})
}
cfg.Flatpak = flatpaks
Expand Down
15 changes: 13 additions & 2 deletions hydrapp/pkg/builders/flatpak/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (
"encoding/base64"
"io"
"path/filepath"
"strings"

"github.com/docker/docker/client"
"github.com/pojntfx/hydrapp/hydrapp/pkg/builders"
"github.com/pojntfx/hydrapp/hydrapp/pkg/executors"
"github.com/pojntfx/hydrapp/hydrapp/pkg/renderers"
"github.com/pojntfx/hydrapp/hydrapp/pkg/renderers/flatpak"
"github.com/pojntfx/hydrapp/hydrapp/pkg/renderers/rpm"
"github.com/pojntfx/hydrapp/hydrapp/pkg/renderers/xdg"
"github.com/pojntfx/hydrapp/hydrapp/pkg/utils"
)
Expand Down Expand Up @@ -42,6 +44,7 @@ func NewBuilder(
appSPDX, // App SPDX license identifier
appURL, // App URL
appGit string, // App Git repo URL
references []rpm.Package, // Flatpak references to install
releases []renderers.Release, // App releases
overwrite bool, // Overwrite files even if they exist
branchID, // Branch ID
Expand Down Expand Up @@ -73,6 +76,7 @@ func NewBuilder(
appSPDX,
appURL,
appGit,
references,
releases,
overwrite,
branchID,
Expand Down Expand Up @@ -106,8 +110,9 @@ type Builder struct {
appSPDX,
appURL,
appGit string
releases []renderers.Release
overwrite bool
references []rpm.Package
releases []renderers.Release
overwrite bool
branchID,
branchName,
goMain,
Expand Down Expand Up @@ -251,6 +256,11 @@ func (b *Builder) Build() error {
appID := builders.GetAppIDForBranch(b.appID, b.branchID)
baseURL := builders.GetPathForBranch(b.baseURL, b.branchID, "")

references := []string{}
for _, reference := range b.references {
references = append(references, `"`+reference.Name+"//"+reference.Version+`"`)
}

return executors.DockerRunImage(
b.ctx,
b.cli,
Expand All @@ -268,6 +278,7 @@ func (b *Builder) Build() error {
"PGP_KEY_ID": b.pgpKeyID,
"BASE_URL": baseURL,
"ARCHITECTURE": b.architecture,
"FLATPAKREFS": strings.Join(references, " "),
"GOMAIN": b.goMain,
},
b.Render,
Expand Down
5 changes: 5 additions & 0 deletions hydrapp/pkg/builders/flatpak/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ fi
# Install pre-build SDKs
flatpak install -y --arch="${DEBARCH}" 'flathub' "org.freedesktop.Platform//23.08" "org.freedesktop.Sdk//23.08" "org.freedesktop.Sdk.Extension.golang//23.08" "org.freedesktop.Sdk.Extension.node20//23.08"

# Install extra references
if [ "${FLATPAKREFS}" != "" ]; then
flatpak install -y --arch="${DEBARCH}" 'flathub' ${FLATPAKREFS}
fi

# Build app and export to repo
flatpak-builder -y --arch="${DEBARCH}" --gpg-sign="$(echo ${PGP_KEY_ID} | base64 -d)" --repo='/hydrapp/dst' --force-clean "build-dir" "${GOMAIN}/${APP_ID}.json"

Expand Down
5 changes: 3 additions & 2 deletions hydrapp/pkg/config/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ type DMG struct {
}

type Flatpak struct {
Path string `yaml:"path"`
Architecture string `yaml:"architecture"`
Path string `yaml:"path"`
Architecture string `yaml:"architecture"`
Packages []rpm.Package `yaml:"packages"`
}

type MSI struct {
Expand Down

0 comments on commit dccd4cc

Please sign in to comment.