§2023-09-21

¶1.ローカルリポジトリ用Portageツリーの作成

(chroot) hc4Gentoo / # mkdir -vp /usr/local/portage/sys-kernel/mkinitcpio
mkdir: created directory '/usr/local/portage/sys-kernel'
mkdir: created directory '/usr/local/portage/sys-kernel/mkinitcpio'
(chroot) hc4Gentoo / # mkdir -vp /usr/local/portage/sys-kernel/mkinitcpio
[localrepo]
location = /usr/local/portage

masters = gentoo

as,

# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="Modular initramfs image creation utility"
HOMEPAGE="https://github.com/archlinux/mkinitcpio"

SRC_URI="https://github.com/archlinux/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="GPL-2"

SLOT="0"

KEYWORDS="amd64 arm arm64 mips x86"

IUSE="+systemd"

DEPEND="sys-apps/kmod
sys-apps/util-linux
app-arch/libarchive
app-arch/zstd
sys-apps/busybox
sys-apps/coreutils
sys-apps/findutils
sys-apps/sed
app-alternatives/awk
sys-apps/baselayout[-split-usr]
"

RDEPEND="${DEPEND}
        systemd? ( sys-apps/systemd[-split-usr] )
"

BDEPEND="
sys-apps/busybox
app-arch/libarchive
app-text/asciidoc
sys-apps/sed
"

RESTRICT="mirror"

src_install(){
        default_src_install
        exeinto /usr/lib/initcpio/
        doexe /bin/busybox
        insinto /usr/lib/initcpio/install
        newins "${FILESDIR}"/initcpio-install-systemd systemd
        newins "${FILESDIR}"/initcpio-install-base base
        insinto /usr/lib/initcpio/hooks
        newins "${FILESDIR}"/initcpio-hook-udev udev
        insinto /etc/mkinitcpio.d
        doins "${FILESDIR}"/linux.preset
}
alexlai@MacMini Downloads % cat  mkinitcpio-34-r1.ebuild
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="Modular initramfs image creation utility"
HOMEPAGE="https://github.com/archlinux/mkinitcpio"

SRC_URI="https://github.com/archlinux/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="GPL-2"

SLOT="0"

KEYWORDS="amd64 arm arm64 mips x86"

IUSE="+systemd"

DEPEND="sys-apps/kmod
sys-apps/util-linux
app-arch/libarchive
app-arch/zstd
sys-apps/busybox
sys-apps/coreutils
sys-apps/findutils
sys-apps/sed
app-alternatives/awk
sys-apps/baselayout[-split-usr]
"

RDEPEND="${DEPEND}
        systemd? ( sys-apps/systemd[-split-usr] )
"

BDEPEND="
sys-apps/busybox
app-arch/libarchive
app-text/asciidoc
sys-apps/sed
"

RESTRICT="mirror"

src_install(){
        default_src_install
        exeinto /usr/lib/initcpio/
        doexe /bin/busybox
        insinto /usr/lib/initcpio/install
        newins "${FILESDIR}"/initcpio-install-systemd systemd
        newins "${FILESDIR}"/initcpio-install-base base
        insinto /usr/lib/initcpio/hooks
        newins "${FILESDIR}"/initcpio-hook-udev udev
        insinto /etc/mkinitcpio.d
        doins "${FILESDIR}"/linux.preset
}

¶4.Manifest(メタデータ)の作成

ebuildファイルを書き終えたらメタデータファイルであるManifestというファイルを作成します。 Manifestファイルにはソースコードの入ったtarballなどのチェックサムが保存してあるみたいです。

mkinitcpio-busyboxのManifestファイルは先ほど作ったシェルスクリプトを実行すれば作成されます。

(chroot) hc4Gentoo / # mkdir  /usr/local/portage/metadata/
(chroot) hc4Gentoo / # nano  /usr/local/portage/metadata/layout.conf
(chroot) hc4Gentoo / # cat /usr/local/portage/metadata/layout.conf
masters = gentoo

(chroot) hc4Gentoo / # ebuild /usr/local/portage/sys-kernel/mkinitcpio/mkinitcpio-34-r1.ebuild manifest
>>> Downloading 'https://github.com/archlinux/mkinitcpio/archive/refs/tags/v34.tar.gz'
--2023-09-21 07:58:28--  https://github.com/archlinux/mkinitcpio/archive/refs/tags/v34.tar.gz
Resolving github.com... 20.27.177.113
Connecting to github.com|20.27.177.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/archlinux/mkinitcpio/tar.gz/refs/tags/v34 [following]
--2023-09-21 07:58:34--  https://codeload.github.com/archlinux/mkinitcpio/tar.gz/refs/tags/v34
Resolving codeload.github.com... 20.27.177.114
Connecting to codeload.github.com|20.27.177.114|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: ‘/var/cache/distfiles/mkinitcpio-34.tar.gz.__download__’

/var/cache/distfiles/mkinitcpio-34.tar.gz.__download__                   [ <=>                                                                                                                                                                 ]  55.81K  --.-KB/s    in 0.1s    

2023-09-21 07:58:34 (529 KB/s) - ‘/var/cache/distfiles/mkinitcpio-34.tar.gz.__download__’ saved [57151]

>>> Creating Manifest for /usr/local/portage/sys-kernel/mkinitcpio