V0.0.3 Nodejs support.
This commit is contained in:
parent
9c4c35fdd6
commit
54f494163a
17 changed files with 1871 additions and 484 deletions
298
ebuild/cli.scm
298
ebuild/cli.scm
|
|
@ -1,6 +1,6 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; cli.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
|
||||
|
|
@ -20,10 +20,12 @@
|
|||
#:use-module (ice-9 pretty-print)
|
||||
#:use-module (ice-9 receive)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-19)
|
||||
#:use-module (dql dql)
|
||||
#:use-module (ebuild defs)
|
||||
#:use-module (ebuild repo)
|
||||
#:use-module (ebuild gen)
|
||||
#:use-module (ebuild utils)
|
||||
#:use-module (ebuild version)
|
||||
#:use-module (config)
|
||||
#:use-module (config api)
|
||||
|
|
@ -62,6 +64,10 @@
|
|||
(name 'init-from) (default "") (test string?)
|
||||
(example "https://www.cor.za.net/code/portage-overlay")
|
||||
(synopsis "An url to initialize the repo from scratch"))
|
||||
(switch
|
||||
(name 'min-interval) (default "7d") (test string?)
|
||||
(example "7D")
|
||||
(synopsis "Minimum interval in witch to update packages in Seconds Minutes Hours or Days"))
|
||||
;;TODO figure out how to use non parameter options from the command
|
||||
;; line instead of this.
|
||||
(switch
|
||||
|
|
@ -90,7 +96,12 @@ authentication when pulling package updates from github."))
|
|||
(example "/tmp/ebuild-autogen/")
|
||||
(handler identity) (test string?)
|
||||
(synopsis "Temporary files path.")
|
||||
(description "Full path to the folder for the temporary files."))))
|
||||
(description "Full path to the folder for the temporary files."))
|
||||
(setting
|
||||
(name 'curl-retries) (default 3) (character #f)
|
||||
(example "3") (handler string->number) (test integer?)
|
||||
(synopsis "curl retry count.")
|
||||
(description "The amount of retries for curl."))))
|
||||
(synopsis "Auto generate Gentoo ebuild's")
|
||||
(description "ebuild-autogen is a Guile scheme application to auto generate
|
||||
gentoo ebuild package definitions from the \"autogen.scm\" specification for
|
||||
|
|
@ -126,7 +137,18 @@ git repository.")
|
|||
(cons 'verbosity (option-ref options 'verbosity))
|
||||
(cons 'cache-path (option-ref options
|
||||
'filecache-path))
|
||||
(cons 'tmp-path (option-ref options 'tmp-path)))))
|
||||
(cons 'tmp-path (option-ref options 'tmp-path))
|
||||
(cons 'age-limit
|
||||
(if (or (option-ref options 'pkg-clean)
|
||||
(option-ref options 'ebuild-clean)
|
||||
(option-ref options 'cache-clean))
|
||||
(begin (display "Warning, ignoring min-interval to clean files!")
|
||||
(current-time))
|
||||
(subtract-duration
|
||||
(current-time)
|
||||
(string->duration
|
||||
(option-ref options
|
||||
'min-interval))))))))
|
||||
;; Update the source repository if requested.
|
||||
(if (option-ref options 'submodule-update)
|
||||
(repo-update-src folder))
|
||||
|
|
@ -140,6 +162,12 @@ git repository.")
|
|||
(assoc-set! parms
|
||||
'github-token
|
||||
(option-ref options 'github-token))))
|
||||
|
||||
;; The curl retries setting.
|
||||
(set! parms
|
||||
(assoc-set! parms
|
||||
'curl-retries
|
||||
(option-ref options 'curl-retries)))
|
||||
|
||||
(with-exception-handler
|
||||
(lambda (exception)
|
||||
|
|
@ -197,126 +225,178 @@ git repository.")
|
|||
".gitignore-repo"
|
||||
(option-ref options 'verbosity)
|
||||
#:file-dst ".gitignore")
|
||||
(cp-repo-file repo
|
||||
""
|
||||
"autogen/"
|
||||
"eclass"
|
||||
(option-ref options 'verbosity)
|
||||
#:required #f)
|
||||
(cp-repo-file repo
|
||||
""
|
||||
"autogen/"
|
||||
"license"
|
||||
(option-ref options 'verbosity)
|
||||
#:required #f)
|
||||
|
||||
;; Preform ebuild generation.
|
||||
(let ((pkg-list (build-pkg-list repo folder #t)))
|
||||
(let ((pkg-list (build-pkg-list repo folder #t))
|
||||
(same-pkg? (lambda (a b)
|
||||
(and (string=? (assoc-ref a 'category)
|
||||
(assoc-ref b 'category))
|
||||
(string=? (assoc-ref a 'name)
|
||||
(assoc-ref b 'name))))))
|
||||
(if (>= (option-ref options 'verbosity)
|
||||
verbosity-warn)
|
||||
(begin (display "package-list:") (newline)
|
||||
(pretty-print pkg-list)))
|
||||
(let ((cache-files-used
|
||||
(append-map (lambda (pkg)
|
||||
(let ((name (string->symbol (assoc-ref pkg 'name)))
|
||||
(cat (string->symbol (assoc-ref pkg 'category))))
|
||||
(if (>= (option-ref options 'verbosity)
|
||||
verbosity-notice)
|
||||
(begin (display "pkg:") (newline)
|
||||
(pretty-print (append parms pkg))))
|
||||
(with-exception-handler
|
||||
(lambda (exception)
|
||||
(if (>= (option-ref options 'verbosity)
|
||||
verbosity-error)
|
||||
(begin
|
||||
(display "Failed to update the package ")
|
||||
(display (assoc-ref pkg 'category))
|
||||
(display "/")
|
||||
(display (assoc-ref pkg 'name))
|
||||
(display " with")
|
||||
(if (exception-with-message? exception)
|
||||
(display
|
||||
(simple-format
|
||||
#f " exception-message: \"~a\""
|
||||
(exception-message exception))))
|
||||
(if (and (exception-with-message? exception)
|
||||
(exception-with-irritants? exception))
|
||||
(display " and"))
|
||||
(if (exception-with-irritants? exception)
|
||||
(display
|
||||
(simple-format
|
||||
#f " exception-irritants: \"~a\""
|
||||
(exception-irritants exception))))
|
||||
(newline)))
|
||||
'())
|
||||
(lambda ()
|
||||
(let* ((pkg-mod (resolve-module `(,cat ,name autogen)))
|
||||
(pkg-parms (append parms pkg))
|
||||
(distfiles-used '())
|
||||
(pkgfiles-used
|
||||
(if pkg-mod
|
||||
(let ((releases
|
||||
(if (module-variable pkg-mod 'get-releases)
|
||||
((module-ref pkg-mod 'get-releases)
|
||||
(append parms pkg))
|
||||
'())))
|
||||
(append
|
||||
;; Setup the folder and links for the package.
|
||||
(if (module-variable pkg-mod 'setup-package)
|
||||
((module-ref pkg-mod 'setup-package)
|
||||
pkg-parms)
|
||||
(setup-pkg pkg-parms))
|
||||
;; Generate the ebuilds.
|
||||
(receive (pkg-files dist-files)
|
||||
(if (module-variable pkg-mod 'generate-ebuilds)
|
||||
((module-ref pkg-mod 'generate-ebuilds)
|
||||
pkg-parms
|
||||
releases)
|
||||
(ebuild-gen pkg-parms
|
||||
releases))
|
||||
(set! distfiles-used
|
||||
(append distfiles-used dist-files))
|
||||
pkg-files)))
|
||||
(setup-pkg pkg-parms))))
|
||||
(if (option-ref options 'ebuild-clean)
|
||||
(clean-files pkgfiles-used
|
||||
(string-join (list repo
|
||||
(assoc-ref pkg 'category)
|
||||
(assoc-ref pkg 'name))
|
||||
file-name-separator-string)
|
||||
(option-ref options 'verbosity)))
|
||||
(display "Done with package: ")
|
||||
(display (assoc-ref pkg 'category))
|
||||
(display "/")
|
||||
(display (assoc-ref pkg 'name))
|
||||
(newline)
|
||||
distfiles-used))
|
||||
#:unwind? (< 1 (length pkg-list)))))
|
||||
pkg-list)))
|
||||
(let* ((cache-files-used
|
||||
(append-map (lambda (pkg)
|
||||
(let ((name (string->symbol (assoc-ref pkg 'name)))
|
||||
(cat (string->symbol (assoc-ref pkg 'category))))
|
||||
(if (>= (option-ref options 'verbosity)
|
||||
verbosity-notice)
|
||||
(begin (display "pkg:") (newline)
|
||||
(pretty-print (append parms pkg))))
|
||||
(with-exception-handler
|
||||
(lambda (exception)
|
||||
(if (>= (option-ref options 'verbosity)
|
||||
verbosity-error)
|
||||
(begin
|
||||
(display "Failed to update the package ")
|
||||
(display (assoc-ref pkg 'category))
|
||||
(display "/")
|
||||
(display (assoc-ref pkg 'name))
|
||||
(display " with")
|
||||
(if (exception-with-message? exception)
|
||||
(display
|
||||
(simple-format
|
||||
#f " exception-message: \"~a\""
|
||||
(exception-message exception))))
|
||||
(if (and (exception-with-message? exception)
|
||||
(exception-with-irritants? exception))
|
||||
(display " and"))
|
||||
(if (exception-with-irritants? exception)
|
||||
(display
|
||||
(simple-format
|
||||
#f " exception-irritants: \"~a\""
|
||||
(exception-irritants exception))))
|
||||
(newline)))
|
||||
'())
|
||||
(lambda ()
|
||||
(let* ((pkg-mod (resolve-module `(,cat ,name autogen)))
|
||||
(pkg-parms (append parms pkg))
|
||||
(pkgfiles-used
|
||||
(if pkg-mod
|
||||
;; Setup the folder and links for the package.
|
||||
(let* ((setup-files ((if (module-variable pkg-mod 'setup-package)
|
||||
(module-ref pkg-mod 'setup-package)
|
||||
setup-pkg)
|
||||
pkg-parms))
|
||||
;; Fetch the releases.
|
||||
(releases
|
||||
(if (module-variable pkg-mod 'get-releases)
|
||||
((module-ref pkg-mod 'get-releases)
|
||||
pkg-parms)
|
||||
'()))
|
||||
;; Generate the ebuilds.
|
||||
(pkg-gen ((if (module-variable pkg-mod 'generate-ebuilds)
|
||||
(module-ref pkg-mod 'generate-ebuilds)
|
||||
ebuild-gen)
|
||||
(assoc-set! pkg-parms
|
||||
'pkgfiles
|
||||
setup-files)
|
||||
releases)))
|
||||
;; Populate package if no ebuilds generated.
|
||||
(if (null? pkg-gen)
|
||||
(list (list (cons 'category (assoc-ref pkg-parms 'category))
|
||||
(cons 'name (assoc-ref pkg-parms 'name))
|
||||
(cons 'pkgfiles setup-files)))
|
||||
pkg-gen))
|
||||
(setup-pkg pkg-parms))))
|
||||
(display "Done with package: ")
|
||||
(display (assoc-ref pkg 'category))
|
||||
(display "/")
|
||||
(display (assoc-ref pkg 'name))
|
||||
(newline)
|
||||
(if (>= (option-ref options 'verbosity)
|
||||
verbosity-notice)
|
||||
(begin (display "package results:") (newline)
|
||||
(pretty-print pkgfiles-used)))
|
||||
pkgfiles-used))
|
||||
#:unwind? (< 1 (length pkg-list)))))
|
||||
pkg-list))
|
||||
(unique-pkgfiles
|
||||
(map (lambda (pkg)
|
||||
(set! pkg
|
||||
(assoc-set! pkg
|
||||
'pkgfiles
|
||||
(delete-duplicates
|
||||
(append-map (lambda (p)
|
||||
(if (same-pkg? pkg p)
|
||||
(if (assoc-ref p 'pkgfiles)
|
||||
(assoc-ref p 'pkgfiles)
|
||||
'())
|
||||
'()))
|
||||
cache-files-used)
|
||||
string=?)))
|
||||
(set! pkg (assoc-set! pkg
|
||||
'distfiles
|
||||
(delete-duplicates
|
||||
(append-map (lambda (p)
|
||||
(if (same-pkg? pkg p)
|
||||
(if (assoc-ref p 'distfiles)
|
||||
(assoc-ref p 'distfiles)
|
||||
'())
|
||||
'()))
|
||||
cache-files-used)
|
||||
string=?)))
|
||||
pkg)
|
||||
(delete-duplicates cache-files-used
|
||||
same-pkg?))))
|
||||
;; Clean deprecated pkgfiles.
|
||||
(if (option-ref options 'ebuild-clean)
|
||||
(clean-ebuilds unique-pkgfiles
|
||||
repo
|
||||
(option-ref options 'verbosity)))
|
||||
;; Clean deprecated cache files if requested.
|
||||
(if (>= (option-ref options 'verbosity)
|
||||
verbosity-notice)
|
||||
(begin (display "distfiles-used:") (newline)
|
||||
(pretty-print cache-files-used)
|
||||
(display "\"") (newline)))
|
||||
(begin ;; (display "generated results:") (newline)
|
||||
;; (pretty-print cache-files-used)
|
||||
(display "generated pkgs:") (newline)
|
||||
(pretty-print unique-pkgfiles)))
|
||||
(if (and (or (string=? folder repo)
|
||||
(string=? folder
|
||||
(string-join (list repo "autogen")
|
||||
file-name-separator-string)))
|
||||
(option-ref options 'cache-clean))
|
||||
(clean-files cache-files-used
|
||||
(option-ref options 'filecache-path)
|
||||
(option-ref options 'verbosity))))
|
||||
|
||||
;; The extra folders in repo not in src.
|
||||
(let ((repo-pkgs (build-pkg-list repo folder #f)))
|
||||
(map (lambda (pkg)
|
||||
(if (null? ((dql (filter (where (lambda (val)
|
||||
(string=? val
|
||||
(assoc-ref pkg 'category)))
|
||||
'category)
|
||||
(where (lambda (val)
|
||||
(string=? val
|
||||
(assoc-ref pkg 'name)))
|
||||
'name)))
|
||||
pkg-list))
|
||||
(if (>= (option-ref options 'verbosity)
|
||||
verbosity-warn)
|
||||
(begin (display "Absolute pkg ")
|
||||
(display (assoc-ref pkg 'category))
|
||||
(display "/")
|
||||
(display (assoc-ref pkg 'name))
|
||||
(display " found.")
|
||||
(newline)))))
|
||||
repo-pkgs)))
|
||||
(clean-cache cache-files-used
|
||||
(option-ref options 'filecache-path)
|
||||
(option-ref options 'verbosity)))
|
||||
;; The extra folders in repo not in src.
|
||||
(if (and (or (string=? folder repo)
|
||||
(string=? folder
|
||||
(string-join (list repo "autogen")
|
||||
file-name-separator-string)))
|
||||
(option-ref options 'pkg-clean))
|
||||
(let ((repo-pkgs (build-pkg-list repo folder #f)))
|
||||
(map (lambda (pkg)
|
||||
(if (not (any (lambda (list-pkg)
|
||||
(same-pkg? list-pkg pkg))
|
||||
cache-files-used))
|
||||
(begin (if (>= (option-ref options 'verbosity)
|
||||
verbosity-warn)
|
||||
(begin (display "Absolute pkg ")
|
||||
(display (assoc-ref pkg 'category))
|
||||
(display "/")
|
||||
(display (assoc-ref pkg 'name))
|
||||
(display " deleted.")
|
||||
(newline)))
|
||||
(delete-file (string-join (list repo
|
||||
(assoc-ref pkg 'category)
|
||||
(assoc-ref pkg 'name))
|
||||
file-name-separator-string)))))
|
||||
repo-pkgs)))))
|
||||
|
||||
;; Commit and push the updates to master if requested.
|
||||
(if (option-ref options 'remote-push)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue