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 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; repo.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
@ -22,10 +22,12 @@
#:use-module (ice-9 pretty-print)
#:use-module (ice-9 textual-ports)
#:use-module (srfi srfi-1)
#:use-module (git)
#:use-module (git bindings)
#:use-module (git repository)
#:use-module (git clone)
#:use-module (git checkout)
#:use-module (git reference)
#:use-module (git submodule)
#:use-module (rx irregex))
@ -107,7 +109,8 @@
(define-public cp-repo-file
(lambda* (repo folder-dst folder-src file verbosity #:key
(file-dst file)
(sub-folder ""))
(sub-folder "")
(required #t))
""
(let ((file-in (string-join (list repo folder-src file)
file-name-separator-string))
@ -139,41 +142,46 @@
file-name-separator-string)
"manifest"))
(list (string-join (if (string=? sub-folder "")
(list file-dst)
(list sub-folder file))
(list folder-dst file-dst)
(list folder-dst file))
file-name-separator-string)))))
(if (eq? (stat:type (stat file-in)) 'directory)
(if (file-exists? file-out)
(if (eq? (stat:type (stat file-out)) 'directory)
(for-each-file (scandir file-in))
(begin (if (>= verbosity verbosity-critical)
(begin (display "warning: \"")
(display file-in)
(display "\" not a folder and won't ")
(display "represent autogen source data!")
(newline)))
'()))
(begin (mkdir file-out)
(for-each-file (scandir file-in))))
(begin (if (file-exists? file-out)
(let* ((port-in (open-input-file file-in))
(port-out (open-input-file file-out))
(data-in (get-string-all port-in))
(data-out (get-string-all port-out)))
(close port-in)
(close port-out)
(if (diff? data-in data-out)
(let ((output-port (open-output-file file-out)))
(if (>= verbosity verbosity-warn)
(begin (display "Destination differs for \"")
(display file)
(display "\" overriding.")
(newline)))
(display data-in output-port)
(close output-port))
(finish)))
(copy-file file-in file-out))
(finish))))))
(if (file-exists? file-in)
(if (eq? (stat:type (stat file-in)) 'directory)
(if (file-exists? file-out)
(if (eq? (stat:type (stat file-out)) 'directory)
(for-each-file (scandir file-in))
(begin (if (>= verbosity verbosity-critical)
(begin (display "warning: \"")
(display file-in)
(display "\" not a folder and won't ")
(display "represent autogen source data!")
(newline)))
'()))
(begin (mkdir file-out)
(for-each-file (scandir file-in))))
(begin (if (file-exists? file-out)
(let* ((port-in (open-input-file file-in))
(port-out (open-input-file file-out))
(data-in (get-string-all port-in))
(data-out (get-string-all port-out)))
(close port-in)
(close port-out)
(if (diff? data-in data-out)
(let ((output-port (open-output-file file-out)))
(if (>= verbosity verbosity-warn)
(begin (display "Destination differs for \"")
(display file)
(display "\" overriding.")
(newline)))
(display data-in output-port)
(close output-port))
(finish)))
(copy-file file-in file-out))
(finish)))
(if required
(error (string-append "Required repo file \""
file-in
"\" does not exits!")))))))
(define-public folder-list
(lambda (path ignore-meta)
@ -183,7 +191,8 @@
(stat:type (stat (string-append path "/" entry))))
(if (and ignore-meta
(or (string=? entry "metadata")
(string=? entry "profiles")))
(string=? entry "profiles")
(string=? entry "autogen")))
#f
(if (char=? (car (string->list entry)) #\.)
#f entry))
@ -272,38 +281,43 @@
(newline)))
(mkpath dst-path))
;;cp each ebuild and the files folder.
(let ((test (append-map
(lambda (file)
(let ((ret (cp-repo-file
(assoc-ref parms 'repo)
(string-join (list (assoc-ref parms 'category)
(assoc-ref parms 'name))
file-name-separator-string)
(string-join (list "autogen"
(assoc-ref parms 'category)
(assoc-ref parms 'name))
file-name-separator-string)
file
(assoc-ref parms 'verbosity))))
ret))
(filter-map
(lambda (file)
(if (irregex-search '(or (seq bos "files" eos)
(seq ".ebuild" eos ))
file)
file
#f))
(scandir src-path)))))
test)
)))
(append-map
(lambda (file)
(map (lambda (dest)
(string-drop dest
(1+ (string-length
(string-join (list (assoc-ref parms 'category)
(assoc-ref parms 'name))
file-name-separator-string)))))
(cp-repo-file (assoc-ref parms 'repo)
(string-join (list (assoc-ref parms 'category)
(assoc-ref parms 'name))
file-name-separator-string)
(string-join (list "autogen"
(assoc-ref parms 'category)
(assoc-ref parms 'name))
file-name-separator-string)
file
(assoc-ref parms 'verbosity))))
(filter-map
(lambda (file)
(if (irregex-search '(or (seq bos "files" eos)
(seq ".ebuild" eos ))
file)
file
#f))
(if (file-exists? src-path)
(scandir src-path)
'()))))))
(define-public clean-files
(lambda (file-list file-folder verbosity)
(define-public clean-ebuilds
(lambda (pkg-list repo verbosity)
""
(letrec* ((for-each-file
(lambda (sub-path)
(lambda (sub-path category pkg)
(append-map
(lambda (file)
(let ((path (string-join (list file-folder sub-path file)
(let ((path (string-join (list repo category pkg sub-path file)
file-name-separator-string)))
(if (not (or (char=? (car (string->list file)) #\.)
(string=? file "Manifest")))
@ -311,35 +325,59 @@
(for-each-file (string-join (if (string=? sub-path "")
(list file)
(list sub-path file))
file-name-separator-string))
file-name-separator-string)
category pkg)
(list (string-join (if (string=? sub-path "")
(list file)
(list sub-path file))
file-name-separator-string)))
'())))
(scandir (string-join (list file-folder sub-path)
(scandir (string-join (list repo category pkg sub-path)
file-name-separator-string))))))
;; (display "file-list:") (newline)
;; (pretty-print file-list)
;; (display "each-file:") (newline)
;; (pretty-print (for-each-file ""))
;; (display "to-clean:") (newline)
;; (pretty-print (filter-map (lambda (file)
;; (if (any (lambda (a)
;; (string=? a file))
;; file-list)
;; #false file))
;; (for-each-file "")))
(for-each (lambda (absolute-file)
(if (>= verbosity verbosity-notice)
(begin (display "Cleaned absolute file \"")
(display absolute-file) (display "\"")
(newline)))
(delete-file (string-join (list file-folder absolute-file)
file-name-separator-string)))
(filter-map (lambda (file)
(if (any (lambda (a)
(string=? a file))
file-list)
#false file))
(for-each-file ""))))))
(for-each (lambda (pkg)
(for-each (lambda (absolute-file)
(delete-file (string-join (list repo
(assoc-ref pkg 'category)
(assoc-ref pkg 'name)
absolute-file)
file-name-separator-string))
(if (>= verbosity verbosity-notice)
(begin (display "Cleaned absolute pkg file \"")
(display absolute-file) (display "\"")
(newline))))
(filter-map (lambda (file)
(if (any (lambda (pkg)
(any (lambda (pkg-file)
(string=? pkg-file file))
(assoc-ref pkg 'pkgfiles)))
pkg-list)
#false file))
(for-each-file ""
(assoc-ref pkg 'category)
(assoc-ref pkg 'name)))))
pkg-list))))
(define-public clean-cache
(lambda (gen-list cache-path verbosity)
""
(for-each (lambda (absolute-file)
(delete-file (string-join (list cache-path absolute-file)
file-name-separator-string))
(if (>= verbosity verbosity-notice)
(begin (display "Cleaned absolute cache file \"")
(display absolute-file) (display "\"")
(newline))))
(filter-map (lambda (file)
(if (any (lambda (pkg)
(if (assoc-ref pkg 'distfiles)
(any (lambda (pkg-file)
(string=? pkg-file file))
(assoc-ref pkg 'distfiles))
#f))
gen-list)
#false file))
(filter-map (lambda (file)
(cond ((string=? "." file) #f)
((string=? ".." file) #f)
(else file)))
(scandir cache-path))))))