From eec56e09218c717716a5fa7aebb6cef53327b35e Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 06:23:02 +0300 Subject: [PATCH 01/54] src: first attempt at a major refactor --- .github/workflows/build-rootfs.yml | 22 ++--- .github/workflows/build.yml | 4 +- .github/workflows/man.yml | 4 +- .gitignore | 2 +- Makefile | 2 +- README.md | 2 +- {src/chkupd => chkupd}/autoupdater.nim | 0 {src/chkupd => chkupd}/backends/arch.nim | 0 {src/chkupd => chkupd}/backends/repology.nim | 0 {src/chkupd => chkupd}/checkall.nim | 0 {src/chkupd => chkupd}/chkupd.nim | 0 {src/chkupd => chkupd}/jsontomd.sh | 0 {src/docker => docker}/Dockerfile | 0 {src/installer => installer}/README.md | 0 {src/installer => installer}/klinstaller | 0 .../jumpstart => jumpstart}/commonImports.nim | 0 {src/jumpstart => jumpstart}/jumpctl.nim | 0 {src/jumpstart => jumpstart}/jumpstart.nim | 0 {src/jumpstart => jumpstart}/logging.nim | 0 .../serviceHandler/disable.nim | 0 .../serviceHandler/enable.nim | 0 .../serviceHandler/globalVariables.nim | 0 .../serviceHandler/jumpmount/main.nim | 0 .../serviceHandler/jumpmount/umount.nim | 0 .../serviceHandler/main.nim | 0 .../serviceHandler/start.nim | 0 .../serviceHandler/status.nim | 0 .../serviceHandler/stop.nim | 0 .../build.nim => kpkg/commands/buildcmd.nim | 21 ++-- .../info.nim => kpkg/commands/infocmd.nim | 7 +- .../commands/installcmd.nim | 18 +++- .../remove.nim => kpkg/commands/removecmd.nim | 8 +- .../update.nim => kpkg/commands/updatecmd.nim | 9 +- .../commands/upgradecmd.nim | 10 +- {src/kpkg => kpkg}/kpkg.nim | 19 ++-- {src/kpkg => kpkg}/modules/config.nim | 16 ++-- {src/kpkg => kpkg}/modules/dephandler.nim | 7 +- {src/kpkg => kpkg}/modules/downloader.nim | 4 +- {src/kpkg => kpkg}/modules/logger.nim | 4 +- {src/kpkg => kpkg}/modules/removeInternal.nim | 7 +- {src/kpkg => kpkg}/modules/runparser.nim | 23 +++-- {src/kpkg => kpkg}/modules/shadow.nim | 4 +- {src/kreastrap => kreastrap}/README.md | 0 .../arch/amd64/configs/builder-gnu.conf | 0 .../arch/amd64/configs/builder-systemd.conf | 0 .../arch/amd64/configs/builder.conf | 0 .../arch/amd64/configs/nocc.conf | 0 .../arch/amd64/configs/server.conf | 0 {src/kreastrap => kreastrap}/kreastrap.nim | 0 .../kreastrap => kreastrap}/overlay/etc/group | 0 .../etc/jumpstart/services/getty-tty1.service | 0 .../etc/jumpstart/services/getty-tty2.service | 0 .../etc/jumpstart/services/getty-tty3.service | 0 .../etc/jumpstart/services/getty-tty4.service | 0 .../etc/jumpstart/services/getty-tty5.service | 0 .../etc/jumpstart/services/getty-tty6.service | 0 .../overlay/etc/os-release | 0 .../overlay/etc/passwd | 0 .../overlay/etc/profile | 0 .../overlay/etc/resolv.conf | 0 .../overlay/etc/shells | 0 man/kpkg.8 | 62 ------------ {src/man => man}/kpkg.8.md | 0 man/kpkg.conf.5 | 69 ------------- {src/man => man}/kpkg.conf.5.md | 0 man/kpkg_run.8 | 96 ------------------- {src/man => man}/kpkg_run.8.md | 0 man/kreastrap.8 | 38 -------- {src/man => man}/kreastrap.8.md | 0 man/kreastrap.conf.5 | 77 --------------- {src/man => man}/kreastrap.conf.5.md | 0 {src/mari => mari}/mari.nim | 0 {src/purr => purr}/README.md | 0 {src/purr => purr}/common.nim | 4 +- {src/purr => purr}/purr.nim | 6 +- {src/scripts => scripts}/build-ci.sh | 0 76 files changed, 129 insertions(+), 416 deletions(-) rename {src/chkupd => chkupd}/autoupdater.nim (100%) rename {src/chkupd => chkupd}/backends/arch.nim (100%) rename {src/chkupd => chkupd}/backends/repology.nim (100%) rename {src/chkupd => chkupd}/checkall.nim (100%) rename {src/chkupd => chkupd}/chkupd.nim (100%) rename {src/chkupd => chkupd}/jsontomd.sh (100%) rename {src/docker => docker}/Dockerfile (100%) rename {src/installer => installer}/README.md (100%) rename {src/installer => installer}/klinstaller (100%) rename {src/jumpstart => jumpstart}/commonImports.nim (100%) rename {src/jumpstart => jumpstart}/jumpctl.nim (100%) rename {src/jumpstart => jumpstart}/jumpstart.nim (100%) rename {src/jumpstart => jumpstart}/logging.nim (100%) rename {src/jumpstart => jumpstart}/serviceHandler/disable.nim (100%) rename {src/jumpstart => jumpstart}/serviceHandler/enable.nim (100%) rename {src/jumpstart => jumpstart}/serviceHandler/globalVariables.nim (100%) rename {src/jumpstart => jumpstart}/serviceHandler/jumpmount/main.nim (100%) rename {src/jumpstart => jumpstart}/serviceHandler/jumpmount/umount.nim (100%) rename {src/jumpstart => jumpstart}/serviceHandler/main.nim (100%) rename {src/jumpstart => jumpstart}/serviceHandler/start.nim (100%) rename {src/jumpstart => jumpstart}/serviceHandler/status.nim (100%) rename {src/jumpstart => jumpstart}/serviceHandler/stop.nim (100%) rename src/kpkg/build.nim => kpkg/commands/buildcmd.nim (96%) rename src/kpkg/info.nim => kpkg/commands/infocmd.nim (85%) rename src/kpkg/install.nim => kpkg/commands/installcmd.nim (94%) rename src/kpkg/remove.nim => kpkg/commands/removecmd.nim (78%) rename src/kpkg/update.nim => kpkg/commands/updatecmd.nim (93%) rename src/kpkg/upgrade.nim => kpkg/commands/upgradecmd.nim (91%) rename {src/kpkg => kpkg}/kpkg.nim (91%) rename {src/kpkg => kpkg}/modules/config.nim (83%) rename {src/kpkg => kpkg}/modules/dephandler.nim (89%) rename {src/kpkg => kpkg}/modules/downloader.nim (84%) rename {src/kpkg => kpkg}/modules/logger.nim (73%) rename {src/kpkg => kpkg}/modules/removeInternal.nim (80%) rename {src/kpkg => kpkg}/modules/runparser.nim (87%) rename {src/kpkg => kpkg}/modules/shadow.nim (85%) rename {src/kreastrap => kreastrap}/README.md (100%) rename {src/kreastrap => kreastrap}/arch/amd64/configs/builder-gnu.conf (100%) rename {src/kreastrap => kreastrap}/arch/amd64/configs/builder-systemd.conf (100%) rename {src/kreastrap => kreastrap}/arch/amd64/configs/builder.conf (100%) rename {src/kreastrap => kreastrap}/arch/amd64/configs/nocc.conf (100%) rename {src/kreastrap => kreastrap}/arch/amd64/configs/server.conf (100%) rename {src/kreastrap => kreastrap}/kreastrap.nim (100%) rename {src/kreastrap => kreastrap}/overlay/etc/group (100%) rename {src/kreastrap => kreastrap}/overlay/etc/jumpstart/services/getty-tty1.service (100%) rename {src/kreastrap => kreastrap}/overlay/etc/jumpstart/services/getty-tty2.service (100%) rename {src/kreastrap => kreastrap}/overlay/etc/jumpstart/services/getty-tty3.service (100%) rename {src/kreastrap => kreastrap}/overlay/etc/jumpstart/services/getty-tty4.service (100%) rename {src/kreastrap => kreastrap}/overlay/etc/jumpstart/services/getty-tty5.service (100%) rename {src/kreastrap => kreastrap}/overlay/etc/jumpstart/services/getty-tty6.service (100%) rename {src/kreastrap => kreastrap}/overlay/etc/os-release (100%) rename {src/kreastrap => kreastrap}/overlay/etc/passwd (100%) rename {src/kreastrap => kreastrap}/overlay/etc/profile (100%) rename {src/kreastrap => kreastrap}/overlay/etc/resolv.conf (100%) rename {src/kreastrap => kreastrap}/overlay/etc/shells (100%) delete mode 100644 man/kpkg.8 rename {src/man => man}/kpkg.8.md (100%) delete mode 100644 man/kpkg.conf.5 rename {src/man => man}/kpkg.conf.5.md (100%) delete mode 100644 man/kpkg_run.8 rename {src/man => man}/kpkg_run.8.md (100%) delete mode 100644 man/kreastrap.8 rename {src/man => man}/kreastrap.8.md (100%) delete mode 100644 man/kreastrap.conf.5 rename {src/man => man}/kreastrap.conf.5.md (100%) rename {src/mari => mari}/mari.nim (100%) rename {src/purr => purr}/README.md (100%) rename {src/purr => purr}/common.nim (91%) rename {src/purr => purr}/purr.nim (95%) rename {src/scripts => scripts}/build-ci.sh (100%) diff --git a/.github/workflows/build-rootfs.yml b/.github/workflows/build-rootfs.yml index 0986e955..4bd42fa5 100644 --- a/.github/workflows/build-rootfs.yml +++ b/.github/workflows/build-rootfs.yml @@ -29,8 +29,8 @@ jobs: - name: Build nocc rootfs tarball run: | - IS_ACTIONS=y sh $GITHUB_WORKSPACE/src/scripts/build-ci.sh init - IS_ACTIONS=y sh $GITHUB_WORKSPACE/src/scripts/build-ci.sh build nocc + IS_ACTIONS=y sh $GITHUB_WORKSPACE/scripts/build-ci.sh init + IS_ACTIONS=y sh $GITHUB_WORKSPACE/scripts/build-ci.sh build nocc - name: Upload nocc Rootfs uses: actions/upload-artifact@v3.1.1 @@ -44,7 +44,7 @@ jobs: - name: Build builder rootfs tarball run: | - IS_ACTIONS=y sh $GITHUB_WORKSPACE/src/scripts/build-ci.sh build builder + IS_ACTIONS=y sh $GITHUB_WORKSPACE/scripts/build-ci.sh build builder - name: Upload Builder Rootfs uses: actions/upload-artifact@v3.1.1 @@ -58,7 +58,7 @@ jobs: - name: Build server rootfs tarball run: | - IS_ACTIONS=y sh $GITHUB_WORKSPACE/src/scripts/build-ci.sh build server + IS_ACTIONS=y sh $GITHUB_WORKSPACE/scripts/build-ci.sh build server - name: Upload Server Rootfs uses: actions/upload-artifact@v3.1.1 @@ -72,7 +72,7 @@ jobs: - name: Build builder-gnu rootfs tarball run: | - IS_ACTIONS=y sh $GITHUB_WORKSPACE/src/scripts/build-ci.sh build builder-gnu + IS_ACTIONS=y sh $GITHUB_WORKSPACE/scripts/build-ci.sh build builder-gnu - name: Upload builder-gnu Rootfs uses: actions/upload-artifact@v3.1.1 @@ -86,7 +86,7 @@ jobs: - name: Build builder-systemd rootfs tarball run: | - IS_ACTIONS=y sh $GITHUB_WORKSPACE/src/scripts/build-ci.sh build builder-systemd + IS_ACTIONS=y sh $GITHUB_WORKSPACE/scripts/build-ci.sh build builder-systemd - name: Upload builder-systemd Rootfs uses: actions/upload-artifact@v3.1.1 @@ -112,11 +112,11 @@ jobs: - name: Prepare for Docker run: | mkdir /tmp/docker.tmp /tmp/docker.tmp.nocc /tmp/docker.tmp.builder-gnu /tmp/docker.tmp.server /tmp/docker.tmp.builder-systemd - cp $GITHUB_WORKSPACE/src/docker/Dockerfile /tmp/docker.tmp.nocc || exit 1 - cp $GITHUB_WORKSPACE/src/docker/Dockerfile /tmp/docker.tmp/ || exit 1 - cp $GITHUB_WORKSPACE/src/docker/Dockerfile /tmp/docker.tmp.builder-gnu || exit 1 - cp $GITHUB_WORKSPACE/src/docker/Dockerfile /tmp/docker.tmp.server || exit 1 - cp $GITHUB_WORKSPACE/src/docker/Dockerfile /tmp/docker.tmp.builder-systemd || exit 1 + cp $GITHUB_WORKSPACE/docker/Dockerfile /tmp/docker.tmp.nocc || exit 1 + cp $GITHUB_WORKSPACE/docker/Dockerfile /tmp/docker.tmp/ || exit 1 + cp $GITHUB_WORKSPACE/docker/Dockerfile /tmp/docker.tmp.builder-gnu || exit 1 + cp $GITHUB_WORKSPACE/docker/Dockerfile /tmp/docker.tmp.server || exit 1 + cp $GITHUB_WORKSPACE/docker/Dockerfile /tmp/docker.tmp.builder-systemd || exit 1 tar -xvpf $GITHUB_WORKSPACE/builder-gnu-rootfs/kreato-linux-builder-gnu-*.tar.gz -C "/tmp/docker.tmp.builder-gnu" tar -xvpf $GITHUB_WORKSPACE/builder-systemd-rootfs/kreato-linux-builder-systemd-*.tar.gz -C "/tmp/docker.tmp.builder-systemd" tar -xvpf $GITHUB_WORKSPACE/builder-rootfs/kreato-linux-builder-*.tar.gz -C "/tmp/docker.tmp" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47a05200..21048da7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: - name: build (amd64) run: | - nim c --threads=on -o=/tmp/kpkg-amd64-linux --passL:-static -d:ssl --passL:-lssl --dynlibOverride:ssl --passL:-lcrypto --dynlibOverride:crypto src/kpkg/kpkg.nim + nim c --threads=on -o=/tmp/kpkg-amd64-linux --passL:-static -d:ssl --passL:-lssl --dynlibOverride:ssl --passL:-lcrypto --dynlibOverride:crypto kpkg/kpkg.nim - uses: actions/upload-artifact@v3 with: @@ -43,5 +43,5 @@ jobs: - name: build and run purr run: | - nim c --threads=on -o=/tmp/ci --passL:-static -d:ssl --passL:-lssl --dynlibOverride:ssl --passL:-lcrypto --dynlibOverride:crypto src/purr/purr.nim + nim c --threads=on -o=/tmp/ci --passL:-static -d:ssl --passL:-lssl --dynlibOverride:ssl --passL:-lcrypto --dynlibOverride:crypto purr/purr.nim /tmp/ci diff --git a/.github/workflows/man.yml b/.github/workflows/man.yml index aedff510..a456e9eb 100644 --- a/.github/workflows/man.yml +++ b/.github/workflows/man.yml @@ -3,7 +3,7 @@ name: Build manpages on: push: paths: - - 'src/man/*.md' + - 'man/*.md' workflow_dispatch: jobs: @@ -21,7 +21,7 @@ jobs: - name: Build manpages run: | [ ! -d "man" ] && mkdir man - for i in src/man/*.md; do + for i in man/*.md; do pandoc --standalone --to man "$i" -o man/"$(basename $i .md)" done diff --git a/.gitignore b/.gitignore index 5006010a..585946e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ out packages -src/kreastrap/kreastrap +kreastrap/kreastrap result kpkg-repo archives diff --git a/Makefile b/Makefile index 07394e8e..d5005a12 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SRCDIR = $(shell pwd)/src +SRCDIR = $(shell pwd) PREFIX = ./out nimbuild = nim c -d:release -d:branch=master --threads:on -d:ssl -o=$(PREFIX)/$1 $(SRCDIR)/$1/$1.nim diff --git a/README.md b/README.md index 4265b447..4d8cdd4c 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ There are a couple of build variables; ## kreastrap There is also kreastrap v3, a rootfs building utility. -You can build it by running `make kreastrap`. The binary will be located on `src/kreastrap/kreastrap`. +You can build it by running `make kreastrap`. The binary will be located on `kreastrap/kreastrap`. ## mari Mari is a very simple http server that uses httpbeast. It is mainly used to run Kreato Linux binary repository. You can build it by running `make mari`. The binary will be located on the usual `out` folder. diff --git a/src/chkupd/autoupdater.nim b/chkupd/autoupdater.nim similarity index 100% rename from src/chkupd/autoupdater.nim rename to chkupd/autoupdater.nim diff --git a/src/chkupd/backends/arch.nim b/chkupd/backends/arch.nim similarity index 100% rename from src/chkupd/backends/arch.nim rename to chkupd/backends/arch.nim diff --git a/src/chkupd/backends/repology.nim b/chkupd/backends/repology.nim similarity index 100% rename from src/chkupd/backends/repology.nim rename to chkupd/backends/repology.nim diff --git a/src/chkupd/checkall.nim b/chkupd/checkall.nim similarity index 100% rename from src/chkupd/checkall.nim rename to chkupd/checkall.nim diff --git a/src/chkupd/chkupd.nim b/chkupd/chkupd.nim similarity index 100% rename from src/chkupd/chkupd.nim rename to chkupd/chkupd.nim diff --git a/src/chkupd/jsontomd.sh b/chkupd/jsontomd.sh similarity index 100% rename from src/chkupd/jsontomd.sh rename to chkupd/jsontomd.sh diff --git a/src/docker/Dockerfile b/docker/Dockerfile similarity index 100% rename from src/docker/Dockerfile rename to docker/Dockerfile diff --git a/src/installer/README.md b/installer/README.md similarity index 100% rename from src/installer/README.md rename to installer/README.md diff --git a/src/installer/klinstaller b/installer/klinstaller similarity index 100% rename from src/installer/klinstaller rename to installer/klinstaller diff --git a/src/jumpstart/commonImports.nim b/jumpstart/commonImports.nim similarity index 100% rename from src/jumpstart/commonImports.nim rename to jumpstart/commonImports.nim diff --git a/src/jumpstart/jumpctl.nim b/jumpstart/jumpctl.nim similarity index 100% rename from src/jumpstart/jumpctl.nim rename to jumpstart/jumpctl.nim diff --git a/src/jumpstart/jumpstart.nim b/jumpstart/jumpstart.nim similarity index 100% rename from src/jumpstart/jumpstart.nim rename to jumpstart/jumpstart.nim diff --git a/src/jumpstart/logging.nim b/jumpstart/logging.nim similarity index 100% rename from src/jumpstart/logging.nim rename to jumpstart/logging.nim diff --git a/src/jumpstart/serviceHandler/disable.nim b/jumpstart/serviceHandler/disable.nim similarity index 100% rename from src/jumpstart/serviceHandler/disable.nim rename to jumpstart/serviceHandler/disable.nim diff --git a/src/jumpstart/serviceHandler/enable.nim b/jumpstart/serviceHandler/enable.nim similarity index 100% rename from src/jumpstart/serviceHandler/enable.nim rename to jumpstart/serviceHandler/enable.nim diff --git a/src/jumpstart/serviceHandler/globalVariables.nim b/jumpstart/serviceHandler/globalVariables.nim similarity index 100% rename from src/jumpstart/serviceHandler/globalVariables.nim rename to jumpstart/serviceHandler/globalVariables.nim diff --git a/src/jumpstart/serviceHandler/jumpmount/main.nim b/jumpstart/serviceHandler/jumpmount/main.nim similarity index 100% rename from src/jumpstart/serviceHandler/jumpmount/main.nim rename to jumpstart/serviceHandler/jumpmount/main.nim diff --git a/src/jumpstart/serviceHandler/jumpmount/umount.nim b/jumpstart/serviceHandler/jumpmount/umount.nim similarity index 100% rename from src/jumpstart/serviceHandler/jumpmount/umount.nim rename to jumpstart/serviceHandler/jumpmount/umount.nim diff --git a/src/jumpstart/serviceHandler/main.nim b/jumpstart/serviceHandler/main.nim similarity index 100% rename from src/jumpstart/serviceHandler/main.nim rename to jumpstart/serviceHandler/main.nim diff --git a/src/jumpstart/serviceHandler/start.nim b/jumpstart/serviceHandler/start.nim similarity index 100% rename from src/jumpstart/serviceHandler/start.nim rename to jumpstart/serviceHandler/start.nim diff --git a/src/jumpstart/serviceHandler/status.nim b/jumpstart/serviceHandler/status.nim similarity index 100% rename from src/jumpstart/serviceHandler/status.nim rename to jumpstart/serviceHandler/status.nim diff --git a/src/jumpstart/serviceHandler/stop.nim b/jumpstart/serviceHandler/stop.nim similarity index 100% rename from src/jumpstart/serviceHandler/stop.nim rename to jumpstart/serviceHandler/stop.nim diff --git a/src/kpkg/build.nim b/kpkg/commands/buildcmd.nim similarity index 96% rename from src/kpkg/build.nim rename to kpkg/commands/buildcmd.nim index 7383d6dc..4ea65dcc 100644 --- a/src/kpkg/build.nim +++ b/kpkg/commands/buildcmd.nim @@ -1,11 +1,16 @@ +import os +import osproc +import installcmd import strutils +import sequtils import libsha/sha256 -include modules/dephandler -include modules/runparser -include modules/downloader -include install -import modules/shadow -import os +import asyncdispatch +import ../modules/logger +import ../modules/shadow +import ../modules/config +import ../modules/runparser +import ../modules/dephandler +import ../modules/downloader const lockfile = "/tmp/kpkg.lock" @@ -14,7 +19,7 @@ proc cleanUp() {.noconv.} = removeFile(lockfile) quit(0) -proc builder(package: string, destdir: string, +proc builder*(package: string, destdir: string, root = "/tmp/kpkg/build", srcdir = "/tmp/kpkg/srcdir", offline = false, dontInstall = false, useCacheIfAvailable = false, binrepo = "mirror.kreato.dev", @@ -178,7 +183,7 @@ proc builder(package: string, destdir: string, return false -proc build(no = false, yes = false, root = "/", +proc build*(no = false, yes = false, root = "/", packages: seq[string], useCacheIfAvailable = false, binrepo = "mirror.kreato.dev", enforceReproducibility = false, diff --git a/src/kpkg/info.nim b/kpkg/commands/infocmd.nim similarity index 85% rename from src/kpkg/info.nim rename to kpkg/commands/infocmd.nim index 1e6984d3..c6c854a4 100644 --- a/src/kpkg/info.nim +++ b/kpkg/commands/infocmd.nim @@ -1,4 +1,9 @@ -proc info(package: seq[string], testing = false): string = +import os +import ../modules/logger +import ../modules/config +import ../modules/runparser + +proc info*(package: seq[string], testing = false): string = ## Get information about packages if package.len == 0: diff --git a/src/kpkg/install.nim b/kpkg/commands/installcmd.nim similarity index 94% rename from src/kpkg/install.nim rename to kpkg/commands/installcmd.nim index ef89210d..072199fe 100644 --- a/src/kpkg/install.nim +++ b/kpkg/commands/installcmd.nim @@ -1,6 +1,16 @@ -import threadpool - -proc install_pkg(repo: string, package: string, root: string, binary = false, +import os +import osproc +import strutils +import sequtils +import asyncdispatch +import libsha/sha256 +import ../modules/config +import ../modules/logger +import ../modules/runparser +import ../modules/downloader +import ../modules/dephandler + +proc install_pkg*(repo: string, package: string, root: string, binary = false, enforceReproducibility = false, binrepo = "mirror.kreato.dev", builddir = "/tmp/kpkg/build") = ## Installs an package. @@ -126,7 +136,7 @@ proc install_bin(packages: seq[string], binrepo: string, root: string, install_pkg(repo, i, root, true) echo "Installation for "&i&" complete" -proc install(promptPackages: seq[string], root = "/", yes: bool = false, +proc install*(promptPackages: seq[string], root = "/", yes: bool = false, no: bool = false, binrepo = "mirror.kreato.dev", offline = false, downloadOnly = false): string = diff --git a/src/kpkg/remove.nim b/kpkg/commands/removecmd.nim similarity index 78% rename from src/kpkg/remove.nim rename to kpkg/commands/removecmd.nim index fcb8ace8..6f71364c 100644 --- a/src/kpkg/remove.nim +++ b/kpkg/commands/removecmd.nim @@ -1,5 +1,9 @@ -include modules/removeInternal -proc remove(packages: seq[string], yes = false, root = ""): string = +import os +import strutils +import ../modules/logger +import ../modules/removeInternal + +proc remove*(packages: seq[string], yes = false, root = ""): string = ## Remove packages # bail early if user isn't admin diff --git a/src/kpkg/update.nim b/kpkg/commands/updatecmd.nim similarity index 93% rename from src/kpkg/update.nim rename to kpkg/commands/updatecmd.nim index b6f18745..070278d0 100644 --- a/src/kpkg/update.nim +++ b/kpkg/commands/updatecmd.nim @@ -1,4 +1,11 @@ -proc update(repo = "", +import os +import osproc +import sequtils +import strutils +import ../modules/logger +import ../modules/config + +proc update*(repo = "", path = "", branch = "master"): string = ## Update repositories diff --git a/src/kpkg/upgrade.nim b/kpkg/commands/upgradecmd.nim similarity index 91% rename from src/kpkg/upgrade.nim rename to kpkg/commands/upgradecmd.nim index 928c100b..a8051362 100644 --- a/src/kpkg/upgrade.nim +++ b/kpkg/commands/upgradecmd.nim @@ -1,4 +1,12 @@ -proc upgrade(root = "/", +import os +import buildcmd +import installcmd +import strutils +import ../modules/config +import ../modules/runparser +import ../modules/removeInternal + +proc upgrade*(root = "/", builddir = "/tmp/kpkg/build", srcdir = "/tmp/kpkg/srcdir"): string = ## Upgrade packages var repo: string diff --git a/src/kpkg/kpkg.nim b/kpkg/kpkg.nim similarity index 91% rename from src/kpkg/kpkg.nim rename to kpkg/kpkg.nim index 20a86fad..4814d796 100644 --- a/src/kpkg/kpkg.nim +++ b/kpkg/kpkg.nim @@ -15,19 +15,16 @@ # # You should have received a copy of the GNU General Public License # along with Kreato Linux. If not, see . + import cligen -import sequtils -import parsecfg -import os -include modules/logger -include modules/config -include build -include update -include remove -include upgrade -include info +import commands/infocmd +import commands/buildcmd +import commands/updatecmd +import commands/removecmd +import commands/upgradecmd +import commands/installcmd -clCfg.version = "kpkg v4" +clCfg.version = "kpkg v5" dispatchMulti( [ diff --git a/src/kpkg/modules/config.nim b/kpkg/modules/config.nim similarity index 83% rename from src/kpkg/modules/config.nim rename to kpkg/modules/config.nim index b8260410..e88ba433 100644 --- a/src/kpkg/modules/config.nim +++ b/kpkg/modules/config.nim @@ -1,12 +1,16 @@ -include shadow +import shadow +import parsecfg +import os +import logger +import strutils const configPath = "/etc/kpkg/kpkg.conf" var config: Config -const branch {.strdefine.}: string = "stable" +const branch* {.strdefine.}: string = "stable" -proc initializeConfig(): Config = +proc initializeConfig*(): Config = ## Initializes the configuration file if not isAdmin(): @@ -39,16 +43,16 @@ proc initializeConfig(): Config = return config -proc getConfigValue(section: string, key: string): string = +proc getConfigValue*(section: string, key: string): string = ## Reads the configuration file and returns value of section. return config.getSectionValue(section, key) -proc setConfigValue(section: string, key: string, value: string) = +proc setConfigValue*(section: string, key: string, value: string) = ## Writes a section to the configuration file. config.setSectionKey(section, key, value) config.writeConfig(configPath) -proc findPkgRepo(package: string): string = +proc findPkgRepo*(package: string): string = ## finds the package repository. for i in getConfigValue("Repositories", "RepoDirs").split(" "): if dirExists(i&"/"&package): diff --git a/src/kpkg/modules/dephandler.nim b/kpkg/modules/dephandler.nim similarity index 89% rename from src/kpkg/modules/dephandler.nim rename to kpkg/modules/dephandler.nim index 6bc7fe30..cd7a2164 100644 --- a/src/kpkg/modules/dephandler.nim +++ b/kpkg/modules/dephandler.nim @@ -1,3 +1,8 @@ +import os +import config +import logger +import sequtils + proc isIn(one: seq[string], two: seq[string]): bool = ## Checks if a variable is in another. for i in one: @@ -5,7 +10,7 @@ proc isIn(one: seq[string], two: seq[string]): bool = return true return false -proc dephandler(pkgs: seq[string], ignoreDeps = @[" "], bdeps = false): seq[string] = +proc dephandler*(pkgs: seq[string], ignoreDeps = @[" "], bdeps = false): seq[string] = ## takes in a seq of packages and returns what to install. var deps: seq[string] try: diff --git a/src/kpkg/modules/downloader.nim b/kpkg/modules/downloader.nim similarity index 84% rename from src/kpkg/modules/downloader.nim rename to kpkg/modules/downloader.nim index b66a1601..2d3f7d5f 100644 --- a/src/kpkg/modules/downloader.nim +++ b/kpkg/modules/downloader.nim @@ -1,5 +1,5 @@ import std/[asyncdispatch, httpclient] -import terminal, math +import terminal, math, strutils proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} = stdout.eraseLine @@ -7,7 +7,7 @@ proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} = " at ", formatSize(speed), "/s ", round(int(progress) / int(total)*100), "% complete") stdout.flushFile -proc download(url: string, file: string) {.async.} = +proc download*(url: string, file: string) {.async.} = var client = newAsyncHttpClient() client.onProgressChanged = onProgressChanged await client.downloadFile(url, file) diff --git a/src/kpkg/modules/logger.nim b/kpkg/modules/logger.nim similarity index 73% rename from src/kpkg/modules/logger.nim rename to kpkg/modules/logger.nim index c263e931..a472abdc 100644 --- a/src/kpkg/modules/logger.nim +++ b/kpkg/modules/logger.nim @@ -1,4 +1,6 @@ -proc err(error: string, removeLockFile = true) = +import os + +proc err*(error: string, removeLockFile = true) = ## Handles errors. echo("kpkg: error: "&error) if removeLockFile: diff --git a/src/kpkg/modules/removeInternal.nim b/kpkg/modules/removeInternal.nim similarity index 80% rename from src/kpkg/modules/removeInternal.nim rename to kpkg/modules/removeInternal.nim index 4b06ed86..3312e75a 100644 --- a/src/kpkg/modules/removeInternal.nim +++ b/kpkg/modules/removeInternal.nim @@ -1,4 +1,9 @@ -proc removeInternal(package: string, root = ""): string = +import os +import logger +import strutils +import sequtils + +proc removeInternal*(package: string, root = ""): string = if not fileExists(root&"/var/cache/kpkg/installed/"&package&"/list_files"): err("package "&package&" is not installed", false) diff --git a/src/kpkg/modules/runparser.nim b/kpkg/modules/runparser.nim similarity index 87% rename from src/kpkg/modules/runparser.nim rename to kpkg/modules/runparser.nim index 9f610f7f..6cb16225 100644 --- a/src/kpkg/modules/runparser.nim +++ b/kpkg/modules/runparser.nim @@ -1,14 +1,17 @@ -type runFile = object - pkg: string - sources: string - version: string - release: string - buildAsRoot: bool - sha256sum: string - epoch: string - versionString: string +import logger +import strutils -proc parse_runfile(path: string, removeLockfileWhenErr = true): runFile = +type runFile* = object + pkg*: string + sources*: string + version*: string + release*: string + buildAsRoot*: bool + sha256sum*: string + epoch*: string + versionString*: string + +proc parse_runfile*(path: string, removeLockfileWhenErr = true): runFile = ## Parse an runfile. var vars: seq[string] diff --git a/src/kpkg/modules/shadow.nim b/kpkg/modules/shadow.nim similarity index 85% rename from src/kpkg/modules/shadow.nim rename to kpkg/modules/shadow.nim index 3fd19143..7262b334 100644 --- a/src/kpkg/modules/shadow.nim +++ b/kpkg/modules/shadow.nim @@ -2,7 +2,7 @@ import osproc const homeDir* = "/tmp/kpkg/homedir" -proc addUser(name: string, path = "/"): bool = +proc addUser*(name: string, path = "/"): bool = ## Adds an user. var cmd = "useradd -M -r -s /bin/nologin -d "&homeDir&" "&name var cmdPasswd = "passwd -d "&name @@ -17,5 +17,5 @@ proc addUser(name: string, path = "/"): bool = else: return false -proc existsUser(name: string): bool = +proc existsUser*(name: string): bool = return execCmdEx("id "&name).exitcode == 0 diff --git a/src/kreastrap/README.md b/kreastrap/README.md similarity index 100% rename from src/kreastrap/README.md rename to kreastrap/README.md diff --git a/src/kreastrap/arch/amd64/configs/builder-gnu.conf b/kreastrap/arch/amd64/configs/builder-gnu.conf similarity index 100% rename from src/kreastrap/arch/amd64/configs/builder-gnu.conf rename to kreastrap/arch/amd64/configs/builder-gnu.conf diff --git a/src/kreastrap/arch/amd64/configs/builder-systemd.conf b/kreastrap/arch/amd64/configs/builder-systemd.conf similarity index 100% rename from src/kreastrap/arch/amd64/configs/builder-systemd.conf rename to kreastrap/arch/amd64/configs/builder-systemd.conf diff --git a/src/kreastrap/arch/amd64/configs/builder.conf b/kreastrap/arch/amd64/configs/builder.conf similarity index 100% rename from src/kreastrap/arch/amd64/configs/builder.conf rename to kreastrap/arch/amd64/configs/builder.conf diff --git a/src/kreastrap/arch/amd64/configs/nocc.conf b/kreastrap/arch/amd64/configs/nocc.conf similarity index 100% rename from src/kreastrap/arch/amd64/configs/nocc.conf rename to kreastrap/arch/amd64/configs/nocc.conf diff --git a/src/kreastrap/arch/amd64/configs/server.conf b/kreastrap/arch/amd64/configs/server.conf similarity index 100% rename from src/kreastrap/arch/amd64/configs/server.conf rename to kreastrap/arch/amd64/configs/server.conf diff --git a/src/kreastrap/kreastrap.nim b/kreastrap/kreastrap.nim similarity index 100% rename from src/kreastrap/kreastrap.nim rename to kreastrap/kreastrap.nim diff --git a/src/kreastrap/overlay/etc/group b/kreastrap/overlay/etc/group similarity index 100% rename from src/kreastrap/overlay/etc/group rename to kreastrap/overlay/etc/group diff --git a/src/kreastrap/overlay/etc/jumpstart/services/getty-tty1.service b/kreastrap/overlay/etc/jumpstart/services/getty-tty1.service similarity index 100% rename from src/kreastrap/overlay/etc/jumpstart/services/getty-tty1.service rename to kreastrap/overlay/etc/jumpstart/services/getty-tty1.service diff --git a/src/kreastrap/overlay/etc/jumpstart/services/getty-tty2.service b/kreastrap/overlay/etc/jumpstart/services/getty-tty2.service similarity index 100% rename from src/kreastrap/overlay/etc/jumpstart/services/getty-tty2.service rename to kreastrap/overlay/etc/jumpstart/services/getty-tty2.service diff --git a/src/kreastrap/overlay/etc/jumpstart/services/getty-tty3.service b/kreastrap/overlay/etc/jumpstart/services/getty-tty3.service similarity index 100% rename from src/kreastrap/overlay/etc/jumpstart/services/getty-tty3.service rename to kreastrap/overlay/etc/jumpstart/services/getty-tty3.service diff --git a/src/kreastrap/overlay/etc/jumpstart/services/getty-tty4.service b/kreastrap/overlay/etc/jumpstart/services/getty-tty4.service similarity index 100% rename from src/kreastrap/overlay/etc/jumpstart/services/getty-tty4.service rename to kreastrap/overlay/etc/jumpstart/services/getty-tty4.service diff --git a/src/kreastrap/overlay/etc/jumpstart/services/getty-tty5.service b/kreastrap/overlay/etc/jumpstart/services/getty-tty5.service similarity index 100% rename from src/kreastrap/overlay/etc/jumpstart/services/getty-tty5.service rename to kreastrap/overlay/etc/jumpstart/services/getty-tty5.service diff --git a/src/kreastrap/overlay/etc/jumpstart/services/getty-tty6.service b/kreastrap/overlay/etc/jumpstart/services/getty-tty6.service similarity index 100% rename from src/kreastrap/overlay/etc/jumpstart/services/getty-tty6.service rename to kreastrap/overlay/etc/jumpstart/services/getty-tty6.service diff --git a/src/kreastrap/overlay/etc/os-release b/kreastrap/overlay/etc/os-release similarity index 100% rename from src/kreastrap/overlay/etc/os-release rename to kreastrap/overlay/etc/os-release diff --git a/src/kreastrap/overlay/etc/passwd b/kreastrap/overlay/etc/passwd similarity index 100% rename from src/kreastrap/overlay/etc/passwd rename to kreastrap/overlay/etc/passwd diff --git a/src/kreastrap/overlay/etc/profile b/kreastrap/overlay/etc/profile similarity index 100% rename from src/kreastrap/overlay/etc/profile rename to kreastrap/overlay/etc/profile diff --git a/src/kreastrap/overlay/etc/resolv.conf b/kreastrap/overlay/etc/resolv.conf similarity index 100% rename from src/kreastrap/overlay/etc/resolv.conf rename to kreastrap/overlay/etc/resolv.conf diff --git a/src/kreastrap/overlay/etc/shells b/kreastrap/overlay/etc/shells similarity index 100% rename from src/kreastrap/overlay/etc/shells rename to kreastrap/overlay/etc/shells diff --git a/man/kpkg.8 b/man/kpkg.8 deleted file mode 100644 index 534e8310..00000000 --- a/man/kpkg.8 +++ /dev/null @@ -1,62 +0,0 @@ -.\" Automatically generated by Pandoc 2.9.2.1 -.\" -.TH "kpkg" "8" "" "" "" -.hy -.SH NAME -.PP -kpkg - package manager -.SH SYNOPSIS -.PP -\f[B]kpkg\f[R] [h] [b] [ins] [inf] [r] [upd] [upg] [PACKAGES] [-y] [-o] -[-r] [ROOTFS] -.SH DESCRIPTION -.PP -kpkg is a package manager written in Nim. -It is under 700> LOC and is meant to be used with Kreato Linux. -.PP -kpkg uses simple build scripts called runfiles, similar to PKGBUILDs -found in the pacman package manager. -You can learn more about runfiles in kpkg_run(8). -.SH COMMANDS -.PP -\f[B]h\f[R] Output help -.PP -\f[B]b\f[R] build package -.PP -\f[B]ins\f[R] install binary package -.PP -\f[B]inf\f[R] get info about a package -.PP -\f[B]r\f[R] remove package -.PP -\f[B]upd\f[R] update repository -.PP -\f[B]upg\f[R] upgrade packages -.PP -\f[B]v\f[R] print version -.PP -\f[B]-o\f[R] only build, dont install -.PP -\f[B]-r\f[R] Rootfs argument. -.PP -\f[B]-y\f[R] Auto-accept installation. -.PP -For full arguments, please see \f[C]kpkg help\f[R] -.SH AUTHOR -.PP -Written by Kreato. -.SH COPYRIGHT -.PP -kpkg is free software: you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation, either version 3 of the License, or (at your -option) any later version. -.PP -kpkg is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. -.PP -You should have received a copy of the GNU General Public License along -with kpkg. -If not, see . diff --git a/src/man/kpkg.8.md b/man/kpkg.8.md similarity index 100% rename from src/man/kpkg.8.md rename to man/kpkg.8.md diff --git a/man/kpkg.conf.5 b/man/kpkg.conf.5 deleted file mode 100644 index 857db6d2..00000000 --- a/man/kpkg.conf.5 +++ /dev/null @@ -1,69 +0,0 @@ -.\" Automatically generated by Pandoc 2.9.2.1 -.\" -.TH "kpkg.conf" "5" "" "" "" -.hy -.SH NAME -.PP -kpkg.conf - Configuration file for kpkg -.SH DESCRIPTION -.PP -/etc/kpkg/kpkg.conf is the main configuration file on kpkg. -A default one is included when you launch kpkg for the first time. -.SH SYNTAX -.PP -kpkg.conf uses a INI format. -The default configuration file currently looks like this; -.IP -.nf -\f[C] -[Options] -cc=gcc - -[Repositories] -RepoDirs=/etc/kpkg/repos/main /etc/kpkg/repos/main-bin -RepoLinks=\[dq]https://github.com/kreatolinux/kpkg-repo.git https://github.com/kreatolinux/kpkg-repo-bin.git\[dq] - -[Upgrade] -buildByDefault=yes -\f[R] -.fi -.SS OPTIONS -.IP \[bu] 2 -cc: Set the CC environment variable when the package is building. -Defaults to gcc. -.SS REPOSITORIES -.IP \[bu] 2 -RepoDirs: Repository directories. -Must line up with RepoLinks. -Seperate by space. -.IP \[bu] 2 -RepoLinks: Repository links. -Must line up with RepoDirs. -Seperate by space. -Has kpkg-repo and kpkg-repo-bin repositories by default. -.PP -Repositories also support branches/commits like this; -.PP -\f[C]RepoLinks=\[dq]https://github.com/kreatolinux/kpkg-repo.git::BRANCHNAME\[dq]\f[R] -.SS UPGRADE -.IP \[bu] 2 -buildByDefault: Enable building by default on upgrades or not. -Is enabled by default. -.SH AUTHOR -.PP -Written by Kreato. -.SH COPYRIGHT -.PP -kpkg is free software: you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation, either version 3 of the License, or (at your -option) any later version. -.PP -kpkg is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. -.PP -You should have received a copy of the GNU General Public License along -with kpkg. -If not, see . diff --git a/src/man/kpkg.conf.5.md b/man/kpkg.conf.5.md similarity index 100% rename from src/man/kpkg.conf.5.md rename to man/kpkg.conf.5.md diff --git a/man/kpkg_run.8 b/man/kpkg_run.8 deleted file mode 100644 index 0dda2e64..00000000 --- a/man/kpkg_run.8 +++ /dev/null @@ -1,96 +0,0 @@ -.\" Automatically generated by Pandoc 2.9.2.1 -.\" -.TH "kpkg_run" "8" "" "" "" -.hy -.SH NAME -.PP -kpkg runfile - main package format of kpkg -.SH DESCRIPTION -.PP -kpkg runfiles are the main package format of kpkg. -It is a basic shell script with some variables so kpkg can build the -package. -.SH RUNFILE STRUCTURE -.PP -Runfiles are just named \[lq]run\[rq] inside the package directory. -It is written in POSIX sh and doesn\[cq]t support any other languages. -In addition to a runfile you also need a deps file which you can add by -just making a file named \[lq]deps\[rq] in the package repository and -putting deps on each line. -.PP -An example runfile structure; -.IP -.nf -\f[C] -NAME=\[dq]test\[dq] -VERSION=\[dq]0.0.1\[dq] -RELEASE=\[dq]1\[dq] -SOURCES=\[dq]https://test.file/source/testfile.tar.gz;git::https://github.com/kreatolinux/kpkg3::543ee30eda806029fa9ea16a1f9767eda7cab4d1\[dq] -SHA256SUM=\[dq]e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 testfile.tar.gz\[dq] -DESCRIPTION=\[dq]Test package\[dq] - -build() { - tar -xvf testfile.tar.gz - echo \[dq]Insert additional installation instructions here\[dq] -} - -install() { - make install -} -\f[R] -.fi -.PP -Now lets break it down. -.SS VARIABLES -.IP \[bu] 2 -NAME: Name of your package. -Will show this name on the info command. -.IP \[bu] 2 -VERSION: Version of your package. -It will be on the info command and updating it will result in kpkg -upgrading the package. -.IP \[bu] 2 -RELEASE: Release of your package. -It will also be on the info command and updating it will result in kpkg -upgrading the package. -.IP \[bu] 2 -SOURCES: Source URL\[cq]s of your package. -Can be seperated by `;' like \f[C]test.url;testurl2\f[R]. -Also supports git URL\[cq]s as shown by the second source. -.IP \[bu] 2 -SHA256SUM: sha256sum output of the sources. -Should align with sources. -Can also be seperated by `;'. -Doesnt support git URL\[cq]s yet. -.IP \[bu] 2 -DESCRIPTION: Description of the package. -It will be on the info command. -.SS FUNCTIONS -.IP \[bu] 2 -build: The main function. -.IP \[bu] 2 -install: The install function. -.SS OPTIONAL FUNCTIONS AND VARIABLES -.IP \[bu] 2 -EPOCH: Only use this when the versioning logic fail for the package. -.IP \[bu] 2 -prepare(): Files downloaded from SOURCES are extracted by default. -Use prepare() to prevent this and have custom prepare procedure. -.SH AUTHOR -.PP -Written by Kreato. -.SH COPYRIGHT -.PP -kpkg is free software: you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation, either version 3 of the License, or (at your -option) any later version. -.PP -kpkg is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. -.PP -You should have received a copy of the GNU General Public License along -with kpkg. -If not, see . diff --git a/src/man/kpkg_run.8.md b/man/kpkg_run.8.md similarity index 100% rename from src/man/kpkg_run.8.md rename to man/kpkg_run.8.md diff --git a/man/kreastrap.8 b/man/kreastrap.8 deleted file mode 100644 index 782e1527..00000000 --- a/man/kreastrap.8 +++ /dev/null @@ -1,38 +0,0 @@ -.\" Automatically generated by Pandoc 2.9.2.1 -.\" -.TH "kreastrap" "8" "" "" "" -.hy -.SH NAME -.PP -kreastrap - rootfs builder -.SH SYNOPSIS -.PP -\f[B]kreastrap\f[R] [\[en]buildType] [BUILDTYPE] [\[en]arch] -[ARCHITECTURE] [\[en]useCacheIfPossible] [true/false] -.SH DESCRIPTION -.PP -Nyaastrap is a rootfs builder written in Nim. -It is currently used for generating rootfs\[cq] for Kreato Linux. -.PP -Nyaastrap has a simple config structure, and uses \f[C]kpkg\f[R] -internal functions to work. -.PP -For the config structure you can see kreastrap.conf(5) -.SH AUTHOR -.PP -Written by Kreato. -.SH COPYRIGHT -.PP -kreastrap is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation, either version 3 of the License, or (at your -option) any later version. -.PP -kreastrap is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. -.PP -You should have received a copy of the GNU General Public License along -with kreastrap. -If not, see . diff --git a/src/man/kreastrap.8.md b/man/kreastrap.8.md similarity index 100% rename from src/man/kreastrap.8.md rename to man/kreastrap.8.md diff --git a/man/kreastrap.conf.5 b/man/kreastrap.conf.5 deleted file mode 100644 index 8e07618a..00000000 --- a/man/kreastrap.conf.5 +++ /dev/null @@ -1,77 +0,0 @@ -.\" Automatically generated by Pandoc 2.9.2.1 -.\" -.TH "kreastrap.conf" "5" "" "" "" -.hy -.SH NAME -.PP -kreastrap.conf - Configuration file for kreastrap v3 -.SH DESCRIPTION -.PP -kreastrap.conf is the configuration file for kreastrap. -It is put on \f[C]arch/ARCHITECTURE/configs/buildTypeName.conf\f[R]. -.SH SYNTAX -.PP -kreastrap.conf uses a INI format. -An example configuration file looks like this; -.IP -.nf -\f[C] -[General] -BuildDirectory=/out -BuildPackages=yes - -[Core] -Libc=glibc -Compiler=gcc -Coreutils=busybox -TlsLibrary=openssl - -[Extras] -ExtraPackages=\[dq]gmake nim\[dq] -\f[R] -.fi -.SS GENERAL -.IP \[bu] 2 -BuildDirectory: Sets the directory the rootfs is gonna be built on. -.IP \[bu] 2 -BuildPackages: Sets if you want to build the packages or download them -from a binary repository. -.SS CORE -.IP \[bu] 2 -Libc: Choose the C library. -Available options include musl and glibc. -.IP \[bu] 2 -Compiler: Choose the compiler that will be included in the rootfs. -Available options include gcc and clang. -You can also specify \[lq]no\[rq] to not include a compiler. -.IP \[bu] 2 -Coreutils: Choose the coreutils that will be included in the rootfs. -Available options include gnu and busybox. -Busybox is the most well-tested one yet. -.IP \[bu] 2 -TlsLibrary: Choose the tls library that will be used in the rootfs. -Available options include openssl and libressl. -Libressl is not tested yet. -.SS EXTRAS -.IP \[bu] 2 -ExtraPackages: Choose extra packages that will be installed onto the -rootfs. -Seperate them by space. -.SH AUTHOR -.PP -Written by Kreato. -.SH COPYRIGHT -.PP -kreastrap is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation, either version 3 of the License, or (at your -option) any later version. -.PP -kreastrap is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. -.PP -You should have received a copy of the GNU General Public License along -with kreastrap. -If not, see . diff --git a/src/man/kreastrap.conf.5.md b/man/kreastrap.conf.5.md similarity index 100% rename from src/man/kreastrap.conf.5.md rename to man/kreastrap.conf.5.md diff --git a/src/mari/mari.nim b/mari/mari.nim similarity index 100% rename from src/mari/mari.nim rename to mari/mari.nim diff --git a/src/purr/README.md b/purr/README.md similarity index 100% rename from src/purr/README.md rename to purr/README.md diff --git a/src/purr/common.nim b/purr/common.nim similarity index 91% rename from src/purr/common.nim rename to purr/common.nim index ad993a3d..144dfedc 100644 --- a/src/purr/common.nim +++ b/purr/common.nim @@ -5,8 +5,8 @@ import os import options include ../kpkg/modules/logger include ../kpkg/modules/config -include ../kpkg/build -include ../kpkg/update +include ../kpkg/commands/buildcmd +include ../kpkg/commands/updatecmd proc debug(message: string) = when not defined(release): diff --git a/src/purr/purr.nim b/purr/purr.nim similarity index 95% rename from src/purr/purr.nim rename to purr/purr.nim index 69065bd5..4004457f 100644 --- a/src/purr/purr.nim +++ b/purr/purr.nim @@ -1,7 +1,7 @@ include common -include ../kpkg/info -include ../kpkg/remove -include ../kpkg/upgrade +include ../kpkg/commands/infocmd +include ../kpkg/commands/removecmd +include ../kpkg/commands/upgradecmd proc genFiles(tmpdir: string) = ## Generates files required for the utility to function. diff --git a/src/scripts/build-ci.sh b/scripts/build-ci.sh similarity index 100% rename from src/scripts/build-ci.sh rename to scripts/build-ci.sh From 6021c0f8e5bb23c22fb816357158ccfb104184ec Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 03:23:40 +0000 Subject: [PATCH 02/54] Commit from GitHub Actions (Build manpages) --- man/kpkg.8 | 62 ++++++++++++++++++++++++++++ man/kpkg.conf.5 | 69 +++++++++++++++++++++++++++++++ man/kpkg_run.8 | 96 ++++++++++++++++++++++++++++++++++++++++++++ man/kreastrap.8 | 38 ++++++++++++++++++ man/kreastrap.conf.5 | 77 +++++++++++++++++++++++++++++++++++ 5 files changed, 342 insertions(+) create mode 100644 man/kpkg.8 create mode 100644 man/kpkg.conf.5 create mode 100644 man/kpkg_run.8 create mode 100644 man/kreastrap.8 create mode 100644 man/kreastrap.conf.5 diff --git a/man/kpkg.8 b/man/kpkg.8 new file mode 100644 index 00000000..534e8310 --- /dev/null +++ b/man/kpkg.8 @@ -0,0 +1,62 @@ +.\" Automatically generated by Pandoc 2.9.2.1 +.\" +.TH "kpkg" "8" "" "" "" +.hy +.SH NAME +.PP +kpkg - package manager +.SH SYNOPSIS +.PP +\f[B]kpkg\f[R] [h] [b] [ins] [inf] [r] [upd] [upg] [PACKAGES] [-y] [-o] +[-r] [ROOTFS] +.SH DESCRIPTION +.PP +kpkg is a package manager written in Nim. +It is under 700> LOC and is meant to be used with Kreato Linux. +.PP +kpkg uses simple build scripts called runfiles, similar to PKGBUILDs +found in the pacman package manager. +You can learn more about runfiles in kpkg_run(8). +.SH COMMANDS +.PP +\f[B]h\f[R] Output help +.PP +\f[B]b\f[R] build package +.PP +\f[B]ins\f[R] install binary package +.PP +\f[B]inf\f[R] get info about a package +.PP +\f[B]r\f[R] remove package +.PP +\f[B]upd\f[R] update repository +.PP +\f[B]upg\f[R] upgrade packages +.PP +\f[B]v\f[R] print version +.PP +\f[B]-o\f[R] only build, dont install +.PP +\f[B]-r\f[R] Rootfs argument. +.PP +\f[B]-y\f[R] Auto-accept installation. +.PP +For full arguments, please see \f[C]kpkg help\f[R] +.SH AUTHOR +.PP +Written by Kreato. +.SH COPYRIGHT +.PP +kpkg is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your +option) any later version. +.PP +kpkg is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. +.PP +You should have received a copy of the GNU General Public License along +with kpkg. +If not, see . diff --git a/man/kpkg.conf.5 b/man/kpkg.conf.5 new file mode 100644 index 00000000..857db6d2 --- /dev/null +++ b/man/kpkg.conf.5 @@ -0,0 +1,69 @@ +.\" Automatically generated by Pandoc 2.9.2.1 +.\" +.TH "kpkg.conf" "5" "" "" "" +.hy +.SH NAME +.PP +kpkg.conf - Configuration file for kpkg +.SH DESCRIPTION +.PP +/etc/kpkg/kpkg.conf is the main configuration file on kpkg. +A default one is included when you launch kpkg for the first time. +.SH SYNTAX +.PP +kpkg.conf uses a INI format. +The default configuration file currently looks like this; +.IP +.nf +\f[C] +[Options] +cc=gcc + +[Repositories] +RepoDirs=/etc/kpkg/repos/main /etc/kpkg/repos/main-bin +RepoLinks=\[dq]https://github.com/kreatolinux/kpkg-repo.git https://github.com/kreatolinux/kpkg-repo-bin.git\[dq] + +[Upgrade] +buildByDefault=yes +\f[R] +.fi +.SS OPTIONS +.IP \[bu] 2 +cc: Set the CC environment variable when the package is building. +Defaults to gcc. +.SS REPOSITORIES +.IP \[bu] 2 +RepoDirs: Repository directories. +Must line up with RepoLinks. +Seperate by space. +.IP \[bu] 2 +RepoLinks: Repository links. +Must line up with RepoDirs. +Seperate by space. +Has kpkg-repo and kpkg-repo-bin repositories by default. +.PP +Repositories also support branches/commits like this; +.PP +\f[C]RepoLinks=\[dq]https://github.com/kreatolinux/kpkg-repo.git::BRANCHNAME\[dq]\f[R] +.SS UPGRADE +.IP \[bu] 2 +buildByDefault: Enable building by default on upgrades or not. +Is enabled by default. +.SH AUTHOR +.PP +Written by Kreato. +.SH COPYRIGHT +.PP +kpkg is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your +option) any later version. +.PP +kpkg is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. +.PP +You should have received a copy of the GNU General Public License along +with kpkg. +If not, see . diff --git a/man/kpkg_run.8 b/man/kpkg_run.8 new file mode 100644 index 00000000..0dda2e64 --- /dev/null +++ b/man/kpkg_run.8 @@ -0,0 +1,96 @@ +.\" Automatically generated by Pandoc 2.9.2.1 +.\" +.TH "kpkg_run" "8" "" "" "" +.hy +.SH NAME +.PP +kpkg runfile - main package format of kpkg +.SH DESCRIPTION +.PP +kpkg runfiles are the main package format of kpkg. +It is a basic shell script with some variables so kpkg can build the +package. +.SH RUNFILE STRUCTURE +.PP +Runfiles are just named \[lq]run\[rq] inside the package directory. +It is written in POSIX sh and doesn\[cq]t support any other languages. +In addition to a runfile you also need a deps file which you can add by +just making a file named \[lq]deps\[rq] in the package repository and +putting deps on each line. +.PP +An example runfile structure; +.IP +.nf +\f[C] +NAME=\[dq]test\[dq] +VERSION=\[dq]0.0.1\[dq] +RELEASE=\[dq]1\[dq] +SOURCES=\[dq]https://test.file/source/testfile.tar.gz;git::https://github.com/kreatolinux/kpkg3::543ee30eda806029fa9ea16a1f9767eda7cab4d1\[dq] +SHA256SUM=\[dq]e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 testfile.tar.gz\[dq] +DESCRIPTION=\[dq]Test package\[dq] + +build() { + tar -xvf testfile.tar.gz + echo \[dq]Insert additional installation instructions here\[dq] +} + +install() { + make install +} +\f[R] +.fi +.PP +Now lets break it down. +.SS VARIABLES +.IP \[bu] 2 +NAME: Name of your package. +Will show this name on the info command. +.IP \[bu] 2 +VERSION: Version of your package. +It will be on the info command and updating it will result in kpkg +upgrading the package. +.IP \[bu] 2 +RELEASE: Release of your package. +It will also be on the info command and updating it will result in kpkg +upgrading the package. +.IP \[bu] 2 +SOURCES: Source URL\[cq]s of your package. +Can be seperated by `;' like \f[C]test.url;testurl2\f[R]. +Also supports git URL\[cq]s as shown by the second source. +.IP \[bu] 2 +SHA256SUM: sha256sum output of the sources. +Should align with sources. +Can also be seperated by `;'. +Doesnt support git URL\[cq]s yet. +.IP \[bu] 2 +DESCRIPTION: Description of the package. +It will be on the info command. +.SS FUNCTIONS +.IP \[bu] 2 +build: The main function. +.IP \[bu] 2 +install: The install function. +.SS OPTIONAL FUNCTIONS AND VARIABLES +.IP \[bu] 2 +EPOCH: Only use this when the versioning logic fail for the package. +.IP \[bu] 2 +prepare(): Files downloaded from SOURCES are extracted by default. +Use prepare() to prevent this and have custom prepare procedure. +.SH AUTHOR +.PP +Written by Kreato. +.SH COPYRIGHT +.PP +kpkg is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your +option) any later version. +.PP +kpkg is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. +.PP +You should have received a copy of the GNU General Public License along +with kpkg. +If not, see . diff --git a/man/kreastrap.8 b/man/kreastrap.8 new file mode 100644 index 00000000..782e1527 --- /dev/null +++ b/man/kreastrap.8 @@ -0,0 +1,38 @@ +.\" Automatically generated by Pandoc 2.9.2.1 +.\" +.TH "kreastrap" "8" "" "" "" +.hy +.SH NAME +.PP +kreastrap - rootfs builder +.SH SYNOPSIS +.PP +\f[B]kreastrap\f[R] [\[en]buildType] [BUILDTYPE] [\[en]arch] +[ARCHITECTURE] [\[en]useCacheIfPossible] [true/false] +.SH DESCRIPTION +.PP +Nyaastrap is a rootfs builder written in Nim. +It is currently used for generating rootfs\[cq] for Kreato Linux. +.PP +Nyaastrap has a simple config structure, and uses \f[C]kpkg\f[R] +internal functions to work. +.PP +For the config structure you can see kreastrap.conf(5) +.SH AUTHOR +.PP +Written by Kreato. +.SH COPYRIGHT +.PP +kreastrap is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation, either version 3 of the License, or (at your +option) any later version. +.PP +kreastrap is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. +.PP +You should have received a copy of the GNU General Public License along +with kreastrap. +If not, see . diff --git a/man/kreastrap.conf.5 b/man/kreastrap.conf.5 new file mode 100644 index 00000000..8e07618a --- /dev/null +++ b/man/kreastrap.conf.5 @@ -0,0 +1,77 @@ +.\" Automatically generated by Pandoc 2.9.2.1 +.\" +.TH "kreastrap.conf" "5" "" "" "" +.hy +.SH NAME +.PP +kreastrap.conf - Configuration file for kreastrap v3 +.SH DESCRIPTION +.PP +kreastrap.conf is the configuration file for kreastrap. +It is put on \f[C]arch/ARCHITECTURE/configs/buildTypeName.conf\f[R]. +.SH SYNTAX +.PP +kreastrap.conf uses a INI format. +An example configuration file looks like this; +.IP +.nf +\f[C] +[General] +BuildDirectory=/out +BuildPackages=yes + +[Core] +Libc=glibc +Compiler=gcc +Coreutils=busybox +TlsLibrary=openssl + +[Extras] +ExtraPackages=\[dq]gmake nim\[dq] +\f[R] +.fi +.SS GENERAL +.IP \[bu] 2 +BuildDirectory: Sets the directory the rootfs is gonna be built on. +.IP \[bu] 2 +BuildPackages: Sets if you want to build the packages or download them +from a binary repository. +.SS CORE +.IP \[bu] 2 +Libc: Choose the C library. +Available options include musl and glibc. +.IP \[bu] 2 +Compiler: Choose the compiler that will be included in the rootfs. +Available options include gcc and clang. +You can also specify \[lq]no\[rq] to not include a compiler. +.IP \[bu] 2 +Coreutils: Choose the coreutils that will be included in the rootfs. +Available options include gnu and busybox. +Busybox is the most well-tested one yet. +.IP \[bu] 2 +TlsLibrary: Choose the tls library that will be used in the rootfs. +Available options include openssl and libressl. +Libressl is not tested yet. +.SS EXTRAS +.IP \[bu] 2 +ExtraPackages: Choose extra packages that will be installed onto the +rootfs. +Seperate them by space. +.SH AUTHOR +.PP +Written by Kreato. +.SH COPYRIGHT +.PP +kreastrap is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation, either version 3 of the License, or (at your +option) any later version. +.PP +kreastrap is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. +.PP +You should have received a copy of the GNU General Public License along +with kreastrap. +If not, see . From 06d9745d8d57e5edab32454bd6652e75cd4b5228 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 06:40:11 +0300 Subject: [PATCH 03/54] refactor part 2 --- {jumpstart => common}/logging.nim | 1 + jumpstart/serviceHandler/main.nim | 2 +- kreastrap/kreastrap.nim | 13 ++++++++++++- purr/common.nim | 27 --------------------------- purr/purr.nim | 12 ++++++++---- 5 files changed, 22 insertions(+), 33 deletions(-) rename {jumpstart => common}/logging.nim (99%) delete mode 100644 purr/common.nim diff --git a/jumpstart/logging.nim b/common/logging.nim similarity index 99% rename from jumpstart/logging.nim rename to common/logging.nim index 7bd0e2b8..d54d3259 100644 --- a/jumpstart/logging.nim +++ b/common/logging.nim @@ -1,3 +1,4 @@ + import terminal proc debug*(message: string) = diff --git a/jumpstart/serviceHandler/main.nim b/jumpstart/serviceHandler/main.nim index 2e31de90..75254e10 100644 --- a/jumpstart/serviceHandler/main.nim +++ b/jumpstart/serviceHandler/main.nim @@ -4,7 +4,7 @@ include ../commonImports import enable, disable, start, stop import os, osproc import parsecfg -import ../logging +import ../../common/logging import jumpmount/main import jumpmount/umount diff --git a/kreastrap/kreastrap.nim b/kreastrap/kreastrap.nim index bbe6df20..91c31f0a 100644 --- a/kreastrap/kreastrap.nim +++ b/kreastrap/kreastrap.nim @@ -1,4 +1,15 @@ -include ../purr/common +import os +import osproc +import cligen +import sequtils +import strutils +import parsecfg +import asyncdispatch +import ../common/logging +import ../kpkg/commands/buildcmd +import ../kpkg/modules/downloader +import ../kpkg/commands/updatecmd +import ../kpkg/commands/installcmd ## Kreato Linux's build tools. diff --git a/purr/common.nim b/purr/common.nim deleted file mode 100644 index 144dfedc..00000000 --- a/purr/common.nim +++ /dev/null @@ -1,27 +0,0 @@ -import cligen -import sequtils -import parsecfg -import os -import options -include ../kpkg/modules/logger -include ../kpkg/modules/config -include ../kpkg/commands/buildcmd -include ../kpkg/commands/updatecmd - -proc debug(message: string) = - when not defined(release): - styledEcho "[", styleBlinkRapid, styleBright, fgYellow, " DEBUG ", - resetStyle, "] "&message - -proc info_msg(message: string) = - styledEcho "[", styleBright, fgBlue, " INFO ", resetStyle, "] "&message - -proc ok(message: string) = - styledEcho "[", styleBright, fgGreen, " OK ", resetStyle, "] "&message - -proc warn(message: string) = - styledEcho "[", styleBright, fgYellow, " WARN ", resetStyle, "] "&message - -proc error(message: string) = - styledEcho "[", styleBright, fgRed, " ERROR ", resetStyle, "] "&message - quit(1) diff --git a/purr/purr.nim b/purr/purr.nim index 4004457f..976441f5 100644 --- a/purr/purr.nim +++ b/purr/purr.nim @@ -1,7 +1,11 @@ -include common -include ../kpkg/commands/infocmd -include ../kpkg/commands/removecmd -include ../kpkg/commands/upgradecmd +import os +import cligen +import strutils +import sequtils +import ../common/logging +import ../kpkg/commands/infocmd +import ../kpkg/commands/updatecmd +import ../kpkg/modules/dephandler proc genFiles(tmpdir: string) = ## Generates files required for the utility to function. From d8d2dc69180004b18073316aa26d58fb85ad508d Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 06:41:55 +0300 Subject: [PATCH 04/54] ci: change when it'll run --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 21048da7..27d5f0e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,11 +2,9 @@ name: CI # Controls when the workflow will run on: - # Triggers the workflow on push or pull request events but only for the "master" branch push: - branches: ["master"] - pull_request: - branches: ["master"] + paths: + - '**.nim' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From 9e8949f2d2ccc92472bb47f04a57583ee03e0402 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 06:46:22 +0300 Subject: [PATCH 05/54] [skip ci] chkupd: move jsontomd.sh to scripts --- {chkupd => scripts}/jsontomd.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {chkupd => scripts}/jsontomd.sh (100%) diff --git a/chkupd/jsontomd.sh b/scripts/jsontomd.sh similarity index 100% rename from chkupd/jsontomd.sh rename to scripts/jsontomd.sh From cb54dd00c923ecd49d4862c3c803f56a4534d672 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 06:49:57 +0300 Subject: [PATCH 06/54] kreastrap: remove buildPackages --- kreastrap/kreastrap.nim | 52 ++++++----------------------------------- scripts/build-ci.sh | 2 +- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/kreastrap/kreastrap.nim b/kreastrap/kreastrap.nim index 91c31f0a..c6557177 100644 --- a/kreastrap/kreastrap.nim +++ b/kreastrap/kreastrap.nim @@ -91,9 +91,9 @@ proc set_default_cc(buildDir: string, cc: string) = if not fileExists(file): createSymlink(cc, file) -proc rootfs(buildType = "builder", arch = "amd64", +proc kreastrap(buildType = "builder", arch = "amd64", useCacheIfPossible = true) = - ## Build a rootfs. + ## Build a Kreato Linux rootfs. if not isAdmin(): error "You have to be root to continue." @@ -296,46 +296,8 @@ proc rootfs(buildType = "builder", arch = "amd64", for i in conf.getSectionValue("Extras", "ExtraPackages").split(" "): kreastrapInstall(i, installWithBinaries, buildDir, useCacheIfPossible) - - -proc buildPackages(useCacheIfPossible = true, repo = "/etc/kpkg/repos/main") = - ## Build all packages available. - - discard update() - - for kind, path in walkDir(repo): - case kind: - of pcDir: - if lastPathPart(path) != ".git" and lastPathPart(path) != "musl": - info_msg "Now building "&lastPathPart(path) - debug "Full path: "&path - kreastrapInstall(lastPathPart(path), false, "/", useCacheIfPossible) - of pcLinkToDir: - if lastPathPart(path) != "musl": - warn "kpkg doesn't support symlinks properly. Issues may occur" - info_msg "Now building "&lastPathPart(path) - debug "Full path: "&path - kreastrapInstall(lastPathPart(path), false, "/", useCacheIfPossible) - else: - discard - - kreastrapInstall("musl", false, "/", useCacheIfPossible) - -dispatchMulti( - [ - rootfs, - help = { - "buildType": "Specify the build type", - "arch": "Specify the architecture", - "useCacheIfPossible": "Use already built packages if possible", - } - ], - - [ - buildPackages, - help = { - "useCacheIfPossible": "Use already built packages if possible", - "repo": "Specify repository", - } - ] -) +dispatch kreastrap, help = { + "buildType": "Specify the build type", + "arch": "Specify the architecture", + "useCacheIfPossible": "Use already built packages if possible" + } diff --git a/scripts/build-ci.sh b/scripts/build-ci.sh index bfdcc65a..3de229e6 100644 --- a/scripts/build-ci.sh +++ b/scripts/build-ci.sh @@ -25,7 +25,7 @@ case $1 in git config --global --add safe.directory /etc/kpkg/repos/main rm -rf /out/* cd /work || exit 1 - ./src/kreastrap/kreastrap rootfs --buildType="$2" --arch=amd64 || exit 1 + ./src/kreastrap/kreastrap --buildType="$2" --arch=amd64 || exit 1 cd /out || exit 1 tar -czvf /work/kreato-linux-"$2"-glibc-"$(date +%d-%m-%Y)"-amd64.tar.gz * ;; From 7be4976e1cad3074074e2eb9720f5369046cdbd8 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 03:50:34 +0000 Subject: [PATCH 07/54] Commit from GitHub Actions (Format Nim Files) --- kreastrap/kreastrap.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kreastrap/kreastrap.nim b/kreastrap/kreastrap.nim index c6557177..d1d16ce6 100644 --- a/kreastrap/kreastrap.nim +++ b/kreastrap/kreastrap.nim @@ -297,7 +297,7 @@ proc kreastrap(buildType = "builder", arch = "amd64", kreastrapInstall(i, installWithBinaries, buildDir, useCacheIfPossible) dispatch kreastrap, help = { - "buildType": "Specify the build type", - "arch": "Specify the architecture", + "buildType": "Specify the build type", + "arch": "Specify the architecture", "useCacheIfPossible": "Use already built packages if possible" - } + } From 677b8cbfb1e1f430af02bdc7300bc90af621e637 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 07:01:43 +0300 Subject: [PATCH 08/54] [skip ci] remove .envrc --- .envrc | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 .envrc diff --git a/.envrc b/.envrc deleted file mode 100644 index e31c3060..00000000 --- a/.envrc +++ /dev/null @@ -1,4 +0,0 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" -fi -use flake From 7f8e02dd670d674bdb1095fa9067de6b27bd16b6 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 07:10:07 +0300 Subject: [PATCH 09/54] kpkg: build: WIP: add the ability to use local files in SOURCES --- kpkg/commands/buildcmd.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index 4ea65dcc..a964f6b1 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -100,7 +100,10 @@ proc builder*(package: string, destdir: string, folder = @[lastPathPart(i.split("::")[1])] else: - waitFor download(i, filename) + if fileExists(path&"/"&i): + filename = i + else: + waitFor download(i, filename) # git cloning doesn't support sha256sum checking var actualDigest = sha256hexdigest(readAll(open( From b5ddac91b10867fc5c860775ab6dc8acb91caebb Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 07:48:18 +0300 Subject: [PATCH 10/54] kpkg: build: attempt to fix last commit --- kpkg/commands/buildcmd.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index a964f6b1..d8f9c405 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -101,7 +101,7 @@ proc builder*(package: string, destdir: string, folder = @[lastPathPart(i.split("::")[1])] else: if fileExists(path&"/"&i): - filename = i + copyFile(path&"/"&i, i) else: waitFor download(i, filename) From 140c5c7a7f6b05b10841de3730e424083c7c794d Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 08:06:19 +0300 Subject: [PATCH 11/54] jumpstart: check pid if it is 1 or not --- jumpstart/jumpstart.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jumpstart/jumpstart.nim b/jumpstart/jumpstart.nim index e467b735..875bfa22 100644 --- a/jumpstart/jumpstart.nim +++ b/jumpstart/jumpstart.nim @@ -2,6 +2,9 @@ import std/net import json include serviceHandler/main +if getCurrentProcessId() != 1: + error "jumpstart needs to be ran as PID 1 (init) to function correctly" + ## Initialize the entire system, such as mounting /proc etc. initSystem() From a83784dba7b93dd854d126ca57f7c4715f351fa6 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 08:11:28 +0300 Subject: [PATCH 12/54] jumpstart: fix build errors --- jumpstart/serviceHandler/disable.nim | 2 +- jumpstart/serviceHandler/enable.nim | 2 +- jumpstart/serviceHandler/jumpmount/main.nim | 2 +- jumpstart/serviceHandler/jumpmount/umount.nim | 2 +- jumpstart/serviceHandler/start.nim | 2 +- jumpstart/serviceHandler/stop.nim | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jumpstart/serviceHandler/disable.nim b/jumpstart/serviceHandler/disable.nim index 7af7da58..ce26ec26 100644 --- a/jumpstart/serviceHandler/disable.nim +++ b/jumpstart/serviceHandler/disable.nim @@ -1,6 +1,6 @@ import os include ../commonImports -import ../logging +import ../../common/logging proc disableService*(service: string, isMount: bool) = ## Disables an service. diff --git a/jumpstart/serviceHandler/enable.nim b/jumpstart/serviceHandler/enable.nim index f21e0499..e68b0385 100644 --- a/jumpstart/serviceHandler/enable.nim +++ b/jumpstart/serviceHandler/enable.nim @@ -1,6 +1,6 @@ import os include ../commonImports -import ../logging +import ../../common/logging proc enableService*(service: string, isMount: bool) = ## Enables an service. diff --git a/jumpstart/serviceHandler/jumpmount/main.nim b/jumpstart/serviceHandler/jumpmount/main.nim index 612699c3..c1538c97 100644 --- a/jumpstart/serviceHandler/jumpmount/main.nim +++ b/jumpstart/serviceHandler/jumpmount/main.nim @@ -1,5 +1,5 @@ import parsecfg -import ../../logging +import ../../../common/logging import os import strutils import osproc diff --git a/jumpstart/serviceHandler/jumpmount/umount.nim b/jumpstart/serviceHandler/jumpmount/umount.nim index d1157731..b370eed0 100644 --- a/jumpstart/serviceHandler/jumpmount/umount.nim +++ b/jumpstart/serviceHandler/jumpmount/umount.nim @@ -2,7 +2,7 @@ import parsecfg import osproc import os import strutils -import ../../logging +import ../../../common/logging include ../../commonImports proc stopMount*(mountName: string) = diff --git a/jumpstart/serviceHandler/start.nim b/jumpstart/serviceHandler/start.nim index c988cdc6..2490e486 100644 --- a/jumpstart/serviceHandler/start.nim +++ b/jumpstart/serviceHandler/start.nim @@ -2,7 +2,7 @@ import parsecfg import os, osproc import std/threadpool import status -import ../logging +import ../../common/logging include ../commonImports import globalVariables diff --git a/jumpstart/serviceHandler/stop.nim b/jumpstart/serviceHandler/stop.nim index e0e69a75..79a1f25c 100644 --- a/jumpstart/serviceHandler/stop.nim +++ b/jumpstart/serviceHandler/stop.nim @@ -1,4 +1,4 @@ -import ../logging +import ../../common/logging import osproc import os import globalVariables From aed8d45181a8c841e2e7a35bbb19aab18c395250 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 08:36:32 +0300 Subject: [PATCH 13/54] kpkg: feat: implement multiple packages off same runfile --- kpkg/commands/buildcmd.nim | 35 ++++++++++++++++++++++------------- kpkg/modules/shadow.nim | 4 ++++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index d8f9c405..17c4098a 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -80,8 +80,12 @@ proc builder*(package: string, destdir: string, return true var filename: string - var existsPrepare = execShellCmd(". "&path&"/run"&" && command -v prepare") - + + let existsPrepare = execCmdEx(". "&path&"/run"&" && command -v prepare").exitCode + let existsInstall = execCmdEx(". "&path&"/run"&" && command -v package").exitCode + let existsPackageInstall = execCmdEx(". "&path&"/run"&" && command -v package_"&package).exitCode + let existsLegacyInstall = execCmdEx(". "&path&"/run"&" && command -v install").exitCode + var int = 0 var usesGit: bool var folder: seq[string] @@ -137,21 +141,26 @@ proc builder*(package: string, destdir: string, # Run ldconfig beforehand for any errors discard execProcess("ldconfig") + var cmdStr = ". "&path&"/run"&" && export CC="&getConfigValue("Options", "cc")&" && export CCACHE_DIR=/tmp/kpkg/cache && build" + var cmd2Str = ". "&path&"/run"&" && export DESTDIR="&root&" && export ROOT=$DESTDIR &&" + + if existsPackageInstall == 0: + cmd2Str = cmd2Str&" package_"&package + elif existsInstall == 0: + cmd2Str = cmd2Str&" package" + elif existsLegacyInstall == 0: + cmd2Str = cmd2Str&" install" + if pkg.sources.split(";").len == 1: if existsPrepare == 0: - cmd = execShellCmd("su -s /bin/sh _kpkg -c '. "&path&"/run"&" && export CC="&getConfigValue( - "Options", "cc")&" && export CCACHE_DIR=/tmp/kpkg/cache && build'") - cmd2 = execShellCmd(". "&path&"/run"&" && export DESTDIR="&root&" && export ROOT=$DESTDIR && install") + cmd = execShellCmd(sboxWrap(cmdStr)) + cmd2 = execShellCmd(cmd2Str) else: - cmd = execShellCmd("su -s /bin/sh _kpkg -c 'cd "&folder[ - 0]&" && . "&path&"/run"&" && export CC="&getConfigValue( - "Options", "cc")&" && export CCACHE_DIR=/tmp/kpkg/cache && build'") - cmd2 = execShellCmd("cd "&folder[ - 0]&" && . "&path&"/run"&" && export DESTDIR="&root&" && export ROOT=$DESTDIR && install") + cmd = execShellCmd(sboxWrap("cd "&folder[0]&" && "&cmdStr)) + cmd2 = execShellCmd("cd "&folder[0]&" && "&cmd2Str) else: - cmd = execShellCmd("su -s /bin/sh _kpkg -c '. "&path&"/run"&" && export CC="&getConfigValue( - "Options", "cc")&" && export CCACHE_DIR=/tmp/kpkg/cache && build'") - cmd2 = execShellCmd(". "&path&"/run"&" && export DESTDIR="&root&" && export ROOT=$DESTDIR && install") + cmd = execShellCmd(sboxWrap(cmdStr)) + cmd2 = execShellCmd(cmd2Str) if cmd != 0: err("build failed") diff --git a/kpkg/modules/shadow.nim b/kpkg/modules/shadow.nim index 7262b334..37679f81 100644 --- a/kpkg/modules/shadow.nim +++ b/kpkg/modules/shadow.nim @@ -19,3 +19,7 @@ proc addUser*(name: string, path = "/"): bool = proc existsUser*(name: string): bool = return execCmdEx("id "&name).exitcode == 0 + +proc sboxWrap*(command: string): string = + ## Convenience proc, just lets you run the command with _kpkg sandbox user. + return "su -s /bin/sh _kpkg -c '"&command&"'" \ No newline at end of file From 5cfaed43cf68dc1986f3cf02629aaf82fe1a1f3a Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 05:37:08 +0000 Subject: [PATCH 14/54] Commit from GitHub Actions (Format Nim Files) --- kpkg/commands/buildcmd.nim | 15 +++++++++------ kpkg/modules/shadow.nim | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index 17c4098a..1f6afde1 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -80,12 +80,14 @@ proc builder*(package: string, destdir: string, return true var filename: string - + let existsPrepare = execCmdEx(". "&path&"/run"&" && command -v prepare").exitCode let existsInstall = execCmdEx(". "&path&"/run"&" && command -v package").exitCode - let existsPackageInstall = execCmdEx(". "&path&"/run"&" && command -v package_"&package).exitCode - let existsLegacyInstall = execCmdEx(". "&path&"/run"&" && command -v install").exitCode - + let existsPackageInstall = execCmdEx( + ". "&path&"/run"&" && command -v package_"&package).exitCode + let existsLegacyInstall = execCmdEx( + ". "&path&"/run"&" && command -v install").exitCode + var int = 0 var usesGit: bool var folder: seq[string] @@ -141,9 +143,10 @@ proc builder*(package: string, destdir: string, # Run ldconfig beforehand for any errors discard execProcess("ldconfig") - var cmdStr = ". "&path&"/run"&" && export CC="&getConfigValue("Options", "cc")&" && export CCACHE_DIR=/tmp/kpkg/cache && build" + var cmdStr = ". "&path&"/run"&" && export CC="&getConfigValue("Options", + "cc")&" && export CCACHE_DIR=/tmp/kpkg/cache && build" var cmd2Str = ". "&path&"/run"&" && export DESTDIR="&root&" && export ROOT=$DESTDIR &&" - + if existsPackageInstall == 0: cmd2Str = cmd2Str&" package_"&package elif existsInstall == 0: diff --git a/kpkg/modules/shadow.nim b/kpkg/modules/shadow.nim index 37679f81..9102788d 100644 --- a/kpkg/modules/shadow.nim +++ b/kpkg/modules/shadow.nim @@ -22,4 +22,4 @@ proc existsUser*(name: string): bool = proc sboxWrap*(command: string): string = ## Convenience proc, just lets you run the command with _kpkg sandbox user. - return "su -s /bin/sh _kpkg -c '"&command&"'" \ No newline at end of file + return "su -s /bin/sh _kpkg -c '"&command&"'" From b7d7ca40d40a03bc35277ebd37fcdfca723e3c72 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 08:43:00 +0300 Subject: [PATCH 15/54] kpkg: build: add warning about deprecation of install() --- kpkg/commands/buildcmd.nim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index 1f6afde1..94c99329 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -152,6 +152,8 @@ proc builder*(package: string, destdir: string, elif existsInstall == 0: cmd2Str = cmd2Str&" package" elif existsLegacyInstall == 0: + echo "kpkg: warning: The package you are currently installing is using the old install() function. This function got renamed (and improved!) in v5.0." + echo "kpkg: warning: The install() function will cease to function at a later version. Please update your runfile to use package() instead of install()." cmd2Str = cmd2Str&" install" if pkg.sources.split(";").len == 1: From 189bfe6f7a95d9aa285025cae0e1f70c5a4cf6e4 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 09:04:18 +0300 Subject: [PATCH 16/54] kpkg: feat: add conflicts support --- kpkg/commands/installcmd.nim | 4 ++++ kpkg/modules/runparser.nim | 3 +++ 2 files changed, 7 insertions(+) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index 072199fe..49c22c1e 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -20,6 +20,10 @@ proc install_pkg*(repo: string, package: string, root: string, binary = false, pkg = parse_runfile(repo&"/"&package) except CatchableError: raise + + for i in pkg.conflicts: + if dirExists("/var/cache/kpkg/installed/"&i): + err(i&" conflicts with "&package) let tarball = "/var/cache/kpkg/archives/arch/"&hostCPU&"/kpkg-tarball-"&pkg.pkg&"-"&pkg.versionString&".tar.gz" diff --git a/kpkg/modules/runparser.nim b/kpkg/modules/runparser.nim index 6cb16225..3113f657 100644 --- a/kpkg/modules/runparser.nim +++ b/kpkg/modules/runparser.nim @@ -10,6 +10,7 @@ type runFile* = object sha256sum*: string epoch*: string versionString*: string + conflicts*: seq[string] proc parse_runfile*(path: string, removeLockfileWhenErr = true): runFile = ## Parse an runfile. @@ -50,6 +51,8 @@ proc parse_runfile*(path: string, removeLockfileWhenErr = true): runFile = ) of "SHA256SUM": ret.sha256sum = vars[1] + of "CONFLICTS": + ret.conflicts = vars[1].split(" ") if "()" in vars[0]: break except CatchableError: From 663672fa0397ca85dd923f39027eb02eaf9110ec Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 06:05:11 +0000 Subject: [PATCH 17/54] Commit from GitHub Actions (Format Nim Files) --- kpkg/commands/installcmd.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index 49c22c1e..d340008a 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -20,7 +20,7 @@ proc install_pkg*(repo: string, package: string, root: string, binary = false, pkg = parse_runfile(repo&"/"&package) except CatchableError: raise - + for i in pkg.conflicts: if dirExists("/var/cache/kpkg/installed/"&i): err(i&" conflicts with "&package) From e654219c84a862f33921ae3441e7e6d1d6fba136 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 09:16:26 +0300 Subject: [PATCH 18/54] kpkg: remove reprod check --- kpkg/commands/installcmd.nim | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index d340008a..2c51c45b 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -10,9 +10,7 @@ import ../modules/runparser import ../modules/downloader import ../modules/dephandler -proc install_pkg*(repo: string, package: string, root: string, binary = false, - enforceReproducibility = false, binrepo = "mirror.kreato.dev", - builddir = "/tmp/kpkg/build") = +proc install_pkg*(repo: string, package: string, root: string, binary = false, builddir = "/tmp/kpkg/build") = ## Installs an package. var pkg: runFile @@ -55,35 +53,13 @@ proc install_pkg*(repo: string, package: string, root: string, binary = false, file.close() - try: - waitFor download("https://"&binrepo&"/arch/"&hostCPU&"/kpkg-tarball-"&pkg.pkg&"-"&pkg.versionString&".tar.gz.sum.bin", - "/tmp/kpkg-temp-"&pkg.pkg&".bin") - downloaded = true - except CatchableError: - if enforceReproducibility: - err("checksum couldn't get downloaded for reproducibility check") - else: - echo "kpkg: skipping reproducibility check, checksum couldn't get downloaded" - echo "kpkg: run with --enforceReproducibility=true if you want to enforce this" - - if downloaded: - let result = execCmdEx("sha256sum -c /tmp/kpkg-temp-"&pkg.pkg&".bin") - if result.exitCode == 0: - echo "kpkg: reproducibility check success" - elif enforceReproducibility: - err("reproducibility check failed") - else: - echo "kpkg: reproducibility check failed" - echo "kpkg: run with --enforceReproducibility=true if you want to enforce this" - discard execProcess("tar -hxf"&tarball&" -C "&root) - copyFile(tarball&".sum.bin", root&"/var/cache/kpkg/installed/"&package&"/list_sums") # Run ldconfig afterwards for any new libraries discard execProcess("ldconfig") - var existsPostinstall = execShellCmd( - ". "&repo&"/"&package&"/run"&" && command -v postinstall") + var existsPostinstall = execCmdEx( + ". "&repo&"/"&package&"/run"&" && command -v postinstall").exitCode if existsPostinstall == 0: if execShellCmd(". "&repo&"/"&package&"/run"&" && postinstall") != 0: From f50976551837b02b4aca1b6d0cb94f32d8b823db Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 06:16:55 +0000 Subject: [PATCH 19/54] Commit from GitHub Actions (Format Nim Files) --- kpkg/commands/installcmd.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index 2c51c45b..9ec7a2bc 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -10,7 +10,8 @@ import ../modules/runparser import ../modules/downloader import ../modules/dephandler -proc install_pkg*(repo: string, package: string, root: string, binary = false, builddir = "/tmp/kpkg/build") = +proc install_pkg*(repo: string, package: string, root: string, binary = false, + builddir = "/tmp/kpkg/build") = ## Installs an package. var pkg: runFile From 6242bdc991d7df8941c7687b38d7aad66358e620 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 09:18:14 +0300 Subject: [PATCH 20/54] oops forgot to remove enforce reprod on buildcmd --- kpkg/commands/buildcmd.nim | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index 94c99329..dd75f574 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -21,9 +21,7 @@ proc cleanUp() {.noconv.} = proc builder*(package: string, destdir: string, root = "/tmp/kpkg/build", srcdir = "/tmp/kpkg/srcdir", offline = false, - dontInstall = false, useCacheIfAvailable = false, - binrepo = "mirror.kreato.dev", - enforceReproducibility = false): bool = + dontInstall = false, useCacheIfAvailable = false): bool = ## Builds the packages. if not isAdmin(): @@ -188,9 +186,7 @@ proc builder*(package: string, destdir: string, install_pkg(repo, package, "/") if not dontInstall: - install_pkg(repo, package, destdir, - enforceReproducibility = enforceReproducibility, - binrepo = binrepo, builddir = root) + install_pkg(repo, package, destdir, builddir = root) removeFile(lockfile) @@ -202,9 +198,7 @@ proc builder*(package: string, destdir: string, proc build*(no = false, yes = false, root = "/", packages: seq[string], - useCacheIfAvailable = false, binrepo = "mirror.kreato.dev", - enforceReproducibility = false, - forceInstallAll = false): string = + useCacheIfAvailable = false, forceInstallAll = false): string = ## Build and install packages var deps: seq[string] @@ -240,7 +234,6 @@ proc build*(no = false, yes = false, root = "/", else: builderOutput = builder(i, fullRootPath, offline = false, useCacheIfAvailable = useCacheIfAvailable, - enforceReproducibility = enforceReproducibility, binrepo = binrepo) if not builderOutput: cacheAvailable = false @@ -256,7 +249,6 @@ proc build*(no = false, yes = false, root = "/", try: discard builder(i, fullRootPath, offline = false, useCacheIfAvailable = cacheAvailable, - enforceReproducibility = enforceReproducibility, binrepo = binrepo) echo("kpkg: installed "&i&" successfully") From b30b41487d657be7f9e35f813afc0d90935a5d36 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 09:21:11 +0300 Subject: [PATCH 21/54] remove the last remaints last 2 commits didnt remove --- kpkg/commands/buildcmd.nim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index dd75f574..d1785b30 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -233,8 +233,7 @@ proc build*(no = false, yes = false, root = "/", discard else: builderOutput = builder(i, fullRootPath, offline = false, - useCacheIfAvailable = useCacheIfAvailable, - binrepo = binrepo) + useCacheIfAvailable = useCacheIfAvailable) if not builderOutput: cacheAvailable = false @@ -248,8 +247,7 @@ proc build*(no = false, yes = false, root = "/", for i in packages: try: discard builder(i, fullRootPath, offline = false, - useCacheIfAvailable = cacheAvailable, - binrepo = binrepo) + useCacheIfAvailable = cacheAvailable) echo("kpkg: installed "&i&" successfully") except CatchableError: From 59fd47d7de7564e2377ac594a9f15e1ecfc23047 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 09:22:22 +0300 Subject: [PATCH 22/54] ahhhhhhh i suck at removing shit --- kpkg/commands/installcmd.nim | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index 9ec7a2bc..586e9ebe 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -41,19 +41,6 @@ proc install_pkg*(repo: string, package: string, root: string, binary = false, writeFile(root&"/var/cache/kpkg/installed/"&package&"/list_files", execProcess("tar -tf"&tarball)) - let file = open(tarball&".sum.bin", fmWrite) - - if not binary: - var downloaded = false - - setCurrentDir(builddir) - - for line in lines root&"/var/cache/kpkg/installed/"&package&"/list_files": - if fileExists(line): - file.writeLine(sha256hexdigest(readAll(open(line)))&" "&line) - - file.close() - discard execProcess("tar -hxf"&tarball&" -C "&root) # Run ldconfig afterwards for any new libraries From 4e3e4873c7ec50403b65eac396820641a0779d47 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 09:25:21 +0300 Subject: [PATCH 23/54] install: remove unnecessary download --- kpkg/commands/installcmd.nim | 2 -- 1 file changed, 2 deletions(-) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index 586e9ebe..84a8dec0 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -90,8 +90,6 @@ proc install_bin(packages: seq[string], binrepo: string, root: string, echo "Downloading checksums for "&i waitFor download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) - waitFor download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum&".bin", - "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum&".bin") except CatchableError: err("couldn't download tarball", false) From 061d36a3f19bc33eb4c22e69b0404b9e3d68b0e3 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 09:31:20 +0300 Subject: [PATCH 24/54] kpkg: downloader: if progress can't be calculated dont show it --- kpkg/modules/downloader.nim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kpkg/modules/downloader.nim b/kpkg/modules/downloader.nim index 2d3f7d5f..b011ef99 100644 --- a/kpkg/modules/downloader.nim +++ b/kpkg/modules/downloader.nim @@ -3,8 +3,12 @@ import terminal, math, strutils proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} = stdout.eraseLine - stdout.write("Downloaded ", formatSize(progress), " of ", formatSize(total), - " at ", formatSize(speed), "/s ", round(int(progress) / int(total)*100), "% complete") + var p = "Downloaded "&formatSize(progress)&" of "&formatSize(total)&" at "&formatSize(speed)&"/s" + + if round(int(progress) / int(total)*100) != "inf": + p = p&" "&round(int(progress) / int(total)*100)"% complete" + + stdout.write(p) stdout.flushFile proc download*(url: string, file: string) {.async.} = From 2d07d26118a2aa7c455bb34342b3092e5b91c656 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 06:31:47 +0000 Subject: [PATCH 25/54] Commit from GitHub Actions (Format Nim Files) --- kpkg/modules/downloader.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kpkg/modules/downloader.nim b/kpkg/modules/downloader.nim index b011ef99..f82715d7 100644 --- a/kpkg/modules/downloader.nim +++ b/kpkg/modules/downloader.nim @@ -3,11 +3,12 @@ import terminal, math, strutils proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} = stdout.eraseLine - var p = "Downloaded "&formatSize(progress)&" of "&formatSize(total)&" at "&formatSize(speed)&"/s" + var p = "Downloaded "&formatSize(progress)&" of "&formatSize( + total)&" at "&formatSize(speed)&"/s" if round(int(progress) / int(total)*100) != "inf": p = p&" "&round(int(progress) / int(total)*100)"% complete" - + stdout.write(p) stdout.flushFile From 7aeeff8181de7d125e975ac04de00e221b805984 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 09:38:05 +0300 Subject: [PATCH 26/54] downloader: fix syntax error, also set precision to -1 so it looks nicer --- kpkg/modules/downloader.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpkg/modules/downloader.nim b/kpkg/modules/downloader.nim index f82715d7..4d535653 100644 --- a/kpkg/modules/downloader.nim +++ b/kpkg/modules/downloader.nim @@ -7,7 +7,7 @@ proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} = total)&" at "&formatSize(speed)&"/s" if round(int(progress) / int(total)*100) != "inf": - p = p&" "&round(int(progress) / int(total)*100)"% complete" + p = p&" "&formatBiggestFloat(round(int(progress) / int(total)*100), precision = -1)&"% complete" stdout.write(p) stdout.flushFile From fe6ec4c373c70f96502f7e6066f2c8e2e90f4a6c Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 09:38:22 +0300 Subject: [PATCH 27/54] Update downloader.nim --- kpkg/modules/downloader.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpkg/modules/downloader.nim b/kpkg/modules/downloader.nim index 4d535653..c1069024 100644 --- a/kpkg/modules/downloader.nim +++ b/kpkg/modules/downloader.nim @@ -6,7 +6,7 @@ proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} = var p = "Downloaded "&formatSize(progress)&" of "&formatSize( total)&" at "&formatSize(speed)&"/s" - if round(int(progress) / int(total)*100) != "inf": + if $round(int(progress) / int(total)*100) != "inf": p = p&" "&formatBiggestFloat(round(int(progress) / int(total)*100), precision = -1)&"% complete" stdout.write(p) From b170bcb9c83c0649c290fa11a17c598584665e02 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 06:38:49 +0000 Subject: [PATCH 28/54] Commit from GitHub Actions (Format Nim Files) --- kpkg/modules/downloader.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kpkg/modules/downloader.nim b/kpkg/modules/downloader.nim index c1069024..a24a33f4 100644 --- a/kpkg/modules/downloader.nim +++ b/kpkg/modules/downloader.nim @@ -7,7 +7,8 @@ proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} = total)&" at "&formatSize(speed)&"/s" if $round(int(progress) / int(total)*100) != "inf": - p = p&" "&formatBiggestFloat(round(int(progress) / int(total)*100), precision = -1)&"% complete" + p = p&" "&formatBiggestFloat(round(int(progress) / int(total)*100), + precision = -1)&"% complete" stdout.write(p) stdout.flushFile From 815a594362b108194d824201057637495d40e282 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 10:13:13 +0300 Subject: [PATCH 29/54] kpkg: feat: move deps to the runfile itself --- kpkg/modules/dephandler.nim | 18 +++++++++--------- kpkg/modules/runparser.nim | 6 ++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/kpkg/modules/dephandler.nim b/kpkg/modules/dephandler.nim index cd7a2164..02d12745 100644 --- a/kpkg/modules/dephandler.nim +++ b/kpkg/modules/dephandler.nim @@ -1,7 +1,7 @@ -import os import config import logger import sequtils +import runparser proc isIn(one: seq[string], two: seq[string]): bool = ## Checks if a variable is in another. @@ -18,20 +18,20 @@ proc dephandler*(pkgs: seq[string], ignoreDeps = @[" "], bdeps = false): seq[st let repo = findPkgRepo(pkg) if repo == "": err("Package "&pkg&" doesn't exist", false) + + let pkgrf = parse_runfile(repo&"/"&pkg) - var depsType: string + var pkgdeps: seq[string] if bdeps: - depsType = "/build_deps" + pkgdeps = pkgrf.bdeps else: - depsType = "/deps" + pkgdeps = pkgrf.deps + if $pkgdeps != "": + for dep in pkgdeps: - - if fileExists(repo&"/"&pkg&depsType): - for dep in lines repo&"/"&pkg&depsType: - - if fileExists(repo&"/"&dep&"/build_deps"): + if $pkgrf.bdeps != "": deps.add(dephandler(@[dep], deps&ignoreDeps, bdeps = true)) if dep in pkgs or dep in deps or isIn(deps, ignoreDeps) or diff --git a/kpkg/modules/runparser.nim b/kpkg/modules/runparser.nim index 3113f657..96c87254 100644 --- a/kpkg/modules/runparser.nim +++ b/kpkg/modules/runparser.nim @@ -11,6 +11,8 @@ type runFile* = object epoch*: string versionString*: string conflicts*: seq[string] + deps*: seq[string] + bdeps*: seq[string] proc parse_runfile*(path: string, removeLockfileWhenErr = true): runFile = ## Parse an runfile. @@ -53,6 +55,10 @@ proc parse_runfile*(path: string, removeLockfileWhenErr = true): runFile = ret.sha256sum = vars[1] of "CONFLICTS": ret.conflicts = vars[1].split(" ") + of "DEPENDS": + ret.deps = vars[1].split(" ") + of "BUILD_DEPENDS": + ret.deps = vars[1].split(" ") if "()" in vars[0]: break except CatchableError: From 0701b638b1605569f24181d340f03a1a72aea62b Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 07:14:42 +0000 Subject: [PATCH 30/54] Commit from GitHub Actions (Format Nim Files) --- kpkg/modules/dephandler.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpkg/modules/dephandler.nim b/kpkg/modules/dephandler.nim index 02d12745..cecfdc95 100644 --- a/kpkg/modules/dephandler.nim +++ b/kpkg/modules/dephandler.nim @@ -18,7 +18,7 @@ proc dephandler*(pkgs: seq[string], ignoreDeps = @[" "], bdeps = false): seq[st let repo = findPkgRepo(pkg) if repo == "": err("Package "&pkg&" doesn't exist", false) - + let pkgrf = parse_runfile(repo&"/"&pkg) var pkgdeps: seq[string] From cb9279bba9656d36575efb395ea324f788c8faba Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 10:16:16 +0300 Subject: [PATCH 31/54] kpkg: feat: remove legacy install function support --- kpkg/commands/buildcmd.nim | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index d1785b30..d5c5bc48 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -83,8 +83,6 @@ proc builder*(package: string, destdir: string, let existsInstall = execCmdEx(". "&path&"/run"&" && command -v package").exitCode let existsPackageInstall = execCmdEx( ". "&path&"/run"&" && command -v package_"&package).exitCode - let existsLegacyInstall = execCmdEx( - ". "&path&"/run"&" && command -v install").exitCode var int = 0 var usesGit: bool @@ -149,10 +147,8 @@ proc builder*(package: string, destdir: string, cmd2Str = cmd2Str&" package_"&package elif existsInstall == 0: cmd2Str = cmd2Str&" package" - elif existsLegacyInstall == 0: - echo "kpkg: warning: The package you are currently installing is using the old install() function. This function got renamed (and improved!) in v5.0." - echo "kpkg: warning: The install() function will cease to function at a later version. Please update your runfile to use package() instead of install()." - cmd2Str = cmd2Str&" install" + else: + err "install stage of package doesn't exist, invalid runfile" if pkg.sources.split(";").len == 1: if existsPrepare == 0: From cf3cd4fabded27664a438125cccf1b2b0e212dd4 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 10:20:26 +0300 Subject: [PATCH 32/54] runparser: depends/bdepends: get rid of quotes --- kpkg/modules/runparser.nim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kpkg/modules/runparser.nim b/kpkg/modules/runparser.nim index 96c87254..b47f43f4 100644 --- a/kpkg/modules/runparser.nim +++ b/kpkg/modules/runparser.nim @@ -56,9 +56,15 @@ proc parse_runfile*(path: string, removeLockfileWhenErr = true): runFile = of "CONFLICTS": ret.conflicts = vars[1].split(" ") of "DEPENDS": - ret.deps = vars[1].split(" ") + ret.deps = vars[1].multiReplace( + ("\"", ""), + ("'", "") + ).split(" ") of "BUILD_DEPENDS": - ret.deps = vars[1].split(" ") + ret.deps = vars[1].multiReplace( + ("\"", ""), + ("'", "") + ).split(" ") if "()" in vars[0]: break except CatchableError: From 3a122d2023d4b07f916b0c38db7202fb6f6d212b Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 10:52:20 +0300 Subject: [PATCH 33/54] [skip ci] scripts: make a migratefromv4 script --- scripts/migratefromv4.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 scripts/migratefromv4.sh diff --git a/scripts/migratefromv4.sh b/scripts/migratefromv4.sh new file mode 100644 index 00000000..1e3be653 --- /dev/null +++ b/scripts/migratefromv4.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# Script to migrate a package from v4 to v5 +# Usage: sh migratefromv4.sh PACKAGEPATH + +[ ! -d "$1" ] && exit 1 + +sed -i 's/install()/package()/g' "$1/run" + +cat "$1/deps" | while read line +do + if [ "$DEPS" = "" ]; then + DEPS="$line" + else + DEPS="$DEPS $line" + fi +done + +cat "$1/build_deps" | while read line +do + if [ "$DEPS" = "" ]; then + BDEPS="$line" + else + BDEPS="$BDEPS $line" + fi +done + +sed -i "1n; /^SHA256SUM/i BUILD_DEPENDS=\"$BDEPS\"" "$1/run" +sed -i "1n; /^BUILD_DEPENDS/i DEPENDS=\"$DEPS\"" "$1/run" + +echo "complete" \ No newline at end of file From a39c38a6d4ee17f1143de4871fa3cc3871a8ace4 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 10:55:13 +0300 Subject: [PATCH 34/54] scripts: improve on migratefromv4 --- scripts/migratefromv4.sh | 43 +++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/scripts/migratefromv4.sh b/scripts/migratefromv4.sh index 1e3be653..d5ae6d4a 100644 --- a/scripts/migratefromv4.sh +++ b/scripts/migratefromv4.sh @@ -2,29 +2,32 @@ # Script to migrate a package from v4 to v5 # Usage: sh migratefromv4.sh PACKAGEPATH -[ ! -d "$1" ] && exit 1 +[ ! -f "$1/run" ] && exit 1 sed -i 's/install()/package()/g' "$1/run" -cat "$1/deps" | while read line -do - if [ "$DEPS" = "" ]; then - DEPS="$line" - else - DEPS="$DEPS $line" - fi -done +if [ -f "$1/build_deps" ]; then + cat "$1/build_deps" | while read line + do + if [ "$DEPS" = "" ]; then + BDEPS="$line" + else + BDEPS="$BDEPS $line" + fi + done + sed -i "1n; /^SHA256SUM/i BUILD_DEPENDS=\"$BDEPS\"" "$1/run" +fi -cat "$1/build_deps" | while read line -do - if [ "$DEPS" = "" ]; then - BDEPS="$line" - else - BDEPS="$BDEPS $line" - fi -done - -sed -i "1n; /^SHA256SUM/i BUILD_DEPENDS=\"$BDEPS\"" "$1/run" -sed -i "1n; /^BUILD_DEPENDS/i DEPENDS=\"$DEPS\"" "$1/run" +if [ -f "$1/deps" ]; then + cat "$1/deps" | while read line + do + if [ "$DEPS" = "" ]; then + DEPS="$line" + else + DEPS="$DEPS $line" + fi + done + sed -i "1n; /^BUILD_DEPENDS/i DEPENDS=\"$DEPS\"" "$1/run" +fi echo "complete" \ No newline at end of file From a052653fce4cccfa9d8bf14fb690ac0e244c6ff2 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 10:56:41 +0300 Subject: [PATCH 35/54] [skip ci] scripts: migratefromv4: fix bug --- scripts/migratefromv4.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/migratefromv4.sh b/scripts/migratefromv4.sh index d5ae6d4a..feb4c015 100644 --- a/scripts/migratefromv4.sh +++ b/scripts/migratefromv4.sh @@ -27,7 +27,8 @@ if [ -f "$1/deps" ]; then DEPS="$DEPS $line" fi done - sed -i "1n; /^BUILD_DEPENDS/i DEPENDS=\"$DEPS\"" "$1/run" + [ -f "$1/build_deps" ] && sed -i "1n; /^BUILD_DEPENDS/i DEPENDS=\"$DEPS\"" "$1/run" + sed -i "1n; /^SHA256SUM/i DEPENDS=\"$DEPS\"" "$1/run" fi echo "complete" \ No newline at end of file From 84576ca8f6e06fb3a47a08294ec5811cf41ee381 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 11:20:33 +0300 Subject: [PATCH 36/54] migratefromv4: remove old depfiles once converted --- scripts/migratefromv4.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/scripts/migratefromv4.sh b/scripts/migratefromv4.sh index feb4c015..ad0d2a08 100644 --- a/scripts/migratefromv4.sh +++ b/scripts/migratefromv4.sh @@ -7,28 +7,33 @@ sed -i 's/install()/package()/g' "$1/run" if [ -f "$1/build_deps" ]; then - cat "$1/build_deps" | while read line + while read line do - if [ "$DEPS" = "" ]; then + if [ -z "$BDEPS" ]; then BDEPS="$line" else BDEPS="$BDEPS $line" fi - done + done < "$1/build_deps" sed -i "1n; /^SHA256SUM/i BUILD_DEPENDS=\"$BDEPS\"" "$1/run" + rm -f "$1/build_deps" fi if [ -f "$1/deps" ]; then - cat "$1/deps" | while read line + while read line do - if [ "$DEPS" = "" ]; then + if [ -z "$DEPS" ]; then DEPS="$line" else DEPS="$DEPS $line" fi - done - [ -f "$1/build_deps" ] && sed -i "1n; /^BUILD_DEPENDS/i DEPENDS=\"$DEPS\"" "$1/run" - sed -i "1n; /^SHA256SUM/i DEPENDS=\"$DEPS\"" "$1/run" + done < "$1/deps" + if [ -f "$1/build_deps" ]; then + sed -i "1n; /^BUILD_DEPENDS/i DEPENDS=\"$DEPS\"" "$1/run" + else + sed -i "1n; /^SHA256SUM/i DEPENDS=\"$DEPS\"" "$1/run" + fi + rm -f "$1/deps" fi echo "complete" \ No newline at end of file From cf050bdab642d5487d8af88333c0a01bb29eab71 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 11:36:01 +0300 Subject: [PATCH 37/54] update manpages to reflect changes --- man/kpkg.8.md | 2 +- man/kpkg.conf.5.md | 2 +- man/kpkg_run.8.md | 33 ++++++++++++++++++++++++++------- man/kreastrap.8.md | 4 ++-- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/man/kpkg.8.md b/man/kpkg.8.md index 9d25c180..ad3feb71 100644 --- a/man/kpkg.8.md +++ b/man/kpkg.8.md @@ -7,7 +7,7 @@ kpkg - package manager **kpkg** [h] [b] [ins] [inf] [r] [upd] [upg] [PACKAGES] [-y] [-o] [-r] [ROOTFS] # DESCRIPTION -kpkg is a package manager written in Nim. It is under 700> LOC and is meant to be used with Kreato Linux. +kpkg is a package manager written in Nim. kpkg uses simple build scripts called runfiles, similar to PKGBUILDs found in the pacman package manager. You can learn more about runfiles in kpkg_run(8). diff --git a/man/kpkg.conf.5.md b/man/kpkg.conf.5.md index a9adf690..69112bfd 100644 --- a/man/kpkg.conf.5.md +++ b/man/kpkg.conf.5.md @@ -15,7 +15,7 @@ cc=gcc [Repositories] RepoDirs=/etc/kpkg/repos/main /etc/kpkg/repos/main-bin -RepoLinks="https://github.com/kreatolinux/kpkg-repo.git https://github.com/kreatolinux/kpkg-repo-bin.git" +RepoLinks="https://github.com/kreatolinux/kpkg-repo.git::stable https://github.com/kreatolinux/kpkg-repo-lockin.git::stable" [Upgrade] buildByDefault=yes diff --git a/man/kpkg_run.8.md b/man/kpkg_run.8.md index da2f668c..9992a0d0 100644 --- a/man/kpkg_run.8.md +++ b/man/kpkg_run.8.md @@ -9,26 +9,41 @@ kpkg runfiles are the main package format of kpkg. It is a basic shell script wi # RUNFILE STRUCTURE Runfiles are just named "run" inside the package directory. It is written in POSIX sh and doesn't support any other languages. -In addition to a runfile you also need a deps file which you can add by just making a file named "deps" in the package repository and putting deps on each line. An example runfile structure; -``` +```sh NAME="test" VERSION="0.0.1" RELEASE="1" -SOURCES="https://test.file/source/testfile.tar.gz;git::https://github.com/kreatolinux/kpkg3::543ee30eda806029fa9ea16a1f9767eda7cab4d1" +SOURCES="https://test.file/source/testfile.tar.gz;git::https://github.com/kreatolinux/src::543ee30eda806029fa9ea16a1f9767eda7cab4d1" +DEPENDS="testpackage1 testpackage3 testpackage4" +BUILD_DEPENDS="testpackage5 testpackage6 testpackage10" SHA256SUM="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 testfile.tar.gz" DESCRIPTION="Test package" -build() { +prepare() { tar -xvf testfile.tar.gz - echo "Insert additional installation instructions here" } -install() { +build() { + cd testfile + echo "Insert build instructions here" +} + +package() { + cd testfile make install } + +package_test2() { + cd testfile + make install_test2 +} + +postinstall() { + echo "Insert postinstall instructions here" +} ``` Now lets break it down. @@ -37,16 +52,20 @@ Now lets break it down. * VERSION: Version of your package. It will be on the info command and updating it will result in kpkg upgrading the package. * RELEASE: Release of your package. It will also be on the info command and updating it will result in kpkg upgrading the package. * SOURCES: Source URL's of your package. Can be seperated by ';' like `test.url;testurl2`. Also supports git URL's as shown by the second source. +* DEPENDS: Dependencies of your package. Seperated by space. +* BUILD_DEPENDS: Build dependencies of your package. Seperated by space. * SHA256SUM: sha256sum output of the sources. Should align with sources. Can also be seperated by ';'. Doesnt support git URL's yet. * DESCRIPTION: Description of the package. It will be on the info command. ## FUNCTIONS * build: The main function. -* install: The install function. +* package: The install function. ## OPTIONAL FUNCTIONS AND VARIABLES * EPOCH: Only use this when the versioning logic fail for the package. * prepare(): Files downloaded from SOURCES are extracted by default. Use prepare() to prevent this and have custom prepare procedure. +* postinstall: Post-install function. Will run after the package is installed. +* package_PACKAGENAME: Install function of PACKAGENAME. With this function you can package multiple things in the same runfile. This may be used for packaging sub-projects easier. # AUTHOR Written by Kreato. diff --git a/man/kreastrap.8.md b/man/kreastrap.8.md index 1a56ebd9..dee3a82c 100644 --- a/man/kreastrap.8.md +++ b/man/kreastrap.8.md @@ -7,9 +7,9 @@ kreastrap - rootfs builder **kreastrap** [--buildType] [BUILDTYPE] [--arch] [ARCHITECTURE] [--useCacheIfPossible] [true/false] # DESCRIPTION -Nyaastrap is a rootfs builder written in Nim. It is currently used for generating rootfs' for Kreato Linux. +Kreastrap is a rootfs builder written in Nim. It is currently used for generating rootfs' for Kreato Linux. -Nyaastrap has a simple config structure, and uses `kpkg` internal functions to work. +Kreastrap has a simple config structure, and uses `kpkg` internal functions to work. For the config structure you can see kreastrap.conf(5) From 3e5da2ddb803da7a5730ae75cd6aa4036aad0c25 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 08:36:39 +0000 Subject: [PATCH 38/54] Commit from GitHub Actions (Build manpages) --- man/kpkg.8 | 1 - man/kpkg.conf.5 | 2 +- man/kpkg_run.8 | 42 ++++++++++++++++++++++++++++++++++-------- man/kreastrap.8 | 4 ++-- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/man/kpkg.8 b/man/kpkg.8 index 534e8310..2be6cd90 100644 --- a/man/kpkg.8 +++ b/man/kpkg.8 @@ -12,7 +12,6 @@ kpkg - package manager .SH DESCRIPTION .PP kpkg is a package manager written in Nim. -It is under 700> LOC and is meant to be used with Kreato Linux. .PP kpkg uses simple build scripts called runfiles, similar to PKGBUILDs found in the pacman package manager. diff --git a/man/kpkg.conf.5 b/man/kpkg.conf.5 index 857db6d2..8a95eea4 100644 --- a/man/kpkg.conf.5 +++ b/man/kpkg.conf.5 @@ -21,7 +21,7 @@ cc=gcc [Repositories] RepoDirs=/etc/kpkg/repos/main /etc/kpkg/repos/main-bin -RepoLinks=\[dq]https://github.com/kreatolinux/kpkg-repo.git https://github.com/kreatolinux/kpkg-repo-bin.git\[dq] +RepoLinks=\[dq]https://github.com/kreatolinux/kpkg-repo.git::stable https://github.com/kreatolinux/kpkg-repo-lockin.git::stable\[dq] [Upgrade] buildByDefault=yes diff --git a/man/kpkg_run.8 b/man/kpkg_run.8 index 0dda2e64..a6c3d89a 100644 --- a/man/kpkg_run.8 +++ b/man/kpkg_run.8 @@ -14,9 +14,6 @@ package. .PP Runfiles are just named \[lq]run\[rq] inside the package directory. It is written in POSIX sh and doesn\[cq]t support any other languages. -In addition to a runfile you also need a deps file which you can add by -just making a file named \[lq]deps\[rq] in the package repository and -putting deps on each line. .PP An example runfile structure; .IP @@ -25,18 +22,34 @@ An example runfile structure; NAME=\[dq]test\[dq] VERSION=\[dq]0.0.1\[dq] RELEASE=\[dq]1\[dq] -SOURCES=\[dq]https://test.file/source/testfile.tar.gz;git::https://github.com/kreatolinux/kpkg3::543ee30eda806029fa9ea16a1f9767eda7cab4d1\[dq] +SOURCES=\[dq]https://test.file/source/testfile.tar.gz;git::https://github.com/kreatolinux/src::543ee30eda806029fa9ea16a1f9767eda7cab4d1\[dq] +DEPENDS=\[dq]testpackage1 testpackage3 testpackage4\[dq] +BUILD_DEPENDS=\[dq]testpackage5 testpackage6 testpackage10\[dq] SHA256SUM=\[dq]e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 testfile.tar.gz\[dq] DESCRIPTION=\[dq]Test package\[dq] -build() { +prepare() { tar -xvf testfile.tar.gz - echo \[dq]Insert additional installation instructions here\[dq] } -install() { +build() { + cd testfile + echo \[dq]Insert build instructions here\[dq] +} + +package() { + cd testfile make install } + +package_test2() { + cd testfile + make install_test2 +} + +postinstall() { + echo \[dq]Insert postinstall instructions here\[dq] +} \f[R] .fi .PP @@ -58,6 +71,12 @@ SOURCES: Source URL\[cq]s of your package. Can be seperated by `;' like \f[C]test.url;testurl2\f[R]. Also supports git URL\[cq]s as shown by the second source. .IP \[bu] 2 +DEPENDS: Dependencies of your package. +Seperated by space. +.IP \[bu] 2 +BUILD_DEPENDS: Build dependencies of your package. +Seperated by space. +.IP \[bu] 2 SHA256SUM: sha256sum output of the sources. Should align with sources. Can also be seperated by `;'. @@ -69,13 +88,20 @@ It will be on the info command. .IP \[bu] 2 build: The main function. .IP \[bu] 2 -install: The install function. +package: The install function. .SS OPTIONAL FUNCTIONS AND VARIABLES .IP \[bu] 2 EPOCH: Only use this when the versioning logic fail for the package. .IP \[bu] 2 prepare(): Files downloaded from SOURCES are extracted by default. Use prepare() to prevent this and have custom prepare procedure. +.IP \[bu] 2 +postinstall: Post-install function. +Will run after the package is installed. +.IP \[bu] 2 +package_PACKAGENAME: Install function of PACKAGENAME. +With this function you can package multiple things in the same runfile. +This may be used for packaging sub-projects easier. .SH AUTHOR .PP Written by Kreato. diff --git a/man/kreastrap.8 b/man/kreastrap.8 index 782e1527..01eb17a3 100644 --- a/man/kreastrap.8 +++ b/man/kreastrap.8 @@ -11,10 +11,10 @@ kreastrap - rootfs builder [ARCHITECTURE] [\[en]useCacheIfPossible] [true/false] .SH DESCRIPTION .PP -Nyaastrap is a rootfs builder written in Nim. +Kreastrap is a rootfs builder written in Nim. It is currently used for generating rootfs\[cq] for Kreato Linux. .PP -Nyaastrap has a simple config structure, and uses \f[C]kpkg\f[R] +Kreastrap has a simple config structure, and uses \f[C]kpkg\f[R] internal functions to work. .PP For the config structure you can see kreastrap.conf(5) From 00bddbf49721180df5a2075bb8668608340cba46 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 11:48:03 +0300 Subject: [PATCH 39/54] [skip ci] readme: removed icons cuz they looked cheesy --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 4d8cdd4c..9ebbed9f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@

- - +

# src From f969fe12d8c2959291f338a0c39aad24743be40e Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 17:42:01 +0300 Subject: [PATCH 40/54] kpkg: feat: build: use fakeroot for install step --- kpkg/commands/buildcmd.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index d5c5bc48..c83c6f1b 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -153,13 +153,13 @@ proc builder*(package: string, destdir: string, if pkg.sources.split(";").len == 1: if existsPrepare == 0: cmd = execShellCmd(sboxWrap(cmdStr)) - cmd2 = execShellCmd(cmd2Str) + cmd2 = execShellCmd("fakeroot -- "&cmd2Str) else: cmd = execShellCmd(sboxWrap("cd "&folder[0]&" && "&cmdStr)) - cmd2 = execShellCmd("cd "&folder[0]&" && "&cmd2Str) + cmd2 = execShellCmd("fakeroot -- cd "&folder[0]&" && "&cmd2Str) else: cmd = execShellCmd(sboxWrap(cmdStr)) - cmd2 = execShellCmd(cmd2Str) + cmd2 = execShellCmd("fakeroot -- "&cmd2Str) if cmd != 0: err("build failed") From 9e4da827448b302f71ee5087c59fa58046ff90e4 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 17:53:42 +0300 Subject: [PATCH 41/54] kpkg: wip: attempt to use threadpool --- kpkg/commands/buildcmd.nim | 5 ++++- kpkg/commands/installcmd.nim | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index c83c6f1b..3cc4912a 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -3,6 +3,7 @@ import osproc import installcmd import strutils import sequtils +import threadpool import libsha/sha256 import asyncdispatch import ../modules/logger @@ -105,7 +106,7 @@ proc builder*(package: string, destdir: string, if fileExists(path&"/"&i): copyFile(path&"/"&i, i) else: - waitFor download(i, filename) + spawn waitFor download(i, filename) # git cloning doesn't support sha256sum checking var actualDigest = sha256hexdigest(readAll(open( @@ -117,6 +118,8 @@ proc builder*(package: string, destdir: string, int = int+1 except CatchableError: raise + + sync() # Create homedir of _kpkg temporarily createDir(homeDir) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index 84a8dec0..61796ca4 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -2,6 +2,7 @@ import os import osproc import strutils import sequtils +import threadpool import asyncdispatch import libsha/sha256 import ../modules/config @@ -85,11 +86,12 @@ proc install_bin(packages: seq[string], binrepo: string, root: string, elif not offline: echo "Downloading tarball for "&i try: - waitFor download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, + spawn waitFor download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) echo "Downloading checksums for "&i - waitFor download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, + spawn waitFor download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) + sync() except CatchableError: err("couldn't download tarball", false) From 0bfef9b69d7a5ef63019225c2261a11b7bf46a51 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 14:54:17 +0000 Subject: [PATCH 42/54] Commit from GitHub Actions (Format Nim Files) --- kpkg/commands/buildcmd.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index 3cc4912a..abde2c2a 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -118,7 +118,7 @@ proc builder*(package: string, destdir: string, int = int+1 except CatchableError: raise - + sync() # Create homedir of _kpkg temporarily From 21b4fc7e873c2edbb4ea0c62e2dc48aed6784144 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 18:02:15 +0300 Subject: [PATCH 43/54] kpkg: downloader: make it non-async --- kpkg/commands/buildcmd.nim | 3 +-- kpkg/commands/installcmd.nim | 5 ++--- kpkg/modules/downloader.nim | 10 +++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index abde2c2a..30347c48 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -5,7 +5,6 @@ import strutils import sequtils import threadpool import libsha/sha256 -import asyncdispatch import ../modules/logger import ../modules/shadow import ../modules/config @@ -106,7 +105,7 @@ proc builder*(package: string, destdir: string, if fileExists(path&"/"&i): copyFile(path&"/"&i, i) else: - spawn waitFor download(i, filename) + spawn download(i, filename) # git cloning doesn't support sha256sum checking var actualDigest = sha256hexdigest(readAll(open( diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index 61796ca4..b05fdd20 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -3,7 +3,6 @@ import osproc import strutils import sequtils import threadpool -import asyncdispatch import libsha/sha256 import ../modules/config import ../modules/logger @@ -86,10 +85,10 @@ proc install_bin(packages: seq[string], binrepo: string, root: string, elif not offline: echo "Downloading tarball for "&i try: - spawn waitFor download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, + spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) echo "Downloading checksums for "&i - spawn waitFor download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, + spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) sync() diff --git a/kpkg/modules/downloader.nim b/kpkg/modules/downloader.nim index a24a33f4..fd6f808e 100644 --- a/kpkg/modules/downloader.nim +++ b/kpkg/modules/downloader.nim @@ -1,7 +1,7 @@ -import std/[asyncdispatch, httpclient] +import std/httpclient import terminal, math, strutils -proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} = +proc onProgressChanged(total, progress, speed: BiggestInt) = stdout.eraseLine var p = "Downloaded "&formatSize(progress)&" of "&formatSize( total)&" at "&formatSize(speed)&"/s" @@ -13,8 +13,8 @@ proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} = stdout.write(p) stdout.flushFile -proc download*(url: string, file: string) {.async.} = - var client = newAsyncHttpClient() +proc download*(url: string, file: string) = + var client = newHttpClient() client.onProgressChanged = onProgressChanged - await client.downloadFile(url, file) + client.downloadFile(url, file) echo "" From 3787579abebc17f09df97b1280bdb96d751ce18c Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 18:07:48 +0300 Subject: [PATCH 44/54] cant make buildcmd parallel for now --- kpkg/commands/buildcmd.nim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index 30347c48..3537f253 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -105,7 +105,7 @@ proc builder*(package: string, destdir: string, if fileExists(path&"/"&i): copyFile(path&"/"&i, i) else: - spawn download(i, filename) + download(i, filename) # git cloning doesn't support sha256sum checking var actualDigest = sha256hexdigest(readAll(open( @@ -118,8 +118,6 @@ proc builder*(package: string, destdir: string, except CatchableError: raise - sync() - # Create homedir of _kpkg temporarily createDir(homeDir) setFilePermissions(homeDir, {fpOthersWrite, fpOthersRead, fpOthersExec}) From f221b479e562ce2e34d6531f9c13c852b3a458cf Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 18:10:28 +0300 Subject: [PATCH 45/54] experimenting with parallelization x2 --- kpkg/commands/installcmd.nim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index b05fdd20..3b27de8a 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -28,7 +28,7 @@ proc install_pkg*(repo: string, package: string, root: string, binary = false, if sha256hexdigest(readAll(open(tarball)))&" "&tarball != readAll(open( tarball&".sum")): - err("sha256sum doesn't match for"&pkg.pkg, false) + err("sha256sum doesn't match for "&pkg.pkg, false) setCurrentDir("/var/cache/kpkg/archives") @@ -150,10 +150,10 @@ proc install*(promptPackages: seq[string], root = "/", yes: bool = false, deps.delete(deps.find(i)) if not (deps.len == 0 and deps == @[""]): - install_bin(deps, binrepo, fullRootPath, offline, - downloadOnly = downloadOnly) - - install_bin(packages, binrepo, fullRootPath, offline, - downloadOnly = downloadOnly) + spawn install_bin(deps, binrepo, fullRootPath, offline, downloadOnly = downloadOnly) + spawn install_bin(packages, binrepo, fullRootPath, offline, downloadOnly = downloadOnly) + + sync() + return "kpkg: done" From 1e6c5541ec021012b76c6ee0a6b4e6e5b609eef6 Mon Sep 17 00:00:00 2001 From: Kreato Date: Sun, 6 Aug 2023 15:10:59 +0000 Subject: [PATCH 46/54] Commit from GitHub Actions (Format Nim Files) --- kpkg/commands/installcmd.nim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index 3b27de8a..350df8c2 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -150,10 +150,12 @@ proc install*(promptPackages: seq[string], root = "/", yes: bool = false, deps.delete(deps.find(i)) if not (deps.len == 0 and deps == @[""]): - spawn install_bin(deps, binrepo, fullRootPath, offline, downloadOnly = downloadOnly) + spawn install_bin(deps, binrepo, fullRootPath, offline, + downloadOnly = downloadOnly) + + spawn install_bin(packages, binrepo, fullRootPath, offline, + downloadOnly = downloadOnly) - spawn install_bin(packages, binrepo, fullRootPath, offline, downloadOnly = downloadOnly) - sync() - + return "kpkg: done" From 5f6501a3c2e0adeef60a3b682b200d6dfc08ca5b Mon Sep 17 00:00:00 2001 From: Kreato Date: Mon, 7 Aug 2023 06:16:35 +0300 Subject: [PATCH 47/54] kpkg: feat: parallelization on installcmd (now complete) --- kpkg/commands/buildcmd.nim | 1 - kpkg/commands/installcmd.nim | 70 ++++++++++++++++++++---------------- kpkg/modules/config.nim | 6 +++- 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/kpkg/commands/buildcmd.nim b/kpkg/commands/buildcmd.nim index 3537f253..b24abee7 100644 --- a/kpkg/commands/buildcmd.nim +++ b/kpkg/commands/buildcmd.nim @@ -3,7 +3,6 @@ import osproc import installcmd import strutils import sequtils -import threadpool import libsha/sha256 import ../modules/logger import ../modules/shadow diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index 350df8c2..391c3071 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -53,49 +53,57 @@ proc install_pkg*(repo: string, package: string, root: string, binary = false, if execShellCmd(". "&repo&"/"&package&"/run"&" && postinstall") != 0: err("postinstall failed") -proc install_bin(packages: seq[string], binrepo: string, root: string, - offline: bool, downloadOnly = false) = - ## Downloads and installs binaries. - +proc down_bin(package: string, binrepo: string, root: string, offline: bool) = + ## Downloads binaries. + discard existsOrCreateDir("/var/") discard existsOrCreateDir("/var/cache") discard existsOrCreateDir("/var/cache/kpkg") discard existsOrCreateDir("/var/cache/kpkg/archives") discard existsOrCreateDir("/var/cache/kpkg/archives/arch") discard existsOrCreateDir("/var/cache/kpkg/archives/arch/"&hostCPU) + setCurrentDir("/var/cache/kpkg/archives") - var repo: string - for i in packages: - repo = findPkgRepo(i) - var pkg: runFile + repo = findPkgRepo(package) + var pkg: runFile + + try: + pkg = parse_runfile(repo&"/"&package) + except CatchableError: + raise + let tarball = "kpkg-tarball-"&pkg.pkg&"-"&pkg.versionString&".tar.gz" + let chksum = tarball&".sum" + + if fileExists("/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) and + fileExists("/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum): + echo "Tarball already exists, not gonna download again" + elif not offline: + echo "Downloading tarball for "&package try: - pkg = parse_runfile(repo&"/"&i) + spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) + echo "Downloading checksums for "&package + spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) + + sync() + except CatchableError: - raise - - let tarball = "kpkg-tarball-"&pkg.pkg&"-"&pkg.versionString&".tar.gz" - let chksum = tarball&".sum" - - if fileExists("/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) and - fileExists("/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum): - echo "Tarball already exists, not gonna download again" - elif not offline: - echo "Downloading tarball for "&i - try: - spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, - "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) - echo "Downloading checksums for "&i - spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, - "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) - sync() - - except CatchableError: - err("couldn't download tarball", false) - else: - err("attempted to download tarball from binary repository in offline mode", false) + err("couldn't download tarball", false) + else: + err("attempted to download tarball from binary repository in offline mode", false) + +proc install_bin(packages: seq[string], binrepo: string, root: string, + offline: bool, downloadOnly = false) = + ## Downloads and installs binaries. + + var repo: string + + for i in packages: + spawn down_bin(i, binrepo, root, offline) + + sync() if not downloadOnly: for i in packages: diff --git a/kpkg/modules/config.nim b/kpkg/modules/config.nim index e88ba433..ba15a853 100644 --- a/kpkg/modules/config.nim +++ b/kpkg/modules/config.nim @@ -6,7 +6,7 @@ import strutils const configPath = "/etc/kpkg/kpkg.conf" -var config: Config +var config {.threadvar.} : Config const branch* {.strdefine.}: string = "stable" @@ -45,6 +45,10 @@ proc initializeConfig*(): Config = proc getConfigValue*(section: string, key: string): string = ## Reads the configuration file and returns value of section. + if not fileExists(configPath): + config = initializeConfig() + else: + config = loadConfig(configPath) return config.getSectionValue(section, key) proc setConfigValue*(section: string, key: string, value: string) = From f9dfa72881cdd1dbcbb589ee0aadf93ce85c2df8 Mon Sep 17 00:00:00 2001 From: Kreato Date: Mon, 7 Aug 2023 03:17:07 +0000 Subject: [PATCH 48/54] Commit from GitHub Actions (Format Nim Files) --- kpkg/commands/installcmd.nim | 14 ++++++++------ kpkg/modules/config.nim | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index 391c3071..52df3276 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -55,14 +55,14 @@ proc install_pkg*(repo: string, package: string, root: string, binary = false, proc down_bin(package: string, binrepo: string, root: string, offline: bool) = ## Downloads binaries. - + discard existsOrCreateDir("/var/") discard existsOrCreateDir("/var/cache") discard existsOrCreateDir("/var/cache/kpkg") discard existsOrCreateDir("/var/cache/kpkg/archives") discard existsOrCreateDir("/var/cache/kpkg/archives/arch") discard existsOrCreateDir("/var/cache/kpkg/archives/arch/"&hostCPU) - + setCurrentDir("/var/cache/kpkg/archives") var repo: string @@ -83,10 +83,12 @@ proc down_bin(package: string, binrepo: string, root: string, offline: bool) = elif not offline: echo "Downloading tarball for "&package try: - spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) + spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, + "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) echo "Downloading checksums for "&package - spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) - + spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, + "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) + sync() except CatchableError: @@ -97,7 +99,7 @@ proc down_bin(package: string, binrepo: string, root: string, offline: bool) = proc install_bin(packages: seq[string], binrepo: string, root: string, offline: bool, downloadOnly = false) = ## Downloads and installs binaries. - + var repo: string for i in packages: diff --git a/kpkg/modules/config.nim b/kpkg/modules/config.nim index ba15a853..e63822a3 100644 --- a/kpkg/modules/config.nim +++ b/kpkg/modules/config.nim @@ -6,7 +6,7 @@ import strutils const configPath = "/etc/kpkg/kpkg.conf" -var config {.threadvar.} : Config +var config {.threadvar.}: Config const branch* {.strdefine.}: string = "stable" From f5c8a6e0bacabaf46065d8b47f52d56fd0c192d9 Mon Sep 17 00:00:00 2001 From: Kreato Date: Mon, 7 Aug 2023 07:45:53 +0300 Subject: [PATCH 49/54] add threadsUsed config option, make all options use camelCase, and fix install bug --- kpkg/commands/installcmd.nim | 58 ++++++++++++++++++++++++++---------- kpkg/commands/updatecmd.nim | 4 +-- kpkg/modules/config.nim | 9 ++++-- kpkg/modules/downloader.nim | 5 ++-- 4 files changed, 53 insertions(+), 23 deletions(-) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index 391c3071..9f33a7c5 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -10,6 +10,26 @@ import ../modules/runparser import ../modules/downloader import ../modules/dephandler +var threadsUsed: int + +try: + threadsUsed = parseInt(getConfigValue("Parallelization", "threadsUsed")) + if threadsUsed < 1: + echo "kpkg: warning: threadsUsed in /etc/kpkg/kpkg.conf can't be below 1. Please update your configuration." + raise +except Exception: + threadsUsed = 32 + +proc ctrlc() {.noconv.} = + for path in walkFiles("/var/cache/kpkg/archives/arch/"&hostCPU&"/*.partial"): + removeFile(path) + + echo "" + echo "kpkg: ctrl+c pressed, shutting down" + quit(130) + +setControlCHook(ctrlc) + proc install_pkg*(repo: string, package: string, root: string, binary = false, builddir = "/tmp/kpkg/build") = ## Installs an package. @@ -55,6 +75,9 @@ proc install_pkg*(repo: string, package: string, root: string, binary = false, proc down_bin(package: string, binrepo: string, root: string, offline: bool) = ## Downloads binaries. + setMinPoolSize(1) + + setMaxPoolSize(threadsUsed) discard existsOrCreateDir("/var/") discard existsOrCreateDir("/var/cache") @@ -83,11 +106,15 @@ proc down_bin(package: string, binrepo: string, root: string, offline: bool) = elif not offline: echo "Downloading tarball for "&package try: - spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) - echo "Downloading checksums for "&package - spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) - - sync() + if threadsUsed == 1: + download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) + echo "Downloading checksums for "&package + download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) + else: + spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) + echo "Downloading checksums for "&package + spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) + sync() except CatchableError: err("couldn't download tarball", false) @@ -101,9 +128,13 @@ proc install_bin(packages: seq[string], binrepo: string, root: string, var repo: string for i in packages: - spawn down_bin(i, binrepo, root, offline) - - sync() + if threadsUsed == 1: + down_bin(i, binrepo, root, offline) + else: + spawn down_bin(i, binrepo, root, offline) + + if threadsUsed != 1: + sync() if not downloadOnly: for i in packages: @@ -158,12 +189,7 @@ proc install*(promptPackages: seq[string], root = "/", yes: bool = false, deps.delete(deps.find(i)) if not (deps.len == 0 and deps == @[""]): - spawn install_bin(deps, binrepo, fullRootPath, offline, - downloadOnly = downloadOnly) - - spawn install_bin(packages, binrepo, fullRootPath, offline, - downloadOnly = downloadOnly) - - sync() - + install_bin(deps, binrepo, fullRootPath, offline, downloadOnly = downloadOnly) + install_bin(packages, binrepo, fullRootPath, offline, downloadOnly = downloadOnly) + return "kpkg: done" diff --git a/kpkg/commands/updatecmd.nim b/kpkg/commands/updatecmd.nim index 070278d0..c5777b61 100644 --- a/kpkg/commands/updatecmd.nim +++ b/kpkg/commands/updatecmd.nim @@ -12,8 +12,8 @@ proc update*(repo = "", if not isAdmin(): err("you have to be root for this action.", false) - let repodirs = getConfigValue("Repositories", "RepoDirs") - let repolinks = getConfigValue("Repositories", "RepoLinks") + let repodirs = getConfigValue("Repositories", "repoDirs") + let repolinks = getConfigValue("Repositories", "repoLinks") let repoList: seq[tuple[dir: string, link: string]] = zip(repodirs.split( " "), repolinks.split(" ")) diff --git a/kpkg/modules/config.nim b/kpkg/modules/config.nim index ba15a853..5c088f02 100644 --- a/kpkg/modules/config.nim +++ b/kpkg/modules/config.nim @@ -24,10 +24,13 @@ proc initializeConfig*(): Config = config.setSectionKey("Options", "cc", "gcc") # GCC works the best right now # [Repositories] - config.setSectionKey("Repositories", "RepoDirs", + config.setSectionKey("Repositories", "repoDirs", "/etc/kpkg/repos/main /etc/kpkg/repos/lockin") # Seperate by space - config.setSectionKey("Repositories", "RepoLinks", + config.setSectionKey("Repositories", "repoLinks", "https://github.com/kreatolinux/kpkg-repo.git::"&branch&" https://github.com/kreatolinux/kpkg-repo-lockin.git::"&branch) # Seperate by space, must match RepoDirs + + # [Parallelization] + config.setSectionKey("Parallelization", "threadsUsed", "32") # [Upgrade] config.setSectionKey("Upgrade", "buildByDefault", "yes") # Build packages by default @@ -58,7 +61,7 @@ proc setConfigValue*(section: string, key: string, value: string) = proc findPkgRepo*(package: string): string = ## finds the package repository. - for i in getConfigValue("Repositories", "RepoDirs").split(" "): + for i in getConfigValue("Repositories", "repoDirs").split(" "): if dirExists(i&"/"&package): return i # return blank line if not found diff --git a/kpkg/modules/downloader.nim b/kpkg/modules/downloader.nim index fd6f808e..76c6a2ed 100644 --- a/kpkg/modules/downloader.nim +++ b/kpkg/modules/downloader.nim @@ -1,5 +1,5 @@ import std/httpclient -import terminal, math, strutils +import terminal, math, strutils, os proc onProgressChanged(total, progress, speed: BiggestInt) = stdout.eraseLine @@ -16,5 +16,6 @@ proc onProgressChanged(total, progress, speed: BiggestInt) = proc download*(url: string, file: string) = var client = newHttpClient() client.onProgressChanged = onProgressChanged - client.downloadFile(url, file) + client.downloadFile(url, file&".partial") + moveFile(file&".partial", file) echo "" From 42846d00f09c18dddea98c19b2b9f7444e920478 Mon Sep 17 00:00:00 2001 From: Kreato Date: Mon, 7 Aug 2023 04:48:25 +0000 Subject: [PATCH 50/54] Commit from GitHub Actions (Format Nim Files) --- kpkg/commands/installcmd.nim | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index cbf9438a..5d8545ea 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -12,7 +12,7 @@ import ../modules/dephandler var threadsUsed: int -try: +try: threadsUsed = parseInt(getConfigValue("Parallelization", "threadsUsed")) if threadsUsed < 1: echo "kpkg: warning: threadsUsed in /etc/kpkg/kpkg.conf can't be below 1. Please update your configuration." @@ -23,7 +23,7 @@ except Exception: proc ctrlc() {.noconv.} = for path in walkFiles("/var/cache/kpkg/archives/arch/"&hostCPU&"/*.partial"): removeFile(path) - + echo "" echo "kpkg: ctrl+c pressed, shutting down" quit(130) @@ -76,9 +76,9 @@ proc install_pkg*(repo: string, package: string, root: string, binary = false, proc down_bin(package: string, binrepo: string, root: string, offline: bool) = ## Downloads binaries. setMinPoolSize(1) - + setMaxPoolSize(threadsUsed) - + discard existsOrCreateDir("/var/") discard existsOrCreateDir("/var/cache") discard existsOrCreateDir("/var/cache/kpkg") @@ -107,13 +107,17 @@ proc down_bin(package: string, binrepo: string, root: string, offline: bool) = echo "Downloading tarball for "&package try: if threadsUsed == 1: - download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) + download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, + "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) echo "Downloading checksums for "&package - download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) + download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, + "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) else: - spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) + spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&tarball, + "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&tarball) echo "Downloading checksums for "&package - spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) + spawn download("https://"&binrepo&"/arch/"&hostCPU&"/"&chksum, + "/var/cache/kpkg/archives/arch/"&hostCPU&"/"&chksum) sync() except CatchableError: @@ -132,7 +136,7 @@ proc install_bin(packages: seq[string], binrepo: string, root: string, down_bin(i, binrepo, root, offline) else: spawn down_bin(i, binrepo, root, offline) - + if threadsUsed != 1: sync() @@ -189,7 +193,9 @@ proc install*(promptPackages: seq[string], root = "/", yes: bool = false, deps.delete(deps.find(i)) if not (deps.len == 0 and deps == @[""]): - install_bin(deps, binrepo, fullRootPath, offline, downloadOnly = downloadOnly) - install_bin(packages, binrepo, fullRootPath, offline, downloadOnly = downloadOnly) - + install_bin(deps, binrepo, fullRootPath, offline, + downloadOnly = downloadOnly) + install_bin(packages, binrepo, fullRootPath, offline, + downloadOnly = downloadOnly) + return "kpkg: done" From 9a22f3670576b76a864f56513ff1312020ca494e Mon Sep 17 00:00:00 2001 From: Kreato Date: Mon, 7 Aug 2023 07:54:08 +0300 Subject: [PATCH 51/54] kpkg: threadsUsed: set the default to a sane 4 --- kpkg/commands/installcmd.nim | 2 +- kpkg/modules/config.nim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kpkg/commands/installcmd.nim b/kpkg/commands/installcmd.nim index cbf9438a..d3909397 100644 --- a/kpkg/commands/installcmd.nim +++ b/kpkg/commands/installcmd.nim @@ -18,7 +18,7 @@ try: echo "kpkg: warning: threadsUsed in /etc/kpkg/kpkg.conf can't be below 1. Please update your configuration." raise except Exception: - threadsUsed = 32 + threadsUsed = 4 proc ctrlc() {.noconv.} = for path in walkFiles("/var/cache/kpkg/archives/arch/"&hostCPU&"/*.partial"): diff --git a/kpkg/modules/config.nim b/kpkg/modules/config.nim index f55cd322..43038517 100644 --- a/kpkg/modules/config.nim +++ b/kpkg/modules/config.nim @@ -30,7 +30,7 @@ proc initializeConfig*(): Config = "https://github.com/kreatolinux/kpkg-repo.git::"&branch&" https://github.com/kreatolinux/kpkg-repo-lockin.git::"&branch) # Seperate by space, must match RepoDirs # [Parallelization] - config.setSectionKey("Parallelization", "threadsUsed", "32") + config.setSectionKey("Parallelization", "threadsUsed", "4") # [Upgrade] config.setSectionKey("Upgrade", "buildByDefault", "yes") # Build packages by default From 94c5c202862a153a66d979e0f579ac38bf02876b Mon Sep 17 00:00:00 2001 From: Kreato Date: Mon, 7 Aug 2023 08:06:15 +0300 Subject: [PATCH 52/54] kpkg: config: update documentation and a comment --- kpkg/modules/config.nim | 2 +- man/kpkg.conf.5.md | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/kpkg/modules/config.nim b/kpkg/modules/config.nim index 43038517..edc8f5d7 100644 --- a/kpkg/modules/config.nim +++ b/kpkg/modules/config.nim @@ -34,7 +34,7 @@ proc initializeConfig*(): Config = # [Upgrade] config.setSectionKey("Upgrade", "buildByDefault", "yes") # Build packages by default - # config.setSectionKey("Upgrade, "dontUpgrade", "") # Nyaa wont touch this package, seperate by space + # config.setSectionKey("Upgrade, "dontUpgrade", "") # kpkg wont touch this package, seperate by space config.writeConfig(configPath) diff --git a/man/kpkg.conf.5.md b/man/kpkg.conf.5.md index 69112bfd..def8003d 100644 --- a/man/kpkg.conf.5.md +++ b/man/kpkg.conf.5.md @@ -9,13 +9,16 @@ kpkg.conf - Configuration file for kpkg # SYNTAX kpkg.conf uses a INI format. The default configuration file currently looks like this; -``` +```ini [Options] cc=gcc [Repositories] -RepoDirs=/etc/kpkg/repos/main /etc/kpkg/repos/main-bin -RepoLinks="https://github.com/kreatolinux/kpkg-repo.git::stable https://github.com/kreatolinux/kpkg-repo-lockin.git::stable" +repoDirs=/etc/kpkg/repos/main /etc/kpkg/repos/lockin +repoLinks="https://github.com/kreatolinux/kpkg-repo.git::stable https://github.com/kreatolinux/kpkg-repo-lockin.git::stable" + +[Parallelization] +threadsUsed="4" [Upgrade] buildByDefault=yes @@ -32,8 +35,13 @@ Repositories also support branches/commits like this; `RepoLinks="https://github.com/kreatolinux/kpkg-repo.git::BRANCHNAME"` +## PARALLELIZATION +kpkg now supports parallelization, allowing for much faster binary package installations. This feature is only on the `install` command for now. +* threadsUsed: You can set threads used to download packages. Set to 1 to disable parallelization. Number must be higher than 1. Defaults to 4. + ## UPGRADE * buildByDefault: Enable building by default on upgrades or not. Is enabled by default. +* dontUpgrade: Optional. You can set packages that shouldn't be upgraded. Seperate by space. # AUTHOR Written by Kreato. From 22e2c7ee640d656303e547f1ea05695416a7652b Mon Sep 17 00:00:00 2001 From: Kreato Date: Mon, 7 Aug 2023 05:06:50 +0000 Subject: [PATCH 53/54] Commit from GitHub Actions (Build manpages) --- man/kpkg.conf.5 | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/man/kpkg.conf.5 b/man/kpkg.conf.5 index 8a95eea4..5bec5b52 100644 --- a/man/kpkg.conf.5 +++ b/man/kpkg.conf.5 @@ -20,8 +20,11 @@ The default configuration file currently looks like this; cc=gcc [Repositories] -RepoDirs=/etc/kpkg/repos/main /etc/kpkg/repos/main-bin -RepoLinks=\[dq]https://github.com/kreatolinux/kpkg-repo.git::stable https://github.com/kreatolinux/kpkg-repo-lockin.git::stable\[dq] +repoDirs=/etc/kpkg/repos/main /etc/kpkg/repos/lockin +repoLinks=\[dq]https://github.com/kreatolinux/kpkg-repo.git::stable https://github.com/kreatolinux/kpkg-repo-lockin.git::stable\[dq] + +[Parallelization] +threadsUsed=\[dq]4\[dq] [Upgrade] buildByDefault=yes @@ -45,10 +48,23 @@ Has kpkg-repo and kpkg-repo-bin repositories by default. Repositories also support branches/commits like this; .PP \f[C]RepoLinks=\[dq]https://github.com/kreatolinux/kpkg-repo.git::BRANCHNAME\[dq]\f[R] +.SS PARALLELIZATION +.PP +kpkg now supports parallelization, allowing for much faster binary +package installations. +This feature is only on the \f[C]install\f[R] command for now. +* threadsUsed: You can set threads used to download packages. +Set to 1 to disable parallelization. +Number must be higher than 1. +Defaults to 4. .SS UPGRADE .IP \[bu] 2 buildByDefault: Enable building by default on upgrades or not. Is enabled by default. +.IP \[bu] 2 +dontUpgrade: Optional. +You can set packages that shouldn\[cq]t be upgraded. +Seperate by space. .SH AUTHOR .PP Written by Kreato. From 3eb8470f389b7c2679352a404099a390192d9d7e Mon Sep 17 00:00:00 2001 From: Kreato Date: Mon, 7 Aug 2023 10:38:01 +0300 Subject: [PATCH 54/54] runparser: CONFLICTS: remove quotes --- kpkg/modules/runparser.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kpkg/modules/runparser.nim b/kpkg/modules/runparser.nim index b47f43f4..cf49cfc8 100644 --- a/kpkg/modules/runparser.nim +++ b/kpkg/modules/runparser.nim @@ -54,7 +54,10 @@ proc parse_runfile*(path: string, removeLockfileWhenErr = true): runFile = of "SHA256SUM": ret.sha256sum = vars[1] of "CONFLICTS": - ret.conflicts = vars[1].split(" ") + ret.conflicts = vars[1].multiReplace( + ("\"", ""), + ("'", "") + ).split(" ") of "DEPENDS": ret.deps = vars[1].multiReplace( ("\"", ""),