V0.0.3 Nodejs support.

This commit is contained in:
Cor Legemaat 2026-03-30 07:00:06 +02:00
commit 54f494163a
17 changed files with 1871 additions and 484 deletions

View file

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; utils.scm
;; Copyright (C) 2025 Cor Legemaat <cor@cor.za.net>
;; Copyright (C) 2025, 2026 Cor Legemaat <cor@cor.za.net>
;;
;; This file is part of ebuild-autogen: you can redistribute it and/or modify it
;; under the terms of the GNU Affero General Public License as published by the
@ -16,8 +16,11 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-module (ebuild utils)
#:use-module (ice-9 ftw)
#:use-module (ice-9 pretty-print)
#:use-module (ice-9 regex)
#:use-module (rx irregex)
#:use-module (srfi srfi-1))
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-19))
(define-public list->str-list
(lambda* (in-list glue #:key (pre "") (post ""))
@ -42,24 +45,50 @@
test-list)))
(define-public diff?
(lambda* (data-a data-b #:key (allow (lambda (a b) #true)))
(lambda* (data-a data-b #:key (allow (lambda (a b) #true)) (print-delta #f))
""
(any (lambda (t) t)
(map (lambda (a b)
(if (string=? a b)
#false
(allow a b)))
(if (string? data-a)
(string-split data-a #\newline)
data-a)
(if (string? data-b)
(string-split data-b #\newline)
data-b)))))
(let ((a-list (if (string? data-a)
(string-split data-a #\newline)
(append-map (lambda (line)
(string-split line #\newline))
data-a)))
(b-list (if (string? data-b)
(string-split data-b #\newline)
(append-map (lambda (line)
(string-split line #\newline))
data-b))))
(any (lambda (t) t)
(map (lambda (a b)
(if (string=? a b)
#false
(if (and print-delta
(not (allow a b)))
(begin (display "Diff between lines:")
(newline)
(display "\"") (display a) (display "\"")
(newline)
(display "\"") (display b) (display "\"")
newline)
(allow a b))))
(if (< (length a-list) (length b-list))
(append a-list
(make-list (- (length b-list)
(length a-list))
""))
a-list)
(if (< (length b-list) (length a-list))
(append b-list
(make-list (- (length a-list)
(length b-list))
""))
b-list))))))
(define-public last-ebuild-rel
(lambda (folder pkg version)
""
(let* ((files (scandir folder))
(let* ((files (if (file-exists? folder)
(scandir folder)
'()))
(releases (filter-map
(lambda (file)
(if (string=? file (string-append pkg
@ -115,3 +144,19 @@
(lambda (list1 list2)
""
(every string=? list1 list2)))
(define-public (string->duration str)
"Parses a string like '10m', '2h', or '30s' into seconds."
(let ((match (string-match "^([0-9]+)([smhdSMHD]?)$" str)))
(if match
(let ((val (string->number (match:substring match 1)))
(unit (match:substring match 2)))
(make-time 'time-duration
0
(cond
((string-ci=? unit "s") val)
((string-ci=? unit "m") (* val 60))
((string-ci=? unit "h") (* val 3600))
((string-ci=? unit "d") (* val 86400))
(else val)))) ; Default to seconds if no unit
(error "Invalid duration format" str))))