On this page:
2.1 Ebuild Class
ebuild%
new
create-list
create
save
append!
concat!
2.2 Metadata Class
metadata%
new
create
save
2.3 Package Class
package%
new
get-versions
get-PVs
get-CATEGORY/  PN
get-Ps
show
save
2.4 Repository Class
repository%
new
show
layout-string
save-layout
save-name
save-packages
save
8.5

2 Ebuild - Classes

 (require ebuild) package: ebuild-lib

ebuild module reexports functions from the class module and modules included in this section, that is: ebuild/ebuild, ebuild/metadata, ebuild/package and ebuild/repository

2.1 Ebuild Class

 (require ebuild/ebuild) package: ebuild-lib

class

ebuild% : class?

  superclass: object%

  extends: printable<%>
Ebuild class.
For creating package ebuild files ("package.ebuild").

constructor

(new ebuild% 
    [[year year] 
    [EAPI EAPI] 
    [custom custom] 
    [inherits inherits] 
    [DESCRIPTION DESCRIPTION] 
    [HOMEPAGE HOMEPAGE] 
    [SRC_URI SRC_URI] 
    [S S] 
    [LICENSE LICENSE] 
    [SLOT SLOT] 
    [KEYWORDS KEYWORDS] 
    [IUSE IUSE] 
    [REQUIRED_USE REQUIRED_USE] 
    [RESTRICT RESTRICT] 
    [COMMON_DEPEND COMMON_DEPEND] 
    [RDEPEND RDEPEND] 
    [DEPEND DEPEND] 
    [BDEPEND BDEPEND] 
    [IDEPEND IDEPEND] 
    [PDEPEND PDEPEND] 
    [DOCS DOCS] 
    [PATCHES PATCHES] 
    [QA_PREBUILT QA_PREBUILT] 
    [QA_TEXTRELS QA_TEXTRELS] 
    [QA_EXECSTACK QA_EXECSTACK] 
    [QA_WX_LOAD QA_WX_LOAD] 
    [QA_FLAGS_IGNORED QA_FLAGS_IGNORED] 
    [QA_MULTILIB_PATHS QA_MULTILIB_PATHS] 
    [QA_PRESTRIPPED QA_PRESTRIPPED] 
    [QA_SONAME QA_SONAME] 
    [QA_SONAME_NO_SYMLINK QA_SONAME_NO_SYMLINK] 
    [QA_AM_MAINTAINER_MODE QA_AM_MAINTAINER_MODE] 
    [QA_CONFIGURE_OPTIONS QA_CONFIGURE_OPTIONS] 
    [QA_DT_NEEDED QA_DT_NEEDED] 
    [QA_DESKTOP_FILE QA_DESKTOP_FILE] 
    [body body]]) 
  (is-a?/c ebuild%)
  year : integer? = (date-year (current-date))
  EAPI : integer? = 8
  custom : (listof (or/c (-> any) string?)) = '()
  inherits : (listof string?) = '()
  DESCRIPTION : string? = "package"
  HOMEPAGE : string?
   = "https://wiki.gentoo.org/wiki/No_homepage"
  SRC_URI : (listof src-uri?) = '()
  S : (or/c #f string?) = #f
  LICENSE : string? = "all-rights-reserved"
  SLOT : string? = "0"
  KEYWORDS : (listof string?) = '("~amd64")
  IUSE : (listof string?) = '()
  REQUIRED_USE : (listof cflag?) = '()
  RESTRICT : (listof (or/c cflag? string?)) = '()
  COMMON_DEPEND : (listof (or/c cflag? string?)) = '()
  RDEPEND : (listof (or/c cflag? string?)) = '()
  DEPEND : (listof (or/c cflag? string?)) = '()
  BDEPEND : (listof (or/c cflag? string?)) = '()
  IDEPEND : (listof (or/c cflag? string?)) = '()
  PDEPEND : (listof (or/c cflag? string?)) = '()
  DOCS : (listof string?) = '()
  PATCHES : (listof string?) = '()
  QA_PREBUILT : (listof string?) = '()
  QA_TEXTRELS : (listof string?) = '()
  QA_EXECSTACK : (listof string?) = '()
  QA_WX_LOAD : (listof string?) = '()
  QA_FLAGS_IGNORED : (listof string?) = '()
  QA_MULTILIB_PATHS : (listof string?) = '()
  QA_PRESTRIPPED : (listof string?) = '()
  QA_SONAME : (listof string?) = '()
  QA_SONAME_NO_SYMLINK : (listof string?) = '()
  QA_AM_MAINTAINER_MODE : (listof string?) = '()
  QA_CONFIGURE_OPTIONS : (listof string?) = '()
  QA_DT_NEEDED : (listof string?) = '()
  QA_DESKTOP_FILE : (listof string?) = '()
  body : (listof (or/c (-> any) string?)) = '()

method

(send an-ebuild create-list)  list?

Creates a list that contains strings or false as elements. The elaments of the list are created using the "unroll" functions which are not exposed to the user.

Also, concatenates values that custom and body arguments return.

method

(send an-ebuild create)  string?

Takes non-false elemets of the list created by create-list method and turns them into one string ready to be written into a file (by save for example).

method

(send an-ebuild save name [pth])  void

  name : string?
  pth : path-string? = (current-directory)
Creates a file named name in the given location pth (or current directory). Internally uses the interfece implemented by this object’s printable<%> to dispaly this to file.

method

(send an-ebuild append! sym lst)  void

  sym : symbol?
  lst : list?
Uses dynamic-get-field and dynamic-set-field!. Sets the field-name represented by sym symbol of this object to that field appended with lst list.

method

(send an-ebuild concat! sym v)  void

  sym : symbol?
  v : any/c
Like append! but a list is automatically generated from v.

Examples:
> (define my-ebuild
    (new ebuild%
         [IUSE (list "debug" "test")]
         [RESTRICT (list (cflag "test?" (list "debug")))]))
> (display my-ebuild)

# Copyright 1999-2022 Gentoo Authors

# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="A package description"

HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage"

LICENSE="all-rights-reserved"

SLOT="0"

KEYWORDS="~amd64"

IUSE="debug test"

RESTRICT="test? ( debug ) mirror"

2.2 Metadata Class

 (require ebuild/metadata) package: ebuild-lib

class

metadata% : class?

  superclass: object%

  extends: printable<%>
Metadata class.
For crating package metadata files ("metadata.xml").

constructor

(new metadata% 
    [[maintainers maintainers] 
    [longdescriptions longdescriptions] 
    [slots slots] 
    [stabilize-allarches stabilize-allarches] 
    [uses uses] 
    [upstream upstream]]) 
  (is-a?/c metadata%)
  maintainers : (listof maintainer?) = '()
  longdescriptions : (listof longdescription?) = '()
  slots : (listof slots?) = '()
  stabilize-allarches : boolean? = #f
  uses : (listof use?) = '()
  upstream : (or/c #f upstream?) = #f

method

(send a-metadata create)  document?

Creates a XML document ready to be written into a file.

method

(send a-metadata save [pth])  void

  pth : path-string? = (current-directory)
Creates a file named "metadata.xml" in the given location (or current directory). Internally uses the interfece implemented by this object’s printable<%> to dispaly object to file.

Examples:
> (define my-metadata
    (new metadata%
         [maintainers
          (list (maintainer 'person #f "me@me.com" "Me" #f))]
         [upstream
          (upstream (list)
                    #f
                    #f
                    #f
                    (list (remote-id 'gitlab "me/myproject")))]))
> (display my-metadata)

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">

<pkgmetadata>

  <maintainer type="person">

    <email>me@me.com</email>

    <name>Me</name>

  </maintainer>

  <upstream>

    <remote-id type="gitlab">me/myproject</remote-id>

  </upstream>

</pkgmetadata>

2.3 Package Class

 (require ebuild/package) package: ebuild-lib

class

package% : class?

  superclass: object%

Package class.
For creating packages.

constructor

(new package%    
    [[CATEGORY CATEGORY]    
    [PN PN]    
    [ebuilds ebuilds]    
    [metadata metadata]])  (is-a?/c package%)
  CATEGORY : string? = "app-misc"
  PN : string? = "unknown"
  ebuilds : (hash/c package-version? (is-a?/c ebuild%))
   = (hash (live-version) (new ebuild%))
  metadata : (is-a?/c metadata%) = (new metadata%)
By default if ebuilds are not given the default ebuild% object (with PN set to "unknown" is used) and if metadata is not given default "empty" metadata% object is used.

method

(send a-package get-versions)  (listof package-version?)

Return a list of package-versions extracted from ebuilds.

Example:
> (send (new package%) get-versions)

(list (package-version "9999" #f #f #f #f #f))

method

(send a-package get-PVs)  (listof string?)

Return a list of package-versions as strings extracted from ebuilds.

Example:
> (send (new package%) get-PVs)

'("9999")

method

(send a-package get-CATEGORY/PN)  string?

Return a string composed of: CATEGORY, "/" and PN.

Example:
> (send (new package%) get-CATEGORY/PN)

"app-misc/unknown"

method

(send a-package get-Ps)  (listof string?)

Return a list of package-versions joined with get-CATEGORY/PN.

Example:
> (send
   (new package%
        [CATEGORY  "dev-scheme"]
        [PN  "bytes"]
        [ebuilds
         (hash (simple-version "1") (new ebuild%)
               (simple-version "2") (new ebuild%))])
   get-Ps)

'("dev-scheme/bytes-1" "dev-scheme/bytes-2")

method

(send a-package show)  void

Display ebuilds and metadata.

Example:
> (send (new package%) show)

CATEGORY/PN: app-misc/unknown

PV: 9999

# Copyright 1999-2022 Gentoo Authors

# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="A package description"

HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage"

LICENSE="all-rights-reserved"

SLOT="0"

KEYWORDS="~amd64"

RESTRICT="mirror"

METADATA:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">

<pkgmetadata>

</pkgmetadata>

method

(send a-package save [pth])  void

  pth : path-string? = (current-directory)
Creates (uses their save methods) ebuilds and metadata of this package. The names of ebuilds are equal to so-called P ebuild variable which is composed of PN (taken from this package% object) and PV (version, taken from the ebuilds hash). So ebuilds will be saved as "P.ebuild".

2.4 Repository Class

 (require ebuild/repository) package: ebuild-lib

class

repository% : class?

  superclass: object%

Repository class.
For creating ebuild repository structures.

constructor

(new repository%    
    [name name]    
    [[layout layout]]    
    [packages packages])  (is-a?/c repository%)
  name : string?
  layout : layout? = (default-layout)
  packages : (listof (is-a?/c package%))
By default if layout is not given default-layout (parameter variable) is used.

method

(send a-repository show)  void

Display repository name, layout and packages it contains.

method

(send a-repository layout-string)  string?

Wrapper for layout->string.

method

(send a-repository save-layout [pth])  void

  pth : path-string? = (current-directory)
Creates directory "metadata" with a file "layout.conf" in the given location (or current directory).

method

(send a-repository save-name [pth])  void

  pth : path-string? = (current-directory)
Creates directory "profiles" with a file "repo_name" in the given location (or current directory).

method

(send a-repository save-packages [pth])  void

  pth : path-string? = (current-directory)
Creates directory "CATEGORY/PN" with a "metadata.xml" file and "P.ebuild" ebuilds in the given location (or current directory).

method

(send a-repository save [pth])  void

  pth : path-string? = (current-directory)
Creates a full ebuild repository directory structure. (uses save-layout, save-name and save-packages).

Examples:
> (define r
    (new repository%
         [name "test"]
         [packages
          (list
           (new package%
                [CATEGORY "sys-devel"]
                [PN "asd"]
                [ebuilds (hash (simple-version "1.1.1") (new ebuild%))]
                [metadata
                 (new metadata%
                      [upstream
                       (upstream
                        (list) #f #f #f (list (remote-id 'gitlab "asd/asd")))])]))]))
> (display (send r layout-string))

cache-formats = md5-dict

eapis-banned = 0 1 2 3 4 5 6

eapis-deprecated =

manifest-hashes = BLAKE2B SHA512

manifest-required-hashes = BLAKE2B

masters = gentoo

sign-commits = true

sign-manifests = false

thin-manifests = true

update-changelog = false

> (send r show)

Repository name:

test

Repository layout:

cache-formats = md5-dict

eapis-banned = 0 1 2 3 4 5 6

eapis-deprecated =

manifest-hashes = BLAKE2B SHA512

manifest-required-hashes = BLAKE2B

masters = gentoo

sign-commits = true

sign-manifests = false

thin-manifests = true

update-changelog = false

Repository packages:

CATEGORY/PN: sys-devel/asd

PV: 1.1.1

# Copyright 1999-2022 Gentoo Authors

# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="A package description"

HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage"

LICENSE="all-rights-reserved"

SLOT="0"

KEYWORDS="~amd64"

RESTRICT="mirror"

METADATA:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">

<pkgmetadata>

  <upstream>

    <remote-id type="gitlab">asd/asd</remote-id>

  </upstream>

</pkgmetadata>