Skip to content

Commit 35b5d30

Browse files
authored
Add a commont brew installer (#254)
1 parent 7fde2eb commit 35b5d30

File tree

8 files changed

+56
-217
lines changed

8 files changed

+56
-217
lines changed

pkg/os/brew/asciinema.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

pkg/os/brew/bash-completion.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

pkg/os/brew/common.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package brew
2+
3+
import (
4+
"fmt"
5+
"github.com/linuxsuren/http-downloader/pkg/exec"
6+
"runtime"
7+
)
8+
9+
// CommonInstaller is the installer of a common brew
10+
type CommonInstaller struct {
11+
Name string
12+
}
13+
14+
// Available check if support current platform
15+
func (d *CommonInstaller) Available() (ok bool) {
16+
if runtime.GOOS == "darwin" {
17+
_, err := exec.LookPath("brew")
18+
ok = err == nil
19+
}
20+
return
21+
}
22+
23+
// Install installs the target package
24+
func (d *CommonInstaller) Install() (err error) {
25+
if err = exec.RunCommand("brew", "install", d.Name); err != nil {
26+
return
27+
}
28+
return
29+
}
30+
31+
// Uninstall uninstalls the Conntrack
32+
func (d *CommonInstaller) Uninstall() (err error) {
33+
err = exec.RunCommand("brew", "remove", d.Name)
34+
return
35+
}
36+
37+
// WaitForStart waits for the service be started
38+
func (d *CommonInstaller) WaitForStart() (ok bool, err error) {
39+
ok = true
40+
return
41+
}
42+
43+
// Start starts the Conntrack service
44+
func (d *CommonInstaller) Start() error {
45+
fmt.Println("not supported yet")
46+
return nil
47+
}
48+
49+
// Stop stops the Conntrack service
50+
func (d *CommonInstaller) Stop() error {
51+
fmt.Println("not supported yet")
52+
return nil
53+
}

pkg/os/brew/ffmpeg.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

pkg/os/brew/init.go

Lines changed: 0 additions & 11 deletions
This file was deleted.

pkg/os/brew/vim.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

pkg/os/generic_installer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/linuxsuren/http-downloader/pkg/exec"
1010
"github.com/linuxsuren/http-downloader/pkg/os/apt"
11+
"github.com/linuxsuren/http-downloader/pkg/os/brew"
1112
"github.com/linuxsuren/http-downloader/pkg/os/core"
1213
"github.com/linuxsuren/http-downloader/pkg/os/yum"
1314
"gopkg.in/yaml.v3"
@@ -75,6 +76,8 @@ func GenericInstallerRegistry(configFile string, registry core.InstallerRegistry
7576
genericPackage.CommonInstaller = &apt.CommonInstaller{Name: genericPackage.Name}
7677
case "yum":
7778
genericPackage.CommonInstaller = &yum.CommonInstaller{Name: genericPackage.Name}
79+
case "brew":
80+
genericPackage.CommonInstaller = &brew.CommonInstaller{Name: genericPackage.Name}
7881
}
7982

8083
registry.Registry(genericPackage.Name, &genericPackage)

pkg/os/installer.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package os
33
import (
44
"fmt"
55
"github.com/linuxsuren/http-downloader/pkg/os/apt"
6-
"github.com/linuxsuren/http-downloader/pkg/os/brew"
76
"github.com/linuxsuren/http-downloader/pkg/os/core"
87
"github.com/linuxsuren/http-downloader/pkg/os/docker"
98
"github.com/linuxsuren/http-downloader/pkg/os/yum"
@@ -25,7 +24,6 @@ func init() {
2524
}
2625
yum.SetInstallerRegistry(defaultInstallerRegistry)
2726
apt.SetInstallerRegistry(defaultInstallerRegistry)
28-
brew.SetInstallerRegistry(defaultInstallerRegistry)
2927
docker.SetInstallerRegistry(defaultInstallerRegistry)
3028

3129
var userHome string

0 commit comments

Comments
 (0)