Compare commits
	
		
			15 Commits
		
	
	
		
			05af0969e9
			...
			main
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| fe0da8ad63 | |||
| 885ce25fe9 | |||
| 1c3e448b8d | |||
| 22fb19a550 | |||
| aa98cd81b3 | |||
| e33f7b6d3c | |||
| a0704d6ac6 | |||
| c44abc78d6 | |||
| 064ee7f404 | |||
| 52ecacc4fe | |||
| 4c88ec3bc2 | |||
| ff5e271195 | |||
| cbea1dd8b5 | |||
| acf00bc5f8 | |||
| b15d847fd2 | 
							
								
								
									
										66
									
								
								cmd/packets/cli.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								cmd/packets/cli.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,66 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"os/exec"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/charmbracelet/bubbles/list"
 | 
				
			||||||
 | 
						tea "github.com/charmbracelet/bubbletea"
 | 
				
			||||||
 | 
						"github.com/charmbracelet/lipgloss"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var docStyle = lipgloss.NewStyle().Margin(1, 2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type item struct {
 | 
				
			||||||
 | 
						title, desc string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (i item) Title() string       { return i.title }
 | 
				
			||||||
 | 
					func (i item) Description() string { return i.desc }
 | 
				
			||||||
 | 
					func (i item) FilterValue() string { return i.title }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type model struct {
 | 
				
			||||||
 | 
						list list.Model
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m model) Init() tea.Cmd {
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type vimMsg struct{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 | 
				
			||||||
 | 
						switch msg := msg.(type) {
 | 
				
			||||||
 | 
						case tea.KeyMsg:
 | 
				
			||||||
 | 
							if msg.String() == "ctrl+c" || msg.String() == "q" {
 | 
				
			||||||
 | 
								return m, tea.Quit
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if msg.String() == "enter" {
 | 
				
			||||||
 | 
								path := m.list.SelectedItem().(item).desc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								tea.ExecProcess(openEditor("vim", path), nil)
 | 
				
			||||||
 | 
								return m, tea.Quit
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						case tea.WindowSizeMsg:
 | 
				
			||||||
 | 
							h, v := docStyle.GetFrameSize()
 | 
				
			||||||
 | 
							m.list.SetSize(msg.Width-h, msg.Height-v)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var cmd tea.Cmd
 | 
				
			||||||
 | 
						m.list, cmd = m.list.Update(msg)
 | 
				
			||||||
 | 
						return m, cmd
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (m model) View() string {
 | 
				
			||||||
 | 
						return docStyle.Render(m.list.View())
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func openEditor(editor, path string) *exec.Cmd {
 | 
				
			||||||
 | 
						time.Sleep(1 * time.Second)
 | 
				
			||||||
 | 
						cmd := exec.Command(editor, path)
 | 
				
			||||||
 | 
						cmd.Stdin = os.Stdin
 | 
				
			||||||
 | 
						cmd.Stdout = os.Stdout
 | 
				
			||||||
 | 
						cmd.Stderr = os.Stderr
 | 
				
			||||||
 | 
						return cmd
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										28
									
								
								cmd/packets/config.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								cmd/packets/config.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"path/filepath"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/pelletier/go-toml/v2"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type PacketsConfiguration struct {
 | 
				
			||||||
 | 
						BinDir string `toml:"BinDir"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func GetConfiguration() error {
 | 
				
			||||||
 | 
						configFile := filepath.Join(ConfigurationDir, "config.toml")
 | 
				
			||||||
 | 
						data, err := os.ReadFile(configFile)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						var config PacketsConfiguration
 | 
				
			||||||
 | 
						err = toml.Unmarshal(data, &config)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Config = &config
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										132
									
								
								cmd/packets/database/execute.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										132
									
								
								cmd/packets/database/execute.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,132 @@
 | 
				
			|||||||
 | 
					package database
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"database/sql"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_ "github.com/mattn/go-sqlite3"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/internal/lua"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/pkg/install"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/pkg/packet.lua.d"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const (
 | 
				
			||||||
 | 
						CreateInstructions = `
 | 
				
			||||||
 | 
					CREATE TABLE IF NOT EXISTS installed_packages(
 | 
				
			||||||
 | 
					    name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    id TEXT PRIMARY KEY,
 | 
				
			||||||
 | 
					    version TEXT NOT NULL,
 | 
				
			||||||
 | 
					    serial INTEGER NOT NULL,
 | 
				
			||||||
 | 
					    maintainer TEXT NOT NULL,
 | 
				
			||||||
 | 
					    verified INTEGER NOT NULL DEFAULT 0,
 | 
				
			||||||
 | 
					    description TEXT NOT NULL,
 | 
				
			||||||
 | 
					    upload_time TEXT NOT NULL,
 | 
				
			||||||
 | 
					    installed_time INTEGER NOT NULL,
 | 
				
			||||||
 | 
					    image BLOB,
 | 
				
			||||||
 | 
					    UNIQUE(name, version),
 | 
				
			||||||
 | 
					    UNIQUE(name, serial)
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE IF NOT EXISTS package_files(
 | 
				
			||||||
 | 
					    package_id TEXT NOT NULL,
 | 
				
			||||||
 | 
					    path TEXT NOT NULL,
 | 
				
			||||||
 | 
					    is_dir INTEGER NOT NULL DEFAULT 0,
 | 
				
			||||||
 | 
					    UNIQUE(package_id, path)
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE IF NOT EXISTS dependencies(
 | 
				
			||||||
 | 
					    package_id TEXT NOT NULL,
 | 
				
			||||||
 | 
					    dependency_name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    version_constraint TEXT NOT NULL,
 | 
				
			||||||
 | 
					    PRIMARY KEY (package_id, dependency_name)
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE IF NOT EXISTS build_dependencies(
 | 
				
			||||||
 | 
					    package_id TEXT NOT NULL,
 | 
				
			||||||
 | 
					    dependency_name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    version_constraint TEXT NOT NULL,
 | 
				
			||||||
 | 
					    PRIMARY KEY (package_id, dependency_name)
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE IF NOT EXISTS conflicts(
 | 
				
			||||||
 | 
					    package_id TEXT NOT NULL,
 | 
				
			||||||
 | 
					    dependency_name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    version_constraint TEXT NOT NULL,
 | 
				
			||||||
 | 
					    PRIMARY KEY (package_id, dependency_name)
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE IF NOT EXISTS package_flags(
 | 
				
			||||||
 | 
					    package_id TEXT NOT NULL,
 | 
				
			||||||
 | 
					    flag TEXT NOT NULL,
 | 
				
			||||||
 | 
					    name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    path TEXT NOT NULL
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					`
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type DatabaseOptions struct {
 | 
				
			||||||
 | 
						// Add any additional options here
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func MarkAsInstalled(pkg packet.PacketLua, files []install.BasicFileStatus, PACKETDIR string, flags []lua.Flag, db *sql.DB, image []byte, upload_time int64) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						switch {
 | 
				
			||||||
 | 
						case upload_time == 0:
 | 
				
			||||||
 | 
							upload_time = time.Now().UnixMilli()
 | 
				
			||||||
 | 
						case image == nil:
 | 
				
			||||||
 | 
							image = []byte{1}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := db.Exec("INSERT INTO installed_packages (name, id, version, installed_time, image, serial, maintainer, description, upload_time) VALUES (?, ?, ?, ?, ?, ?,?,?,?)", pkg.Name, pkg.Name+"@"+pkg.Version, pkg.Version, time.Now().UnixMilli(), image, pkg.Serial, pkg.Maintainer, pkg.Description, time.Now().UnixMilli())
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							db.Exec("DELETE FROM installed_packages WHERE id = ?", pkg.Name+"@"+pkg.Version)
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, v := range files {
 | 
				
			||||||
 | 
							v.Filepath, _ = strings.CutPrefix(v.Filepath, PACKETDIR)
 | 
				
			||||||
 | 
							_, err = db.Exec("INSERT INTO package_files (package_id, path, is_dir) VALUES (?, ?, ?)", pkg.Name+"@"+pkg.Version, v.Filepath, v.IsDir)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								db.Exec("DELETE FROM installed_packages WHERE id = ?", pkg.Name+"@"+pkg.Version)
 | 
				
			||||||
 | 
								db.Exec("DELETE FROM package_files WHERE package_id = ?", pkg.Name+"@"+pkg.Version)
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, v := range flags {
 | 
				
			||||||
 | 
							_, err = db.Exec("INSERT INTO package_flags (package_id, flag, name, path) VALUES (?, ?, ?, ?)", pkg.Name+"@"+pkg.Version, v.FlagType, v.Name, v.Path)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								db.Exec("DELETE FROM installed_packages WHERE id = ?", pkg.Name+"@"+pkg.Version)
 | 
				
			||||||
 | 
								db.Exec("DELETE FROM package_files WHERE package_id = ?", pkg.Name+"@"+pkg.Version)
 | 
				
			||||||
 | 
								db.Exec("DELETE FROM package_flags WHERE package_id = ?", pkg.Name+"@"+pkg.Version)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func MarkAsUninstalled(id string, db *sql.DB) error {
 | 
				
			||||||
 | 
						if _, err := db.Exec("DELETE FROM installed_packages WHERE id = ?", id); err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if _, err := db.Exec("DELETE FROM package_files WHERE package_id = ?", id); err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if _, err := db.Exec("DELETE FROM package_flags WHERE package_id = ?", id); err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func PrepareDataBase(db *sql.DB) {
 | 
				
			||||||
 | 
						_, err := db.Exec(CreateInstructions)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							fmt.Println("Error preparing database:", err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										72
									
								
								cmd/packets/database/query.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								cmd/packets/database/query.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,72 @@
 | 
				
			|||||||
 | 
					package database
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"database/sql"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/internal/lua"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/pkg/install"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/pkg/packet.lua.d"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// this function will get from a package name an id based on installed packages
 | 
				
			||||||
 | 
					func GetPackageId(name string, db *sql.DB) (packet.PackageID, error) {
 | 
				
			||||||
 | 
						var id packet.PackageID
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if strings.Contains(name, "@") {
 | 
				
			||||||
 | 
							id.ID = strings.SplitAfter(name, "@")[0]
 | 
				
			||||||
 | 
							return id, nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						err := db.QueryRow("SELECT id FROM installed_packages WHERE name = ?", name).Scan(&id.ID)
 | 
				
			||||||
 | 
						return id, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func SearchIfIsInstalled(name string, db *sql.DB) (bool, error) {
 | 
				
			||||||
 | 
						var exists bool
 | 
				
			||||||
 | 
						err := db.QueryRow("SELECT EXISTS(SELECT 1 FROM installed_packages WHERE name = ?)", name).Scan(&exists)
 | 
				
			||||||
 | 
						return exists, err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func GetAllFromFlag(packageID packet.PackageID, flagType string, db *sql.DB) ([]lua.Flag, error) {
 | 
				
			||||||
 | 
						var flags []lua.Flag
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						rows, err := db.Query("SELECT name, path FROM package_flags WHERE package_id = ? AND flag = ?", packageID.ID, flagType)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						defer rows.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for rows.Next() {
 | 
				
			||||||
 | 
							var flag lua.Flag
 | 
				
			||||||
 | 
							if err := rows.Scan(&flag.Name, &flag.Path); err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							flag.FlagType = flagType
 | 
				
			||||||
 | 
							flags = append(flags, flag)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return flags, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func GetPackageFiles(packageID packet.PackageID, db *sql.DB) ([]install.BasicFileStatus, error) {
 | 
				
			||||||
 | 
						var files []install.BasicFileStatus
 | 
				
			||||||
 | 
						rows, err := db.Query("SELECT path, is_dir FROM package_files WHERE package_id = ?", packageID.ID)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						defer rows.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for rows.Next() {
 | 
				
			||||||
 | 
							var file install.BasicFileStatus
 | 
				
			||||||
 | 
							if err := rows.Scan(&file.Filepath, &file.IsDir); err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							files = append(files, file)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if err := rows.Err(); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return files, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										153
									
								
								cmd/packets/decompress/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								cmd/packets/decompress/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,153 @@
 | 
				
			|||||||
 | 
					package decompress
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"archive/tar"
 | 
				
			||||||
 | 
						"archive/zip"
 | 
				
			||||||
 | 
						"bytes"
 | 
				
			||||||
 | 
						"compress/bzip2"
 | 
				
			||||||
 | 
						"compress/gzip"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"path/filepath"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/klauspost/compress/zstd"
 | 
				
			||||||
 | 
						"github.com/pierrec/lz4/v4"
 | 
				
			||||||
 | 
						"github.com/ulikunitz/xz"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func extractZipFile(file *zip.File, dest string) error {
 | 
				
			||||||
 | 
						rc, err := file.Open()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						defer rc.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						path := filepath.Join(dest, file.Name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if file.FileInfo().IsDir() {
 | 
				
			||||||
 | 
							return os.MkdirAll(path, file.Mode())
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						outFile, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, file.Mode())
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						defer outFile.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err = io.Copy(outFile, rc)
 | 
				
			||||||
 | 
						return err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func Decompress(data io.Reader, outputDir, filename string) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var reader io.Reader
 | 
				
			||||||
 | 
						switch {
 | 
				
			||||||
 | 
						case strings.HasSuffix(filename, ".gz"):
 | 
				
			||||||
 | 
							var err error
 | 
				
			||||||
 | 
							reader, err = gzip.NewReader(data)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							filename, _ = strings.CutSuffix(filename, ".gz")
 | 
				
			||||||
 | 
						case strings.HasSuffix(filename, ".xz"):
 | 
				
			||||||
 | 
							var err error
 | 
				
			||||||
 | 
							reader, err = xz.NewReader(data)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							filename, _ = strings.CutSuffix(filename, ".xz")
 | 
				
			||||||
 | 
						case strings.HasSuffix(filename, ".zst"), strings.HasSuffix(filename, ".pkt"):
 | 
				
			||||||
 | 
							var err error
 | 
				
			||||||
 | 
							reader, err = zstd.NewReader(data)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							filename, _ = strings.CutSuffix(filename, ".zst")
 | 
				
			||||||
 | 
						case strings.HasSuffix(filename, ".bz2"):
 | 
				
			||||||
 | 
							reader = bzip2.NewReader(data)
 | 
				
			||||||
 | 
							filename, _ = strings.CutSuffix(filename, ".bz2")
 | 
				
			||||||
 | 
						case strings.HasSuffix(filename, ".lz4"):
 | 
				
			||||||
 | 
							reader = lz4.NewReader(data)
 | 
				
			||||||
 | 
							filename, _ = strings.CutSuffix(filename, ".lz4")
 | 
				
			||||||
 | 
						case strings.HasSuffix(filename, ".zip"):
 | 
				
			||||||
 | 
							content, err := io.ReadAll(data)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							reader, err := zip.NewReader(bytes.NewReader(content), int64(len(content)))
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if err := os.MkdirAll(outputDir, 0755); err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for _, file := range reader.File {
 | 
				
			||||||
 | 
								err := extractZipFile(file, outputDir)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return fmt.Errorf("error unziping %s: %w", file.Name, err)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if strings.HasSuffix(filename, ".tar") || strings.HasSuffix(filename, ".pkt") {
 | 
				
			||||||
 | 
							tarReader := tar.NewReader(reader)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for {
 | 
				
			||||||
 | 
								header, err := tarReader.Next()
 | 
				
			||||||
 | 
								if err == io.EOF {
 | 
				
			||||||
 | 
									break
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								targetPath := filepath.Join(outputDir, filepath.Clean(header.Name))
 | 
				
			||||||
 | 
								if !strings.HasPrefix(targetPath, outputDir) {
 | 
				
			||||||
 | 
									return fmt.Errorf("invalid path: %s", targetPath)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								switch header.Typeflag {
 | 
				
			||||||
 | 
								case tar.TypeDir:
 | 
				
			||||||
 | 
									if err := os.MkdirAll(targetPath, os.FileMode(header.Mode)); err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								case tar.TypeReg, tar.TypeRegA:
 | 
				
			||||||
 | 
									if err := os.MkdirAll(filepath.Dir(targetPath), 0755); err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									outFile, err := os.OpenFile(targetPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.FileMode(header.Mode))
 | 
				
			||||||
 | 
									if err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									defer outFile.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if _, err := io.Copy(outFile, tarReader); err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								case tar.TypeSymlink:
 | 
				
			||||||
 | 
									if err := os.Symlink(header.Linkname, targetPath); err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								case tar.TypeLink:
 | 
				
			||||||
 | 
									linkPath := filepath.Join(outputDir, header.Linkname)
 | 
				
			||||||
 | 
									if err := os.Link(linkPath, targetPath); err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								default:
 | 
				
			||||||
 | 
									return fmt.Errorf("unknown file type: %c => %s", header.Typeflag, header.Name)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										84
									
								
								cmd/packets/flags.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								cmd/packets/flags.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,84 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"database/sql"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/charmbracelet/bubbles/list"
 | 
				
			||||||
 | 
						tea "github.com/charmbracelet/bubbletea"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/cmd/packets/database"
 | 
				
			||||||
 | 
						"github.com/spf13/cobra"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var configCmd = &cobra.Command{
 | 
				
			||||||
 | 
						Use:   "config {name or id}",
 | 
				
			||||||
 | 
						Short: "Show package configuration file",
 | 
				
			||||||
 | 
						Long:  "Show package configuration file",
 | 
				
			||||||
 | 
						Args:  cobra.RangeArgs(1, 1),
 | 
				
			||||||
 | 
						PreRun: func(cmd *cobra.Command, args []string) {
 | 
				
			||||||
 | 
							GrantPrivilegies()
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						Run: func(cmd *cobra.Command, args []string) {
 | 
				
			||||||
 | 
							insertedName := args[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							db, err := sql.Open("sqlite3", InternalDB)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								fmt.Println("Error opening database:", err)
 | 
				
			||||||
 | 
								os.Exit(1)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							defer db.Close()
 | 
				
			||||||
 | 
							database.PrepareDataBase(db)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							id, err := database.GetPackageId(insertedName, db)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								fmt.Println("Error getting package ID:", err)
 | 
				
			||||||
 | 
								os.Exit(1)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							flags, err := database.GetAllFromFlag(id, "config", db)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								fmt.Println("Error getting flags:", err)
 | 
				
			||||||
 | 
								os.Exit(1)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var all []list.Item
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for _, flag := range flags {
 | 
				
			||||||
 | 
								item := item{
 | 
				
			||||||
 | 
									title: flag.Name,
 | 
				
			||||||
 | 
									desc:  flag.Path,
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								all = append(all, item)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							/*
 | 
				
			||||||
 | 
								delegate1 := list.NewDefaultDelegate()
 | 
				
			||||||
 | 
								delegate1.Styles.NormalTitle = lipgloss.NewStyle().
 | 
				
			||||||
 | 
									Foreground(lipgloss.Color("#FFFFFF")).
 | 
				
			||||||
 | 
									Background(lipgloss.Color("#000000")).
 | 
				
			||||||
 | 
									Margin(1)
 | 
				
			||||||
 | 
								delegate1.Styles.NormalDesc = lipgloss.NewStyle().
 | 
				
			||||||
 | 
									Foreground(lipgloss.Color("#000000"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								delegate1.Styles.SelectedTitle = lipgloss.NewStyle().
 | 
				
			||||||
 | 
									Foreground(lipgloss.Color("#0056FF")).
 | 
				
			||||||
 | 
									Bold(true).
 | 
				
			||||||
 | 
									Blink(true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								delegate1.Styles.SelectedDesc = lipgloss.NewStyle().
 | 
				
			||||||
 | 
									Foreground(lipgloss.Color("#FFFFFF")).
 | 
				
			||||||
 | 
									Bold(true).
 | 
				
			||||||
 | 
									Faint(true)
 | 
				
			||||||
 | 
							*/
 | 
				
			||||||
 | 
							m := model{list: list.New(all, list.NewDefaultDelegate(), 0, 0)}
 | 
				
			||||||
 | 
							m.list.Title = "Configuration files"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							p := tea.NewProgram(m, tea.WithAltScreen())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if _, err := p.Run(); err != nil {
 | 
				
			||||||
 | 
								fmt.Println("Error running program:", err)
 | 
				
			||||||
 | 
								os.Exit(1)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										44
									
								
								cmd/packets/functions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								cmd/packets/functions.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"bytes"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"path"
 | 
				
			||||||
 | 
						"path/filepath"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/go-git/go-git/v6"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/cmd/packets/decompress"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/pkg/packet.lua.d"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func DownloadSource(sources *[]packet.Source, configs *packet.Config) error {
 | 
				
			||||||
 | 
						for _, source := range *sources {
 | 
				
			||||||
 | 
							downloaded, err := packet.GetSource(source.Url, source.Method, source.Specs, NumberOfTryAttempts)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return fmt.Errorf("error: %s", err.Error())
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if source.Method == "GET" || source.Method == "POST" {
 | 
				
			||||||
 | 
								f := downloaded.([]byte)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								buf := bytes.NewBuffer(f)
 | 
				
			||||||
 | 
								_ = os.MkdirAll(configs.SourcesDir, 0755)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if err := decompress.Decompress(buf, configs.SourcesDir, path.Base(source.Url)); err != nil {
 | 
				
			||||||
 | 
									return fmt.Errorf("error: %s", err.Error())
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								options := downloaded.(*git.CloneOptions)
 | 
				
			||||||
 | 
								repoName, _ := strings.CutSuffix(filepath.Base(source.Url), ".git")
 | 
				
			||||||
 | 
								_ = os.MkdirAll(filepath.Join(configs.SourcesDir, repoName), 0755)
 | 
				
			||||||
 | 
								_, err := git.PlainClone(filepath.Join(configs.SourcesDir, repoName), options)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return fmt.Errorf("error: %s", err.Error())
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								os.RemoveAll(filepath.Join(configs.SourcesDir, repoName, ".git"))
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										309
									
								
								cmd/packets/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										309
									
								
								cmd/packets/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,309 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"archive/tar"
 | 
				
			||||||
 | 
						"database/sql"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
 | 
						"io/fs"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"path/filepath"
 | 
				
			||||||
 | 
						"runtime"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/klauspost/compress/zstd"
 | 
				
			||||||
 | 
						_ "github.com/mattn/go-sqlite3"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/cmd/packets/database"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/cmd/packets/decompress"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/pkg/install"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/pkg/packet.lua.d"
 | 
				
			||||||
 | 
						"github.com/spf13/cobra"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func GrantPrivilegies() {
 | 
				
			||||||
 | 
						if os.Geteuid() != 0 {
 | 
				
			||||||
 | 
							fmt.Println("error: this operation must be run as root")
 | 
				
			||||||
 | 
							os.Exit(1)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var Config *PacketsConfiguration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var rootCmd = &cobra.Command{
 | 
				
			||||||
 | 
						Use:   "packets",
 | 
				
			||||||
 | 
						Short: "A tool for managing packets",
 | 
				
			||||||
 | 
						Long:  "A multiplatform package manager",
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var executeCmd = &cobra.Command{
 | 
				
			||||||
 | 
						Use:   "execute {path}",
 | 
				
			||||||
 | 
						Short: "Installs a package from a given .pkt file",
 | 
				
			||||||
 | 
						Long:  "Installs a package from a given .pkt file",
 | 
				
			||||||
 | 
						Args:  cobra.MinimumNArgs(1),
 | 
				
			||||||
 | 
						PreRunE: func(cmd *cobra.Command, args []string) error {
 | 
				
			||||||
 | 
							GrantPrivilegies()
 | 
				
			||||||
 | 
							return GetConfiguration()
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						Run: func(cmd *cobra.Command, args []string) {
 | 
				
			||||||
 | 
							for _, v := range args {
 | 
				
			||||||
 | 
								var pkg packet.PacketLua
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if !strings.HasSuffix(v, ".pkt") {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s is not a valid Packets packet file\n", v)
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								contentBlob, err := os.Open(v)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s could not be read\n", v)
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								defer contentBlob.Close()
 | 
				
			||||||
 | 
								pkg, err = packet.ReadPacketFromZSTDF(contentBlob, &packet.Config{BinDir: Config.BinDir})
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								rootdir, err := filepath.Abs(filepath.Join(PackageRootDir, pkg.Name+"@"+pkg.Version))
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								sourcesdir, err := filepath.Abs(filepath.Join(rootdir, "src"))
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								packetsdir, err := filepath.Abs(filepath.Join(rootdir, "packet"))
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								configs := &packet.Config{
 | 
				
			||||||
 | 
									BinDir:     Config.BinDir,
 | 
				
			||||||
 | 
									RootDir:    rootdir,
 | 
				
			||||||
 | 
									SourcesDir: sourcesdir,
 | 
				
			||||||
 | 
									PacketDir:  packetsdir,
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								db, err := sql.Open("sqlite3", InternalDB)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								defer db.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								database.PrepareDataBase(db)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if installed, err := database.SearchIfIsInstalled(pkg.Name, db); err == nil {
 | 
				
			||||||
 | 
									if installed {
 | 
				
			||||||
 | 
										fmt.Printf("package %s is already installed", pkg.Name)
 | 
				
			||||||
 | 
										continue
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								backupDir, err := filepath.Abs(".")
 | 
				
			||||||
 | 
								_ = ChangeToNoPermission()
 | 
				
			||||||
 | 
								_ = os.MkdirAll(configs.RootDir, 0755)
 | 
				
			||||||
 | 
								contentBlob.Seek(0, io.SeekStart)
 | 
				
			||||||
 | 
								if err := decompress.Decompress(contentBlob, configs.RootDir, filepath.Base(v)); err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								_ = os.MkdirAll(configs.SourcesDir, 0755)
 | 
				
			||||||
 | 
								_ = os.MkdirAll(configs.PacketDir, 0755)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if err := DownloadSource(pkg.GlobalSources, configs); err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if pkg.Plataforms != nil {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									temp := *pkg.Plataforms
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if plataform, exists := temp[packet.OperationalSystem(runtime.GOOS)]; exists {
 | 
				
			||||||
 | 
										if err := DownloadSource(plataform.Sources, configs); err != nil {
 | 
				
			||||||
 | 
											fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
											os.Exit(1)
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								pkg.ExecuteBuild(configs)
 | 
				
			||||||
 | 
								pkg.ExecuteInstall(configs)
 | 
				
			||||||
 | 
								_ = ElevatePermission()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								os.Chdir(backupDir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								files, err := install.GetPackageFiles(configs.PacketDir)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if err := install.InstallFiles(files, configs.PacketDir); err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if err := database.MarkAsInstalled(pkg, files, configs.PacketDir, pkg.Flags, db, nil, 0); err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var removeCmd = &cobra.Command{
 | 
				
			||||||
 | 
						Use:   "remove {name or id}",
 | 
				
			||||||
 | 
						Short: "Removes a package from the system",
 | 
				
			||||||
 | 
						Long:  "Removes a package from the system",
 | 
				
			||||||
 | 
						Args:  cobra.MinimumNArgs(1),
 | 
				
			||||||
 | 
						PreRun: func(cmd *cobra.Command, args []string) {
 | 
				
			||||||
 | 
							GrantPrivilegies()
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						Run: func(cmd *cobra.Command, args []string) {
 | 
				
			||||||
 | 
							for _, arg := range args {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								db, err := sql.Open("sqlite3", InternalDB)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s\n", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								defer db.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								id, err := database.GetPackageId(arg, db)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									if err == sql.ErrNoRows {
 | 
				
			||||||
 | 
										fmt.Printf("package %s not found\n", arg)
 | 
				
			||||||
 | 
										continue
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									fmt.Printf("error: %s\n", err.Error())
 | 
				
			||||||
 | 
									continue
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								files, err := database.GetPackageFiles(id, db)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s\n", err.Error())
 | 
				
			||||||
 | 
									continue
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								for _, file := range files {
 | 
				
			||||||
 | 
									if !file.IsDir {
 | 
				
			||||||
 | 
										if err := os.Remove(file.Filepath); err != nil {
 | 
				
			||||||
 | 
											fmt.Printf("error: %s\n", err.Error())
 | 
				
			||||||
 | 
											continue
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if err := database.MarkAsUninstalled(id.ID, db); err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error removing package from database but successfully removed it from the system: %s\n", err.Error())
 | 
				
			||||||
 | 
									continue
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var devCmd = &cobra.Command{
 | 
				
			||||||
 | 
						Use:   "dev",
 | 
				
			||||||
 | 
						Short: "Develop a package",
 | 
				
			||||||
 | 
						Long:  "Useful commands for developing packages",
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var packCmd = &cobra.Command{
 | 
				
			||||||
 | 
						Use:   "pack",
 | 
				
			||||||
 | 
						Short: "Package a directory",
 | 
				
			||||||
 | 
						Long:  "Package a directory",
 | 
				
			||||||
 | 
						Run: func(cmd *cobra.Command, args []string) {
 | 
				
			||||||
 | 
							for _, arg := range args {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								packetDotLuaBlob, err := os.ReadFile(filepath.Join(arg, "Packet.lua"))
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("invalid package dir can't find Packet.lua")
 | 
				
			||||||
 | 
									continue
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								packet, err := packet.ReadPacket(packetDotLuaBlob, nil)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s\n", err.Error())
 | 
				
			||||||
 | 
									continue
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								packageFile, err := os.OpenFile(packet.Name+"@"+packet.Version+".pkt", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s\n", err.Error())
 | 
				
			||||||
 | 
									continue
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								zstdWriter, err := zstd.NewWriter(packageFile)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s\n", err.Error())
 | 
				
			||||||
 | 
									continue
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								defer zstdWriter.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								baseDir := filepath.Clean(arg)
 | 
				
			||||||
 | 
								tarWriter := tar.NewWriter(zstdWriter)
 | 
				
			||||||
 | 
								defer tarWriter.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								filepath.Walk(arg, func(path string, info fs.FileInfo, err error) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									header, err := tar.FileInfoHeader(info, "")
 | 
				
			||||||
 | 
									if err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									relPath, err := filepath.Rel(baseDir, path)
 | 
				
			||||||
 | 
									if err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if relPath == "." {
 | 
				
			||||||
 | 
										return nil
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									header.Name = relPath
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if err := tarWriter.WriteHeader(header); err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if !info.IsDir() {
 | 
				
			||||||
 | 
										file, err := os.Open(path)
 | 
				
			||||||
 | 
										if err != nil {
 | 
				
			||||||
 | 
											return err
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										defer file.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if _, err := io.Copy(tarWriter, file); err != nil {
 | 
				
			||||||
 | 
											return err
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									return nil
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func main() {
 | 
				
			||||||
 | 
						rootCmd.AddCommand(executeCmd)
 | 
				
			||||||
 | 
						rootCmd.AddCommand(removeCmd)
 | 
				
			||||||
 | 
						rootCmd.AddCommand(configCmd)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						rootCmd.AddCommand(devCmd)
 | 
				
			||||||
 | 
						devCmd.AddCommand(packCmd)
 | 
				
			||||||
 | 
						rootCmd.Execute()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										11
									
								
								cmd/packets/specifications.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								cmd/packets/specifications.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const (
 | 
				
			||||||
 | 
						ConfigurationDir       = "/etc/packets"
 | 
				
			||||||
 | 
						InternalDB             = ConfigurationDir + "/internal.db"
 | 
				
			||||||
 | 
						HomeDir                = "/var/lib/packets"
 | 
				
			||||||
 | 
						PackageRootDir         = "/var/lib/packets/packages"
 | 
				
			||||||
 | 
						NumberOfTryAttempts    = 4
 | 
				
			||||||
 | 
						UserHomeDirPlaceholder = "{{ USER HOME FOLDER }}"
 | 
				
			||||||
 | 
						UsernamePlaceholder    = "{{ USERNAME }}"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
							
								
								
									
										37
									
								
								cmd/packets/user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								cmd/packets/user.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"os/exec"
 | 
				
			||||||
 | 
						"strconv"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
						"syscall"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func GetPacketsUID() (int, error) {
 | 
				
			||||||
 | 
						_ = exec.Command("useradd", "-M", "-N", "-r", "-s", "/bin/false", "-d", "/etc/packets", "packets").Run()
 | 
				
			||||||
 | 
						cmd := exec.Command("id", "-u", "packets")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						out, err := cmd.CombinedOutput()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return -1, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						s := strings.TrimSpace(string(out))
 | 
				
			||||||
 | 
						uid, err := strconv.Atoi(s)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return -1, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return uid, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func ChangeToNoPermission() error {
 | 
				
			||||||
 | 
						uid, err := GetPacketsUID()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return syscall.Setresuid(0, uid, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func ElevatePermission() error { return syscall.Setresuid(0, 0, 0) }
 | 
				
			||||||
							
								
								
									
										61
									
								
								doc/internal.db.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								doc/internal.db.sql
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,61 @@
 | 
				
			|||||||
 | 
					CREATE TABLE installed_packges(
 | 
				
			||||||
 | 
					    name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    id TEXT PRIMARY KEY,
 | 
				
			||||||
 | 
					    version TEXT NOT NULL,
 | 
				
			||||||
 | 
					    serial INTEGER NOT NULL,
 | 
				
			||||||
 | 
					    maintainer TEXT NOT NULL,
 | 
				
			||||||
 | 
					    verified INTEGER NOT NULL DEFAULT 0,
 | 
				
			||||||
 | 
					    description TEXT NOT NULL,
 | 
				
			||||||
 | 
					    upload_time TEXT NOT NULL,
 | 
				
			||||||
 | 
					    installed_time TEXT NOT NULL,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public_key BLOB NOT NULL,
 | 
				
			||||||
 | 
					    signature BLOB NOT NULL,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    image BLOB,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    UNIQUE(name, signature),
 | 
				
			||||||
 | 
					    UNIQUE(name, version),
 | 
				
			||||||
 | 
					    UNIQUE(name, serial)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE package_files(
 | 
				
			||||||
 | 
					    package_id TEXT PRIMARY KEY,
 | 
				
			||||||
 | 
					    filepath TEXT NOT NULL,
 | 
				
			||||||
 | 
					    is_dir INTEGER NOT NULL DEFAULT 0,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    UNIQUE(package_id, filepath)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE dependencies(
 | 
				
			||||||
 | 
					    package_id TEXT NOT NULL,
 | 
				
			||||||
 | 
					    dependency_name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    constraint TEXT NOT NULL,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PRIMARY KEY (package_id, dependency_name)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE build_dependencies(
 | 
				
			||||||
 | 
					    package_id TEXT NOT NULL,
 | 
				
			||||||
 | 
					    dependency_name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    constraint TEXT NOT NULL,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PRIMARY KEY (package_id, dependency_name)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE conflicts(
 | 
				
			||||||
 | 
					    package_id TEXT NOT NULL,
 | 
				
			||||||
 | 
					    dependency_name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    constraint TEXT NOT NULL,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PRIMARY KEY (package_id, dependency_name)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE package_flags(
 | 
				
			||||||
 | 
					    package_id TEXT NOT NULL,
 | 
				
			||||||
 | 
					    flag TEXT NOT NULL,
 | 
				
			||||||
 | 
					    name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    path TEXT NOT NULL,
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
							
								
								
									
										41
									
								
								doc/source.db.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								doc/source.db.sql
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					CREATE TABLE packges(
 | 
				
			||||||
 | 
					    name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    id TEXT PRIMARY KEY,
 | 
				
			||||||
 | 
					    version TEXT NOT NULL,
 | 
				
			||||||
 | 
					    serial INTEGER NOT NULL,
 | 
				
			||||||
 | 
					    maintainer TEXT NOT NULL,
 | 
				
			||||||
 | 
					    verified INTEGER NOT NULL DEFAULT 0,
 | 
				
			||||||
 | 
					    description TEXT NOT NULL,
 | 
				
			||||||
 | 
					    upload_time TEXT NOT NULL,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    UNIQUE(name, signature),
 | 
				
			||||||
 | 
					    UNIQUE(name, version),
 | 
				
			||||||
 | 
					    UNIQUE(name, serial)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE dependencies(
 | 
				
			||||||
 | 
					    package_id TEXT NOT NULL,
 | 
				
			||||||
 | 
					    dependency_name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    constraint TEXT NOT NULL,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PRIMARY KEY (package_id, dependency_name)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE build_dependencies(
 | 
				
			||||||
 | 
					    package_id TEXT NOT NULL,
 | 
				
			||||||
 | 
					    dependency_name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    constraint TEXT NOT NULL,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PRIMARY KEY (package_id, dependency_name)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE conflicts(
 | 
				
			||||||
 | 
					    package_id TEXT NOT NULL,
 | 
				
			||||||
 | 
					    dependency_name TEXT NOT NULL,
 | 
				
			||||||
 | 
					    constraint TEXT NOT NULL,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PRIMARY KEY (package_id, dependency_name)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
							
								
								
									
										51
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								go.mod
									
									
									
									
									
								
							@@ -4,4 +4,53 @@ go 1.25.3
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
require github.com/yuin/gopher-lua v1.1.1
 | 
					require github.com/yuin/gopher-lua v1.1.1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require github.com/klauspost/compress v1.18.1
 | 
					require (
 | 
				
			||||||
 | 
						github.com/go-git/go-git/v6 v6.0.0-20251029213217-0bbfc0875edd
 | 
				
			||||||
 | 
						github.com/klauspost/compress v1.18.1
 | 
				
			||||||
 | 
						github.com/mattn/go-sqlite3 v1.14.32
 | 
				
			||||||
 | 
						github.com/pelletier/go-toml/v2 v2.2.4
 | 
				
			||||||
 | 
						github.com/pierrec/lz4/v4 v4.1.22
 | 
				
			||||||
 | 
						github.com/spf13/cobra v1.10.1
 | 
				
			||||||
 | 
						github.com/ulikunitz/xz v0.5.15
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					require (
 | 
				
			||||||
 | 
						github.com/Microsoft/go-winio v0.6.2 // indirect
 | 
				
			||||||
 | 
						github.com/ProtonMail/go-crypto v1.3.0 // indirect
 | 
				
			||||||
 | 
						github.com/atotto/clipboard v0.1.4 // indirect
 | 
				
			||||||
 | 
						github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
 | 
				
			||||||
 | 
						github.com/charmbracelet/bubbles v0.21.0 // indirect
 | 
				
			||||||
 | 
						github.com/charmbracelet/bubbletea v1.3.10 // indirect
 | 
				
			||||||
 | 
						github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
 | 
				
			||||||
 | 
						github.com/charmbracelet/lipgloss v1.1.0 // indirect
 | 
				
			||||||
 | 
						github.com/charmbracelet/x/ansi v0.10.1 // indirect
 | 
				
			||||||
 | 
						github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
 | 
				
			||||||
 | 
						github.com/charmbracelet/x/term v0.2.1 // indirect
 | 
				
			||||||
 | 
						github.com/cloudflare/circl v1.6.1 // indirect
 | 
				
			||||||
 | 
						github.com/cyphar/filepath-securejoin v0.5.0 // indirect
 | 
				
			||||||
 | 
						github.com/emirpasic/gods v1.18.1 // indirect
 | 
				
			||||||
 | 
						github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
 | 
				
			||||||
 | 
						github.com/go-git/gcfg/v2 v2.0.2 // indirect
 | 
				
			||||||
 | 
						github.com/go-git/go-billy/v6 v6.0.0-20251022185412-61e52df296a5 // indirect
 | 
				
			||||||
 | 
						github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
 | 
				
			||||||
 | 
						github.com/inconshreveable/mousetrap v1.1.0 // indirect
 | 
				
			||||||
 | 
						github.com/kevinburke/ssh_config v1.4.0 // indirect
 | 
				
			||||||
 | 
						github.com/klauspost/cpuid/v2 v2.3.0 // indirect
 | 
				
			||||||
 | 
						github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
 | 
				
			||||||
 | 
						github.com/mattn/go-isatty v0.0.20 // indirect
 | 
				
			||||||
 | 
						github.com/mattn/go-localereader v0.0.1 // indirect
 | 
				
			||||||
 | 
						github.com/mattn/go-runewidth v0.0.16 // indirect
 | 
				
			||||||
 | 
						github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
 | 
				
			||||||
 | 
						github.com/muesli/cancelreader v0.2.2 // indirect
 | 
				
			||||||
 | 
						github.com/muesli/termenv v0.16.0 // indirect
 | 
				
			||||||
 | 
						github.com/pjbgf/sha1cd v0.5.0 // indirect
 | 
				
			||||||
 | 
						github.com/rivo/uniseg v0.4.7 // indirect
 | 
				
			||||||
 | 
						github.com/sahilm/fuzzy v0.1.1 // indirect
 | 
				
			||||||
 | 
						github.com/sergi/go-diff v1.4.0 // indirect
 | 
				
			||||||
 | 
						github.com/spf13/pflag v1.0.9 // indirect
 | 
				
			||||||
 | 
						github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
 | 
				
			||||||
 | 
						golang.org/x/crypto v0.43.0 // indirect
 | 
				
			||||||
 | 
						golang.org/x/net v0.46.0 // indirect
 | 
				
			||||||
 | 
						golang.org/x/sys v0.37.0 // indirect
 | 
				
			||||||
 | 
						golang.org/x/text v0.30.0 // indirect
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										125
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										125
									
								
								go.sum
									
									
									
									
									
								
							@@ -1,4 +1,129 @@
 | 
				
			|||||||
 | 
					github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
 | 
				
			||||||
 | 
					github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
 | 
				
			||||||
 | 
					github.com/ProtonMail/go-crypto v1.3.0 h1:ILq8+Sf5If5DCpHQp4PbZdS1J7HDFRXz/+xKBiRGFrw=
 | 
				
			||||||
 | 
					github.com/ProtonMail/go-crypto v1.3.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE=
 | 
				
			||||||
 | 
					github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
 | 
				
			||||||
 | 
					github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
 | 
				
			||||||
 | 
					github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
 | 
				
			||||||
 | 
					github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
 | 
				
			||||||
 | 
					github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
 | 
				
			||||||
 | 
					github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
 | 
				
			||||||
 | 
					github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
 | 
				
			||||||
 | 
					github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
 | 
				
			||||||
 | 
					github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs=
 | 
				
			||||||
 | 
					github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg=
 | 
				
			||||||
 | 
					github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=
 | 
				
			||||||
 | 
					github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
 | 
				
			||||||
 | 
					github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
 | 
				
			||||||
 | 
					github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
 | 
				
			||||||
 | 
					github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
 | 
				
			||||||
 | 
					github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
 | 
				
			||||||
 | 
					github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE=
 | 
				
			||||||
 | 
					github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q=
 | 
				
			||||||
 | 
					github.com/charmbracelet/x/ansi v0.10.1 h1:rL3Koar5XvX0pHGfovN03f5cxLbCF2YvLeyz7D2jVDQ=
 | 
				
			||||||
 | 
					github.com/charmbracelet/x/ansi v0.10.1/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
 | 
				
			||||||
 | 
					github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
 | 
				
			||||||
 | 
					github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
 | 
				
			||||||
 | 
					github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
 | 
				
			||||||
 | 
					github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
 | 
				
			||||||
 | 
					github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
 | 
				
			||||||
 | 
					github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
 | 
				
			||||||
 | 
					github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
 | 
				
			||||||
 | 
					github.com/cyphar/filepath-securejoin v0.5.0 h1:hIAhkRBMQ8nIeuVwcAoymp7MY4oherZdAxD+m0u9zaw=
 | 
				
			||||||
 | 
					github.com/cyphar/filepath-securejoin v0.5.0/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
 | 
				
			||||||
 | 
					github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
				
			||||||
 | 
					github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 | 
				
			||||||
 | 
					github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
				
			||||||
 | 
					github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o=
 | 
				
			||||||
 | 
					github.com/elazarl/goproxy v1.7.2/go.mod h1:82vkLNir0ALaW14Rc399OTTjyNREgmdL2cVoIbS6XaE=
 | 
				
			||||||
 | 
					github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
 | 
				
			||||||
 | 
					github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
 | 
				
			||||||
 | 
					github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
 | 
				
			||||||
 | 
					github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
 | 
				
			||||||
 | 
					github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
 | 
				
			||||||
 | 
					github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU=
 | 
				
			||||||
 | 
					github.com/go-git/gcfg/v2 v2.0.2 h1:MY5SIIfTGGEMhdA7d7JePuVVxtKL7Hp+ApGDJAJ7dpo=
 | 
				
			||||||
 | 
					github.com/go-git/gcfg/v2 v2.0.2/go.mod h1:/lv2NsxvhepuMrldsFilrgct6pxzpGdSRC13ydTLSLs=
 | 
				
			||||||
 | 
					github.com/go-git/go-billy/v6 v6.0.0-20251022185412-61e52df296a5 h1:9nXOQ3HupDEerUXxiPrw3olFy/jHGZ3O3DyM/o6ejdc=
 | 
				
			||||||
 | 
					github.com/go-git/go-billy/v6 v6.0.0-20251022185412-61e52df296a5/go.mod h1:TpCYxdQ0tWZkrnAkd7yqK+z1C8RKcyjcaYAJNAcnUnM=
 | 
				
			||||||
 | 
					github.com/go-git/go-git-fixtures/v5 v5.1.1 h1:OH8i1ojV9bWfr0ZfasfpgtUXQHQyVS8HXik/V1C099w=
 | 
				
			||||||
 | 
					github.com/go-git/go-git-fixtures/v5 v5.1.1/go.mod h1:Altk43lx3b1ks+dVoAG2300o5WWUnktvfY3VI6bcaXU=
 | 
				
			||||||
 | 
					github.com/go-git/go-git/v6 v6.0.0-20251029213217-0bbfc0875edd h1:pn6+tR4O8McyqEr2MbQwqcySovpG8jDd11F/jQ6aAfA=
 | 
				
			||||||
 | 
					github.com/go-git/go-git/v6 v6.0.0-20251029213217-0bbfc0875edd/go.mod h1:z9pQiXCfyOZIs/8qa5zmozzbcsDPtGN91UD7+qeX3hk=
 | 
				
			||||||
 | 
					github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
 | 
				
			||||||
 | 
					github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
 | 
				
			||||||
 | 
					github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
 | 
				
			||||||
 | 
					github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
 | 
				
			||||||
 | 
					github.com/kevinburke/ssh_config v1.4.0 h1:6xxtP5bZ2E4NF5tuQulISpTO2z8XbtH8cg1PWkxoFkQ=
 | 
				
			||||||
 | 
					github.com/kevinburke/ssh_config v1.4.0/go.mod h1:q2RIzfka+BXARoNexmF9gkxEX7DmvbW9P4hIVx2Kg4M=
 | 
				
			||||||
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
 | 
					github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
 | 
				
			||||||
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
 | 
					github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
 | 
				
			||||||
 | 
					github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
 | 
				
			||||||
 | 
					github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
 | 
				
			||||||
 | 
					github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 | 
				
			||||||
 | 
					github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
 | 
				
			||||||
 | 
					github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 | 
				
			||||||
 | 
					github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
 | 
				
			||||||
 | 
					github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
 | 
				
			||||||
 | 
					github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
 | 
				
			||||||
 | 
					github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
 | 
				
			||||||
 | 
					github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
 | 
				
			||||||
 | 
					github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
 | 
				
			||||||
 | 
					github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
 | 
				
			||||||
 | 
					github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
 | 
				
			||||||
 | 
					github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
 | 
				
			||||||
 | 
					github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
 | 
				
			||||||
 | 
					github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
 | 
				
			||||||
 | 
					github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
 | 
				
			||||||
 | 
					github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
 | 
				
			||||||
 | 
					github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
 | 
				
			||||||
 | 
					github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
 | 
				
			||||||
 | 
					github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
 | 
				
			||||||
 | 
					github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
 | 
				
			||||||
 | 
					github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
 | 
				
			||||||
 | 
					github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
 | 
				
			||||||
 | 
					github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
 | 
				
			||||||
 | 
					github.com/pjbgf/sha1cd v0.5.0 h1:a+UkboSi1znleCDUNT3M5YxjOnN1fz2FhN48FlwCxs0=
 | 
				
			||||||
 | 
					github.com/pjbgf/sha1cd v0.5.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM=
 | 
				
			||||||
 | 
					github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 | 
				
			||||||
 | 
					github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 | 
				
			||||||
 | 
					github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
 | 
				
			||||||
 | 
					github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
 | 
				
			||||||
 | 
					github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
 | 
				
			||||||
 | 
					github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 | 
				
			||||||
 | 
					github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA=
 | 
				
			||||||
 | 
					github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
 | 
				
			||||||
 | 
					github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
 | 
				
			||||||
 | 
					github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
 | 
				
			||||||
 | 
					github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
 | 
				
			||||||
 | 
					github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
 | 
				
			||||||
 | 
					github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
 | 
				
			||||||
 | 
					github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
 | 
				
			||||||
 | 
					github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 | 
				
			||||||
 | 
					github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
 | 
				
			||||||
 | 
					github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
 | 
				
			||||||
 | 
					github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
 | 
				
			||||||
 | 
					github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY=
 | 
				
			||||||
 | 
					github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
 | 
				
			||||||
 | 
					github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
 | 
				
			||||||
 | 
					github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
 | 
				
			||||||
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
 | 
					github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
 | 
				
			||||||
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
 | 
					github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
 | 
				
			||||||
 | 
					golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
 | 
				
			||||||
 | 
					golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
 | 
				
			||||||
 | 
					golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
 | 
				
			||||||
 | 
					golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
 | 
				
			||||||
 | 
					golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
				
			||||||
 | 
					golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
				
			||||||
 | 
					golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
 | 
				
			||||||
 | 
					golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
 | 
				
			||||||
 | 
					golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q=
 | 
				
			||||||
 | 
					golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss=
 | 
				
			||||||
 | 
					golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
 | 
				
			||||||
 | 
					golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
 | 
				
			||||||
 | 
					gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
				
			||||||
 | 
					gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
				
			||||||
 | 
					gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
				
			||||||
 | 
					gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
 | 
				
			||||||
 | 
					gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 | 
				
			||||||
 | 
					gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										195
									
								
								internal/lua/luafunctions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										195
									
								
								internal/lua/luafunctions.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,195 @@
 | 
				
			|||||||
 | 
					package lua
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"log"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"path/filepath"
 | 
				
			||||||
 | 
						"strconv"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						lua "github.com/yuin/gopher-lua"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func LRemove(L *lua.LState) int {
 | 
				
			||||||
 | 
						filename := L.CheckString(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						err := os.RemoveAll(filename)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							L.Push(lua.LFalse)
 | 
				
			||||||
 | 
							L.Push(lua.LString(err.Error()))
 | 
				
			||||||
 | 
							return 2
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						L.Push(lua.LTrue)
 | 
				
			||||||
 | 
						L.Push(lua.LNil)
 | 
				
			||||||
 | 
						return 2
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func LRename(L *lua.LState) int {
 | 
				
			||||||
 | 
						oldname := L.CheckString(1)
 | 
				
			||||||
 | 
						newname := L.CheckString(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err := os.Rename(oldname, newname); err != nil {
 | 
				
			||||||
 | 
							L.Push(lua.LFalse)
 | 
				
			||||||
 | 
							L.Push(lua.LString(err.Error()))
 | 
				
			||||||
 | 
							return 2
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.Push(lua.LTrue)
 | 
				
			||||||
 | 
						return 1
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					func LCopy(L *lua.LState) int {
 | 
				
			||||||
 | 
						oldname := L.CheckString(1)
 | 
				
			||||||
 | 
						newname := L.CheckString(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_ = os.MkdirAll(filepath.Dir(newname), 0755)
 | 
				
			||||||
 | 
						if err := copyDir(oldname, newname); err != nil {
 | 
				
			||||||
 | 
							L.Push(lua.LFalse)
 | 
				
			||||||
 | 
							L.Push(lua.LString(err.Error()))
 | 
				
			||||||
 | 
							return 2
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.Push(lua.LTrue)
 | 
				
			||||||
 | 
						L.Push(lua.LNil)
 | 
				
			||||||
 | 
						return 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func LSymlink(L *lua.LState) int {
 | 
				
			||||||
 | 
						fileName := L.CheckString(1)
 | 
				
			||||||
 | 
						destination := L.CheckString(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_ = os.RemoveAll(destination)
 | 
				
			||||||
 | 
						if err := os.Symlink(fileName, destination); err != nil {
 | 
				
			||||||
 | 
							L.Push(lua.LFalse)
 | 
				
			||||||
 | 
							L.Push(lua.LString(err.Error()))
 | 
				
			||||||
 | 
							return 2
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.Push(lua.LTrue)
 | 
				
			||||||
 | 
						L.Push(lua.LNil)
 | 
				
			||||||
 | 
						return 2
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func Ljoin(L *lua.LState) int {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						n := L.GetTop()
 | 
				
			||||||
 | 
						parts := make([]string, 0, n)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for i := 1; i <= n; i++ {
 | 
				
			||||||
 | 
							val := L.Get(i)
 | 
				
			||||||
 | 
							parts = append(parts, val.String())
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						result := filepath.Join(parts...)
 | 
				
			||||||
 | 
						L.Push(lua.LString(result))
 | 
				
			||||||
 | 
						return 1
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func LMkdir(L *lua.LState) int {
 | 
				
			||||||
 | 
						path := L.CheckString(1)
 | 
				
			||||||
 | 
						perm := L.CheckInt(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						modeStr := strconv.Itoa(perm)
 | 
				
			||||||
 | 
						modeUint, err := strconv.ParseUint(modeStr, 8, 32)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							fmt.Println("Error parsing mode:", err)
 | 
				
			||||||
 | 
							L.Push(lua.LFalse)
 | 
				
			||||||
 | 
							L.Push(lua.LString(err.Error()))
 | 
				
			||||||
 | 
							return 2
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err := os.MkdirAll(path, os.FileMode(modeUint)); err != nil {
 | 
				
			||||||
 | 
							fmt.Println("Error creating directory:", err)
 | 
				
			||||||
 | 
							L.Push(lua.LFalse)
 | 
				
			||||||
 | 
							L.Push(lua.LString(err.Error()))
 | 
				
			||||||
 | 
							return 2
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.Push(lua.LTrue)
 | 
				
			||||||
 | 
						L.Push(lua.LNil)
 | 
				
			||||||
 | 
						return 2
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func LError(L *lua.LState) int {
 | 
				
			||||||
 | 
						n := L.GetTop()
 | 
				
			||||||
 | 
						parts := make([]any, 0, n)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for i := 1; i <= n; i++ {
 | 
				
			||||||
 | 
							val := L.Get(i)
 | 
				
			||||||
 | 
							parts = append(parts, val.String())
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						llogger().Panic(parts...)
 | 
				
			||||||
 | 
						return 0
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func LSetEnv(L *lua.LState) int {
 | 
				
			||||||
 | 
						env := L.CheckString(1)
 | 
				
			||||||
 | 
						value := L.CheckString(2)
 | 
				
			||||||
 | 
						os.Setenv(env, value)
 | 
				
			||||||
 | 
						return 0
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func LCD(L *lua.LState) int {
 | 
				
			||||||
 | 
						dir := L.CheckString(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err := os.Chdir(dir); err != nil {
 | 
				
			||||||
 | 
							L.Push(lua.LFalse)
 | 
				
			||||||
 | 
							L.Push(lua.LString(err.Error()))
 | 
				
			||||||
 | 
							return 2
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.Push(lua.LTrue)
 | 
				
			||||||
 | 
						L.Push(lua.LNil)
 | 
				
			||||||
 | 
						return 2
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func LChmod(L *lua.LState) int {
 | 
				
			||||||
 | 
						f := L.CheckString(1)
 | 
				
			||||||
 | 
						mode := L.CheckInt(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						modeStr := strconv.Itoa(mode)
 | 
				
			||||||
 | 
						modeUint, err := strconv.ParseUint(modeStr, 8, 32)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							fmt.Println("Error parsing mode:", err)
 | 
				
			||||||
 | 
							L.Push(lua.LFalse)
 | 
				
			||||||
 | 
							L.Push(lua.LString(err.Error()))
 | 
				
			||||||
 | 
							return 2
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err := os.Chmod(f, os.FileMode(modeUint)); err != nil {
 | 
				
			||||||
 | 
							L.Push(lua.LFalse)
 | 
				
			||||||
 | 
							L.Push(lua.LString(err.Error()))
 | 
				
			||||||
 | 
							return 2
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.Push(lua.LTrue)
 | 
				
			||||||
 | 
						L.Push(lua.LNil)
 | 
				
			||||||
 | 
						return 2
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type Flag struct {
 | 
				
			||||||
 | 
						Name     string
 | 
				
			||||||
 | 
						Path     string
 | 
				
			||||||
 | 
						FlagType string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type Flags struct {
 | 
				
			||||||
 | 
						Flags []Flag
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (f *Flags) LSetFlag(L *lua.LState) int {
 | 
				
			||||||
 | 
						flagtype := L.CheckString(1)
 | 
				
			||||||
 | 
						name := L.CheckString(2)
 | 
				
			||||||
 | 
						flagPath := L.CheckString(3)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						f.Flags = append(f.Flags, Flag{
 | 
				
			||||||
 | 
							Name:     name,
 | 
				
			||||||
 | 
							Path:     flagPath,
 | 
				
			||||||
 | 
							FlagType: flagtype,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return 0
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func llogger() *log.Logger { return log.New(os.Stderr, "script error: ", 0) }
 | 
				
			||||||
							
								
								
									
										95
									
								
								internal/lua/utils.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								internal/lua/utils.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,95 @@
 | 
				
			|||||||
 | 
					package lua
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"path/filepath"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func copyDir(src string, dest string) error {
 | 
				
			||||||
 | 
						if stats, err := os.Stat(src); err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							if stats.IsDir() {
 | 
				
			||||||
 | 
								files, err := os.ReadDir(src)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if err := os.MkdirAll(dest, 0755); err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								for _, file := range files {
 | 
				
			||||||
 | 
									if file.IsDir() {
 | 
				
			||||||
 | 
										copyDir(filepath.Join(src, file.Name()), filepath.Join(dest, file.Name()))
 | 
				
			||||||
 | 
										continue
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									srcFile := filepath.Join(src, file.Name())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									f, err := os.Create(filepath.Join(dest, file.Name()))
 | 
				
			||||||
 | 
									if err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									defer f.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									opennedSrcFile, err := os.Open(srcFile)
 | 
				
			||||||
 | 
									if err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									defer opennedSrcFile.Close()
 | 
				
			||||||
 | 
									if _, err := io.Copy(f, opennedSrcFile); err != nil {
 | 
				
			||||||
 | 
										return err
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								if err := copyFile(src, dest); err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func copyFile(source string, destination string) error {
 | 
				
			||||||
 | 
						src, err := os.Open(source)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						defer src.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						status, err := src.Stat()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						err = os.MkdirAll(filepath.Dir(destination), 0o755)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						dst, err := os.Create(destination)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							if !os.IsExist(err) {
 | 
				
			||||||
 | 
								dst, err = os.Open(destination)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						defer dst.Close()
 | 
				
			||||||
 | 
						if err := dst.Chmod(status.Mode()); err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err = io.Copy(dst, src)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										102
									
								
								pkg/install/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								pkg/install/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,102 @@
 | 
				
			|||||||
 | 
					package install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"path/filepath"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type BasicFileStatus struct {
 | 
				
			||||||
 | 
						Filepath string
 | 
				
			||||||
 | 
						PermMode os.FileMode
 | 
				
			||||||
 | 
						IsDir    bool
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func GetPackageFiles(packetDir string) ([]BasicFileStatus, error) {
 | 
				
			||||||
 | 
						return walkAll(packetDir)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func walkAll(dirToWalk string) ([]BasicFileStatus, error) {
 | 
				
			||||||
 | 
						var filesSlice []BasicFileStatus
 | 
				
			||||||
 | 
						files, err := os.ReadDir(dirToWalk)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return []BasicFileStatus{}, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, v := range files {
 | 
				
			||||||
 | 
							basicStat := &BasicFileStatus{
 | 
				
			||||||
 | 
								Filepath: filepath.Join(dirToWalk, v.Name()),
 | 
				
			||||||
 | 
								PermMode: v.Type().Perm(),
 | 
				
			||||||
 | 
								IsDir:    v.IsDir(),
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							filesSlice = append(filesSlice, *basicStat)
 | 
				
			||||||
 | 
							if v.IsDir() {
 | 
				
			||||||
 | 
								tmp, err := walkAll(filepath.Join(dirToWalk, v.Name()))
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return []BasicFileStatus{}, err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								filesSlice = append(filesSlice, tmp...)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return filesSlice, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func InstallFiles(files []BasicFileStatus, packetDir string) error {
 | 
				
			||||||
 | 
						for _, v := range files {
 | 
				
			||||||
 | 
							sysPath, _ := strings.CutPrefix(v.Filepath, packetDir)
 | 
				
			||||||
 | 
							if v.IsDir {
 | 
				
			||||||
 | 
								if err := os.MkdirAll(sysPath, v.PermMode.Perm()); err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								if err := copyFile(v.Filepath, sysPath); err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func copyFile(source string, destination string) error {
 | 
				
			||||||
 | 
						src, err := os.Open(source)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						defer src.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						status, err := src.Stat()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						err = os.MkdirAll(filepath.Dir(destination), 0755)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						dst, err := os.Create(destination)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							if !os.IsExist(err) {
 | 
				
			||||||
 | 
								dst, err = os.Open(destination)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						defer dst.Close()
 | 
				
			||||||
 | 
						if err := dst.Chmod(status.Mode()); err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err = io.Copy(dst, src)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -104,10 +104,15 @@ func getSourcesFromTable(table *lua.LTable, key string) *[]Source {
 | 
				
			|||||||
			case "GET":
 | 
								case "GET":
 | 
				
			||||||
				var getSpecs GETSpecs
 | 
									var getSpecs GETSpecs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				getSpecs.SHA256 = new(string)
 | 
									getSpecs.SHA256 = new([]string)
 | 
				
			||||||
				sha256sumL := src.RawGetString("sha256")
 | 
									sha256sumL := src.RawGetString("sha256")
 | 
				
			||||||
				if sha256sumL.Type() == lua.LTString {
 | 
									if sha256sumL.Type() == lua.LTTable {
 | 
				
			||||||
					*getSpecs.SHA256 = sha256sumL.String()
 | 
										shatable := sha256sumL.(*lua.LTable)
 | 
				
			||||||
 | 
										shatable.ForEach(func(_, value lua.LValue) {
 | 
				
			||||||
 | 
											if value.Type() == lua.LTString {
 | 
				
			||||||
 | 
												*getSpecs.SHA256 = append(*getSpecs.SHA256, value.String())
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										})
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				headersLT := src.RawGetString("headers")
 | 
									headersLT := src.RawGetString("headers")
 | 
				
			||||||
@@ -148,8 +153,13 @@ func getSourcesFromTable(table *lua.LTable, key string) *[]Source {
 | 
				
			|||||||
				var postSpecs POSTSpecs
 | 
									var postSpecs POSTSpecs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				sha256sumL := src.RawGetString("sha256")
 | 
									sha256sumL := src.RawGetString("sha256")
 | 
				
			||||||
				if sha256sumL.Type() == lua.LTString {
 | 
									if sha256sumL.Type() == lua.LTTable {
 | 
				
			||||||
					*postSpecs.SHA256 = sha256sumL.String()
 | 
										shatable := sha256sumL.(*lua.LTable)
 | 
				
			||||||
 | 
										shatable.ForEach(func(_, value lua.LValue) {
 | 
				
			||||||
 | 
											if value.Type() == lua.LTString {
 | 
				
			||||||
 | 
												*postSpecs.SHA256 = append(*postSpecs.SHA256, value.String())
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										})
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				headersLT := src.RawGetString("headers")
 | 
									headersLT := src.RawGetString("headers")
 | 
				
			||||||
@@ -287,3 +297,58 @@ func parseVersionString(s string) version {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return version{}
 | 
						return version{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func normalizeArch(arch string) string {
 | 
				
			||||||
 | 
						switch arch {
 | 
				
			||||||
 | 
						case "386":
 | 
				
			||||||
 | 
							return "i686"
 | 
				
			||||||
 | 
						case "amd64":
 | 
				
			||||||
 | 
							return "x86_64"
 | 
				
			||||||
 | 
						case "amd64p32":
 | 
				
			||||||
 | 
							return "x86_64"
 | 
				
			||||||
 | 
						case "arm":
 | 
				
			||||||
 | 
							return "arm"
 | 
				
			||||||
 | 
						case "arm64":
 | 
				
			||||||
 | 
							return "aarch64"
 | 
				
			||||||
 | 
						case "arm64be":
 | 
				
			||||||
 | 
							return "aarch64_be"
 | 
				
			||||||
 | 
						case "armbe":
 | 
				
			||||||
 | 
							return "armbe"
 | 
				
			||||||
 | 
						case "loong64":
 | 
				
			||||||
 | 
							return "loongarch64"
 | 
				
			||||||
 | 
						case "mips":
 | 
				
			||||||
 | 
							return "mips"
 | 
				
			||||||
 | 
						case "mips64":
 | 
				
			||||||
 | 
							return "mips64"
 | 
				
			||||||
 | 
						case "mips64le":
 | 
				
			||||||
 | 
							return "mips64el"
 | 
				
			||||||
 | 
						case "mips64p32":
 | 
				
			||||||
 | 
							return "mips64"
 | 
				
			||||||
 | 
						case "mips64p32le":
 | 
				
			||||||
 | 
							return "mips64el"
 | 
				
			||||||
 | 
						case "mipsle":
 | 
				
			||||||
 | 
							return "mipsel"
 | 
				
			||||||
 | 
						case "ppc":
 | 
				
			||||||
 | 
							return "powerpc"
 | 
				
			||||||
 | 
						case "ppc64":
 | 
				
			||||||
 | 
							return "ppc64"
 | 
				
			||||||
 | 
						case "ppc64le":
 | 
				
			||||||
 | 
							return "ppc64le"
 | 
				
			||||||
 | 
						case "riscv":
 | 
				
			||||||
 | 
							return "riscv"
 | 
				
			||||||
 | 
						case "riscv64":
 | 
				
			||||||
 | 
							return "riscv64"
 | 
				
			||||||
 | 
						case "s390":
 | 
				
			||||||
 | 
							return "s390"
 | 
				
			||||||
 | 
						case "s390x":
 | 
				
			||||||
 | 
							return "s390x"
 | 
				
			||||||
 | 
						case "sparc":
 | 
				
			||||||
 | 
							return "sparc"
 | 
				
			||||||
 | 
						case "sparc64":
 | 
				
			||||||
 | 
							return "sparc64"
 | 
				
			||||||
 | 
						case "wasm":
 | 
				
			||||||
 | 
							return "wasm"
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return arch
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,24 +1,33 @@
 | 
				
			|||||||
package packet
 | 
					package packet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "path/filepath"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Config struct {
 | 
					type Config struct {
 | 
				
			||||||
	BinDir string
 | 
						BinDir     string
 | 
				
			||||||
 | 
						PacketDir  string
 | 
				
			||||||
 | 
						SourcesDir string
 | 
				
			||||||
 | 
						RootDir    string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const defaultBinDir = "/usr/bin"
 | 
					const defaultBinDir = "/usr/bin"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func checkConfig(cfg *Config) *Config {
 | 
					func checkConfig(cfg *Config) *Config {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if cfg == nil {
 | 
						if cfg == nil {
 | 
				
			||||||
 | 
							bin := defaultBinDir
 | 
				
			||||||
		return &Config{
 | 
							return &Config{
 | 
				
			||||||
			BinDir: defaultBinDir,
 | 
								BinDir: bin,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if cfg.BinDir == "" {
 | 
					 | 
				
			||||||
		return &Config{
 | 
					 | 
				
			||||||
			BinDir: defaultBinDir,
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		return cfg
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						switch {
 | 
				
			||||||
 | 
						case cfg.BinDir == "":
 | 
				
			||||||
 | 
							return &Config{
 | 
				
			||||||
 | 
								BinDir: defaultBinDir,
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						case cfg.PacketDir == "":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							cfg.PacketDir = filepath.Join("/tmp", randStringBytes(12))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return cfg
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,14 +2,24 @@ package packet
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"archive/tar"
 | 
						"archive/tar"
 | 
				
			||||||
 | 
						"bytes"
 | 
				
			||||||
 | 
						"crypto/sha256"
 | 
				
			||||||
 | 
						"encoding/hex"
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"runtime"
 | 
						"runtime"
 | 
				
			||||||
 | 
						"slices"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/go-git/go-git/v6"
 | 
				
			||||||
 | 
						"github.com/go-git/go-git/v6/plumbing"
 | 
				
			||||||
	"github.com/klauspost/compress/zstd"
 | 
						"github.com/klauspost/compress/zstd"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						lua_utils "github.com/roboogg133/packets/internal/lua"
 | 
				
			||||||
	lua "github.com/yuin/gopher-lua"
 | 
						lua "github.com/yuin/gopher-lua"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -18,7 +28,7 @@ type OperationalSystem string
 | 
				
			|||||||
type PacketLua struct {
 | 
					type PacketLua struct {
 | 
				
			||||||
	Name        string
 | 
						Name        string
 | 
				
			||||||
	Version     string
 | 
						Version     string
 | 
				
			||||||
	Maintaner   string
 | 
						Maintainer  string
 | 
				
			||||||
	Description string
 | 
						Description string
 | 
				
			||||||
	Serial      int
 | 
						Serial      int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -26,14 +36,17 @@ type PacketLua struct {
 | 
				
			|||||||
	GlobalSources      *[]Source
 | 
						GlobalSources      *[]Source
 | 
				
			||||||
	GlobalDependencies *PkgDependencies
 | 
						GlobalDependencies *PkgDependencies
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Build   *lua.LFunction
 | 
						Flags []lua_utils.Flag
 | 
				
			||||||
	Install *lua.LFunction
 | 
					
 | 
				
			||||||
 | 
						Build    *lua.LFunction
 | 
				
			||||||
 | 
						Install  *lua.LFunction
 | 
				
			||||||
 | 
						LuaState *lua.LState
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Source struct {
 | 
					type Source struct {
 | 
				
			||||||
	Method string
 | 
						Method string
 | 
				
			||||||
	Url    string
 | 
						Url    string
 | 
				
			||||||
	Specs  interface{}
 | 
						Specs  any
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type VersionConstraint string
 | 
					type VersionConstraint string
 | 
				
			||||||
@@ -57,26 +70,29 @@ type GitSpecs struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type POSTSpecs struct {
 | 
					type POSTSpecs struct {
 | 
				
			||||||
	SHA256  *string
 | 
						SHA256  *[]string
 | 
				
			||||||
	Body    *string
 | 
						Body    *string
 | 
				
			||||||
	Headers *map[string]string
 | 
						Headers *map[string]string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type GETSpecs struct {
 | 
					type GETSpecs struct {
 | 
				
			||||||
	SHA256  *string
 | 
						SHA256  *[]string
 | 
				
			||||||
	Headers *map[string]string
 | 
						Headers *map[string]string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var ErrCantFindPacketDotLua = errors.New("can't find Packet.lua in .tar.zst file")
 | 
					var ErrCantFindPacketDotLua = errors.New("can't find Packet.lua in .tar.zst file")
 | 
				
			||||||
var ErrFileDontReturnTable = errors.New("invalid Packet.lua format: the file do not return a table")
 | 
					var ErrFileDontReturnTable = errors.New("invalid Packet.lua format: the file do not return a table")
 | 
				
			||||||
var ErrCannotFindPackageTable = errors.New("invalid Packet.lua format: can't find package table")
 | 
					var ErrCannotFindPackageTable = errors.New("invalid Packet.lua format: can't find package table")
 | 
				
			||||||
 | 
					var ErrInstallFunctionDoesNotExist = errors.New("can not find install()")
 | 
				
			||||||
 | 
					var ErrSha256Sum = errors.New("false checksum")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ReadPacket read a Packet.lua and alredy set global vars
 | 
					// ReadPacket read a Packet.lua and alredy set global vars
 | 
				
			||||||
func ReadPacket(f []byte, cfg *Config) (PacketLua, error) {
 | 
					func ReadPacket(f []byte, cfg *Config) (PacketLua, error) {
 | 
				
			||||||
	cfg = checkConfig(cfg)
 | 
						cfg = checkConfig(cfg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	L := lua.NewState()
 | 
						L := lua.NewState()
 | 
				
			||||||
	defer L.Close()
 | 
					
 | 
				
			||||||
 | 
						L.SetGlobal("error", L.NewFunction(lua_utils.LError))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	osObject := L.GetGlobal("os").(*lua.LTable)
 | 
						osObject := L.GetGlobal("os").(*lua.LTable)
 | 
				
			||||||
	ioObject := L.GetGlobal("io").(*lua.LTable)
 | 
						ioObject := L.GetGlobal("io").(*lua.LTable)
 | 
				
			||||||
@@ -86,8 +102,13 @@ func ReadPacket(f []byte, cfg *Config) (PacketLua, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	L.SetGlobal("BIN_DIR", lua.LString(cfg.BinDir))
 | 
						L.SetGlobal("BIN_DIR", lua.LString(cfg.BinDir))
 | 
				
			||||||
	L.SetGlobal("CURRENT_ARCH", lua.LString(runtime.GOARCH))
 | 
						L.SetGlobal("CURRENT_ARCH", lua.LString(runtime.GOARCH))
 | 
				
			||||||
 | 
						L.SetGlobal("CURRENT_ARCH_NORMALIZED", lua.LString(normalizeArch(runtime.GOARCH)))
 | 
				
			||||||
	L.SetGlobal("CURRENT_PLATAFORM", lua.LString(runtime.GOOS))
 | 
						L.SetGlobal("CURRENT_PLATAFORM", lua.LString(runtime.GOOS))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var newFlags lua_utils.Flags
 | 
				
			||||||
 | 
						L.SetGlobal("setflags", L.NewFunction(newFlags.LSetFlag))
 | 
				
			||||||
 | 
						L.SetGlobal("pathjoin", L.NewFunction(lua_utils.Ljoin))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err := L.DoString(string(f)); err != nil {
 | 
						if err := L.DoString(string(f)); err != nil {
 | 
				
			||||||
		return PacketLua{}, err
 | 
							return PacketLua{}, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -112,7 +133,7 @@ func ReadPacket(f []byte, cfg *Config) (PacketLua, error) {
 | 
				
			|||||||
	packetLua := &PacketLua{
 | 
						packetLua := &PacketLua{
 | 
				
			||||||
		Name:        getStringFromTable(pkgTable, "name"),
 | 
							Name:        getStringFromTable(pkgTable, "name"),
 | 
				
			||||||
		Version:     getStringFromTable(pkgTable, "version"),
 | 
							Version:     getStringFromTable(pkgTable, "version"),
 | 
				
			||||||
		Maintaner:   getStringFromTable(pkgTable, "maintainer"),
 | 
							Maintainer:  getStringFromTable(pkgTable, "maintainer"),
 | 
				
			||||||
		Description: getStringFromTable(pkgTable, "description"),
 | 
							Description: getStringFromTable(pkgTable, "description"),
 | 
				
			||||||
		Serial:      getIntFromTable(pkgTable, "serial"),
 | 
							Serial:      getIntFromTable(pkgTable, "serial"),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -125,8 +146,11 @@ func ReadPacket(f []byte, cfg *Config) (PacketLua, error) {
 | 
				
			|||||||
		Install: getFunctionFromTable(table, "install"),
 | 
							Install: getFunctionFromTable(table, "install"),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						packetLua.Flags = append(packetLua.Flags, newFlags.Flags...)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						packetLua.LuaState = L
 | 
				
			||||||
	if packetLua.Install == nil {
 | 
						if packetLua.Install == nil {
 | 
				
			||||||
		return PacketLua{}, fmt.Errorf("install() does not exist")
 | 
							return PacketLua{}, ErrInstallFunctionDoesNotExist
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return *packetLua, nil
 | 
						return *packetLua, nil
 | 
				
			||||||
@@ -164,3 +188,199 @@ func ReadPacketFromZSTDF(file io.Reader, cfg *Config) (PacketLua, error) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	return PacketLua{}, ErrCantFindPacketDotLua
 | 
						return PacketLua{}, ErrCantFindPacketDotLua
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetSource returns file []byte if method is "GET" or "POST", if is "git" returns *git.CloneOptions{}
 | 
				
			||||||
 | 
					func GetSource(url, method string, info any, tryAttempts int) (any, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						switch method {
 | 
				
			||||||
 | 
						case "GET":
 | 
				
			||||||
 | 
							req, err := http.NewRequest("GET", url, nil)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							specs := info.(GETSpecs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if specs.Headers != nil {
 | 
				
			||||||
 | 
								for k, v := range *specs.Headers {
 | 
				
			||||||
 | 
									req.Header.Set(k, v)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							client := http.Client{Timeout: 5 * time.Minute}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var resp *http.Response
 | 
				
			||||||
 | 
							for range tryAttempts {
 | 
				
			||||||
 | 
								resp, err = client.Do(req)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return nil, err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if resp.StatusCode >= 200 && resp.StatusCode < 300 {
 | 
				
			||||||
 | 
									break
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								resp.Body.Close()
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							defer resp.Body.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							data, err := io.ReadAll(resp.Body)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if !verifySHA256(*specs.SHA256, data) {
 | 
				
			||||||
 | 
								return nil, ErrSha256Sum
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return data, nil
 | 
				
			||||||
 | 
						case "POST":
 | 
				
			||||||
 | 
							specs := info.(POSTSpecs)
 | 
				
			||||||
 | 
							var body *bytes.Reader
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if specs.Body != nil {
 | 
				
			||||||
 | 
								body = bytes.NewReader([]byte(*specs.Body))
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								body = nil
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							req, err := http.NewRequest("POST", url, body)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if specs.Headers != nil {
 | 
				
			||||||
 | 
								for k, v := range *specs.Headers {
 | 
				
			||||||
 | 
									req.Header.Set(k, v)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							client := http.Client{Timeout: 5 * time.Minute}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var resp *http.Response
 | 
				
			||||||
 | 
							for range tryAttempts {
 | 
				
			||||||
 | 
								resp, err = client.Do(req)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return nil, err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if resp.StatusCode >= 200 && resp.StatusCode < 300 {
 | 
				
			||||||
 | 
									break
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								resp.Body.Close()
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							defer resp.Body.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							data, err := io.ReadAll(resp.Body)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if !verifySHA256(*specs.SHA256, data) {
 | 
				
			||||||
 | 
								return nil, ErrSha256Sum
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return data, nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						case "git":
 | 
				
			||||||
 | 
							specs := info.(GitSpecs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if specs.Tag == nil {
 | 
				
			||||||
 | 
								return &git.CloneOptions{
 | 
				
			||||||
 | 
									URL:           url,
 | 
				
			||||||
 | 
									SingleBranch:  true,
 | 
				
			||||||
 | 
									ReferenceName: plumbing.NewBranchReferenceName(specs.Branch),
 | 
				
			||||||
 | 
									Depth:         1,
 | 
				
			||||||
 | 
								}, nil
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								return &git.CloneOptions{
 | 
				
			||||||
 | 
									URL:           url,
 | 
				
			||||||
 | 
									SingleBranch:  true,
 | 
				
			||||||
 | 
									ReferenceName: plumbing.NewTagReferenceName(*specs.Tag),
 | 
				
			||||||
 | 
									Depth:         1,
 | 
				
			||||||
 | 
								}, nil
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil, fmt.Errorf("invalid method")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func verifySHA256(checksum []string, src []byte) bool {
 | 
				
			||||||
 | 
						check := sha256.Sum256(src)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return slices.Contains(checksum, hex.EncodeToString(check[:]))
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (pkg *PacketLua) ExecuteBuild(cfg *Config) {
 | 
				
			||||||
 | 
						L := pkg.LuaState
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.SetGlobal("error", L.NewFunction(lua_utils.LError))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						osObject := L.GetGlobal("os").(*lua.LTable)
 | 
				
			||||||
 | 
						osObject.RawSetString("chdir", L.NewFunction(lua_utils.LCD))
 | 
				
			||||||
 | 
						osObject.RawSetString("setenv", L.NewFunction(lua_utils.LSetEnv))
 | 
				
			||||||
 | 
						osObject.RawSetString("copy", L.NewFunction(lua_utils.LCopy))
 | 
				
			||||||
 | 
						osObject.RawSetString("mkdir", L.NewFunction(lua_utils.LMkdir))
 | 
				
			||||||
 | 
						osObject.RawSetString("remove", L.NewFunction(lua_utils.LRemove))
 | 
				
			||||||
 | 
						osObject.RawSetString("rename", L.NewFunction(lua_utils.LRename))
 | 
				
			||||||
 | 
						osObject.RawSetString("symlink", L.NewFunction(lua_utils.LSymlink))
 | 
				
			||||||
 | 
						osObject.RawSetString("chmod", L.NewFunction(lua_utils.LChmod))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.SetGlobal("BIN_DIR", lua.LString(cfg.BinDir))
 | 
				
			||||||
 | 
						L.SetGlobal("CURRENT_ARCH", lua.LString(runtime.GOARCH))
 | 
				
			||||||
 | 
						L.SetGlobal("CURRENT_ARCH_NORMALIZED", lua.LString(normalizeArch(runtime.GOARCH)))
 | 
				
			||||||
 | 
						L.SetGlobal("CURRENT_PLATAFORM", lua.LString(runtime.GOOS))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.SetGlobal("SOURCESDIR", lua.LString(cfg.SourcesDir))
 | 
				
			||||||
 | 
						L.SetGlobal("PACKETDIR", lua.LString(cfg.PacketDir))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var newFlags lua_utils.Flags
 | 
				
			||||||
 | 
						L.SetGlobal("setflags", L.NewFunction(newFlags.LSetFlag))
 | 
				
			||||||
 | 
						L.SetGlobal("pathjoin", L.NewFunction(lua_utils.Ljoin))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						os.Chdir(cfg.RootDir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						os.Setenv("PATH", os.Getenv("PATH")+":"+cfg.BinDir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.Push(pkg.Build)
 | 
				
			||||||
 | 
						L.Call(0, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pkg.Flags = append(pkg.Flags, newFlags.Flags...)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (pkg *PacketLua) ExecuteInstall(cfg *Config) {
 | 
				
			||||||
 | 
						L := pkg.LuaState
 | 
				
			||||||
 | 
						defer L.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.SetGlobal("error", L.NewFunction(lua_utils.LError))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						osObject := L.GetGlobal("os").(*lua.LTable)
 | 
				
			||||||
 | 
						osObject.RawSetString("chdir", L.NewFunction(lua_utils.LCD))
 | 
				
			||||||
 | 
						osObject.RawSetString("setenv", L.NewFunction(lua_utils.LSetEnv))
 | 
				
			||||||
 | 
						osObject.RawSetString("copy", L.NewFunction(lua_utils.LCopy))
 | 
				
			||||||
 | 
						osObject.RawSetString("mkdir", L.NewFunction(lua_utils.LMkdir))
 | 
				
			||||||
 | 
						osObject.RawSetString("remove", L.NewFunction(lua_utils.LRemove))
 | 
				
			||||||
 | 
						osObject.RawSetString("rename", L.NewFunction(lua_utils.LRename))
 | 
				
			||||||
 | 
						osObject.RawSetString("symlink", L.NewFunction(lua_utils.LSymlink))
 | 
				
			||||||
 | 
						osObject.RawSetString("chmod", L.NewFunction(lua_utils.LChmod))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.SetGlobal("BIN_DIR", lua.LString(cfg.BinDir))
 | 
				
			||||||
 | 
						L.SetGlobal("CURRENT_ARCH", lua.LString(runtime.GOARCH))
 | 
				
			||||||
 | 
						L.SetGlobal("CURRENT_ARCH_NORMALIZED", lua.LString(normalizeArch(runtime.GOARCH)))
 | 
				
			||||||
 | 
						L.SetGlobal("CURRENT_PLATAFORM", lua.LString(runtime.GOOS))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.SetGlobal("SOURCESDIR", lua.LString(cfg.SourcesDir))
 | 
				
			||||||
 | 
						L.SetGlobal("PACKETDIR", lua.LString(cfg.PacketDir))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var newFlags lua_utils.Flags
 | 
				
			||||||
 | 
						L.SetGlobal("setflags", L.NewFunction(newFlags.LSetFlag))
 | 
				
			||||||
 | 
						L.SetGlobal("pathjoin", L.NewFunction(lua_utils.Ljoin))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						os.Chdir(cfg.RootDir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						os.Setenv("PATH", os.Getenv("PATH")+":"+cfg.BinDir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						L.Push(pkg.Install)
 | 
				
			||||||
 | 
						L.Call(0, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pkg.Flags = append(pkg.Flags, newFlags.Flags...)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,5 @@
 | 
				
			|||||||
package packet
 | 
					package packet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					 | 
				
			||||||
	"fmt"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (pkg PacketLua) IsValid() bool {
 | 
					func (pkg PacketLua) IsValid() bool {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var a, b int
 | 
						var a, b int
 | 
				
			||||||
@@ -15,18 +11,15 @@ func (pkg PacketLua) IsValid() bool {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	a += len(*pkg.GlobalSources)
 | 
						a += len(*pkg.GlobalSources)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if a <= 0 || b <= 0 {
 | 
						if a < 1 || len(*pkg.Plataforms) > b {
 | 
				
			||||||
		fmt.Println("invalid")
 | 
					 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch {
 | 
						switch {
 | 
				
			||||||
	case pkg.Serial == -133:
 | 
						case pkg.Serial == -133:
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	case pkg.Description == "" || pkg.Maintaner == "" || pkg.Name == "" || pkg.Version == "":
 | 
						case pkg.Description == "" || pkg.Maintainer == "" || pkg.Name == "" || pkg.Version == "":
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	fmt.Println("valid")
 | 
					 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										34
									
								
								pkg/packet.lua.d/utils.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								pkg/packet.lua.d/utils.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					package packet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"math/rand"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$%!@%&*()-=+[]{}:;.,1234567890"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func randStringBytes(n int) string {
 | 
				
			||||||
 | 
						b := make([]byte, n)
 | 
				
			||||||
 | 
						for i := range b {
 | 
				
			||||||
 | 
							b[i] = letterBytes[rand.Intn(len(letterBytes))]
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return string(b)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type PackageID struct {
 | 
				
			||||||
 | 
						ID string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (id PackageID) Name() string {
 | 
				
			||||||
 | 
						return strings.SplitAfter(id.ID, "@")[0]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (id PackageID) Version() string {
 | 
				
			||||||
 | 
						return strings.SplitAfter(id.ID, "@")[1]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewId(id string) PackageID {
 | 
				
			||||||
 | 
						var ID PackageID
 | 
				
			||||||
 | 
						ID.ID = id
 | 
				
			||||||
 | 
						return ID
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,27 +1,20 @@
 | 
				
			|||||||
local arch_map = {
 | 
					 | 
				
			||||||
    amd64 = "x86_64",
 | 
					 | 
				
			||||||
    aarch64 = "aarch64",
 | 
					 | 
				
			||||||
    arm64 = "aarch64",
 | 
					 | 
				
			||||||
    ['386'] = "i686" 
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
local srcarch = arch_map[CURRENT_ARCH]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
return {
 | 
					return {
 | 
				
			||||||
    package = {
 | 
					    package = {
 | 
				
			||||||
        name = "bat-bin", -- required
 | 
					        name = "bat-bin",                                                             -- required
 | 
				
			||||||
        version = "0.26.0", -- required
 | 
					        version = "0.26.0",                                                           -- required
 | 
				
			||||||
        maintainer = "robogg133", -- required
 | 
					        maintainer = "robogg133",                                                     -- required
 | 
				
			||||||
        description = "A cat(1) clone with syntax highlighting and Git integration.", -- required
 | 
					        description = "A cat(1) clone with syntax highlighting and Git integration.", -- required
 | 
				
			||||||
        serial = 0,-- required
 | 
					        serial = 0,                                                                   -- required
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        plataforms = {
 | 
					        plataforms = {
 | 
				
			||||||
            windows = {
 | 
					            windows = {
 | 
				
			||||||
                arch = {"amd64"},
 | 
					                arch = { "amd64" },
 | 
				
			||||||
                sources = {
 | 
					                sources = {
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        url = "https://github.com/sharkdp/bat/releases/download/v0.26.0/bat-v0.26.0-" ..srcarch .."-pc-windows-msvc.zip",
 | 
					                        url = "https://github.com/sharkdp/bat/releases/download/v0.26.0/bat-v0.26.0-" ..
 | 
				
			||||||
 | 
					                            CURRENT_ARCH_NORMALIZED .. "-pc-windows-msvc.zip",
 | 
				
			||||||
                        method = "GET",
 | 
					                        method = "GET",
 | 
				
			||||||
                        sha256="a8a6862f14698b45e101b0932c69bc47a007f4c0456f3a129fdcef54d443d501"
 | 
					                        sha256 = { "a8a6862f14698b45e101b0932c69bc47a007f4c0456f3a129fdcef54d443d501" }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                dependencies = {
 | 
					                dependencies = {
 | 
				
			||||||
@@ -31,12 +24,13 @@ return {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            linux = {
 | 
					            linux = {
 | 
				
			||||||
                arch = {"amd64"},
 | 
					                arch = { "amd64" },
 | 
				
			||||||
                sources = {
 | 
					                sources = {
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        url = "https://github.com/sharkdp/bat/releases/download/v0.26.0/bat-v0.26.0-".. srcarch .."-unknown-linux-gnu.tar.gz",
 | 
					                        url = "https://github.com/sharkdp/bat/releases/download/v0.26.0/bat-v0.26.0-" ..
 | 
				
			||||||
 | 
					                            CURRENT_ARCH_NORMALIZED .. "-unknown-linux-gnu.tar.gz",
 | 
				
			||||||
                        method = "GET",
 | 
					                        method = "GET",
 | 
				
			||||||
                        sha256 = "7efed0c768fae36f18ddbbb4a38f5c4b64db7c55a170dfc89fd380805809a44b"
 | 
					                        sha256 = { "7efed0c768fae36f18ddbbb4a38f5c4b64db7c55a170dfc89fd380805809a44b" }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                dependencies = {
 | 
					                dependencies = {
 | 
				
			||||||
@@ -50,12 +44,22 @@ return {
 | 
				
			|||||||
        sources = {}
 | 
					        sources = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
    build = function() 
 | 
					    build = function()
 | 
				
			||||||
    end,
 | 
					
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    install = function() -- required 
 | 
					 | 
				
			||||||
    print("oi amores")
 | 
					 | 
				
			||||||
    end,
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					    install = function()
 | 
				
			||||||
 | 
					        os.chdir(pathjoin(SOURCESDIR, "bat-v0.26.0-" .. CURRENT_ARCH_NORMALIZED .. "-unknown-linux-gnu"))
 | 
				
			||||||
 | 
					        os.chmod("bat", 755)
 | 
				
			||||||
 | 
					        local suc, errmsg = os.copy("bat", pathjoin(PACKETDIR, BIN_DIR, "bat"))
 | 
				
			||||||
 | 
					        if not suc then
 | 
				
			||||||
 | 
					            error("failed to copy bat: " .. errmsg)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("bat.1", pathjoin(PACKETDIR, "/usr/share/man/man1/bat.1"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        setflags("man", "manual", "/usr/share/man/man1/bat.1")
 | 
				
			||||||
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										65
									
								
								test/go/Packet.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								test/go/Packet.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,65 @@
 | 
				
			|||||||
 | 
					return {
 | 
				
			||||||
 | 
					    package = {
 | 
				
			||||||
 | 
					        name = "go",
 | 
				
			||||||
 | 
					        version = "1.25.3",
 | 
				
			||||||
 | 
					        maintainer = "robogg133",
 | 
				
			||||||
 | 
					        description = "A cat(1) clone with syntax highlighting and Git integration.",
 | 
				
			||||||
 | 
					        serial = 0,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        plataforms = {
 | 
				
			||||||
 | 
					            windows = {
 | 
				
			||||||
 | 
					                arch = { "amd64" },
 | 
				
			||||||
 | 
					                sources = {
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        url = "https://github.com/sharkdp/bat/releases/download/v0.26.0/bat-v0.26.0-" ..
 | 
				
			||||||
 | 
					                            CURRENT_ARCH_NORMALIZED .. "-pc-windows-msvc.zip",
 | 
				
			||||||
 | 
					                        method = "GET",
 | 
				
			||||||
 | 
					                        sha256 = "a8a6862f14698b45e101b0932c69bc47a007f4c0456f3a129fdcef54d443d501"
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					                dependencies = {
 | 
				
			||||||
 | 
					                    build = {},
 | 
				
			||||||
 | 
					                    runtime = {},
 | 
				
			||||||
 | 
					                    conflicts = {}
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            linux = {
 | 
				
			||||||
 | 
					                arch = { "amd64" },
 | 
				
			||||||
 | 
					                sources = {
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        url = "https://github.com/sharkdp/bat/releases/download/v0.26.0/bat-v0.26.0-" ..
 | 
				
			||||||
 | 
					                            CURRENT_ARCH_NORMALIZED .. "-unknown-linux-gnu.tar.gz",
 | 
				
			||||||
 | 
					                        method = "GET",
 | 
				
			||||||
 | 
					                        sha256 = "7efed0c768fae36f18ddbbb4a38f5c4b64db7c55a170dfc89fd380805809a44b"
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					                dependencies = {
 | 
				
			||||||
 | 
					                    build = {},
 | 
				
			||||||
 | 
					                    runtime = {},
 | 
				
			||||||
 | 
					                    conflicts = {}
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        sources = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    build = function()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    install = function()
 | 
				
			||||||
 | 
					        os.chdir(pathjoin(SOURCESDIR, "bat-v0.26.0-" .. CURRENT_ARCH_NORMALIZED .. "-unknown-linux-gnu"))
 | 
				
			||||||
 | 
					        os.chmod("bat", 755)
 | 
				
			||||||
 | 
					        local suc, errmsg = os.copy("bat", pathjoin(PACKETDIR, BIN_DIR, "bat"))
 | 
				
			||||||
 | 
					        if not suc then
 | 
				
			||||||
 | 
					            error("failed to copy bat: " .. errmsg)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("bat.1", pathjoin(PACKETDIR, "/usr/share/man/man1/bat.1"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        setflags("man", "manual", "/usr/share/man/man1/bat.1")
 | 
				
			||||||
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										127
									
								
								test/nginx/Packet.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								test/nginx/Packet.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,127 @@
 | 
				
			|||||||
 | 
					-- https://nginx.org/download/nginx-1.29.3.tar.gz
 | 
				
			||||||
 | 
					return {
 | 
				
			||||||
 | 
					    package = {
 | 
				
			||||||
 | 
					        name = "nginx",
 | 
				
			||||||
 | 
					        version = "1.29.3",
 | 
				
			||||||
 | 
					        maintainer = "robogg133",
 | 
				
			||||||
 | 
					        description =
 | 
				
			||||||
 | 
					        [[nginx ("engine x") is an HTTP web server, reverse proxy, content cache, load balancer, TCP/UDP proxy server, and mail proxy server. Originally written by Igor Sysoev and distributed under the 2-clause BSD License. Enterprise distributions, commercial support and training are available from F5, Inc.]],
 | 
				
			||||||
 | 
					        serial = 0,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        plataforms = {
 | 
				
			||||||
 | 
					            windows = {
 | 
				
			||||||
 | 
					                arch = { "amd64" },
 | 
				
			||||||
 | 
					                sources = {
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        url = "https://nginx.org/download/nginx-1.29.3.zip",
 | 
				
			||||||
 | 
					                        method = "GET",
 | 
				
			||||||
 | 
					                        sha256 = { "afa2fde9fdf0ac64b91a17dcd34100ac557a3ff8e6154eeb0eeae7aa8e5bbc2d" }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					                dependencies = {
 | 
				
			||||||
 | 
					                    build = {
 | 
				
			||||||
 | 
					                        "cc",
 | 
				
			||||||
 | 
					                        "cmake",
 | 
				
			||||||
 | 
					                        "make"
 | 
				
			||||||
 | 
					                    },
 | 
				
			||||||
 | 
					                    runtime = {},
 | 
				
			||||||
 | 
					                    conflicts = {}
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            linux = {
 | 
				
			||||||
 | 
					                arch = { "amd64" },
 | 
				
			||||||
 | 
					                sources = {
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        url = "https://nginx.org/download/nginx-1.29.3.tar.gz",
 | 
				
			||||||
 | 
					                        method = "GET",
 | 
				
			||||||
 | 
					                        sha256 = { "9befcced12ee09c2f4e1385d7e8e21c91f1a5a63b196f78f897c2d044b8c9312" }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					                dependencies = {
 | 
				
			||||||
 | 
					                    build = {
 | 
				
			||||||
 | 
					                        "cc",
 | 
				
			||||||
 | 
					                        "cmake",
 | 
				
			||||||
 | 
					                        "make"
 | 
				
			||||||
 | 
					                    },
 | 
				
			||||||
 | 
					                    runtime = {},
 | 
				
			||||||
 | 
					                    conflicts = {}
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        sources = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    build = function()
 | 
				
			||||||
 | 
					        local uncompressedname = "nginx-1.29.3"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.chdir(pathjoin(SOURCESDIR, uncompressedname))
 | 
				
			||||||
 | 
					        os.chmod("configure", 0755)
 | 
				
			||||||
 | 
					        os.execute("./configure --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=" ..
 | 
				
			||||||
 | 
					            pathjoin(BIN_DIR, "nginx"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        print("Build progress: executing Make...")
 | 
				
			||||||
 | 
					        local handle = io.popen("make", "r")
 | 
				
			||||||
 | 
					        local _ = handle:read("*a")
 | 
				
			||||||
 | 
					        local success, reason, exitcode = handle:close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if not success then
 | 
				
			||||||
 | 
					            error("make failed with code " .. tostring(exitcode) .. ": " .. tostring(reason))
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        print("Build progress: Make completed!")
 | 
				
			||||||
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    install = function()
 | 
				
			||||||
 | 
					        local uncompressedname = "nginx-1.29.3"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("nginx.service", pathjoin(PACKETDIR, "/etc/systemd/system/nginx.service"))
 | 
				
			||||||
 | 
					        os.chdir(pathjoin(SOURCESDIR, uncompressedname))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.chmod("objs/nginx", 755)
 | 
				
			||||||
 | 
					        os.copy("objs/nginx", pathjoin(PACKETDIR, BIN_DIR, "nginx"))
 | 
				
			||||||
 | 
					        os.mkdir(pathjoin(PACKETDIR, "/usr/local/nginx"), 755)
 | 
				
			||||||
 | 
					        os.mkdir(pathjoin(PACKETDIR, "/etc/nginx"), 755)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("conf/koi-win", pathjoin(PACKETDIR, "/etc/nginx/koi-win"))
 | 
				
			||||||
 | 
					        os.copy("conf/koi-utf", pathjoin(PACKETDIR, "/etc/nginx/koi-utf"))
 | 
				
			||||||
 | 
					        os.copy("conf/win-utf", pathjoin(PACKETDIR, "/etc/nginx/win-utf"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("conf/mime.types", pathjoin(PACKETDIR, "/etc/nginx/mime.types"))
 | 
				
			||||||
 | 
					        os.copy("conf/mime.types", pathjoin(PACKETDIR, "/etc/nginx/mime.types.default"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("conf/fastcgi_params", pathjoin(PACKETDIR, "/etc/nginx/fastcgi_params"))
 | 
				
			||||||
 | 
					        os.copy("conf/fastcgi_params", pathjoin(PACKETDIR, "/etc/nginx/fastcgi_params.default"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("conf/fastcgi.conf", pathjoin(PACKETDIR, "/etc/nginx/fastcgi.conf"))
 | 
				
			||||||
 | 
					        os.copy("conf/fastcgi.conf", pathjoin(PACKETDIR, "/etc/nginx/fastcgi.conf.default"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("conf/uwsgi_params", pathjoin(PACKETDIR, "/etc/nginx/uwsgi_params"))
 | 
				
			||||||
 | 
					        os.copy("conf/uwsgi_params", pathjoin(PACKETDIR, "/etc/nginx/uwsgi_params.default"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("conf/scgi_params", pathjoin(PACKETDIR, "/etc/nginx/scgi_params"))
 | 
				
			||||||
 | 
					        os.copy("conf/scgi_params", pathjoin(PACKETDIR, "/etc/nginx/scgi_params.default"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("conf/nginx.conf", pathjoin(PACKETDIR, "/etc/nginx/nginx.conf"))
 | 
				
			||||||
 | 
					        os.copy("conf/nginx.conf", pathjoin(PACKETDIR, "/etc/nginx/nginx.conf.default"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("html", pathjoin(PACKETDIR, "/usr/share/nginx/html"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("LICENSE", pathjoin(PACKETDIR, "/usr/share/licenses/nginx/LICENSE"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.copy("man/nginx.8", pathjoin(PACKETDIR, "/usr/share/man/man8/nginx.8"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        os.mkdir(pathjoin(PACKETDIR, "/etc/nginx/logs"), 755)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        setflags("bin", "nginx", pathjoin(BIN_DIR, "nginx"))
 | 
				
			||||||
 | 
					        setflags("config", "main", "/etc/nginx/nginx.conf")
 | 
				
			||||||
 | 
					        setflags("config", "sites-available", "/etc/nginx/sites-available")
 | 
				
			||||||
 | 
					        setflags("config", "sites-enabled", "/etc/nginx/sites-enabled")
 | 
				
			||||||
 | 
					        setflags("man", "nginx.8", "/usr/share/man/man8/nginx.8")
 | 
				
			||||||
 | 
					        setflags("license", "license", "/usr/share/licenses/nginx/LICENSE")
 | 
				
			||||||
 | 
					        setflags("systemd", "nginx.service", "/etc/systemd/system/nginx.service")
 | 
				
			||||||
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										20
									
								
								test/nginx/nginx.service
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								test/nginx/nginx.service
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					[Unit]
 | 
				
			||||||
 | 
					 Description=nginx web server
 | 
				
			||||||
 | 
					 After=network-online.target remote-fs.target nss-lookup.target
 | 
				
			||||||
 | 
					 Wants=network-online.target
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Service]
 | 
				
			||||||
 | 
					 Type=forking
 | 
				
			||||||
 | 
					 PrivateDevices=yes
 | 
				
			||||||
 | 
					 PrivateTmp=true
 | 
				
			||||||
 | 
					 SyslogLevel=err
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 ExecStart=/usr/bin/nginx
 | 
				
			||||||
 | 
					 ExecReload=/usr/bin/nginx -s reload
 | 
				
			||||||
 | 
					 Restart=on-failure
 | 
				
			||||||
 | 
					 KillMode=mixed
 | 
				
			||||||
 | 
					 KillSignal=SIGQUIT
 | 
				
			||||||
 | 
					 TimeoutStopSec=5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Install]
 | 
				
			||||||
 | 
					 WantedBy=multi-user.target
 | 
				
			||||||
@@ -1,34 +1,40 @@
 | 
				
			|||||||
return {
 | 
					return {
 | 
				
			||||||
    package = {
 | 
					    package = {
 | 
				
			||||||
        name = "utctimerightnow", -- required
 | 
					        name = "utctimerightnow",       -- required
 | 
				
			||||||
        version = "0.1.0", -- required
 | 
					        version = "0.1.0",              -- required
 | 
				
			||||||
        maintainer = "robogg133", -- required
 | 
					        maintainer = "robogg133",       -- required
 | 
				
			||||||
        description = "shows utc time", -- required
 | 
					        description = "shows utc time", -- required
 | 
				
			||||||
        serial = 0,-- required
 | 
					        serial = 0,                     -- required
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        dependencies = {
 | 
					        dependencies = {
 | 
				
			||||||
            build = {"go"},
 | 
					            build = { "go" },
 | 
				
			||||||
            runtime = {},
 | 
					            runtime = {},
 | 
				
			||||||
            conflicts = {}
 | 
					            conflicts = {}
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        sources = { --optional 
 | 
					        sources = {                                                            --optional
 | 
				
			||||||
            { 
 | 
					            {
 | 
				
			||||||
                url = "https://git.opentty.xyz/robogg133/utctimerightnow.git", -- required
 | 
					                url = "https://git.opentty.xyz/robogg133/utctimerightnow.git", -- required
 | 
				
			||||||
                method = "git", -- required
 | 
					                method = "git",                                                -- required
 | 
				
			||||||
                branch = "main" -- required 
 | 
					                branch = "main"                                                -- required
 | 
				
			||||||
            --  tag = ""
 | 
					                --  tag = ""
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    build = function()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    end,
 | 
					    build   = function()
 | 
				
			||||||
    
 | 
					        --   os.setenv("GOPATH", pathjoin(SOURCESDIR, "gopath"))
 | 
				
			||||||
    install  = function() -- required 
 | 
					        os.chdir(pathjoin(SOURCESDIR, "utctimerightnow"))
 | 
				
			||||||
        print("goku")
 | 
					        os.execute('go build -trimpath -ldflags="-s -w" -o utctimerightnow main.go')
 | 
				
			||||||
 | 
					        os.chmod("utctimerightnow", 777)
 | 
				
			||||||
    end,
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					    install = function() -- required
 | 
				
			||||||
 | 
					        os.copy(pathjoin(SOURCESDIR, "utctimerightnow", "utctimerightnow"),
 | 
				
			||||||
 | 
					            pathjoin(PACKETDIR, BIN_DIR, "utctimerightnow"))
 | 
				
			||||||
 | 
					        os.copy(pathjoin(SOURCESDIR, "utctimerightnow", "LICENSE"),
 | 
				
			||||||
 | 
					            pathjoin(PACKETDIR, "/usr/share/licenses/utctimerightnow/LICENSE"))
 | 
				
			||||||
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user