creating database schemas for packets cli, started doing packets cli and
packing nginx
This commit is contained in:
		
							
								
								
									
										154
									
								
								cmd/main.go
									
									
									
									
									
								
							
							
						
						
									
										154
									
								
								cmd/main.go
									
									
									
									
									
								
							@@ -1,154 +0,0 @@
 | 
				
			|||||||
package main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import (
 | 
					 | 
				
			||||||
	"log"
 | 
					 | 
				
			||||||
	"os"
 | 
					 | 
				
			||||||
	"path"
 | 
					 | 
				
			||||||
	"path/filepath"
 | 
					 | 
				
			||||||
	"runtime"
 | 
					 | 
				
			||||||
	"strings"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	"github.com/go-git/go-git/v6"
 | 
					 | 
				
			||||||
	"github.com/roboogg133/packets/pkg/install"
 | 
					 | 
				
			||||||
	"github.com/roboogg133/packets/pkg/packet.lua.d"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const bipath = "/usr/bin"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func main() {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	log.SetFlags(log.Llongfile)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	switch os.Args[1] {
 | 
					 | 
				
			||||||
	case "install":
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		f, err := os.ReadFile(os.Args[2])
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			log.Fatal(err)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		options := &packet.Config{
 | 
					 | 
				
			||||||
			BinDir: bipath,
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		pkg, err := packet.ReadPacket(f, options)
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			log.Fatal(err)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		pkgId := pkg.Name + "@" + pkg.Version
 | 
					 | 
				
			||||||
		if err := os.MkdirAll("_pkgtest/"+pkgId, 0777); err != nil {
 | 
					 | 
				
			||||||
			log.Fatal(err)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		os.MkdirAll("_pkgtest/"+pkgId+"/src", 0777)
 | 
					 | 
				
			||||||
		os.MkdirAll("_pkgtest/"+pkgId+"/packet", 0777)
 | 
					 | 
				
			||||||
		if pkg.Plataforms != nil {
 | 
					 | 
				
			||||||
			tmp := *pkg.Plataforms
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			plataform := tmp[packet.OperationalSystem(runtime.GOOS)]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			for _, v := range *plataform.Sources {
 | 
					 | 
				
			||||||
				src, err := packet.GetSource(v.Url, v.Method, v.Specs, 5)
 | 
					 | 
				
			||||||
				if err != nil {
 | 
					 | 
				
			||||||
					log.Fatal(err)
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if v.Method == "GET" || v.Method == "POST" {
 | 
					 | 
				
			||||||
					f := src.([]byte)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					if err := os.WriteFile("_pkgtest/"+pkgId+"/"+path.Base(v.Url), f, 0777); err != nil {
 | 
					 | 
				
			||||||
						log.Fatal(err)
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					if err := packet.Dearchive("_pkgtest/"+pkgId+"/"+path.Base(v.Url), "_pkgtest/"+pkgId+"/src"); err != nil {
 | 
					 | 
				
			||||||
						log.Fatal(err)
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					os.Remove("_pkgtest/" + pkgId + "/" + path.Base(v.Url))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				} else {
 | 
					 | 
				
			||||||
					result, err := packet.GetSource(v.Url, v.Method, v.Specs, -213123)
 | 
					 | 
				
			||||||
					if err != nil {
 | 
					 | 
				
			||||||
						log.Fatal(err)
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					reponame, _ := strings.CutSuffix(path.Base(v.Url), ".git")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					_, err = git.PlainClone("_pkgtest/"+pkgId+"/src/"+reponame, result.(*git.CloneOptions))
 | 
					 | 
				
			||||||
					if err != nil {
 | 
					 | 
				
			||||||
						log.Fatal(err)
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if pkg.GlobalSources != nil {
 | 
					 | 
				
			||||||
			for _, v := range *pkg.GlobalSources {
 | 
					 | 
				
			||||||
				src, err := packet.GetSource(v.Url, v.Method, v.Specs, 5)
 | 
					 | 
				
			||||||
				if err != nil {
 | 
					 | 
				
			||||||
					log.Fatal(err)
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if v.Method == "GET" || v.Method == "POST" {
 | 
					 | 
				
			||||||
					f := src.([]byte)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					if err := os.WriteFile("_pkgtest/"+pkgId+"/"+path.Base(v.Url), f, 0777); err != nil {
 | 
					 | 
				
			||||||
						log.Fatal(err)
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					if err := packet.Dearchive("_pkgtest/"+pkgId+"/"+path.Base(v.Url), "_pkgtest/"+pkgId+"/src"); err != nil {
 | 
					 | 
				
			||||||
						log.Fatal(err)
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					os.Remove("_pkgtest/" + pkgId + "/" + path.Base(v.Url))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				} else {
 | 
					 | 
				
			||||||
					result, err := packet.GetSource(v.Url, v.Method, v.Specs, -213123)
 | 
					 | 
				
			||||||
					if err != nil {
 | 
					 | 
				
			||||||
						log.Fatal(err)
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					reponame, _ := strings.CutSuffix(path.Base(v.Url), ".git")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					_, err = git.PlainClone("_pkgtest/"+pkgId+"/src/"+reponame, result.(*git.CloneOptions))
 | 
					 | 
				
			||||||
					if err != nil {
 | 
					 | 
				
			||||||
						log.Fatal(err)
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		packetdir, err := filepath.Abs("_pkgtest/" + pkgId + "/packet")
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			log.Fatal(err)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		srcdir, err := filepath.Abs("_pkgtest/" + pkgId + "/src")
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			log.Fatal(err)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		rootdir, err := filepath.Abs("_pkgtest/" + pkgId)
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			log.Fatal(err)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		pkg.ExecuteBuild(&packet.Config{
 | 
					 | 
				
			||||||
			BinDir:     bipath,
 | 
					 | 
				
			||||||
			PacketDir:  packetdir,
 | 
					 | 
				
			||||||
			SourcesDir: srcdir,
 | 
					 | 
				
			||||||
			RootDir:    rootdir,
 | 
					 | 
				
			||||||
		})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		pkg.ExecuteInstall(&packet.Config{
 | 
					 | 
				
			||||||
			BinDir:     bipath,
 | 
					 | 
				
			||||||
			PacketDir:  packetdir,
 | 
					 | 
				
			||||||
			SourcesDir: srcdir,
 | 
					 | 
				
			||||||
			RootDir:    rootdir,
 | 
					 | 
				
			||||||
		})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		files, err := install.GetPackageFiles(packetdir)
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			log.Fatal(err)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if err := install.InstallFiles(files, packetdir); err != nil {
 | 
					 | 
				
			||||||
			log.Fatal(err)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										91
									
								
								cmd/packets/database/database.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								cmd/packets/database/database.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,91 @@
 | 
				
			|||||||
 | 
					package database
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"database/sql"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_ "github.com/mattn/go-sqlite3"
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/pkg/packet.lua.d"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const (
 | 
				
			||||||
 | 
						CreateInstructions = `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,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    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,
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					`
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type DatabaseOptions struct {
 | 
				
			||||||
 | 
						// Add any additional options here
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func MarkAsInstalled(pkg packet.PacketLua, db *sql.DB, image *[]byte) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if image != nil {
 | 
				
			||||||
 | 
							_, err := db.Exec("INSERT INTO installed_packages (name, id, version, installed_time, image) VALUES (?, ?, ?, ?, ?, ?, ?)", pkg.Name, pkg.Name+"@"+pkg.Version, pkg.Version, time.Now().UnixMilli(), image)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							_, err := db.Exec("INSERT INTO installed_packages (name, id, version, installed_time, image) VALUES (?, ?, ?, ?, ?, ?, ?)", pkg.Name, pkg.Name+"@"+pkg.Version, pkg.Version, time.Now().UnixMilli(), []byte{1})
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										152
									
								
								cmd/packets/decompress/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										152
									
								
								cmd/packets/decompress/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,152 @@
 | 
				
			|||||||
 | 
					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 []byte, outputDir, filename string) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var reader io.Reader
 | 
				
			||||||
 | 
						switch {
 | 
				
			||||||
 | 
						case strings.HasSuffix(filename, ".gz"):
 | 
				
			||||||
 | 
							var err error
 | 
				
			||||||
 | 
							reader, err = gzip.NewReader(bytes.NewReader(data))
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							filename, _ = strings.CutSuffix(filename, ".gz")
 | 
				
			||||||
 | 
						case strings.HasSuffix(filename, ".xz"):
 | 
				
			||||||
 | 
							var err error
 | 
				
			||||||
 | 
							reader, err = xz.NewReader(bytes.NewReader(data))
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							filename, _ = strings.CutSuffix(filename, ".xz")
 | 
				
			||||||
 | 
						case strings.HasSuffix(filename, ".zst"):
 | 
				
			||||||
 | 
							var err error
 | 
				
			||||||
 | 
							reader, err = zstd.NewReader(bytes.NewReader(data))
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							filename, _ = strings.CutSuffix(filename, ".zst")
 | 
				
			||||||
 | 
						case strings.HasSuffix(filename, ".bz2"):
 | 
				
			||||||
 | 
							reader = bzip2.NewReader(bytes.NewReader(data))
 | 
				
			||||||
 | 
							filename, _ = strings.CutSuffix(filename, ".bz2")
 | 
				
			||||||
 | 
						case strings.HasSuffix(filename, ".lz4"):
 | 
				
			||||||
 | 
							reader = lz4.NewReader(bytes.NewReader(data))
 | 
				
			||||||
 | 
							filename, _ = strings.CutSuffix(filename, ".lz4")
 | 
				
			||||||
 | 
						case strings.HasSuffix(filename, ".zip"):
 | 
				
			||||||
 | 
							byteReader := bytes.NewReader(data)
 | 
				
			||||||
 | 
							reader, err := zip.NewReader(byteReader, int64(len(data)))
 | 
				
			||||||
 | 
							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") {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										41
									
								
								cmd/packets/functions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								cmd/packets/functions.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								_ = os.MkdirAll(configs.SourcesDir, 0755)
 | 
				
			||||||
 | 
								if err := decompress.Decompress(f, 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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										107
									
								
								cmd/packets/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								cmd/packets/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,107 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"path/filepath"
 | 
				
			||||||
 | 
						"runtime"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/roboogg133/packets/pkg/packet.lua.d"
 | 
				
			||||||
 | 
						"github.com/spf13/cobra"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 Packet.lua file",
 | 
				
			||||||
 | 
						Long:  "Installs a package from a given Packet.lua file",
 | 
				
			||||||
 | 
						Args:  cobra.MinimumNArgs(1),
 | 
				
			||||||
 | 
						PreRunE: func(cmd *cobra.Command, args []string) error {
 | 
				
			||||||
 | 
							return GetConfiguration()
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						Run: func(cmd *cobra.Command, args []string) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for _, v := range args {
 | 
				
			||||||
 | 
								if !strings.HasSuffix(v, ".lua") {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s need to have .lua suffix\n", v)
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								contentBlob, err := os.ReadFile(v)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s could not be read\n", v)
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								pkg, err := packet.ReadPacket(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,
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								_ = os.MkdirAll(configs.RootDir, 0755)
 | 
				
			||||||
 | 
								_ = 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)
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								backupDir, err := filepath.Abs(".")
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									fmt.Printf("error: %s", err.Error())
 | 
				
			||||||
 | 
									os.Exit(1)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								pkg.ExecuteBuild(configs)
 | 
				
			||||||
 | 
								pkg.ExecuteInstall(configs)
 | 
				
			||||||
 | 
								os.Chdir(backupDir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func main() {
 | 
				
			||||||
 | 
						rootCmd.AddCommand(executeCmd)
 | 
				
			||||||
 | 
						rootCmd.Execute()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										10
									
								
								cmd/packets/specifications.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								cmd/packets/specifications.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const (
 | 
				
			||||||
 | 
						ConfigurationDir       = "/etc/packets"
 | 
				
			||||||
 | 
						HomeDir                = "/var/lib/packets"
 | 
				
			||||||
 | 
						PackageRootDir         = "_pkgtest"
 | 
				
			||||||
 | 
						NumberOfTryAttempts    = 4
 | 
				
			||||||
 | 
						UserHomeDirPlaceholder = "{{ USER HOME FOLDER }}"
 | 
				
			||||||
 | 
						UsernamePlaceholder    = "{{ USERNAME }}"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
							
								
								
									
										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)
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
							
								
								
									
										7
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								go.mod
									
									
									
									
									
								
							@@ -7,6 +7,11 @@ require github.com/yuin/gopher-lua v1.1.1
 | 
				
			|||||||
require (
 | 
					require (
 | 
				
			||||||
	github.com/go-git/go-git/v6 v6.0.0-20251029213217-0bbfc0875edd
 | 
						github.com/go-git/go-git/v6 v6.0.0-20251029213217-0bbfc0875edd
 | 
				
			||||||
	github.com/klauspost/compress v1.18.1
 | 
						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 (
 | 
					require (
 | 
				
			||||||
@@ -18,10 +23,12 @@ require (
 | 
				
			|||||||
	github.com/go-git/gcfg/v2 v2.0.2 // 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/go-git/go-billy/v6 v6.0.0-20251022185412-61e52df296a5 // indirect
 | 
				
			||||||
	github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // 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/kevinburke/ssh_config v1.4.0 // indirect
 | 
				
			||||||
	github.com/klauspost/cpuid/v2 v2.3.0 // indirect
 | 
						github.com/klauspost/cpuid/v2 v2.3.0 // indirect
 | 
				
			||||||
	github.com/pjbgf/sha1cd v0.5.0 // indirect
 | 
						github.com/pjbgf/sha1cd v0.5.0 // indirect
 | 
				
			||||||
	github.com/sergi/go-diff v1.4.0 // indirect
 | 
						github.com/sergi/go-diff v1.4.0 // indirect
 | 
				
			||||||
 | 
						github.com/spf13/pflag v1.0.9 // indirect
 | 
				
			||||||
	golang.org/x/crypto v0.43.0 // indirect
 | 
						golang.org/x/crypto v0.43.0 // indirect
 | 
				
			||||||
	golang.org/x/net v0.46.0 // indirect
 | 
						golang.org/x/net v0.46.0 // indirect
 | 
				
			||||||
	golang.org/x/sys v0.37.0 // indirect
 | 
						golang.org/x/sys v0.37.0 // indirect
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										16
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								go.sum
									
									
									
									
									
								
							@@ -8,6 +8,7 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
 | 
				
			|||||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
 | 
					github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
 | 
				
			||||||
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
 | 
					github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
 | 
				
			||||||
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
 | 
					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 h1:hIAhkRBMQ8nIeuVwcAoymp7MY4oherZdAxD+m0u9zaw=
 | 
				
			||||||
github.com/cyphar/filepath-securejoin v0.5.0/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
 | 
					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.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
				
			||||||
@@ -29,6 +30,8 @@ github.com/go-git/go-git/v6 v6.0.0-20251029213217-0bbfc0875edd h1:pn6+tR4O8McyqE
 | 
				
			|||||||
github.com/go-git/go-git/v6 v6.0.0-20251029213217-0bbfc0875edd/go.mod h1:z9pQiXCfyOZIs/8qa5zmozzbcsDPtGN91UD7+qeX3hk=
 | 
					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 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
 | 
				
			||||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
 | 
					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 h1:6xxtP5bZ2E4NF5tuQulISpTO2z8XbtH8cg1PWkxoFkQ=
 | 
				
			||||||
github.com/kevinburke/ssh_config v1.4.0/go.mod h1:q2RIzfka+BXARoNexmF9gkxEX7DmvbW9P4hIVx2Kg4M=
 | 
					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=
 | 
				
			||||||
@@ -38,16 +41,29 @@ github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu
 | 
				
			|||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 | 
					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/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/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 | 
				
			||||||
 | 
					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/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 h1:a+UkboSi1znleCDUNT3M5YxjOnN1fz2FhN48FlwCxs0=
 | 
				
			||||||
github.com/pjbgf/sha1cd v0.5.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM=
 | 
					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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 | 
				
			||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 | 
					github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 | 
				
			||||||
 | 
					github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 | 
				
			||||||
github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
 | 
					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/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/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.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 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
 | 
				
			||||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
 | 
					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/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 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,11 @@
 | 
				
			|||||||
package lua
 | 
					package lua
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
	"log"
 | 
						"log"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
 | 
						"strconv"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	lua "github.com/yuin/gopher-lua"
 | 
						lua "github.com/yuin/gopher-lua"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -39,7 +41,7 @@ func LCopy(L *lua.LState) int {
 | 
				
			|||||||
	oldname := L.CheckString(1)
 | 
						oldname := L.CheckString(1)
 | 
				
			||||||
	newname := L.CheckString(2)
 | 
						newname := L.CheckString(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	os.MkdirAll(filepath.Dir(newname), 0755)
 | 
						_ = os.MkdirAll(filepath.Dir(newname), 0755)
 | 
				
			||||||
	if err := copyDir(oldname, newname); err != nil {
 | 
						if err := copyDir(oldname, newname); err != nil {
 | 
				
			||||||
		L.Push(lua.LFalse)
 | 
							L.Push(lua.LFalse)
 | 
				
			||||||
		L.Push(lua.LString(err.Error()))
 | 
							L.Push(lua.LString(err.Error()))
 | 
				
			||||||
@@ -87,7 +89,17 @@ func LMkdir(L *lua.LState) int {
 | 
				
			|||||||
	path := L.CheckString(1)
 | 
						path := L.CheckString(1)
 | 
				
			||||||
	perm := L.CheckInt(2)
 | 
						perm := L.CheckInt(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err := os.MkdirAll(path, os.FileMode(perm)); err != nil {
 | 
						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.LFalse)
 | 
				
			||||||
		L.Push(lua.LString(err.Error()))
 | 
							L.Push(lua.LString(err.Error()))
 | 
				
			||||||
		return 2
 | 
							return 2
 | 
				
			||||||
@@ -136,7 +148,16 @@ func LChmod(L *lua.LState) int {
 | 
				
			|||||||
	f := L.CheckString(1)
 | 
						f := L.CheckString(1)
 | 
				
			||||||
	mode := L.CheckInt(2)
 | 
						mode := L.CheckInt(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err := os.Chmod(f, os.FileMode(mode)); err != nil {
 | 
						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.LFalse)
 | 
				
			||||||
		L.Push(lua.LString(err.Error()))
 | 
							L.Push(lua.LString(err.Error()))
 | 
				
			||||||
		return 2
 | 
							return 2
 | 
				
			||||||
@@ -157,7 +178,7 @@ type Flags struct {
 | 
				
			|||||||
	Flags []Flag
 | 
						Flags []Flag
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (f Flags) LSetFlag(L *lua.LState) int {
 | 
					func (f *Flags) LSetFlag(L *lua.LState) int {
 | 
				
			||||||
	flagtype := L.CheckString(1)
 | 
						flagtype := L.CheckString(1)
 | 
				
			||||||
	name := L.CheckString(2)
 | 
						name := L.CheckString(2)
 | 
				
			||||||
	flagPath := L.CheckString(3)
 | 
						flagPath := L.CheckString(3)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,10 +33,11 @@ func walkAll(dirToWalk string) ([]BasicFileStatus, error) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		filesSlice = append(filesSlice, *basicStat)
 | 
							filesSlice = append(filesSlice, *basicStat)
 | 
				
			||||||
		if v.IsDir() {
 | 
							if v.IsDir() {
 | 
				
			||||||
			filesSlice, err = walkAll(filepath.Join(dirToWalk, v.Name()))
 | 
								tmp, err := walkAll(filepath.Join(dirToWalk, v.Name()))
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				return []BasicFileStatus{}, err
 | 
									return []BasicFileStatus{}, err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								filesSlice = append(filesSlice, tmp...)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -47,11 +48,17 @@ func InstallFiles(files []BasicFileStatus, packetDir string) error {
 | 
				
			|||||||
	for i, v := range files {
 | 
						for i, v := range files {
 | 
				
			||||||
		sysPath, _ := strings.CutPrefix(v.Filepath, packetDir)
 | 
							sysPath, _ := strings.CutPrefix(v.Filepath, packetDir)
 | 
				
			||||||
		fmt.Printf("[%d] Installing file %s\n", i, v.Filepath)
 | 
							fmt.Printf("[%d] Installing file %s\n", i, v.Filepath)
 | 
				
			||||||
		fmt.Printf("[%d] NEED tro track file %s\n", i, sysPath)
 | 
							fmt.Printf("[%d] NEED to track file %s\n", i, sysPath)
 | 
				
			||||||
 | 
							if v.IsDir {
 | 
				
			||||||
 | 
								if err := os.MkdirAll(sysPath, v.PermMode.Perm()); err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
			if err := copyFile(v.Filepath, sysPath); err != nil {
 | 
								if err := copyFile(v.Filepath, sysPath); err != nil {
 | 
				
			||||||
				return err
 | 
									return err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -67,7 +74,7 @@ func copyFile(source string, destination string) error {
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = os.MkdirAll(filepath.Dir(destination), 0o755)
 | 
						err = os.MkdirAll(filepath.Dir(destination), 0755)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,7 @@ type PacketLua struct {
 | 
				
			|||||||
	GlobalSources      *[]Source
 | 
						GlobalSources      *[]Source
 | 
				
			||||||
	GlobalDependencies *PkgDependencies
 | 
						GlobalDependencies *PkgDependencies
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Flags *[]lua_utils.Flag
 | 
						Flags []lua_utils.Flag
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Build     *lua.LFunction
 | 
						Build     *lua.LFunction
 | 
				
			||||||
	Install   *lua.LFunction
 | 
						Install   *lua.LFunction
 | 
				
			||||||
@@ -147,9 +147,7 @@ func ReadPacket(f []byte, cfg *Config) (PacketLua, error) {
 | 
				
			|||||||
		PreRemove: getFunctionFromTable(table, "pre_remove"),
 | 
							PreRemove: getFunctionFromTable(table, "pre_remove"),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(newFlags.Flags) > 0 {
 | 
						packetLua.Flags = append(packetLua.Flags, newFlags.Flags...)
 | 
				
			||||||
		packetLua.Flags = &newFlags.Flags
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	packetLua.LuaState = L
 | 
						packetLua.LuaState = L
 | 
				
			||||||
	if packetLua.Install == nil {
 | 
						if packetLua.Install == nil {
 | 
				
			||||||
@@ -313,7 +311,7 @@ func verifySHA256(checksum string, src []byte) bool {
 | 
				
			|||||||
	return hex.EncodeToString(check[:]) == checksum
 | 
						return hex.EncodeToString(check[:]) == checksum
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (pkg PacketLua) ExecuteBuild(cfg *Config) error {
 | 
					func (pkg *PacketLua) ExecuteBuild(cfg *Config) {
 | 
				
			||||||
	L := pkg.LuaState
 | 
						L := pkg.LuaState
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	L.SetGlobal("error", L.NewFunction(lua_utils.LError))
 | 
						L.SetGlobal("error", L.NewFunction(lua_utils.LError))
 | 
				
			||||||
@@ -347,15 +345,10 @@ func (pkg PacketLua) ExecuteBuild(cfg *Config) error {
 | 
				
			|||||||
	L.Push(pkg.Build)
 | 
						L.Push(pkg.Build)
 | 
				
			||||||
	L.Call(0, 0)
 | 
						L.Call(0, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(newFlags.Flags) > 0 && pkg.Flags != nil {
 | 
						pkg.Flags = append(pkg.Flags, newFlags.Flags...)
 | 
				
			||||||
		*pkg.Flags = append(*pkg.Flags, newFlags.Flags...)
 | 
					 | 
				
			||||||
	} else if len(newFlags.Flags) > 0 {
 | 
					 | 
				
			||||||
		*pkg.Flags = newFlags.Flags
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return nil
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (pkg PacketLua) ExecuteInstall(cfg *Config) error {
 | 
					func (pkg *PacketLua) ExecuteInstall(cfg *Config) {
 | 
				
			||||||
	L := pkg.LuaState
 | 
						L := pkg.LuaState
 | 
				
			||||||
	defer L.Close()
 | 
						defer L.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -390,10 +383,6 @@ func (pkg PacketLua) ExecuteInstall(cfg *Config) error {
 | 
				
			|||||||
	L.Push(pkg.Install)
 | 
						L.Push(pkg.Install)
 | 
				
			||||||
	L.Call(0, 0)
 | 
						L.Call(0, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(newFlags.Flags) > 0 && pkg.Flags != nil {
 | 
						pkg.Flags = append(pkg.Flags, newFlags.Flags...)
 | 
				
			||||||
		*pkg.Flags = append(*pkg.Flags, newFlags.Flags...)
 | 
					
 | 
				
			||||||
	} else if len(newFlags.Flags) > 0 {
 | 
					 | 
				
			||||||
		*pkg.Flags = newFlags.Flags
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return nil
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,16 +4,17 @@ return {
 | 
				
			|||||||
        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-" ..CURRENT_ARCH_NORMALIZED.."-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 = {
 | 
				
			||||||
@@ -23,10 +24,11 @@ return {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            linux = {
 | 
					            linux = {
 | 
				
			||||||
                arch = {"amd64"},
 | 
					                arch = { "amd64" },
 | 
				
			||||||
                sources = {
 | 
					                sources = {
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        url = "https://github.com/sharkdp/bat/releases/download/v0.26.0/bat-v0.26.0-".. CURRENT_ARCH_NORMALIZED .."-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"
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
@@ -48,12 +50,11 @@ return {
 | 
				
			|||||||
    end,
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    install = function()
 | 
					    install = function()
 | 
				
			||||||
    
 | 
					        os.chdir(pathjoin(SOURCESDIR, "bat-v0.26.0-" .. CURRENT_ARCH_NORMALIZED .. "-unknown-linux-gnu"))
 | 
				
			||||||
        os.chdir(pathjoin(SOURCESDIR,"bat-v0.26.0-".. CURRENT_ARCH_NORMALIZED .."-unknown-linux-gnu"))
 | 
					        os.chmod("bat", 755)
 | 
				
			||||||
        os.chmod("bat",0777)
 | 
					 | 
				
			||||||
        local suc, errmsg = os.copy("bat", pathjoin(PACKETDIR, BIN_DIR, "bat"))
 | 
					        local suc, errmsg = os.copy("bat", pathjoin(PACKETDIR, BIN_DIR, "bat"))
 | 
				
			||||||
        if not suc then
 | 
					        if not suc then
 | 
				
			||||||
            error(errmsg)
 | 
					            error("failed to copy bat: " .. errmsg)
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
    end,
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										123
									
								
								test/nginx/Packet.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										123
									
								
								test/nginx/Packet.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,123 @@
 | 
				
			|||||||
 | 
					-- 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.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")
 | 
				
			||||||
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -4,10 +4,10 @@ return {
 | 
				
			|||||||
        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 = {}
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
@@ -27,12 +27,14 @@ return {
 | 
				
			|||||||
        --   os.setenv("GOPATH", pathjoin(SOURCESDIR, "gopath"))
 | 
					        --   os.setenv("GOPATH", pathjoin(SOURCESDIR, "gopath"))
 | 
				
			||||||
        os.chdir(pathjoin(SOURCESDIR, "utctimerightnow"))
 | 
					        os.chdir(pathjoin(SOURCESDIR, "utctimerightnow"))
 | 
				
			||||||
        os.execute('go build -trimpath -ldflags="-s -w" -o utctimerightnow main.go')
 | 
					        os.execute('go build -trimpath -ldflags="-s -w" -o utctimerightnow main.go')
 | 
				
			||||||
        os.chmod(utctimerightnow, 0777)
 | 
					        os.chmod("utctimerightnow", 777)
 | 
				
			||||||
    end,
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    install = function() -- required
 | 
					    install = function() -- required
 | 
				
			||||||
        os.copy(pathjoin(SOURCESDIR, "utctimerightnow", "utctimerightnow"), pathjoin(PACKETDIR, BIN_DIR, "utctimerightnow"))
 | 
					        os.copy(pathjoin(SOURCESDIR, "utctimerightnow", "utctimerightnow"),
 | 
				
			||||||
        os.copy(pathjoin(SOURCESDIR, "utctimerightnow", "LICENSE"), pathjoin(PACKETDIR, "/usr/share/licenses/utctimerightnow/LICENSE"))
 | 
					            pathjoin(PACKETDIR, BIN_DIR, "utctimerightnow"))
 | 
				
			||||||
 | 
					        os.copy(pathjoin(SOURCESDIR, "utctimerightnow", "LICENSE"),
 | 
				
			||||||
 | 
					            pathjoin(PACKETDIR, "/usr/share/licenses/utctimerightnow/LICENSE"))
 | 
				
			||||||
    end,
 | 
					    end,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user