Skip to content

Commit

Permalink
feat:[#45] Waydroid support
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkobrombin committed Sep 2, 2023
1 parent d8afaa0 commit f80f02f
Show file tree
Hide file tree
Showing 313 changed files with 20,709 additions and 10,317 deletions.
121 changes: 121 additions & 0 deletions cmd/waydroid.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package cmd

/* License: GPLv3
Authors:
Mirko Brombin <send@mirko.pm>
Vanilla OS Contributors <https://github.com/vanilla-os/>
Copyright: 2023
Description: VSO is a utility which allows you to perform maintenance
tasks on your Vanilla OS installation.
*/

import (
"github.com/spf13/cobra"
"github.com/vanilla-os/orchid/cmdr"
"github.com/vanilla-os/vso/core"
)

func NewWayCommand() []*cmdr.Command {
// Root command
cmd := cmdr.NewCommand(
"android",
vso.Trans("waydroid.description"),
vso.Trans("waydroid.description"),
nil,
)

// Subcommands
installCmd := cmdr.NewCommand(
"install",
vso.Trans("waydroid.export.description"),
vso.Trans("waydroid.export.description"),
wayInstall,
)

initCmd := cmdr.NewCommand(
"init",
vso.Trans("waydroid.init.description"),
vso.Trans("waydroid.init.description"),
wayInit,
)
initCmd.WithBoolFlag(
cmdr.NewBoolFlag(
"force",
"f",
vso.Trans("waydroid.init.options.force.description"),
false,
),
)

launchCmd := cmdr.NewCommand(
"launch",
vso.Trans("waydroid.launch.description"),
vso.Trans("waydroid.launch.description"),
wayLaunch,
)

launcherCmd := cmdr.NewCommand(
"launcher",
vso.Trans("waydroid.launcher.description"),
vso.Trans("waydroid.launcher.description"),
wayLauncher,
)

// Add subcommands to root
cmd.AddCommand(installCmd)
cmd.AddCommand(initCmd)
cmd.AddCommand(launchCmd)
cmd.AddCommand(launcherCmd)

return []*cmdr.Command{cmd}
}

func wayInit(cmd *cobra.Command, args []string) error {
force, _ := cmd.Flags().GetBool("force")

if core.WayExists() && !force {
cmdr.Error.Println(vso.Trans("waydroid.error.alreadyInitialized"))
return nil
}

err := core.WayInit()
if err != nil {
return err
}

cmdr.Success.Println(vso.Trans("waydroid.info.initialized"))
return nil
}

func wayInstall(cmd *cobra.Command, args []string) error {
way, err := core.GetWay()
if err != nil {
return err
}

finalArgs := []string{"ewaydroid", "app", "install"}
_, err = way.Exec(false, finalArgs...)
return err
}

func wayLaunch(cmd *cobra.Command, args []string) error {
way, err := core.GetWay()
if err != nil {
return err
}

finalArgs := []string{"ewaydroid", "app", "launch"}
_, err = way.Exec(false, finalArgs...)
return err
}

func wayLauncher(cmd *cobra.Command, args []string) error {
way, err := core.GetWay()
if err != nil {
return err
}

finalArgs := []string{"ewaydroid", "show-full-ui"}
_, err = way.Exec(false, finalArgs...)
return err
}
4 changes: 3 additions & 1 deletion core/pico.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func GetPico() (*core.SubSystem, error) {
subsystem, err := core.LoadSubSystem("vso-pico")
subsystem, err := core.LoadSubSystem("vso-pico", false)
if err != nil {
return nil, err
}
Expand All @@ -25,6 +25,8 @@ func PicoInit() error {
stack,
true,
true,
false,
false,
)

if err != nil {
Expand Down
57 changes: 57 additions & 0 deletions core/waydroid.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package core

import (
"github.com/vanilla-os/apx/core"
)

func GetWay() (*core.SubSystem, error) {
subsystem, err := core.LoadSubSystem("vso-waydroid", true)
if err != nil {
return nil, err
}

return subsystem, nil
}

func WayExists() bool {
_, err := GetWay()
return err == nil
}

func WayInit() error {
stack, _ := core.LoadStack("vso-waydroid")
subsystem, err := core.NewSubSystem(
"vso-waydroid",
stack,
true,
true,
true,
true,
)

if err != nil {
return err
}

err = subsystem.Create()
if err != nil {
return err
}

_, err = subsystem.Exec(false, "ewaydroid", "--version")
return err
}

func WayDelete() error {
subsystem, err := GetWay()
if err != nil {
return err
}

err = subsystem.Remove()
if err != nil {
return err
}

return nil
}
33 changes: 17 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,39 @@ go 1.18

require (
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/cobra v1.6.1
github.com/vanilla-os/apx v1.7.0-1.0.20230709131234-3596eecab438
github.com/spf13/cobra v1.7.0
github.com/vanilla-os/apx v1.7.0-1.0.20230902193854-6327d3dbba3a
github.com/vanilla-os/orchid v0.4.0
)

require (
atomicgo.dev/cursor v0.1.1 // indirect
atomicgo.dev/cursor v0.2.0 // indirect
atomicgo.dev/keyboard v0.2.9 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/fitv/go-i18n v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/gookit/color v1.5.2 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/lithammer/fuzzysearch v1.1.5 // indirect
github.com/lithammer/fuzzysearch v1.1.8 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pterm/pterm v0.12.53 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/term v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/term v0.11.0 // indirect
golang.org/x/text v0.13.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand All @@ -44,5 +45,5 @@ require (
require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.14.0
github.com/spf13/viper v1.16.0
)

0 comments on commit f80f02f

Please sign in to comment.