§2023-09-21
¶Ebuild repositories
In order for ebuilds to be available to Portage, they are placed in an ebuild repository that is configured for Portage through /etc/portage/repos.conf .
Create an ebuild repository to experiment in, while following on with this guide. The rest of the article will consider a repository in /var/db/repos/example_repository.
eselect repository makes creating a repository simple
:
- install
chroot) hc4Gentoo / # emerge -a app-eselect/eselect-repository
!!! Section 'localrepo' in repos.conf has location attribute set to nonexistent directory: '/usr/local/portage'
* IMPORTANT: 12 news items need reading for repository 'gentoo'.
* Use eselect news read to view new items.
These are the packages that would be merged, in order:
Calculating dependencies... done!
Dependency resolution took 5.87 s.
[ebuild N ] app-eselect/eselect-repository-13 USE="-test" PYTHON_SINGLE_TARGET="python3_11 -python3_10 (-python3_12)"
Would you like to merge these packages? [Yes/No]
- cretate
(chroot) hc4Gentoo / # eselect repository create example_repository
--2023-09-22 00:06:01-- https://qa-reports.gentoo.org/output/repos/repositories.xml
Resolving qa-reports.gentoo.org... 199.232.45.91, 2a04:4e42:48::347
Connecting to qa-reports.gentoo.org|199.232.45.91|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 256652 (251K) [text/xml]
Saving to: ‘/root/.cache/eselect-repo/repositories.xml’
repositories.xml 100%[=======================================================================================================>] 250.64K 898KB/s in 0.3s
2023-09-22 00:06:08 (898 KB/s) - ‘/root/.cache/eselect-repo/repositories.xml’ saved [256652/256652]
Adding example_repository to /etc/portage/repos.conf/eselect-repo.conf ...
Repository example_repository created and added
- verify
(chroot) hc4Gentoo / # ls /var/db/repos/
example_repository gentoo
(chroot) hc4Gentoo / # ls /var/db/repos/example_repository/
metadata profiles
(chroot) hc4Gentoo / # ls /var/db/repos/example_repository/metadata/
layout.conf
(chroot) hc4Gentoo / # cat /var/db/repos/example_repository/metadata/layout.conf
masters = gentoo
thin-manifests = true
sign-manifests = false
(chroot) hc4Gentoo / # ls /var/db/repos/example_repository/profiles/
repo_name
(chroot) hc4Gentoo / # cat /var/db/repos/example_repository/profiles/repo_name
example_repository
¶How to create an ebuild
Ebuilds are simply text files, in their most basic form. All that is needed to start writing ebuilds is a text editor, to provide installable software packages for Gentoo.
An exampe_repository has been set up as follows
(chroot) hc4Gentoo / # tree /var/db/repos/example_repository/
/var/db/repos/example_repository/
├── metadata
│ └── layout.conf
└── profiles
└── repo_name
3 directories, 2 files
(chroot) hc4Gentoo / # cat /var/db/repos/example_repository/metadata/layout.conf
masters = gentoo
thin-manifests = true
sign-manifests = false
(chroot) hc4Gentoo / # cat /var/db/repos/example_repository/profiles/repo_name
example_repository
Please help me to write a simple hello as
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
return 0;
}
using ebuild script inside example_repository.
(chroot) hc4Gentoo / # mkdir -p /var/db/repos/example_repository/dev-util/hello-world
(chroot) hc4Gentoo / # touch /var/db/repos/example_repository/dev-util/hello-world/hello-world-1.0.ebuild
(chroot) hc4Gentoo / # nano /var/db/repos/example_repository/dev-util/hello-world/hello-world-1.0.ebuild
(chroot) hc4Gentoo / # ebuild /var/db/repos/example_repository/dev-util/hello-world/hello-world-1.0.ebuild manifest
>>> Creating Manifest for /var/db/repos/example_repository/dev-util/hello-world
(chroot) hc4Gentoo / # ebuild /var/db/repos/example_repository/dev-util/hello-world/hello-world-1.0.ebuild digest
>>> Creating Manifest for /var/db/repos/example_repository/dev-util/hello-world
(chroot) hc4Gentoo / # tree /var/db/repos/example_repository/dev-util/hello-world/
/var/db/repos/example_repository/dev-util/hello-world/
├── files
│ └── hello.c
└── hello-world-1.0.ebuild
2 directories, 2 files
(chroot) hc4Gentoo / # cat /var/db/repos/example_repository/dev-util/hello-world/files/hello.c
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
return 0;
}
(chroot) hc4Gentoo / # cat /var/db/repos/example_repository/dev-util/hello-world/
files/ hello-world-1.0.ebuild
(chroot) hc4Gentoo / # cat /var/db/repos/example_repository/dev-util/hello-world/hello-world-1.0.ebuild
EAPI=7
DESCRIPTION="A simple Hello World program"
HOMEPAGE=""
SRC_URI=""
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
IUSE=""
src_compile() {
emake
}
src_install() {
emake DESTDIR="${D}" install
}
(chroot) hc4Gentoo / # emerge -av dev-util/hello-world
* IMPORTANT: 12 news items need reading for repository 'gentoo'.
* Use eselect news read to view new items.
These are the packages that would be merged, in order:
Calculating dependencies... done!
Dependency resolution took 3.60 s.
!!! All ebuilds that could satisfy "dev-util/hello-world" have been masked.
!!! One of the following masked packages is required to complete your request:
- dev-util/hello-world-1.0::example_repository (masked by: missing keyword)
For more information, see the MASKED PACKAGES section in the emerge
man page or refer to the Gentoo Handbook.
- /var/db/repos/example_repository/dev-util/hello-world/hello-world-1.0.ebuild, as
EAPI=7
DESCRIPTION="A simple Hello World program"
HOMEPAGE=""
# SRC_URI="file:///var/db/repos/example_repository/dev-util/hello-world/files/hello.c"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~aarch64"
IUSE=""
MY_SRC="${FILESDIR}/hello.c"
src_unpack() {
# Create the source directory
mkdir -p "${S}"
cp "${MY_SRC}" "${S}/hello.c"
}
src_compile() {
emake hello
}
src_install() {
# Install the binary manually
dobin "${S}/hello"
}
(chroot) hc4Gentoo / # tree /var/db/repos/example_repository
/var/db/repos/example_repository
├── dev-util
│ └── hello-world
│ ├── files
│ │ └── hello.c
│ └── hello-world-1.0.ebuild
├── metadata
│ └── layout.conf
└── profiles
└── repo_name
6 directories, 4 files