From 79b47a76e24c6c7e79617a53185991cf67bb2c0e Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Fri, 18 Feb 2022 21:59:33 +0100 Subject: [PATCH 1/4] Remove packages from db before adding new version --- src/repo/repo.v | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/repo/repo.v b/src/repo/repo.v index 554b744..1bf2d0c 100644 --- a/src/repo/repo.v +++ b/src/repo/repo.v @@ -74,6 +74,9 @@ fn (r &Repo) add(pkg &package.Pkg) ?bool { return false } + // We remove the older package version first, if present + r.remove(pkg.info.name, false) ? + os.mkdir(pkg_dir) or { return error('Failed to create package directory.') } os.write_file(os.join_path_single(pkg_dir, 'desc'), pkg.to_desc()) or { @@ -92,6 +95,31 @@ fn (r &Repo) add(pkg &package.Pkg) ?bool { return true } +// remove removes a package from the database. It returns false if the package +// wasn't present in the database. +fn (r &Repo) remove(pkg_name string, sync bool) ?bool { + // We iterate over every directory in the repo dir + for d in os.ls(r.repo_dir) ? { + name := d.split('-')#[..-2].join('-') + + if name == pkg_name { + // We lock the mutex here to prevent other routines from creating a + // new archive while we removed an entry + lock r.mutex { + os.rmdir_all(os.join_path_single(r.repo_dir, d)) ? + } + + if sync { + r.sync() ? + } + + return true + } + } + + return false +} + // Returns the path where the given package's desc & files files are stored fn (r &Repo) pkg_path(pkg &package.Pkg) string { return os.join_path(r.repo_dir, '$pkg.info.name-$pkg.info.version') From 99f6dc69fdef38c27a6b2b4784165bd2d25baa27 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Fri, 18 Feb 2022 22:08:58 +0100 Subject: [PATCH 2/4] Fixed tiny linting error --- src/web/parse.v | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/parse.v b/src/web/parse.v index b592540..2eeef5e 100644 --- a/src/web/parse.v +++ b/src/web/parse.v @@ -34,7 +34,7 @@ fn parse_attrs(name string, attrs []string) ?([]http.Method, string) { } if x.len > 0 { return IError(http.UnexpectedExtraAttributeError{ - attributes: x + attributes: x }) } if methods.len == 0 { From 07bd0beb5876bee877a3be0a2fdfdba28a50eba7 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sat, 19 Feb 2022 15:27:41 +0100 Subject: [PATCH 3/4] Removed builder & patches code; updated README --- .gitignore | 2 +- .woodpecker/.build.yml | 2 -- .woodpecker/.builder.yml | 18 ----------------- .woodpecker/.docker.yml | 1 - Dockerfile.builder | 36 --------------------------------- Makefile | 15 ++++++-------- README.md | 10 ++++----- patches/parse_request_no_body.v | 23 --------------------- patches/patch.sh | 13 ------------ 9 files changed, 12 insertions(+), 108 deletions(-) delete mode 100644 .woodpecker/.builder.yml delete mode 100644 Dockerfile.builder delete mode 100644 patches/parse_request_no_body.v delete mode 100755 patches/patch.sh diff --git a/.gitignore b/.gitignore index df4fcc9..ca2e2f8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,4 @@ libarchive-* test/ # V compiler directory -v-*/ +v/ diff --git a/.woodpecker/.build.yml b/.woodpecker/.build.yml index c81e10b..66caa8c 100644 --- a/.woodpecker/.build.yml +++ b/.woodpecker/.build.yml @@ -6,8 +6,6 @@ matrix: # These checks already get performed on the feature branches platform: ${PLATFORM} -depends_on: - - builder pipeline: # The default build isn't needed, as alpine switches to gcc for the compiler anyways diff --git a/.woodpecker/.builder.yml b/.woodpecker/.builder.yml deleted file mode 100644 index e94a846..0000000 --- a/.woodpecker/.builder.yml +++ /dev/null @@ -1,18 +0,0 @@ -branches: dev -platform: linux/amd64 - -pipeline: - publish: - image: woodpeckerci/plugin-docker-buildx - secrets: [ docker_username, docker_password ] - settings: - repo: chewingbever/vlang - tag: latest - dockerfile: Dockerfile.builder - platforms: [ linux/arm/v7, linux/arm64/v8, linux/amd64 ] - when: - event: push - path: - - Makefile - - Dockerfile.builder - - patches/* diff --git a/.woodpecker/.docker.yml b/.woodpecker/.docker.yml index 9dfdf08..6202fe6 100644 --- a/.woodpecker/.docker.yml +++ b/.woodpecker/.docker.yml @@ -1,7 +1,6 @@ branches: [main, dev] platform: linux/amd64 depends_on: - - builder - build pipeline: diff --git a/Dockerfile.builder b/Dockerfile.builder deleted file mode 100644 index e88d0a6..0000000 --- a/Dockerfile.builder +++ /dev/null @@ -1,36 +0,0 @@ -FROM alpine:3.12 - -ARG TARGETPLATFORM - -WORKDIR /opt/vlang - -ENV VVV /opt/vlang -ENV PATH /opt/vlang:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -ENV VFLAGS -cc gcc -ENV V_PATH /opt/vlang/v - -RUN ln -s /opt/vlang/v /usr/bin/v && \ - apk --no-cache add \ - git make gcc curl openssl \ - musl-dev \ - openssl-libs-static openssl-dev \ - zlib-static bzip2-static xz-dev expat-static zstd-static lz4-static \ - sqlite-static sqlite-dev \ - libx11-dev glfw-dev freetype-dev \ - libarchive-static libarchive-dev \ - gc-dev \ - diffutils - -COPY patches ./patches -COPY Makefile ./ - -RUN make v && \ - mv v-*/* /opt/vlang && \ - v -version - -RUN if [ "$TARGETPLATFORM" = 'linux/amd64' ]; then \ - wget -O /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc && \ - chmod +x /usr/local/bin/mc ; \ -fi - -CMD ["v"] diff --git a/Makefile b/Makefile index 7166c66..d7efc45 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,7 @@ SRC_DIR := src SOURCES != find '$(SRC_DIR)' -iname '*.v' -V_RELEASE := weekly.2022.07 -V_PATH ?= v-$(V_RELEASE)/v +V_PATH ?= v/v V := $(V_PATH) -showcc -gc boehm all: vieter @@ -46,7 +45,6 @@ run-prod: prod watch: API_KEY=test DOWNLOAD_DIR=data/downloads REPO_DIR=data/repo PKG_DIR=data/pkgs LOG_LEVEL=DEBUG $(V) watch run vieter - # =====OTHER===== .PHONY: lint lint: @@ -63,11 +61,10 @@ vet: # Build & patch the V compiler .PHONY: v -v: v-$(V_RELEASE)/v -v-$(V_RELEASE)/v: - curl -Lo - 'https://github.com/vlang/v/archive/refs/tags/$(V_RELEASE).tar.gz' | tar xzf - - cd patches && sh patch.sh '../v-$(V_RELEASE)' - make -C 'v-$(V_RELEASE)' +v: v/v +v/v: + git clone --single-branch --branch patches https://git.rustybever.be/Chewing_Bever/vieter-v v + make -C v clean: - rm -rf 'data' 'vieter' 'dvieter' 'pvieter' 'vieter.c' 'v-$(V_RELEASE)' + rm -rf 'data' 'vieter' 'dvieter' 'pvieter' 'vieter.c' diff --git a/README.md b/README.md index fbfa259..f269027 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,11 @@ that. ### Custom Compiler Currently, this program only works with a very slightly modified version of the -V standard library, and therefore the compiler. The changes that are made to -the standard V release can be found in the [patches](/patches) directory. You -can obtain this modified version of the compiler by running `make v`, which -will download, patch & build the compiler. Afterwards, all make commands that -require the V compiler will use this new binary. +V standard library, and therefore the compiler. The source code for this fork +can be found [here](https://git.rustybever.be/Chewing_Bever/vieter-v). You can +obtain this modified version of the compiler by running `make v`, which will +clone & build the compiler. Afterwards, all make commands that require the V +compiler will use this new binary. ## Features diff --git a/patches/parse_request_no_body.v b/patches/parse_request_no_body.v deleted file mode 100644 index c00a51c..0000000 --- a/patches/parse_request_no_body.v +++ /dev/null @@ -1,23 +0,0 @@ -// Parse the header of a raw HTTP request into a Request object -pub fn parse_request_head(mut reader io.BufferedReader) ?Request { - // request line - mut line := reader.read_line() ? - method, target, version := parse_request_line(line) ? - - // headers - mut header := new_header() - line = reader.read_line() ? - for line != '' { - key, value := parse_header(line) ? - header.add_custom(key, value) ? - line = reader.read_line() ? - } - header.coerce(canonicalize: true) - - return Request{ - method: method - url: target.str() - header: header - version: version - } -} diff --git a/patches/patch.sh b/patches/patch.sh deleted file mode 100755 index 89f2176..0000000 --- a/patches/patch.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env sh -# This file patches the downloaded V version -# Should be run from within the directory it's in, as it uses relative paths to the files used for patching. -# $1 is the path to the downloaded V version - -# Add parse_request_no_body -cat parse_request_no_body.v >> "$1"/vlib/net/http/request.v - -# weekly.2022.07 fixes the write function being private -# Make sha256 functions public -sed -i \ - -e 's/\(fn (mut d Digest) checksum(\)/pub \1/' \ - "$1"/vlib/crypto/sha256/sha256.v From 3b3a2f4fc1a5a238b4a9a4e816184ae598093187 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sat, 19 Feb 2022 15:36:30 +0100 Subject: [PATCH 4/4] Fixed linting errors --- src/web/parse.v | 2 +- src/web/web.v | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/web/parse.v b/src/web/parse.v index b592540..2eeef5e 100644 --- a/src/web/parse.v +++ b/src/web/parse.v @@ -34,7 +34,7 @@ fn parse_attrs(name string, attrs []string) ?([]http.Method, string) { } if x.len > 0 { return IError(http.UnexpectedExtraAttributeError{ - attributes: x + attributes: x }) } if methods.len == 0 { diff --git a/src/web/web.v b/src/web/web.v index b1e8b92..ad647f2 100644 --- a/src/web/web.v +++ b/src/web/web.v @@ -22,7 +22,7 @@ pub struct Result {} pub const ( methods_with_form = [http.Method.post, .put, .patch] headers_close = http.new_custom_header_from_map({ - 'Server': 'VWeb' + 'Server': 'VWeb' http.CommonHeader.connection.str(): 'close' }) or { panic('should never fail') }