On this page:
3.1 Ebuild Functions
3.1.1 Source URL
src-uri
src-uri-src
src-uri->string
3.1.2 Shell Variables
list-as-variable
as-variable
make-variable
list-as-array-variable
as-array-variable
make-array-variable
3.1.3 Object manipulation
ebuild-append!
ebuild-concat!
3.2 Shell Script Functions
3.2.1 POSIX shell script function creation
sh-function
sh-function->string
unroll-sh-functions
make-script
conditional-depend
3.3 Metadata Functions
3.3.1 XML tags
metadata-empty-tags
3.3.2 longdescription
longdescription
longdescription->xexpr
3.3.3 maintainer
maintainer
maintainer->xexpr
3.3.4 slots
slot
slots
slots->xexpr
3.3.5 upstream
upstreammaintainer
remote-id
upstream
upstream->xexpr
3.3.6 use
flag
use
use->xexpr
3.4 Package Functions
3.4.1 Package Version
release?
package-version
live-version
simple-version
package-version->string
3.5 Repository Functions
3.5.1 Layout
layout
default-layout
layout->string
8.2

3 Ebuild - Exported Functions

Functions used to be prefixed with "ebuild:" and "metadata:". If you still wish to keep this naming scheme, use:
(require (prefix-in ebuild: ebuild/ebuild)
         (prefix-in metadata: ebuild/metadata))

3.1 Ebuild Functions

3.1.1 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?)
Struct to hold URLs of SRC_URI.

Fields represent inside a ebuild:
  • 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
Creates a source string from given src-uri.

Example:
> (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
Creates a source string, with optional flag, from given src-uri.

Example:
> (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.2 Shell Variables

procedure

(list-as-variable name lst)  (or/c #f string?)

  name : string?
  lst : (or/c #f (listof (or/c number? string? symbol?)))
Returns a string that can be used in creating POSIX-like shell scripts. "name=\"value\"" if only value in list lst is a string or 2 or more of any type of values or "name=value" if given list lst with one value that is a number or symbol. If #f is given as lst, then #f is returned.

Examples:
> (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?))
Wrapper for list-as-variable.

Example:
> (as-variable "TURN_ON_FEATURE" 'YES)

"TURN_ON_FEATURE=YES"

syntax

(make-variable name)

 
  name : (or/c identifier? string? symbol?)
Uses as-variable. If name is an identifier, then it is the name of variable and the value is what that name resolves to. If name is a string or a symbol then it is passed to both name and value of as-variable (symbol is converted to a string).

Examples:
> (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?)))
Simialr to list-as-variable, except for arrays.

Example:
> (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?))
Wrapper for list-as-variable.

Example:
> (as-array-variable "FEATURES" "mirror" "test")

"FEATURES=(\"mirror\" \"test\")"

syntax

(make-array-variable name)

 
  name : (or/c identifier? string? symbol?)

Examples:
> (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.3 Object manipulation

syntax

(ebuild-append! id obj lst)

 
  id : identifier?
  obj : (is-a? ebuild%)
  lst : list?
Calls append! method of a given obj ebuild% object.

syntax

(ebuild-concat! id obj v)

 
  id : identifier?
  obj : (is-a? ebuild%)
  v : any/c
Calls concat! method of a given obj ebuild% object.

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?

procedure

(sh-function->string sf)  string?

  sf : sh-function?
Creates a string that looks like a function from as POSIX shell script.

procedure

(unroll-sh-functions lst)  string?

  lst : (listof sh-function?)
Uses sh-function->string to create a shell script body string. Basically it is some POSIX shell script functions.

procedure

(make-script indent strs ...)  string?

  indent : exact-integer?
  strs : string?
Produces a shell script body from any amount of given strings, with the indentation indent represented by tab characters (this its to comply with the ebuild format where we indent with tabs).

This function exists to ease writing custom ebuild (shell script) functions.

procedure

(conditional-depend condition    
  dependencies ...+)  string?
  condition : string?
  dependencies : string?
Produses a ebuild condition to manpiulate dependencies.

This function exists to ease writing custom ebuild depedndencies (*DEPEND).

For more info see Devmanual: Use-Conditional Dependencies

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?

(metadata-empty-tags list)  void?
  list : list?
 = (list 'stabilize-allarches)
Parameter that determines shorthanded tags list passed to empty-tag-shorthand.

3.3.2 longdescription

struct

(struct longdescription (lang data)
    #:extra-constructor-name make-longdescription)
  lang : (or/c #f string? symbol?)
  data : string?

procedure

(longdescription->xexpr ld)  xexpr?

  ld : longdescription?
Converts ld longdescription struct to a x-expression.

3.3.3 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?
Converts maint maintainer struct to a x-expression.

3.3.4 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?
Converts ss slots struct to a x-expression.

3.3.5 upstream

struct

(struct upstreammaintainer (status email name)
    #:extra-constructor-name make-upstreammaintainer)
  status : (or/c 'active 'inactive 'unknown)
  email : string?
  name : string?

struct

(struct remote-id (type tracker)
    #:extra-constructor-name make-remote-id)
  type : 
(or/c
 'bitbucket 'cpan 'cpan-module 'cpe 'cran 'ctan
 'freecode 'freshmeat
 'gentoo 'github 'gitlab 'gitorious 'google-code
 'heptapod
 'launchpad
 'pear 'pecl 'pypi
 'rubyforge 'rubygems 'sourceforge 'sourceforge-jp
 'vim)
  tracker : string?

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?)
  bugs-to : (or/c #f string?)
  remote-ids : (listof remote-id?)

procedure

(upstream->xexpr up)  xexpr?

  up : upstream?
Converts up upstream struct to a x-expression.

3.3.6 use

struct

(struct flag (name data)
    #:extra-constructor-name make-flag)
  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 flag?)

procedure

(use->xexpr us)  xexpr?

  us : use?
Converts us use struct to a x-expression.

3.4 Package Functions

3.4.1 Package Version

procedure

(release? v)  boolean?

  v : any/c
Checks if given argement passes package-version validation. True if is a string a and has only digits and dots (".") and no more than one letter at the end.

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? integer?)
  rc : (or/c boolean? integer?)
  patch : (or/c #f integer?)
  revision : (or/c #f integer?)

procedure

(live-version [nines])  package-version

  nines : (and/c positive? exact-integer?) = 4
Generates a live package-version, that is: the one that has only 9s in "release" (all other fields are false). Optional number determines athe number of 9s.

procedure

(simple-version rel)  package-version

  rel : release?
Generates a package-version with only a given rel (other fields are #f).

procedure

(package-version->string ver)  string?

  ver : package-version?
Converts package-version struct to a string.

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?

(default-layout layout)  void?
  layout : layout?
 = 
(layout
 "gentoo"
 '("md5-dict")
 #t
 #f
 '(0 1 2 3 4 5 6)
 '()
 '("BLAKE2B" "SHA512")
 '("BLAKE2B")
 #f
 #t)
Parameter that determines default layout used when creating a repository% object.

procedure

(layout->string lo)  string?

  lo : layout?
Converts lo layout struct to a string.