Coder Social home page Coder Social logo

sjwhyte / syspkg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bluet/syspkg

0.0 0.0 0.0 119 KB

SysPkg: a unified Go library and CLI tool for managing system packages across different package managers (apt, snap, flatpak, yum, dnf, and more).

License: MIT License

Go 98.98% Makefile 1.02%

syspkg's Introduction

SysPkg

Go Reference Go Report Card License

SysPkg is a unified CLI tool and Golang library for managing system packages across different package managers (apt, snap, flatpak, yum, dnf, and more). It simplifies the process of working with various package managers by providing a consistent interface and API through an abstraction layer.

Features

  • A unified package management interface for various package managers
  • Supports popular package managers such as APT, Snap, Flatpak, and more
  • Easy-to-use API for package installation, removal, search, listing, and system upgrades
  • Expandable architecture to support more package managers in the future

API Documentation

See the Go Reference for the full API documentation.

Getting Started

Prerequisites

  • Go 1.16 or later (1.20+ preferred)

Installation (as CLI tool)

Install the CLI tool using the go install command:

go install github.com/bluet/syspkg/cmd/syspkg@latest

Installation (as Go library)

Install the library using the go get command:

go get github.com/bluet/syspkg

Usage

CLI Tool

SysPkg provides a unified CLI tool for managing system packages across different package managers. It simplifies the process of working with various package managers by providing a consistent interface through an abstraction layer.

Here's an example demonstrating how to use SysPkg as a CLI tool:

# Install a package using APT
syspkg --apt install vim

# Remove a package using APT
syspkg --apt remove vim

# Search for a package using Snap
syspkg --snap search vim

# Show all upgradable packages using Flatpak
syspkg --flatpak show upgradable

Or, you can do operations without knowing the package manager:

# Install a package using all available package managers
syspkg install vim

# Remove a package using all available package manager
syspkg remove vim

# Search for a package using all available package manager
syspkg search vim

# Upgrade all packages using all available package manager
syspkg upgrade

For more examples and real use cases, see the cmd/syspkg/ directory.

Go Library

Here's an example demonstrating how to use SysPkg as a Go library:

package main

import (
 "fmt"
 "github.com/bluet/syspkg"
)

func main() {
 // Initialize SysPkg with all available package managers on current system
 includeOptions := syspkg.IncludeOptions{
  AllAvailable: true,
 }
 syspkgManager, err := syspkg.New(includeOptions)
 if err != nil {
  fmt.Printf("Error initializing SysPkg: %v\n", err)
  return
 }

 // List installed packages using APT
 aptManager := syspkgManager.GetPackageManager("apt")
 installedPackages, err := aptManager.ListInstalled(nil)
 if err != nil {
  fmt.Printf("Error listing installed packages: %v\n", err)
  return
 }

 fmt.Println("Installed packages:")
 for _, pkg := range installedPackages {
  fmt.Printf("- %s (%s)\n", pkg.Name, pkg.Version)
 }
}

For more examples and real use cases, see the cmd/syspkg/ directory.

Supported Package Managers

Package Manager Install Remove Search Upgrade List Installed List Upgradable Get Package Info
APT
SNAP
Flatpak
Your favorite package manager here! 🚀 🚀 🚀 🚀 🚀 🚀 🚀

Please open an issue (or PR ❤️) if you'd like to see support for any unlisted specific package manager.

TODO

  • Add support for more package managers
  • Improve error handling
  • Enhance return values and status codes

Contributing

We welcome contributions to Go-SysPkg! Please read our CONTRIBUTING.md for more information on how to contribute.

License

This project is licensed under the MIT License. See the LICENSE file for details.

syspkg's People

Contributors

bluet avatar dependabot[bot] avatar vincentinttsh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.