diff --git a/.gitignore b/.gitignore index a2804fe..4d9f94f 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,3 @@ gdb.txt # Generated docs _docs/ /man/ - -# VLS logs -vls.log 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 f5f228e..b8f4c7a 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-v/vieter/raw/tag/$CI_COMMIT_TAG/PKGBUILD" + - curl -OL "https://git.rustybever.be/vieter/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 8f1a6ff..b2a59ba 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-v/vieter/raw/branch/dev/PKGBUILD.dev + - curl -o PKGBUILD -L https://git.rustybever.be/vieter/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 9ee8085..b0fd267 100644 --- a/.woodpecker/build.yml +++ b/.woodpecker/.build.yml @@ -1,6 +1,3 @@ -variables: - - &vlang_image 'chewingbever/vlang:0.3' - matrix: PLATFORM: - 'linux/amd64' @@ -9,19 +6,10 @@ matrix: platform: ${PLATFORM} pipeline: - install-modules: - image: *vlang_image + debug: + image: 'chewingbever/vlang:latest' 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] @@ -29,11 +17,11 @@ pipeline: exclude: [main] prod: - image: *vlang_image + image: 'chewingbever/vlang:latest' + pull: true 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 @@ -47,7 +35,7 @@ pipeline: event: [push, pull_request] upload: - image: *vlang_image + image: 'chewingbever/vlang:latest' 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 048b1ad..c342e38 100644 --- a/.woodpecker/docs.yml +++ b/.woodpecker/.docs.yml @@ -1,20 +1,17 @@ -variables: - - &vlang_image 'chewingbever/vlang:0.3' - platform: 'linux/amd64' branches: exclude: [ main ] pipeline: docs: - image: 'klakegg/hugo:ext-alpine' + image: 'klakegg/hugo:alpine' group: 'generate' commands: - apk add git - make docs api-docs: - image: *vlang_image + image: 'chewingbever/vlang:latest' 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 8e3b9d4..d0825c2 100644 --- a/.woodpecker/gitea.yml +++ b/.woodpecker/.gitea.yml @@ -1,6 +1,3 @@ -variables: - - &vlang_image 'chewingbever/vlang:0.3' - platform: 'linux/amd64' branches: [ 'main' ] depends_on: @@ -11,7 +8,7 @@ skip_clone: true pipeline: prepare: - image: *vlang_image + image: 'chewingbever/vlang:latest' 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 c80ce33..e70648d 100644 --- a/.woodpecker/lint.yml +++ b/.woodpecker/.lint.yml @@ -1,6 +1,3 @@ -variables: - - &vlang_image 'chewingbever/vlang:0.3' - # These checks already get performed on the feature branches branches: exclude: [ main ] @@ -8,7 +5,7 @@ platform: 'linux/amd64' pipeline: lint: - image: *vlang_image + image: 'chewingbever/vlang:latest' 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 86a1bd8..0b80886 100644 --- a/.woodpecker/man.yml +++ b/.woodpecker/.man.yml @@ -1,6 +1,3 @@ -variables: - - &vlang_image 'chewingbever/vlang:0.3' - platform: 'linux/amd64' branches: exclude: [ main ] @@ -12,7 +9,7 @@ skip_clone: true pipeline: generate: - image: *vlang_image + image: 'chewingbever/vlang:latest' 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 0000000..6b7b646 --- /dev/null +++ b/.woodpecker/.test.yml @@ -0,0 +1,17 @@ +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/test.yml b/.woodpecker/test.yml deleted file mode 100644 index 08b7534..0000000 --- a/.woodpecker/test.yml +++ /dev/null @@ -1,30 +0,0 @@ -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 3cd39c4..99a795a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,50 +5,13 @@ 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-v/vieter/src/branch/dev) +## [Unreleased](https://git.rustybever.be/vieter/vieter/src/branch/dev) -## [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) +## [0.3.0](https://git.rustybever.be/vieter/vieter/src/tag/0.3.0) Nothing besides bumping the versions. -## [0.3.0-rc.1](https://git.rustybever.be/vieter-v/vieter/src/tag/0.3.0-rc.1) +## [0.3.0-rc.1](https://git.rustybever.be/vieter/vieter/src/tag/0.3.0-rc.1) ### Added @@ -76,7 +39,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-v/vieter/src/tag/0.3.0-alpha.2) +## [0.3.0-alpha.2](https://git.rustybever.be/vieter/vieter/src/tag/0.3.0-alpha.2) ### Added @@ -101,7 +64,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-v/vieter/src/tag/0.3.0-alpha.1) +## [0.3.0-alpha.1](https://git.rustybever.be/vieter/vieter/src/tag/0.3.0-alpha.1) ### Changed @@ -120,7 +83,7 @@ Nothing besides bumping the versions. * Binary no longer panics when an env var is missing -## [0.2.0](https://git.rustybever.be/vieter-v/vieter/src/tag/0.2.0) +## [0.2.0](https://git.rustybever.be/vieter/vieter/src/tag/0.2.0) ### Changed @@ -154,13 +117,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-v/vieter/src/tag/0.1.0) +## [0.1.0](https://git.rustybever.be/vieter/vieter/src/tag/0.1.0) ### Changed * Improved logging -## [0.1.0-rc.1](https://git.rustybever.be/vieter-v/vieter/src/tag/0.1.0-rc.1) +## [0.1.0-rc.1](https://git.rustybever.be/vieter/vieter/src/tag/0.1.0-rc.1) ### Added diff --git a/Dockerfile b/Dockerfile index 7aed917..5997adc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM chewingbever/vlang:0.3 AS builder +FROM chewingbever/vlang:latest AS builder ARG TARGETPLATFORM ARG CI_COMMIT_SHA diff --git a/Makefile b/Makefile index 69bd795..7eb3547 100644 --- a/Makefile +++ b/Makefile @@ -83,9 +83,16 @@ 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' 'pkg' 'src/vieter' *.pkg.tar.zst 'suvieter' 'afvieter' '$(SRC_DIR)/_docs' 'docs/public' + rm -rf 'data' 'vieter' 'dvieter' 'pvieter' 'vieter.c' 'dvieterctl' 'vieterctl' 'pkg' 'src/vieter' *.pkg.tar.zst 'suvieter' 'afvieter' '$(SRC_DIR)/_docs' 'docs/public' # =====EXPERIMENTAL===== diff --git a/PKGBUILD b/PKGBUILD index b600ba0..639ce95 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -3,26 +3,18 @@ pkgbase='vieter' pkgname='vieter' -pkgver='0.4.0' +pkgver='0.3.0' pkgrel=1 -pkgdesc="Lightweight Arch repository server & package build system" +pkgdesc="Vieter is a lightweight implementation of an Arch repository server." depends=('glibc' 'openssl' 'libarchive' 'sqlite') -makedepends=('git' 'vlang') +makedepends=('git' 'vieter-v') arch=('x86_64' 'aarch64') -url='https://git.rustybever.be/vieter-v/vieter' +url='https://git.rustybever.be/vieter/vieter' license=('AGPL3') -source=("$pkgname::git+https://git.rustybever.be/vieter-v/vieter#tag=${pkgver//_/-}") +source=("$pkgname::git+https://git.rustybever.be/vieter/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 79c7f37..d25abb3 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="Lightweight Arch repository server & package build system (development version)" +pkgdesc="Vieter is a lightweight implementation of an Arch repository server." depends=('glibc' 'openssl' 'libarchive' 'sqlite') -makedepends=('git' 'vlang') +makedepends=('git' 'vieter-v') arch=('x86_64' 'aarch64') -url='https://git.rustybever.be/vieter-v/vieter' +url='https://git.rustybever.be/vieter/vieter' license=('AGPL3') -source=("$pkgname::git+https://git.rustybever.be/vieter-v/vieter#branch=dev") +source=("$pkgname::git+https://git.rustybever.be/vieter/vieter#branch=dev") md5sums=('SKIP') provides=('vieter') conflicts=('vieter') @@ -22,15 +22,7 @@ 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 b9fff69..892396a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ # 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, @@ -37,19 +36,22 @@ 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 -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. +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. ## Contributing diff --git a/docs/api/source/includes/_targets.md b/docs/api/source/includes/_git.md similarity index 65% rename from docs/api/source/includes/_targets.md rename to docs/api/source/includes/_git.md index 93a4e86..8458834 100644 --- a/docs/api/source/includes/_targets.md +++ b/docs/api/source/includes/_git.md @@ -1,4 +1,4 @@ -# Targets +# Git Repositories -Endpoints for interacting with the list of targets stored on the server. +Endpoints for interacting with the list of Git repositories stored on the +server. -## List targets +## List repos ```shell curl \ -H 'X-Api-Key: secret' \ - https://example.com/api/v1/targets?offset=10&limit=20 + https://example.com/api/repos?offset=10&limit=20 ``` > JSON output format @@ -24,7 +25,6 @@ curl \ "data": [ { "id": 1, - "kind": "git", "url": "https://aur.archlinux.org/discord-ptb.git", "branch": "master", "repo": "bur", @@ -32,7 +32,7 @@ curl \ "arch": [ { "id": 1, - "target_id": 1, + "repo_id": 1, "value": "x86_64" } ] @@ -41,11 +41,11 @@ curl \ } ``` -Retrieve a list of targets. +Retrieve a list of Git repositories. ### HTTP Request -`GET /api/v1/targets` +`GET /api/repos` ### Query Parameters @@ -53,14 +53,14 @@ Parameter | Description --------- | ----------- limit | Maximum amount of results to return. offset | Offset of results. -repo | Limit results to targets that publish to the given repo. +repo | Limit results to repositories that publish to the given repo. -## Get specific target +## Get a repo ```shell curl \ -H 'X-Api-Key: secret' \ - https://example.com/api/v1/targets/1 + https://example.com/api/repos/15 ``` > JSON output format @@ -70,7 +70,6 @@ curl \ "message": "", "data": { "id": 1, - "kind": "git", "url": "https://aur.archlinux.org/discord-ptb.git", "branch": "master", "repo": "bur", @@ -78,7 +77,7 @@ curl \ "arch": [ { "id": 1, - "target_id": 1, + "repo_id": 1, "value": "x86_64" } ] @@ -86,83 +85,70 @@ curl \ } ``` -Get info about a specific target. +Get info about a specific Git repository. ### HTTP Request -`GET /api/v1/targets/:id` +`GET /api/repos/:id` ### URL Parameters Parameter | Description --------- | ----------- -id | id of requested target +id | ID of requested repo -## Create a new target +## Create a new repo -> JSON output format - -```json -{ - "message": "", - "data": { - "id": 15 - } -} -``` - -Create a new target with the given data. +Create a new Git repository with the given data. ### HTTP Request -`POST /api/v1/targets` +`POST /api/repos` ### Query Parameters Parameter | Description --------- | ----------- -kind | Kind of target to add; one of 'git', 'url'. url | URL of the Git repository. branch | Branch of the Git repository. repo | Vieter repository to publish built packages to. schedule | Cron build schedule (syntax explained [here](https://rustybever.be/docs/vieter/usage/builds/schedule/)) arch | Comma-separated list of architectures to build package on. -## Modify a target +## Modify a repo -Modify the data of an existing target. +Modify the data of an existing Git repository. ### HTTP Request -`PATCH /api/v1/targets/:id` +`PATCH /api/repos/:id` ### URL Parameters Parameter | Description --------- | ----------- -id | id of target to modify +id | ID of requested repo ### Query Parameters Parameter | Description --------- | ----------- -kind | Kind of target; one of 'git', 'url'. url | URL of the Git repository. branch | Branch of the Git repository. repo | Vieter repository to publish built packages to. schedule | Cron build schedule arch | Comma-separated list of architectures to build package on. -## Remove a target +## Remove a repo -Remove a target from the server. +Remove a Git repository from the server. ### HTTP Request -`DELETE /api/v1/targets/:id` +`DELETE /api/repos/:id` ### URL Parameters Parameter | Description --------- | ----------- -id | id of target to remove +id | ID of repo to remove diff --git a/docs/api/source/includes/_logs.md b/docs/api/source/includes/_logs.md index 1c14e71..d4f7632 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/v1/logs?offset=10&limit=20 + https://example.com/api/logs?offset=10&limit=20 ``` > JSON output format @@ -24,7 +24,7 @@ curl \ "data": [ { "id": 1, - "target_id": 3, + "repo_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/v1/logs` +`GET /api/logs` ### Query Parameters @@ -46,7 +46,7 @@ Parameter | Description --------- | ----------- limit | Maximum amount of results to return. offset | Offset of results. -target | Only return builds for this target id. +repo | Only return builds published to this repository. 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/v1/logs/1 + https://example.com/api/logs/15 ``` > JSON output format @@ -68,7 +68,7 @@ curl \ "message": "", "data": { "id": 1, - "target_id": 3, + "repo_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/v1/logs/:id` +`GET /api/logs/:id` ### URL Parameters @@ -94,7 +94,7 @@ id | ID of requested log ```shell curl \ -H 'X-Api-Key: secret' \ - https://example.com/api/v1/logs/15/content + https://example.com/api/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/v1/logs/:id/content` +`GET /api/logs/:id/content` ### URL Parameters @@ -112,17 +112,6 @@ id | ID of requested log ## Publish build log -> JSON output format - -```json -{ - "message": "", - "data": { - "id": 15 - } -} -``` -