summaryrefslogtreecommitdiff
path: root/flx/initramfs/initramfs-0.ebuild
blob: c38053b9a0588c270a3143283e3d1eee26c2fe8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7
inherit flx-tools

DESCRIPTION="build initramfs"

LICENSE="public-domain"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="bzip2 gzip lzma lzo"

BDEPEND="app-arch/cpio
	bzip2? ( app-arch/bzip2 )
	gzip? ( app-arch/gzip )
	lzma? ( app-arch/xz-utils )
	lzo? ( app-arch/lzop )"

DEF_CPIO_FLAGS="--quiet"
DEF_BZIP2_FLAGS="--best"
DEF_GZIP_FLAGS="--best"
DEF_LZMA_FLAGS="--best"
DEF_LZO_FLAGS="--best"
DEF_XZ_FLAGS="--best"

src_unpack () {
	mkdir "${S}"
	unpack_plist initramfs "${S}/fs"
}

src_compile () {
	check_symbol "${S}/fs"
	big_compress "${S}/fs"

	einfo "Building initramfs.cpio"
	(
		cd fs
		find . -print | \
			cpio ${CPIO_FLAGS:-$DEF_CPIO_FLAGS} -o -H newc \
	) > initramfs.cpio

	if use bzip2 ; then
		einfo "Building initramfs.cpio.bz2"
		bzip2 -c ${BZIP2_FLAGS:-$DEF_BZIP2_FLAGS} \
				< initramfs.cpio \
				> initramfs.cpio.bz2 \
			|| die "Failed to create initramfs.cpio.bz2"
	fi

	if use gzip ; then
		einfo "Building initramfs.cpio.gzip"
		gzip -c ${GZIP_FLAGS:-$DEF_GZIP_FLAGS} \
				< initramfs.cpio \
				> initramfs.cpio.gz \
			|| die "Failed to create initramfs.cpio.gz"
	fi

	if use lzma ; then
		einfo "Building initramfs.cpio.xz"
		xz -c ${XZ_FLAGS:-$DEF_XZ_FLAGS} \
				< initramfs.cpio \
				> initramfs.cpio.xz \
			|| die "Failed to create initramfs.cpio.xz"
	fi

	if use lzo ; then
		einfo "Building initramfs.cpio.lzo"
		lzop -c ${LZO_FLAGS:-$DEF_LZO_FLAGS} \
				< initramfs.cpio \
				> initramfs.cpio.lzo \
			|| die "Failed to create initramfs.cpio.lzo"
	fi
}

src_install () {
	insinto /fs

	doins initramfs.cpio

	use bzip2 && doins initramfs.cpio.bz2
	use gzip  && doins initramfs.cpio.gz
	use lzma  && doins initramfs.cpio.xz
	use lzo   && doins initramfs.cpio.lzo
}