diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml index 565e4c06..e9900b8f 100644 --- a/.github/workflows/build-packages.yml +++ b/.github/workflows/build-packages.yml @@ -25,7 +25,7 @@ jobs: - name: Build packages run: | - ./build.sh deps - ./build.sh kreastrap - ./src/kreastrap/kreastrap buildPackages + make deps + make kreastrap + ./out/kreastrap buildPackages diff --git a/.github/workflows/build-rootfs.yml b/.github/workflows/build-rootfs.yml index 5b0f3695..09b691fa 100644 --- a/.github/workflows/build-rootfs.yml +++ b/.github/workflows/build-rootfs.yml @@ -35,9 +35,9 @@ jobs: mkdir /out ln -s /out /work/out cd /work - ./build.sh deps - ./build.sh kreastrap - /work/src/kreastrap/kreastrap rootfs --buildType=nocc --arch=amd64 + make deps + make kreastrap + ./out/kreastrap rootfs --buildType=nocc --arch=amd64 cd /out tar -czvf /work/kreato-linux-nocc-"$(date +%d-%m-%Y)"-amd64.tar.gz * @@ -54,9 +54,8 @@ jobs: - name: Build builder rootfs tarball run: | - rm -rf /out/* cd /work - /work/src/kreastrap/kreastrap rootfs --buildType=builder --arch=amd64 + ./out/kreastrap rootfs --buildType=builder --arch=amd64 cd /out tar -czvf /work/kreato-linux-builder-"$(date +%d-%m-%Y)"-amd64.tar.gz * @@ -72,9 +71,8 @@ jobs: - name: Build server rootfs tarball run: | - rm -rf /out/* cd /work - /work/src/kreastrap/kreastrap rootfs --buildType=server --arch=amd64 + ./out/kreastrap rootfs --buildType=server --arch=amd64 cd /out tar -czvf /work/kreato-linux-builder-"$(date +%d-%m-%Y)"-amd64.tar.gz * diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e10a4714..9f6265bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,14 +23,14 @@ jobs: - uses: jiro4989/setup-nim-action@v1 with: nim-version: 'stable' # default is 'stable' - - run: ./build.sh deps - - run: ./build.sh kpkg + - run: make deps + - run: make kpkg - uses: actions/upload-artifact@v3 with: name: kpkg path: ${{ github.workspace }}/out/* - run: | - ./build.sh tests + make purr sudo ./out/kpkg # This is done to generate the config, purr cant seem to generate them by itself for now sudo ./out/purr diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..18361656 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +SRCDIR = $(shell pwd)/src +PREFIX = ./out + +nimbuild = nim c -d:release -d:branch=master --threads:on -d:ssl -o=$(PREFIX)/$1 $(SRCDIR)/$1/$1.nim +tasks = kpkg chkupd kreastrap mari purr + +all: $(tasks) + +deps: + nimble install cligen libsha httpbeast -y + +$(tasks):: + $(call nimbuild,$@) + +purr:: kpkg + +prettify: + find $(SRCDIR) -type f -name '*.nim' | xargs nimpretty + +clean: + rm -rf $(PREFIX) diff --git a/README.md b/README.md index 81d8b609..7a39f260 100644 --- a/README.md +++ b/README.md @@ -17,20 +17,20 @@ There are a couple of build variables; ## kpkg `kpkg` is a rewrite of the nyaa2 package manager. It is written in Nim, and is mainly for use with Kreato Linux. -`kpkg` is heavily inspired by package managers such as `kiss`, `dnf` and `pacman`. Run `./build.sh kpkg` to build. +`kpkg` is heavily inspired by package managers such as `kiss`, `dnf` and `pacman`. Run `make kpkg` to build. ## kreastrap There is also kreastrap v3, a rootfs building utility. -You can build it by running `./build.sh kreastrap`. The binary will be located on `src/kreastrap/kreastrap`. +You can build it by running `make kreastrap`. The binary will be located on `src/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 `./build.sh mari`. The binary will be located on the usual `out` folder. +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. ## purr -purr is kpkg's testing utility. You can build it by running `./build.sh tests`. The binary will be located on the usual `out` folder. +purr is kpkg's testing utility. You can build it by running `make tests`. The binary will be located on the usual `out` folder. ## chkupd -chkupd is a tool to check if a package is up-to-date on a kpkg repository. It also has the ability to attempt to autoupdate the package. You can build it by running `./build.sh chkupd`. The binary will be located on the usual `out` folder. +chkupd is a tool to check if a package is up-to-date on a kpkg repository. It also has the ability to attempt to autoupdate the package. You can build it by running `make chkupd`. The binary will be located on the usual `out` folder. # License Licensed under GPLv3. Check LICENSE file for details diff --git a/build.sh b/build.sh deleted file mode 100755 index 957db72a..00000000 --- a/build.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -OUTDIR="$(dirname $0)/out/" -SRCDIR="$(dirname $0)/src/" - -run() { - echo "Running $@" - "$@" -} - -case $1 in - "kpkg") - shift - run nim c -d:release -d:branch=master --threads:on -d:ssl "$@" -o="$OUTDIR" "$SRCDIR/kpkg/kpkg.nim" - ;; - "prettify") - run nimpretty src/*/*/* - ;; - "tests") - shift - run nim c -d:release --threads:on -d:ssl "$@" -o="$OUTDIR" "$SRCDIR/purr/purr.nim" - ;; - "chkupd") - shift - run nim c -d:release -d:ssl "$@" -o="$OUTDIR" "$SRCDIR/chkupd/chkupd.nim" - ;; - "kreastrap") - shift - run nim c --threads:on -d:ssl "$@" -o="$SRCDIR/kreastrap/kreastrap" "$SRCDIR/kreastrap/kreastrap.nim" - ;; - "mari") - shift - run nim c -d:release -o="$OUTDIR" "$SRCDIR/mari/mari.nim" - ;; - "deps") - shift - run nimble install cligen libsha httpbeast "$@" -y - ;; - *) - echo """./build.sh kpkg: builds kpkg -./build.sh prettify: uses nimpretty to prettify code -./build.sh tests: builds tests -./build.sh mari: builds mari -./build.sh chkupd: builds chkupd -./build.sh kreastrap: builds kreastrap -./build.sh deps: Install dependencies through Nimble""" - ;; -esac diff --git a/src/chkupd/backends/repology.nim b/src/chkupd/backends/repology.nim index 03c22ce3..73cca186 100644 --- a/src/chkupd/backends/repology.nim +++ b/src/chkupd/backends/repology.nim @@ -1,8 +1,8 @@ # chkupd v3 repology backend import json, strutils, os, libsha/sha256 -include ../../kpkg/src/modules/logger -include ../../kpkg/src/modules/downloader -include ../../kpkg/src/modules/runparser +include ../../kpkg/modules/logger +include ../../kpkg/modules/downloader +include ../../kpkg/modules/runparser proc repologyCheck(package: string, repo: string, autoUpdate = false, skipIfDownloadFails = true) =