3 Ebuild - Exported Functions
3.1 Ebuild Functions
3.1.1 Constraint Flag
struct
(struct cflag (predicate content) #:extra-constructor-name make-cflag) predicate : (or/c #f string?) content : (listof (or/c cflag? string?))
cflags can be nested, for recursively transforming them, see cflag->string.
predicate symbolizes the logical ebuild condition to satisfy.
> (define restrict (cflag "||" (list "qt5" "gtk"))) > restrict (cflag "||" '("qt5" "gtk"))
> (cflag->string restrict) "|| ( qt5\n\tgtk )"
> (display (cflag->string restrict))
|| ( qt5
gtk )
> (define iuse (cflag "X?" (list (cflag "gtk?" (list "x11-libs/gtk+:3")) (cflag "qt5?" (list "dev-qt/qtcore:5"))))) > iuse
(cflag
"X?"
(list
(cflag "gtk?" '("x11-libs/gtk+:3"))
(cflag "qt5?" '("dev-qt/qtcore:5"))))
> (for ([i '(0 1 2)]) {define s (cflag->string iuse i)} (printf "~v~%" s) (displayln s))
"X? ( gtk? ( x11-libs/gtk+:3 )\nqt5? ( dev-qt/qtcore:5 ) )"
X? ( gtk? ( x11-libs/gtk+:3 )
qt5? ( dev-qt/qtcore:5 ) )
"X? ( gtk? ( x11-libs/gtk+:3 )\n\tqt5? ( dev-qt/qtcore:5 ) )"
X? ( gtk? ( x11-libs/gtk+:3 )
qt5? ( dev-qt/qtcore:5 ) )
"X? ( gtk? ( x11-libs/gtk+:3 )\n\t\tqt5? ( dev-qt/qtcore:5 ) )"
X? ( gtk? ( x11-libs/gtk+:3 )
qt5? ( dev-qt/qtcore:5 ) )
procedure
(cflag->string fl [tabs #:flat? flat?]) → string?
fl : cflag? tabs : exact-nonnegative-integer? = 1 flat? : boolean? = #f
cflag->string calls itself recursively if a cflag is encountered inside currently given fl variable.
Each internal recursive call increments tabs by 1. If tabs is given (grater than 0), then that tab step is applied to the result.
If flat? is true, then the produced string does not contain neither tabs nor newlines.
> (cflag->string (cflag "||" (list "qt5" "gtk")) #:flat? #t) "|| ( qt5 gtk )"
3.1.2 Source URL
Functions and structs used to create SRC_URI ebuild variable.
struct
(struct src-uri (flag url name) #:extra-constructor-name make-src-uri) flag : (or/c #f string?) url : string? name : (or/c #f string?)
flag —
condition to grab given URL url —
any URL, maybe with shell variables inside name —
optional file name to which source downloaded from url will be renamd to, ie.: "${P}.tag.gz"
procedure
(src-uri-src su) → string?
su : src-uri
> (src-uri-src (src-uri "doc" "https://mywebsite.com/${PN}-docs-${PV}.zip" "${P}-docs.zip")) "https://mywebsite.com/${PN}-docs-${PV}.zip -> ${P}-docs.zip"
procedure
(src-uri->string su) → string?
su : src-uri
> (src-uri->string (src-uri "doc" "https://mywebsite.com/${PN}-docs-${PV}.zip" "${P}-docs.zip")) "doc ( https://mywebsite.com/${PN}-docs-${PV}.zip -> ${P}-docs.zip )"
3.1.3 Shell Variables
procedure
(list-as-variable name lst) → (or/c #f string?)
name : string? lst : (or/c #f (listof (or/c number? string? symbol?)))
> (list-as-variable "TURN_ON_FEATURE" '(YES)) "TURN_ON_FEATURE=YES"
> (list-as-variable "TURN_ON_FEATURES" '(THIS THAT)) "TURN_ON_FEATURES=\"THIS THAT\""
procedure
(as-variable name value ...) → (or/c #f string?)
name : string? value : (or/c #f (or/c number? string? symbol?))
> (as-variable "TURN_ON_FEATURE" 'YES) "TURN_ON_FEATURE=YES"
syntax
(make-variable name)
name : (or/c identifier? string? symbol?)
> (make-variable "this_variable_will_probably_change") "this_variable_will_probably_change=\"this_variable_will_probably_change\""
> (define Z "Zzz...") > (make-variable Z) "Z=\"Zzz...\""
procedure
(list-as-array-variable name lst) → (or/c #f string?)
name : string? lst : (or/c #f (listof (or/c number? string? symbol?)))
> (list-as-array-variable "FEATURES" '("mirror" "test")) "FEATURES=(\"mirror\" \"test\")"
procedure
(as-array-variable name value ...) → (or/c #f string?)
name : string? value : (or/c #f (or/c number? string? symbol?))
> (as-array-variable "FEATURES" "mirror" "test") "FEATURES=(\"mirror\" \"test\")"
syntax
(make-array-variable name)
name : (or/c identifier? string? symbol?)
> (make-array-variable "this_variable_will_probably_change") "this_variable_will_probably_change=(\"this_variable_will_probably_change\")"
> (define FEATURES '("mirror" "test")) > (make-array-variable FEATURES) "FEATURES=(\"mirror\" \"test\")"
3.1.4 Object manipulation
syntax
(ebuild-append! id obj lst)
id : identifier?
obj : (is-a? ebuild%)
lst : list?
syntax
(ebuild-concat! id obj v)
id : identifier?
obj : (is-a? ebuild%)
v : any/c
3.2 Shell Script Functions
(require ebuild/sh-function) | package: ebuild-lib |
3.2.1 POSIX shell script function creation
Ease the creation of ebuild scripts’ "body".
struct
(struct sh-function (name body) #:extra-constructor-name make-sh-function) name : string? body : string?
> (sh-function "my_function" "do_something || die") #<sh-function>
procedure
(sh-function->string sf) → string?
sf : sh-function?
> (display (sh-function->string (sh-function "my_function" "do_something || die")))
my_function() {
do_something || die
}
procedure
(unroll-sh-functions lst) → string?
lst : (listof sh-function?)
procedure
(make-script #:indent indent strs ...) → string?
indent : exact-integer? strs : string?
This function exists to ease writing custom ebuild (shell script) functions.
> (display (sh-function->string (sh-function "my_function" (make-script "do_something || die"))))
my_function() {
do_something || die
}
3.3 Metadata Functions
The structname->xexpr procedures are primarily used internally but are also exported because sometimes they can be handy.
3.3.1 XML tags
parameter
(metadata-empty-tags list) → void? list : list?
= (list 'stabilize-allarches)
3.3.2 localized
struct
(struct localized (lang data) #:extra-constructor-name make-localized) lang : (or/c #f string? symbol?) data : string?
procedure
(localized->xexpr lo element-name) → xexpr?
lo : localized? element-name : symbol?
3.3.3 longdescription
struct
(struct longdescription localized () #:extra-constructor-name make-longdescription)
procedure
(longdescription->xexpr ld) → xexpr?
ld : longdescription?
> (define my-longdescription (longdescription "en" "This is some package providing some very important function,\n everybody probably needs it, of course it is written in the best\n programming language starting with letter R ;D")) > (display-xml/content (xexpr->xml (longdescription->xexpr my-longdescription)))
<longdescription lang="en">
This is some package providing some very important function, everybody
probably needs it, of course it is written in the best programming language
starting with letter R ;D
</longdescription>
3.3.4 maintainer
struct
(struct maintainer (type proxied email name description) #:extra-constructor-name make-maintainer) type : (or/c 'person 'project 'unknown) proxied : (or/c #f 'yes 'no 'proxy) email : string? name : (or/c #f string?) description : (or/c #f string?)
procedure
(maintainer->xexpr maint) → xexpr?
maint : maintainer?
> (define my-maintainer (maintainer 'person #f "asd@asd.asd" "A.S.D." #f)) > (display-xml/content (xexpr->xml (maintainer->xexpr my-maintainer)))
<maintainer type="person">
<email>
asd@asd.asd
</email>
<name>
A.S.D.
</name>
</maintainer>
3.3.5 slots
struct
(struct slot (name data) #:extra-constructor-name make-slot) name : string? data : string?
struct
(struct slots (lang slotlist subslots) #:extra-constructor-name make-slots) lang : (or/c #f string? symbol?) slotlist : (or/c #f (listof slot?)) subslots : (or/c #f string?)
procedure
(slots->xexpr ss) → xexpr?
ss : slots?
> (define my-slots (slots #f (list (slot "1.9" "Provides libmypkg19.so.0")) #f)) > (display-xml/content (xexpr->xml (slots->xexpr my-slots)))
<slots>
<slot name="1.9">
Provides libmypkg19.so.0
</slot>
</slots>
3.3.6 upstream
struct
(struct upstreammaintainer (status email name) #:extra-constructor-name make-upstreammaintainer) status : (or/c #f 'active 'inactive 'unknown) email : (or/c #f string?) name : string?
struct
(struct remote-id (type tracker) #:extra-constructor-name make-remote-id)
type :
(or/c 'bitbucket 'codeberg 'cpan 'cpan-module 'cpe 'cran 'ctan 'gentoo 'github 'gitlab 'google-code 'heptapod 'launchpad 'osdn 'pear 'pecl 'pypi 'rubygems 'sourceforge 'vim) tracker : string?
struct
(struct doc localized () #:extra-constructor-name make-doc)
struct
(struct upstream (maintainers changelog doc bugs-to remote-ids) #:extra-constructor-name make-upstream) maintainers : (listof upstreammaintainer?) changelog : (or/c #f string?) doc : (or/c #f string? (listof doc?)) bugs-to : (or/c #f string?) remote-ids : (listof remote-id?)
procedure
(upstream->xexpr up) → xexpr?
up : upstream?
> (define my-upstream (upstream (list) #f #f #f (list (remote-id 'gitlab "asd/asd")))) > (display-xml/content (xexpr->xml (upstream->xexpr my-upstream)))
<upstream>
<remote-id type="gitlab">
asd/asd
</remote-id>
</upstream>
> (set-upstream-doc! my-upstream "https://asd.asd/docs.html") > (display-xml/content (xexpr->xml (upstream->xexpr my-upstream)))
<upstream>
<doc>
https://asd.asd/docs.html
</doc>
<remote-id type="gitlab">
asd/asd
</remote-id>
</upstream>
> (set-upstream-doc! my-upstream (list (doc "en" "https://asd.asd/doc.html") (doc "pl" "https://asd.asd/dok.html"))) > (display-xml/content (xexpr->xml (upstream->xexpr my-upstream)))
<upstream>
<doc lang="en">
https://asd.asd/doc.html
</doc>
<doc lang="pl">
https://asd.asd/dok.html
</doc>
<remote-id type="gitlab">
asd/asd
</remote-id>
</upstream>
3.3.7 use
struct
(struct uflag (name data) #:extra-constructor-name make-uflag) name : string? data : (or/c #f string?)
struct
(struct use (lang flags) #:extra-constructor-name make-use) lang : (or/c #f string? symbol?) flags : (listof uflag?)
procedure
(use->xexpr us) → xexpr?
us : use?
> (define my-use (use #f (list (uflag "racket" "Build using dev-scheme/racket")))) > (display-xml/content (xexpr->xml (use->xexpr my-use)))
<use>
<flag name="racket">
Build using dev-scheme/racket
</flag>
</use>
3.4 Package Functions
3.4.1 Package Version
> (release? "") #f
> (release? "0") #t
> (release? "1q") #t
> (release? "1.2.3a") #t
> (release? "1.2.3abc") #f
struct
(struct package-version (release phase pre rc patch revision) #:extra-constructor-name make-package-version) release : release? phase : (or/c #f 'a 'alpha 'b 'beta) pre : (or/c boolean? exact-nonnegative-integer?) rc : (or/c boolean? exact-nonnegative-integer?) patch : (or/c #f exact-positive-integer?) revision : (or/c #f exact-positive-integer?)
> (package-version "0a" 'beta 1 2 3 4) (package-version "0a" 'beta 1 2 3 4)
procedure
(live-version [nines]) → package-version
nines : (and/c positive? exact-integer?) = 4
> (live-version 8) (package-version "99999999" #f #f #f #f #f)
procedure
(simple-version rel) → package-version
rel : release?
> (simple-version "8.0") (package-version "8.0" #f #f #f #f #f)
procedure
(package-version->string ver) → string?
ver : package-version?
> (package-version->string (package-version "0a" 'beta 1 2 3 4)) "0a_beta_pre1_rc2_p3-r4"
> (package-version->string (live-version)) "9999"
> (package-version->string (simple-version "0a")) "0a"
3.5 Repository Functions
3.5.1 Layout
struct
(struct layout ( masters cache-formats sign-commits update-changelog eapis-banned eapis-deprecated manifest-hashes manifest-required-hashes sign-manifests thin-manifests) #:extra-constructor-name make-layout) masters : string? cache-formats : (listof string?) sign-commits : boolean? update-changelog : boolean? eapis-banned : (listof exact-integer?) eapis-deprecated : (listof exact-integer?) manifest-hashes : (listof string?) manifest-required-hashes : (listof string?) sign-manifests : boolean? thin-manifests : boolean?
parameter
(default-layout layout) → void? layout : layout?
=
(layout "gentoo" '("md5-dict") #t #f '(0 1 2 3 4 5 6) '() '("BLAKE2B" "SHA512") '("BLAKE2B") #f #t)
procedure
(layout->string lo) → string?
lo : layout?
> (display (layout->string (default-layout)))
masters = gentoo
cache-formats = md5-dict
sign-commits = true
update-changelog = false
eapis-banned = 0 1 2 3 4 5 6
eapis-deprecated =
manifest-hashes = BLAKE2B SHA512
manifest-required-hashes = BLAKE2B
sign-manifests = false
thin-manifests = true
3.6 Manifest Functions
(require ebuild/manifest) | package: ebuild-lib |
This library does not use classes but rather structs. It is implemented in Typed Racket.
This library allows reading and creating Manifests.
Manifest files hold digests and size data for every file used by the package. More info about Manifests can be found in the Gentoo Developer manual.
3.6.1 Checksum
struct
(struct checksum (type hash) #:extra-constructor-name make-checksum) type : string? hash : string?
> (checksum "BLAKE2B" "aa81a1a") (checksum "BLAKE2B" "aa81a1a")
procedure
(list->checksums lst) → (listof checksum?)
lst : (listof string?)
> (list->checksums '("BLAKE2B" "aa81a1a" "SHA521" "b6095d4")) (list (checksum "BLAKE2B" "aa81a1a") (checksum "SHA521" "b6095d4"))
procedure
(checksum->string cs) → string?
cs : checksum?
> (checksum->string (checksum "BLAKE2B" "aa81a1a")) "BLAKE2B aa81a1a"
3.6.2 Dist
struct
(struct dist (type file size checksums) #:extra-constructor-name make-dist) type : (or/c 'dist 'ebuild 'misc) file : string? size : integer? checksums : (listof checksum?)
procedure
(string->dist-type str) → (or/c 'dist 'ebuild 'misc)
str : string?
> (string->dist-type "EBUILD") 'ebuild
procedure
(dist-type->string dist-type) → string?
dist-type : (or/c 'dist 'ebuild 'misc)
> (dist-type->string 'misc) "MISC"
procedure
(string->dist str) → dist?
str : string?
> (string->dist "DIST gcc-9.4.0.tar.xz 72411232 BLAKE2B 4bb000d SHA512 dfd3500")
(dist
'dist
"gcc-9.4.0.tar.xz"
72411232
(list (checksum "BLAKE2B" "4bb000d") (checksum "SHA512" "dfd3500")))
procedure
(dist->string dst) → string?
dst : dist?
3.6.3 Manifest
struct
(struct manifest (dists) #:extra-constructor-name make-manifest) dists : (listof dist?)
procedure
(read-manifest path) → manifest?
path : path-string?
procedure
(write-manifest mnfst [out]) → void?
mnfst : manifest? out : output-port? = (current-output-port)
procedure
(save-manifest mnfst path) → void?
mnfst : manifest? path : path-string?