diff --git a/.gitignore b/.gitignore index 4d9f94f2..a2804fe6 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ gdb.txt # Generated docs _docs/ /man/ + +# VLS logs +vls.log diff --git a/.woodpecker/.test.yml b/.woodpecker/.test.yml deleted file mode 100644 index 6b7b646d..00000000 --- a/.woodpecker/.test.yml +++ /dev/null @@ -1,17 +0,0 @@ -matrix: - PLATFORM: - - 'linux/amd64' - - 'linux/arm64' - -branches: - exclude: [ main ] -platform: ${PLATFORM} - -pipeline: - test: - image: 'chewingbever/vlang:latest' - pull: true - commands: - - make test - when: - event: [pull_request] diff --git a/.woodpecker/.arch-rel.yml b/.woodpecker/arch-rel.yml similarity index 92% rename from .woodpecker/.arch-rel.yml rename to .woodpecker/arch-rel.yml index b8f4c7ae..f5f228ef 100644 --- a/.woodpecker/.arch-rel.yml +++ b/.woodpecker/arch-rel.yml @@ -23,7 +23,7 @@ pipeline: - su builder # Due to a bug with the V compiler, we can't just use the PKGBUILD from # inside the repo - - curl -OL "https://git.rustybever.be/vieter/vieter/raw/tag/$CI_COMMIT_TAG/PKGBUILD" + - curl -OL "https://git.rustybever.be/vieter-v/vieter/raw/tag/$CI_COMMIT_TAG/PKGBUILD" - makepkg -s --noconfirm --needed when: event: tag diff --git a/.woodpecker/.arch.yml b/.woodpecker/arch.yml similarity index 92% rename from .woodpecker/.arch.yml rename to .woodpecker/arch.yml index b2a59ba5..8f1a6ff0 100644 --- a/.woodpecker/.arch.yml +++ b/.woodpecker/arch.yml @@ -23,7 +23,7 @@ pipeline: - su builder # Due to a bug with the V compiler, we can't just use the PKGBUILD from # inside the repo - - curl -o PKGBUILD -L https://git.rustybever.be/vieter/vieter/raw/branch/dev/PKGBUILD.dev + - curl -o PKGBUILD -L https://git.rustybever.be/vieter-v/vieter/raw/branch/dev/PKGBUILD.dev - makepkg -s --noconfirm --needed when: event: push diff --git a/.woodpecker/.build.yml b/.woodpecker/build.yml similarity index 80% rename from .woodpecker/.build.yml rename to .woodpecker/build.yml index b0fd267e..9ee80853 100644 --- a/.woodpecker/.build.yml +++ b/.woodpecker/build.yml @@ -1,3 +1,6 @@ +variables: + - &vlang_image 'chewingbever/vlang:0.3' + matrix: PLATFORM: - 'linux/amd64' @@ -6,10 +9,19 @@ matrix: platform: ${PLATFORM} pipeline: - debug: - image: 'chewingbever/vlang:latest' + install-modules: + image: *vlang_image pull: true commands: + - export VMODULES=$PWD/.vmodules + - 'cd src && v install' + when: + event: [push, pull_request] + + debug: + image: *vlang_image + commands: + - export VMODULES=$PWD/.vmodules - make when: event: [pull_request] @@ -17,11 +29,11 @@ pipeline: exclude: [main] prod: - image: 'chewingbever/vlang:latest' - pull: true + image: *vlang_image environment: - LDFLAGS=-lz -lbz2 -llzma -lexpat -lzstd -llz4 -lsqlite3 -static commands: + - export VMODULES=$PWD/.vmodules # Apparently this -D is *very* important - CFLAGS='-DGC_THREADS=1' make prod # Make sure the binary is actually statically built @@ -35,7 +47,7 @@ pipeline: event: [push, pull_request] upload: - image: 'chewingbever/vlang:latest' + image: *vlang_image secrets: [ s3_username, s3_password ] commands: # https://gist.github.com/JustinTimperio/7c7115f87b775618637d67ac911e595f diff --git a/.woodpecker/.deploy.yml b/.woodpecker/deploy.yml similarity index 100% rename from .woodpecker/.deploy.yml rename to .woodpecker/deploy.yml diff --git a/.woodpecker/.docker.yml b/.woodpecker/docker.yml similarity index 100% rename from .woodpecker/.docker.yml rename to .woodpecker/docker.yml diff --git a/.woodpecker/.docs.yml b/.woodpecker/docs.yml similarity index 90% rename from .woodpecker/.docs.yml rename to .woodpecker/docs.yml index c342e388..048b1ad9 100644 --- a/.woodpecker/.docs.yml +++ b/.woodpecker/docs.yml @@ -1,17 +1,20 @@ +variables: + - &vlang_image 'chewingbever/vlang:0.3' + platform: 'linux/amd64' branches: exclude: [ main ] pipeline: docs: - image: 'klakegg/hugo:alpine' + image: 'klakegg/hugo:ext-alpine' group: 'generate' commands: - apk add git - make docs api-docs: - image: 'chewingbever/vlang:latest' + image: *vlang_image pull: true group: 'generate' commands: diff --git a/.woodpecker/.gitea.yml b/.woodpecker/gitea.yml similarity index 89% rename from .woodpecker/.gitea.yml rename to .woodpecker/gitea.yml index d0825c2c..8e3b9d44 100644 --- a/.woodpecker/.gitea.yml +++ b/.woodpecker/gitea.yml @@ -1,3 +1,6 @@ +variables: + - &vlang_image 'chewingbever/vlang:0.3' + platform: 'linux/amd64' branches: [ 'main' ] depends_on: @@ -8,7 +11,7 @@ skip_clone: true pipeline: prepare: - image: 'chewingbever/vlang:latest' + image: *vlang_image pull: true secrets: [ s3_username, s3_password ] commands: diff --git a/.woodpecker/.lint.yml b/.woodpecker/lint.yml similarity index 73% rename from .woodpecker/.lint.yml rename to .woodpecker/lint.yml index e70648d8..c80ce338 100644 --- a/.woodpecker/.lint.yml +++ b/.woodpecker/lint.yml @@ -1,3 +1,6 @@ +variables: + - &vlang_image 'chewingbever/vlang:0.3' + # These checks already get performed on the feature branches branches: exclude: [ main ] @@ -5,7 +8,7 @@ platform: 'linux/amd64' pipeline: lint: - image: 'chewingbever/vlang:latest' + image: *vlang_image pull: true commands: - make lint diff --git a/.woodpecker/.man.yml b/.woodpecker/man.yml similarity index 92% rename from .woodpecker/.man.yml rename to .woodpecker/man.yml index 0b808866..86a1bd8c 100644 --- a/.woodpecker/.man.yml +++ b/.woodpecker/man.yml @@ -1,3 +1,6 @@ +variables: + - &vlang_image 'chewingbever/vlang:0.3' + platform: 'linux/amd64' branches: exclude: [ main ] @@ -9,7 +12,7 @@ skip_clone: true pipeline: generate: - image: 'chewingbever/vlang:latest' + image: *vlang_image pull: true commands: - curl -o vieter -L "https://s3.rustybever.be/vieter/commits/$CI_COMMIT_SHA/vieter-linux-amd64" diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml new file mode 100644 index 00000000..08b7534f --- /dev/null +++ b/.woodpecker/test.yml @@ -0,0 +1,30 @@ +variables: + - &vlang_image 'chewingbever/vlang:0.3' + +matrix: + PLATFORM: + - 'linux/amd64' + - 'linux/arm64' + +branches: + exclude: [ main ] +platform: ${PLATFORM} + +pipeline: + install-modules: + image: *vlang_image + pull: true + commands: + - export VMODULES=$PWD/.vmodules + - 'cd src && v install' + when: + event: [pull_request] + + test: + image: *vlang_image + pull: true + commands: + - export VMODULES=$PWD/.vmodules + - make test + when: + event: [pull_request] diff --git a/CHANGELOG.md b/CHANGELOG.md index 99a795a4..3cd39c4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,50 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased](https://git.rustybever.be/vieter/vieter/src/branch/dev) +## [Unreleased](https://git.rustybever.be/vieter-v/vieter/src/branch/dev) -## [0.3.0](https://git.rustybever.be/vieter/vieter/src/tag/0.3.0) +## [0.4.0](https://git.rustybever.be/vieter-v/vieter/src/tag/0.4.0) + +### Added + +* Server port can now be configured +* Targets now have a 'kind' field describing whether it's a Git repository or a + URL to a PKGBUILD +* Targets with kind 'url' can provide a direct URL to a PKGBUILD instead of + providing a Git repository +* CLI commands for searching the AUR & directly adding packages +* HTTP routes for removing packages, arch-repos & repos +* All endpoints serving files now support HTTP byte range requests +* Better CLI UX + * When adding targets, the ID of the created target is returned + * The `-r` flag only shows raw data of action + * When adding a target, only ID is shown and not surrounding text + * Tabled output returns a tab-separated list (easy to script using + `cut`) + +### Changed + +* Moved all API routes under `/v1` namespace +* Renamed `vieter repos` to `vieter targets` +* Renamed `/api/v1/repos` namespace to `/api/v1/targets` +* Branch name for 'git' targets is now optional; if not provided, the + repository will be cloned with the default branch +* Build containers now explicitely set the PATH variable +* Refactor of web framework +* API endpoints now return id of newly created entries +* Repo POST requests now return information on published package +* `api` can no longer be used as a repository name +* CLI client now allows setting values to an empty value + +### Removed + +* md5 hashes are no longer calculated for packages + +## [0.3.0](https://git.rustybever.be/vieter-v/vieter/src/tag/0.3.0) Nothing besides bumping the versions. -## [0.3.0-rc.1](https://git.rustybever.be/vieter/vieter/src/tag/0.3.0-rc.1) +## [0.3.0-rc.1](https://git.rustybever.be/vieter-v/vieter/src/tag/0.3.0-rc.1) ### Added @@ -39,7 +76,7 @@ Nothing besides bumping the versions. * `POST /api/logs` now correctly uses epoch timestamps instead of strings -## [0.3.0-alpha.2](https://git.rustybever.be/vieter/vieter/src/tag/0.3.0-alpha.2) +## [0.3.0-alpha.2](https://git.rustybever.be/vieter-v/vieter/src/tag/0.3.0-alpha.2) ### Added @@ -64,7 +101,7 @@ Nothing besides bumping the versions. * `vieter-git` is the latest commit on the dev branch * Full refactor of Docker socket code -## [0.3.0-alpha.1](https://git.rustybever.be/vieter/vieter/src/tag/0.3.0-alpha.1) +## [0.3.0-alpha.1](https://git.rustybever.be/vieter-v/vieter/src/tag/0.3.0-alpha.1) ### Changed @@ -83,7 +120,7 @@ Nothing besides bumping the versions. * Binary no longer panics when an env var is missing -## [0.2.0](https://git.rustybever.be/vieter/vieter/src/tag/0.2.0) +## [0.2.0](https://git.rustybever.be/vieter-v/vieter/src/tag/0.2.0) ### Changed @@ -117,13 +154,13 @@ Nothing besides bumping the versions. * Packages with unknown fields in .PKGINFO are now allowed * Old packages are now properly removed -## [0.1.0](https://git.rustybever.be/vieter/vieter/src/tag/0.1.0) +## [0.1.0](https://git.rustybever.be/vieter-v/vieter/src/tag/0.1.0) ### Changed * Improved logging -## [0.1.0-rc.1](https://git.rustybever.be/vieter/vieter/src/tag/0.1.0-rc.1) +## [0.1.0-rc.1](https://git.rustybever.be/vieter-v/vieter/src/tag/0.1.0-rc.1) ### Added diff --git a/Dockerfile b/Dockerfile index 5997adca..7aed9179 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM chewingbever/vlang:latest AS builder +FROM chewingbever/vlang:0.3 AS builder ARG TARGETPLATFORM ARG CI_COMMIT_SHA diff --git a/Makefile b/Makefile index 7eb35472..69bd7957 100644 --- a/Makefile +++ b/Makefile @@ -83,16 +83,9 @@ fmt: test: $(V) test $(SRC_DIR) -# Build & patch the V compiler -.PHONY: v -v: v/v -v/v: - git clone --single-branch https://git.rustybever.be/Chewing_Bever/v v - make -C v - .PHONY: clean clean: - rm -rf 'data' 'vieter' 'dvieter' 'pvieter' 'vieter.c' 'dvieterctl' 'vieterctl' 'pkg' 'src/vieter' *.pkg.tar.zst 'suvieter' 'afvieter' '$(SRC_DIR)/_docs' 'docs/public' + rm -rf 'data' 'vieter' 'dvieter' 'pvieter' 'vieter.c' 'pkg' 'src/vieter' *.pkg.tar.zst 'suvieter' 'afvieter' '$(SRC_DIR)/_docs' 'docs/public' # =====EXPERIMENTAL===== diff --git a/PKGBUILD b/PKGBUILD index 639ce95c..b600ba0e 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -3,18 +3,26 @@ pkgbase='vieter' pkgname='vieter' -pkgver='0.3.0' +pkgver='0.4.0' pkgrel=1 -pkgdesc="Vieter is a lightweight implementation of an Arch repository server." +pkgdesc="Lightweight Arch repository server & package build system" depends=('glibc' 'openssl' 'libarchive' 'sqlite') -makedepends=('git' 'vieter-v') +makedepends=('git' 'vlang') arch=('x86_64' 'aarch64') -url='https://git.rustybever.be/vieter/vieter' +url='https://git.rustybever.be/vieter-v/vieter' license=('AGPL3') -source=("$pkgname::git+https://git.rustybever.be/vieter/vieter#tag=${pkgver//_/-}") +source=("$pkgname::git+https://git.rustybever.be/vieter-v/vieter#tag=${pkgver//_/-}") md5sums=('SKIP') +prepare() { + export VMODULES="$srcdir/.vmodules" + + cd "$pkgname/src" && v install +} + build() { + export VMODULES="$srcdir/.vmodules" + cd "$pkgname" make prod diff --git a/PKGBUILD.dev b/PKGBUILD.dev index d25abb34..79c7f37f 100644 --- a/PKGBUILD.dev +++ b/PKGBUILD.dev @@ -5,13 +5,13 @@ pkgbase='vieter-git' pkgname='vieter-git' pkgver=0.2.0.r25.g20112b8 pkgrel=1 -pkgdesc="Vieter is a lightweight implementation of an Arch repository server." +pkgdesc="Lightweight Arch repository server & package build system (development version)" depends=('glibc' 'openssl' 'libarchive' 'sqlite') -makedepends=('git' 'vieter-v') +makedepends=('git' 'vlang') arch=('x86_64' 'aarch64') -url='https://git.rustybever.be/vieter/vieter' +url='https://git.rustybever.be/vieter-v/vieter' license=('AGPL3') -source=("$pkgname::git+https://git.rustybever.be/vieter/vieter#branch=dev") +source=("$pkgname::git+https://git.rustybever.be/vieter-v/vieter#branch=dev") md5sums=('SKIP') provides=('vieter') conflicts=('vieter') @@ -22,7 +22,15 @@ pkgver() { git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' } +prepare() { + export VMODULES="$srcdir/.vmodules" + + cd "$pkgname/src" && v install +} + build() { + export VMODULES="$srcdir/.vmodules" + cd "$pkgname" make prod diff --git a/README.md b/README.md index 892396a2..b9fff692 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # Vieter -## Documentation - I host documentation for Vieter over at https://rustybever.be/docs/vieter/. API documentation for the current codebase can be found at https://rustybever.be/api-docs/vieter/. +For more information, questions or just a chat, there's +[#vieter:rustybever.be](https://matrix.to/#/#vieter:rustybever.be) on Matrix! + ## Overview Vieter is a restart of the Pieter project. The goal is to create a simple, @@ -36,22 +37,19 @@ that. Besides a V installer, Vieter also requires the following libraries to work: -* gc * libarchive * openssl * sqlite3 +Vieter also depends on some external V modules which you can install using `cd +src && v install`. Make sure to keep these dependencies up to date using `v +update`. + ### Compiler -Vieter compiles with the standard Vlang compiler. However, I do maintain a -[mirror](https://git.rustybever.be/vieter/v). This is to ensure my CI does not -break without reason, as I control when & how frequently the mirror is updated -to reflect the official repository. - -If you encounter issues using the latest V compiler, try using my mirror -instead. `make v` will clone the repository & build the mirror. Afterwards, -prepending any make command with `V_PATH=v/v` tells make to use the locally -compiled mirror instead. +I used to maintain a mirror that tracked the latest master, but nowadays, I +maintain a Docker image containing the specific compiler version that Vieter +builds with. Currently, this is V 0.3. ## Contributing diff --git a/docs/api/source/includes/_logs.md b/docs/api/source/includes/_logs.md index d4f76320..1c14e71a 100644 --- a/docs/api/source/includes/_logs.md +++ b/docs/api/source/includes/_logs.md @@ -13,7 +13,7 @@ Endpoints for interacting with stored build logs. ```shell curl \ -H 'X-Api-Key: secret' \ - https://example.com/api/logs?offset=10&limit=20 + https://example.com/api/v1/logs?offset=10&limit=20 ``` > JSON output format @@ -24,7 +24,7 @@ curl \ "data": [ { "id": 1, - "repo_id": 3, + "target_id": 3, "start_time": 1652008554, "end_time": 1652008559, "arch": "x86_64", @@ -38,7 +38,7 @@ Retrieve a list of build logs. ### HTTP Request -`GET /api/logs` +`GET /api/v1/logs` ### Query Parameters @@ -46,7 +46,7 @@ Parameter | Description --------- | ----------- limit | Maximum amount of results to return. offset | Offset of results. -repo | Only return builds published to this repository. +target | Only return builds for this target id. before | Only return logs started before this time (UTC epoch) after | Only return logs started after this time (UTC epoch) arch | Only return logs built on this architecture @@ -58,7 +58,7 @@ exit_codes | Comma-separated list of exit codes to limit result to; using `!` as ```shell curl \ -H 'X-Api-Key: secret' \ - https://example.com/api/logs/15 + https://example.com/api/v1/logs/1 ``` > JSON output format @@ -68,7 +68,7 @@ curl \ "message": "", "data": { "id": 1, - "repo_id": 3, + "target_id": 3, "start_time": 1652008554, "end_time": 1652008559, "arch": "x86_64", @@ -81,7 +81,7 @@ Retrieve info about a specific build log. ### HTTP Request -`GET /api/logs/:id` +`GET /api/v1/logs/:id` ### URL Parameters @@ -94,7 +94,7 @@ id | ID of requested log ```shell curl \ -H 'X-Api-Key: secret' \ - https://example.com/api/logs/15/content + https://example.com/api/v1/logs/15/content ``` Retrieve the contents of a build log. The response is the build log in @@ -102,7 +102,7 @@ plaintext. ### HTTP Request -`GET /api/logs/:id/content` +`GET /api/v1/logs/:id/content` ### URL Parameters @@ -112,6 +112,17 @@ id | ID of requested log ## Publish build log +> JSON output format + +```json +{ + "message": "", + "data": { + "id": 15 + } +} +``` +