From 487b2357272050d1fcabf9cead73872fa5ea524e Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Wed, 22 Jun 2022 16:19:07 +0200 Subject: [PATCH 1/4] feat(cli): add aur search command --- .gitignore | 3 +++ src/console/aur/aur.v | 26 ++++++++++++++++++++++++++ src/main.v | 2 ++ src/v.mod | 3 ++- 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/console/aur/aur.v diff --git a/.gitignore b/.gitignore index 4d9f94f..a2804fe 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ gdb.txt # Generated docs _docs/ /man/ + +# VLS logs +vls.log diff --git a/src/console/aur/aur.v b/src/console/aur/aur.v new file mode 100644 index 0000000..3f20dfc --- /dev/null +++ b/src/console/aur/aur.v @@ -0,0 +1,26 @@ +module aur + +import cli +import console +import vieter_v.aur + +pub fn cmd() cli.Command { + return cli.Command{ + name: 'aur' + description: 'Interact with the AUR.' + commands: [ + cli.Command{ + name: 'search' + description: 'Search for packages.' + required_args: 1 + execute: fn (cmd cli.Command) ? { + c := aur.new() + pkgs := c.search(cmd.args[0])? + data := pkgs.map([it.name, it.description]) + + println(console.pretty_table(['name', 'description'], data)?) + } + }, + ] + } +} diff --git a/src/main.v b/src/main.v index cba410c..4ade930 100644 --- a/src/main.v +++ b/src/main.v @@ -7,6 +7,7 @@ import console.targets import console.logs import console.schedule import console.man +import console.aur import cron fn main() { @@ -31,6 +32,7 @@ fn main() { logs.cmd(), schedule.cmd(), man.cmd(), + aur.cmd(), ] } app.setup() diff --git a/src/v.mod b/src/v.mod index 5b89062..710c976 100644 --- a/src/v.mod +++ b/src/v.mod @@ -1,6 +1,7 @@ Module { dependencies: [ 'https://git.rustybever.be/vieter-v/conf', - 'https://git.rustybever.be/vieter-v/docker' + 'https://git.rustybever.be/vieter-v/docker', + 'https://git.rustybever.be/vieter-v/aur' ] } From 1a940f2f98e6c2c7794e4f06b2913a32316cfbfd Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Wed, 22 Jun 2022 16:38:53 +0200 Subject: [PATCH 2/4] feat(cli): added "aur add" command --- CHANGELOG.md | 1 + src/console/aur/aur.v | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf2b829..a03c18c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 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 ### Changed diff --git a/src/console/aur/aur.v b/src/console/aur/aur.v index 3f20dfc..c98f8e6 100644 --- a/src/console/aur/aur.v +++ b/src/console/aur/aur.v @@ -2,8 +2,16 @@ module aur import cli import console +import client import vieter_v.aur +import vieter_v.conf as vconf +struct Config { + address string [required] + api_key string [required] +} + +// cmd returns the cli module for interacting with the AUR API. pub fn cmd() cli.Command { return cli.Command{ name: 'aur' @@ -21,6 +29,34 @@ pub fn cmd() cli.Command { println(console.pretty_table(['name', 'description'], data)?) } }, + cli.Command{ + name: 'add' + usage: 'repo pkg-name [pkg-name...]' + description: 'Add the given AUR package(s) to Vieter. Non-existent packages will be silently ignored.' + required_args: 2 + execute: fn (cmd cli.Command) ? { + config_file := cmd.flags.get_string('config-file')? + conf := vconf.load(prefix: 'VIETER_', default_path: config_file)? + + c := aur.new() + pkgs := c.info(cmd.args[1..])? + + vc := client.new(conf.address, conf.api_key) + + for pkg in pkgs { + vc.add_target( + kind: 'git' + url: 'https://aur.archlinux.org/$pkg.package_base' + '.git' + repo: cmd.args[0] + ) or { + println('Failed to add $pkg.name: $err.msg()') + continue + } + + println('Added $pkg.name' + '.') + } + } + }, ] } } From 0d0fb323f235c0381d8737ccd777bfa6167a7e4b Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sun, 3 Jul 2022 14:11:29 +0200 Subject: [PATCH 3/4] chore: switched to vlang 0.3 Docker image --- .woodpecker/.build.yml | 8 ++++---- .woodpecker/.docs.yml | 2 +- .woodpecker/.gitea.yml | 2 +- .woodpecker/.lint.yml | 2 +- .woodpecker/.man.yml | 2 +- .woodpecker/.test.yml | 4 ++-- Dockerfile | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.woodpecker/.build.yml b/.woodpecker/.build.yml index 7cb7d53..580fa69 100644 --- a/.woodpecker/.build.yml +++ b/.woodpecker/.build.yml @@ -7,7 +7,7 @@ platform: ${PLATFORM} pipeline: install-modules: - image: 'chewingbever/vlang:latest' + image: 'chewingbever/vlang:0.3' pull: true commands: - export VMODULES=$PWD/.vmodules @@ -16,7 +16,7 @@ pipeline: event: [push, pull_request] debug: - image: 'chewingbever/vlang:latest' + image: 'chewingbever/vlang:0.3' commands: - export VMODULES=$PWD/.vmodules - make @@ -26,7 +26,7 @@ pipeline: exclude: [main] prod: - image: 'chewingbever/vlang:latest' + image: 'chewingbever/vlang:0.3' environment: - LDFLAGS=-lz -lbz2 -llzma -lexpat -lzstd -llz4 -lsqlite3 -static commands: @@ -44,7 +44,7 @@ pipeline: event: [push, pull_request] upload: - image: 'chewingbever/vlang:latest' + image: 'chewingbever/vlang:0.3' secrets: [ s3_username, s3_password ] commands: # https://gist.github.com/JustinTimperio/7c7115f87b775618637d67ac911e595f diff --git a/.woodpecker/.docs.yml b/.woodpecker/.docs.yml index 051d852..da495fc 100644 --- a/.woodpecker/.docs.yml +++ b/.woodpecker/.docs.yml @@ -11,7 +11,7 @@ pipeline: - make docs api-docs: - image: 'chewingbever/vlang:latest' + image: 'chewingbever/vlang:0.3' pull: true group: 'generate' commands: diff --git a/.woodpecker/.gitea.yml b/.woodpecker/.gitea.yml index d0825c2..55f991e 100644 --- a/.woodpecker/.gitea.yml +++ b/.woodpecker/.gitea.yml @@ -8,7 +8,7 @@ skip_clone: true pipeline: prepare: - image: 'chewingbever/vlang:latest' + image: 'chewingbever/vlang:0.3' pull: true secrets: [ s3_username, s3_password ] commands: diff --git a/.woodpecker/.lint.yml b/.woodpecker/.lint.yml index e70648d..75a8105 100644 --- a/.woodpecker/.lint.yml +++ b/.woodpecker/.lint.yml @@ -5,7 +5,7 @@ platform: 'linux/amd64' pipeline: lint: - image: 'chewingbever/vlang:latest' + image: 'chewingbever/vlang:0.3' pull: true commands: - make lint diff --git a/.woodpecker/.man.yml b/.woodpecker/.man.yml index 0b80886..1a30b03 100644 --- a/.woodpecker/.man.yml +++ b/.woodpecker/.man.yml @@ -9,7 +9,7 @@ skip_clone: true pipeline: generate: - image: 'chewingbever/vlang:latest' + image: 'chewingbever/vlang:0.3' 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 index a19dbd4..6c267fa 100644 --- a/.woodpecker/.test.yml +++ b/.woodpecker/.test.yml @@ -9,7 +9,7 @@ platform: ${PLATFORM} pipeline: install-modules: - image: 'chewingbever/vlang:latest' + image: 'chewingbever/vlang:0.3' pull: true commands: - export VMODULES=$PWD/.vmodules @@ -18,7 +18,7 @@ pipeline: event: [pull_request] test: - image: 'chewingbever/vlang:latest' + image: 'chewingbever/vlang:0.3' pull: true commands: - export VMODULES=$PWD/.vmodules diff --git a/Dockerfile b/Dockerfile index 5997adc..7aed917 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 From 0f6630b9404acb2b2217f52091c38d636ffc81f0 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sun, 17 Jul 2022 13:38:46 +0200 Subject: [PATCH 4/4] chore: updated PKGBUILDs to use vlang package --- PKGBUILD | 4 ++-- PKGBUILD.dev | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 6b664d1..14ea71b 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -5,9 +5,9 @@ pkgbase='vieter' pkgname='vieter' pkgver='0.3.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-v/vieter' license=('AGPL3') diff --git a/PKGBUILD.dev b/PKGBUILD.dev index 045e576..79c7f37 100644 --- a/PKGBUILD.dev +++ b/PKGBUILD.dev @@ -5,9 +5,9 @@ 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-v/vieter' license=('AGPL3')