From 820ffc299f9d674b0c99c7dfc261eb4d663582a1 Mon Sep 17 00:00:00 2001 From: robogg133 Date: Sat, 25 Oct 2025 20:17:20 -0300 Subject: [PATCH] code maybe confusing, but now using Packet.lua format --- go.mod | 46 ++++++++- go.sum | 132 +++++++++++++++++++++++-- internal/build/complete.go | 72 ++++++++++++++ internal/build/install.go | 30 +++--- internal/build/manager.go | 3 +- internal/utils/lua/lua.go | 5 +- pkg/main.go | 193 ++++++++++++++++++++++++++++++------- 7 files changed, 413 insertions(+), 68 deletions(-) create mode 100644 internal/build/complete.go diff --git a/go.mod b/go.mod index 2338ffc..4c688b2 100644 --- a/go.mod +++ b/go.mod @@ -3,27 +3,65 @@ module packets go 1.25.1 require ( + github.com/gin-gonic/gin v1.11.0 + github.com/go-git/go-git/v6 v6.0.0-20251021092831-91c33c9361ce github.com/klauspost/compress v1.18.0 github.com/pelletier/go-toml/v2 v2.2.4 github.com/spf13/afero v1.15.0 github.com/spf13/cobra v1.10.1 github.com/yuin/gopher-lua v1.1.1 - golang.org/x/net v0.44.0 + golang.org/x/net v0.46.0 modernc.org/sqlite v1.38.2 ) require ( + github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/ProtonMail/go-crypto v1.3.0 // indirect + github.com/bytedance/sonic v1.14.0 // indirect + github.com/bytedance/sonic/loader v0.3.0 // indirect + github.com/cloudflare/circl v1.6.1 // indirect + github.com/cloudwego/base64x v0.1.6 // indirect + github.com/cyphar/filepath-securejoin v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect + github.com/emirpasic/gods v1.18.1 // indirect + github.com/gabriel-vasile/mimetype v1.4.8 // indirect + github.com/gin-contrib/sse v1.1.0 // indirect + github.com/go-git/gcfg/v2 v2.0.2 // indirect + github.com/go-git/go-billy/v6 v6.0.0-20251016063423-4289a4e54aa4 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.27.0 // indirect + github.com/goccy/go-json v0.10.2 // indirect + github.com/goccy/go-yaml v1.18.0 // indirect + github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect github.com/google/uuid v1.6.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/kevinburke/ssh_config v1.4.0 // indirect + github.com/klauspost/cpuid/v2 v2.3.0 // indirect + github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect + github.com/pjbgf/sha1cd v0.5.0 // indirect + github.com/quic-go/qpack v0.5.1 // indirect + github.com/quic-go/quic-go v0.54.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - github.com/spf13/afero v1.15.0 // indirect + github.com/sergi/go-diff v1.4.0 // indirect github.com/spf13/pflag v1.0.10 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.3.0 // indirect + go.uber.org/mock v0.5.0 // indirect + golang.org/x/arch v0.20.0 // indirect + golang.org/x/crypto v0.43.0 // indirect golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect - golang.org/x/sys v0.36.0 // indirect - golang.org/x/text v0.29.0 // indirect + golang.org/x/mod v0.28.0 // indirect + golang.org/x/sync v0.17.0 // indirect + golang.org/x/sys v0.37.0 // indirect + golang.org/x/text v0.30.0 // indirect + golang.org/x/tools v0.37.0 // indirect + google.golang.org/protobuf v1.36.9 // indirect modernc.org/libc v1.66.3 // indirect modernc.org/mathutil v1.7.1 // indirect modernc.org/memory v1.11.0 // indirect diff --git a/go.sum b/go.sum index 103047d..046ff98 100644 --- a/go.sum +++ b/go.sum @@ -1,23 +1,106 @@ +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/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ= +github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA= +github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA= +github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= +github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0= +github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= +github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M= +github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU= 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/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +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/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= +github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= +github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w= +github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM= +github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk= +github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls= +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-20251016063423-4289a4e54aa4 h1:xQLkKmWcw9n5CUkl//bKQB7SPWQbaoKSVnHXH9V8sg8= +github.com/go-git/go-billy/v6 v6.0.0-20251016063423-4289a4e54aa4/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-20251021092831-91c33c9361ce h1:DFvDcCiFZk2yDXVreC9+B+SAZYHH2RssMmtR2zBwANE= +github.com/go-git/go-git/v6 v6.0.0-20251021092831-91c33c9361ce/go.mod h1:xtOWa43AoQlsqYogmpf0MnjBJHKPL2/3teh4fmZ/k+Y= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4= +github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw= +github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= +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/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs= github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +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.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= +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/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= 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/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= 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/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/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= +github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= +github.com/quic-go/quic-go v0.54.0 h1:6s1YB9QotYI6Ospeiguknbp2Znb/jZYjZLRXn9kMQBg= +github.com/quic-go/quic-go v0.54.0/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= 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/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s= @@ -25,24 +108,53 @@ github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4 github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +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/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA= +github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4= github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= +go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= +go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= +golang.org/x/arch v0.20.0 h1:dx1zTU0MAE98U+TQ8BLl7XsJbgze2WnNKF/8tGp/Q6c= +golang.org/x/arch v0.20.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= +golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04= +golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0= golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o= golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8= -golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ= -golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc= -golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= -golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= +golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U= +golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI= +golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4= +golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210= golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= -golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= -golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= -golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg= -golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s= +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= +golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE= +golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w= +google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw= +google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= 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.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= modernc.org/cc/v4 v4.26.2 h1:991HMkLjJzYBIfha6ECZdjrIYz2/1ayr+FL8GN+CNzM= modernc.org/cc/v4 v4.26.2/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= diff --git a/internal/build/complete.go b/internal/build/complete.go new file mode 100644 index 0000000..bf6ceb3 --- /dev/null +++ b/internal/build/complete.go @@ -0,0 +1,72 @@ +package build + +import ( + "packets/internal/packet" + utils_lua "packets/internal/utils/lua" + + lua "github.com/yuin/gopher-lua" +) + +func (container Container) ExecutePrepare(packetLua packet.PacketLua, L *lua.LState) error { + + gitTable := L.NewTable() + + gitTable.RawSetString("clone", L.NewFunction(utils_lua.LGitClone)) + gitTable.RawSetString("checkout", L.NewFunction(utils_lua.LGitCheckout)) + gitTable.RawSetString("pull", L.NewFunction(utils_lua.LGitPUll)) + + containerTable := L.NewTable() + + containerTable.RawSetString("dir", L.NewFunction(container.lDir)) + + L.SetGlobal("git", gitTable) + L.Push(packetLua.Prepare) + L.Push(containerTable) + + return L.PCall(1, 0, nil) + +} + +func (container Container) ExecuteBuild(packetLua packet.PacketLua, L *lua.LState) error { + + osObject := L.GetGlobal("os").(*lua.LTable) + ioObject := L.GetGlobal("io").(*lua.LTable) + + OnlyContainerOS := L.NewTable() + + OnlyContainerOS.RawSetString("copy", L.NewFunction(container.lCopy)) + OnlyContainerOS.RawSetString("mkdir", L.NewFunction(container.lMkdir)) + OnlyContainerOS.RawSetString("rename", L.NewFunction(container.lRename)) + OnlyContainerOS.RawSetString("remove", L.NewFunction(container.lRemove)) + OnlyContainerOS.RawSetString("execute", L.NewFunction(container.lexecute)) + OnlyContainerOS.RawSetString("open", L.NewFunction(container.lOpen)) + + OnlyContainerIO := L.NewTable() + + OnlyContainerIO.RawSetString("popen", L.NewFunction(container.lpopen)) + + L.SetGlobal("io", OnlyContainerIO) + L.SetGlobal("os", OnlyContainerOS) + + L.Push(packetLua.Build) + err := L.PCall(0, 0, nil) + if err != nil { + return err + } + + L.SetGlobal("os", osObject) + L.SetGlobal("io", ioObject) + return nil +} + +func (container Container) ExecuteInstall(packetLua packet.PacketLua, L *lua.LState) error { + + containerTable := L.NewTable() + + containerTable.RawSetString("dir", L.NewFunction(container.lDir)) + + L.Push(packetLua.Install) + L.Push(containerTable) + + return L.PCall(1, 0, nil) +} diff --git a/internal/build/install.go b/internal/build/install.go index 7dcb95e..f87b621 100644 --- a/internal/build/install.go +++ b/internal/build/install.go @@ -7,6 +7,7 @@ import ( "io" "log" "os" + "packets/internal/packet" "packets/internal/utils" utils_lua "packets/internal/utils/lua" "path/filepath" @@ -14,11 +15,10 @@ import ( "sync" "github.com/klauspost/compress/zstd" - lua "github.com/yuin/gopher-lua" ) func (container Container) installPackage(file []byte, destDir string) error { - manifest, err := utils.ReadManifest(bytes.NewReader(file)) + manifest, err := packet.ReadPacketFromFile(bytes.NewReader(file)) if err != nil { return err } @@ -95,7 +95,7 @@ func (container Container) installPackage(file []byte, destDir string) error { return err } - if filepath.Base(hdr.Name) == "manifest.toml" || filepath.Base(hdr.Name) == manifest.Hooks.Install || filepath.Base(hdr.Name) == manifest.Hooks.Remove { + if filepath.Base(hdr.Name) == "Packet.lua" { err = os.Chmod(absPath, os.FileMode(0755)) if err != nil { return err @@ -113,34 +113,34 @@ func (container Container) installPackage(file []byte, destDir string) error { return err } - L.SetGlobal("DATA_DIR", lua.LString(filepath.Join(destDir, "data"))) - L.SetGlobal("script", lua.LString(manifest.Hooks.Build)) - - bootstrapcontainer, err := NewContainer(filepath.Join(container.Root, destDir, "data"), manifest) + bootstrapcontainer, err := NewContainer(manifest) if err != nil { return err } - bootstrapcontainer.LuaState.DoFile(manifest.Hooks.Build) + if err := bootstrapcontainer.ExecutePrepare(manifest, &L); err != nil { + return fmt.Errorf("error executing prepare: %s", err) + } - L.SetGlobal("DATA_DIR", lua.LString(filepath.Join(destDir, "data"))) - L.SetGlobal("script", lua.LString(manifest.Hooks.Install)) + if err := bootstrapcontainer.ExecuteBuild(manifest, &L); err != nil { + return fmt.Errorf("error executing build: %s", err) + } if err := utils.ChangeToNoPermission(); err != nil { - return err + return fmt.Errorf("error changing to packet user: %s", err) } - if err := L.DoFile(filepath.Join(destDir, manifest.Hooks.Install)); err != nil { - return err + if err := bootstrapcontainer.ExecuteInstall(manifest, &L); err != nil { + return fmt.Errorf("error executing build: %s", err) } if err := utils.ElevatePermission(); err != nil { - return err + return fmt.Errorf("error changing to root: %s", err) } return nil } -func (container Container) asyncFullInstallDependencie(dep string, storePackages bool, installPath string, wg *sync.WaitGroup, mu *sync.Mutex) { +func (container Container) asyncFullInstallDependencie(dep string, storePackages bool, installPath string, wg *sync.WaitGroup) { defer wg.Done() fmt.Printf(" downloading %s \n", dep) diff --git a/internal/build/manager.go b/internal/build/manager.go index f8b1fda..3880efe 100644 --- a/internal/build/manager.go +++ b/internal/build/manager.go @@ -32,10 +32,9 @@ func (container Container) createNew() error { return err } var wg sync.WaitGroup - var mu sync.Mutex for _, depn := range dependencies { wg.Add(1) - go container.asyncFullInstallDependencie(depn, cfg.Config.StorePackages, depn, &wg, &mu) + go container.asyncFullInstallDependencie(depn, cfg.Config.StorePackages, depn, &wg) } wg.Wait() diff --git a/internal/utils/lua/lua.go b/internal/utils/lua/lua.go index f4a5607..6e5b663 100644 --- a/internal/utils/lua/lua.go +++ b/internal/utils/lua/lua.go @@ -16,13 +16,10 @@ func GetSandBox() (lua.LState, error) { osObject := L.GetGlobal("os").(*lua.LTable) L.SetGlobal("SAFE_MODE", lua.LTrue) - L.SetGlobal("PACKETS_DATADIR", lua.LString(cfg.Config.Data_d)) - L.SetGlobal("packets_bin_dir", lua.LString(cfg.Config.Bin_d)) + L.SetGlobal("BIN_DIR", lua.LString(cfg.Config.Bin_d)) L.SetGlobal("path_join", L.NewFunction(Ljoin)) - // Packets build functions - osObject.RawSetString("remove", L.NewFunction(LSafeRemove)) osObject.RawSetString("rename", L.NewFunction(LSafeRename)) osObject.RawSetString("copy", L.NewFunction(LSafeCopy)) diff --git a/pkg/main.go b/pkg/main.go index a0d76e8..26a1b82 100644 --- a/pkg/main.go +++ b/pkg/main.go @@ -3,24 +3,53 @@ package packets import ( "archive/tar" "bytes" + "crypto/ed25519" + "database/sql" + "fmt" "io" + "log" + "net/http" "os" "packets/internal/build" + "packets/internal/consts" + errors_packets "packets/internal/errors" + "packets/internal/packet" "packets/internal/utils" - "runtime" + "path" utils_lua "packets/internal/utils/lua" "path/filepath" "strings" "github.com/klauspost/compress/zstd" - lua "github.com/yuin/gopher-lua" _ "modernc.org/sqlite" ) +type Package struct { + PackageF []byte + Version string + ImageUrl string + QueryName string + Description string + Author string + AuthorVerified bool + OS string + Arch string + Filename string + Size int64 + Dependencies map[string]string + + Signature []byte + PublicKey ed25519.PublicKey + + Serial int + + Manifest packet.PacketLua +} + // Install exctract and fully install from a package file ( tar.zst ) func InstallPackage(file []byte, destDir string) error { - manifest, err := utils.ReadManifest(bytes.NewReader(file)) + manifest, err := packet.ReadPacketFromFile(bytes.NewReader(file)) if err != nil { return err } @@ -97,7 +126,7 @@ func InstallPackage(file []byte, destDir string) error { return err } - if filepath.Base(hdr.Name) == "manifest.toml" || filepath.Base(hdr.Name) == manifest.Hooks.Install || filepath.Base(hdr.Name) == manifest.Hooks.Remove { + if filepath.Base(hdr.Name) == "Packet.lua" { err = os.Chmod(absPath, os.FileMode(0755)) if err != nil { return err @@ -115,61 +144,159 @@ func InstallPackage(file []byte, destDir string) error { return err } - L.SetGlobal("DATA_DIR", lua.LString(filepath.Join(destDir, "data"))) - L.SetGlobal("script", lua.LString(manifest.Hooks.Build)) - - container, err := build.NewContainer(filepath.Join(destDir, "data"), manifest) + bootstrapcontainer, err := build.NewContainer(manifest) if err != nil { return err } - container.GetLuaState() + if err := bootstrapcontainer.ExecutePrepare(manifest, &L); err != nil { + return fmt.Errorf("error executing prepare: %s", err) + } - L.SetGlobal("data_dir", lua.LString(filepath.Join(destDir, "data"))) - L.SetGlobal("script", lua.LString(manifest.Hooks.Install)) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() + if err := bootstrapcontainer.ExecuteBuild(manifest, &L); err != nil { + return fmt.Errorf("error executing build: %s", err) + } if err := utils.ChangeToNoPermission(); err != nil { - return err + return fmt.Errorf("error changing to packet user: %s", err) } - if err := L.DoFile(filepath.Join(destDir, manifest.Hooks.Install)); err != nil { - return err + if err := bootstrapcontainer.ExecuteInstall(manifest, &L); err != nil { + return fmt.Errorf("error executing build: %s", err) } if err := utils.ElevatePermission(); err != nil { - return err + return fmt.Errorf("error changing to root: %s", err) } return nil } -// ExecuteRemoveScript executes the remove script from the package -func ExecuteRemoveScript(path string) error { +func GetPackage(id string) (Package, error) { - L, err := utils_lua.GetSandBox() + var this Package + this.Dependencies = make(map[string]string) + var peers []Peer + + db, err := sql.Open("sqlite", consts.IndexDB) if err != nil { - return err + return this, err + } + defer db.Close() + + var packageUrl string + err = db.QueryRow("SELECT query_name, version, package_url, image_url, description, author, author_verified, os, arch, signature, public_key, serial, size FROM packages WHERE id = ?", id). + Scan( + &this.QueryName, + &this.Version, + &packageUrl, + &this.ImageUrl, + &this.Description, + &this.Author, + &this.AuthorVerified, + &this.OS, + &this.Arch, + &this.Signature, + &this.PublicKey, + &this.Serial, + &this.Size, + ) + if err != nil { + return Package{}, err } - L.SetGlobal("DATA_DIR", lua.LFalse) - L.SetGlobal("script", lua.LString(path)) + rows, err := db.Query("SELECT dependency_name, version_constraint FROM package_dependencies WHERE package_id = ?", id) + if err != nil { + return Package{}, err + } + defer rows.Close() - runtime.LockOSThread() - defer runtime.UnlockOSThread() + for rows.Next() { + var a, vConstraint string + if err := rows.Scan(&a, &vConstraint); err != nil { + return Package{}, err + } - if err := utils.ChangeToNoPermission(); err != nil { - return err + this.Dependencies[a] = vConstraint } - if err := L.DoFile(path); err != nil { - return err + filename := path.Base(packageUrl) + this.Filename = filename + + dirEntry, err := os.ReadDir(consts.DefaultCache_d) + if err != nil { + return Package{}, err } - if err := utils.ElevatePermission(); err != nil { - return err + for _, v := range dirEntry { + if v.Name() == filename { + this.PackageF, err = os.ReadFile(filepath.Join(consts.DefaultCache_d, filename)) + if err != nil { + break + } + goto skipping + + } } - return nil + peers, err = AskLAN(filename) + if err != nil { + return Package{}, err + } + + if len(peers) == 0 { + fmt.Printf(":: Pulling from %s\n", packageUrl) + this.PackageF, err = getFileHTTP(packageUrl) + if err != nil { + return Package{}, err + } + } else { + var totalerrors int = 0 + for _, peer := range peers { + fmt.Printf(":: Pulling from local network (%s)\n", peer.IP) + this.PackageF, err = getFileHTTP(fmt.Sprintf("http://%s:%d/%s", peer.IP, peer.Port, filename)) + if err == nil { + break + } else { + totalerrors++ + } + } + if totalerrors == len(peers) { + this.PackageF, err = getFileHTTP(packageUrl) + if err != nil { + return Package{}, err + } + } + } + +skipping: + + reader := bytes.NewReader(this.PackageF) + this.Manifest, err = packet.ReadPacketFromFile(reader) + if err != nil { + return Package{}, err + } + + if !ed25519.Verify(this.PublicKey, this.PackageF, this.Signature) { + return Package{}, errors_packets.ErrInvalidSignature + } + + return this, nil +} + +func getFileHTTP(url string) ([]byte, error) { + resp, err := http.Get(url) + if err != nil { + log.Fatal(err) + } + + if resp.StatusCode != http.StatusOK { + return nil, errors_packets.ErrResponseNot200OK + } + + fileBytes, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + return fileBytes, nil }