From 00a56fa985750bbd5df15f3b038bdbb9fe81df43 Mon Sep 17 00:00:00 2001 From: wheelchairy Date: Tue, 4 Feb 2025 21:53:22 +0300 Subject: [PATCH] mehh --- pkg/installer/installer.go | 19 ++++++++++++++++++- pkg/manifest/manifest.go | 3 ++- pkg/version/current.go | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/pkg/installer/installer.go b/pkg/installer/installer.go index 7b09dbd..05cc49e 100644 --- a/pkg/installer/installer.go +++ b/pkg/installer/installer.go @@ -195,6 +195,23 @@ func RemovePackage(name string) error { if _, err := os.Stat(packagePath); os.IsNotExist(err) { return errors.New("package not found") } + manifestPath := filepath.Join(packagePath, "manifest.json") + data, err := ioutil.ReadFile(manifestPath) + if err == nil { + var m manifest.Manifest + if err := json.Unmarshal(data, &m); err == nil { + if len(m.Uninstall) > 0 { + for _, cmdStr := range m.Uninstall { + cmd := exec.Command("sh", "-c", cmdStr) + cmd.Dir = packagePath + output, err := cmd.CombinedOutput() + if err != nil { + return fmt.Errorf("uninstall command '%s' failed: %s", cmdStr, string(output)) + } + } + } + } + } if err := os.RemoveAll(packagePath); err != nil { return fmt.Errorf("failed to remove package: %w", err) } @@ -232,4 +249,4 @@ func GetPackageInfo(name string) (string, error) { return "", err } return string(data), nil -} \ No newline at end of file +} diff --git a/pkg/manifest/manifest.go b/pkg/manifest/manifest.go index 4977f4a..b8681dc 100644 --- a/pkg/manifest/manifest.go +++ b/pkg/manifest/manifest.go @@ -23,6 +23,7 @@ type Manifest struct { Dependencies []string `json:"dependencies"` Build []string `json:"build"` Binaries map[string]BinaryInfo `json:"binaries"` + Uninstall []string `json:"uninstall"` } func FetchManifest(name string) (*Manifest, error) { @@ -66,4 +67,4 @@ func fetchManifestFromURL(url string) (*Manifest, error) { return nil, err } return &m, nil -} \ No newline at end of file +} diff --git a/pkg/version/current.go b/pkg/version/current.go index 02d33a6..8377b37 100644 --- a/pkg/version/current.go +++ b/pkg/version/current.go @@ -1,3 +1,3 @@ package version -const CurrentVersion = "1.0.6" \ No newline at end of file +const CurrentVersion = "1.0.7" \ No newline at end of file