Diff bzip2-1.0.8-r4 with a bzip2-9999

/usr/portage/app-arch/bzip2/bzip2-9999.ebuild 2023-10-09 14:52:28.180368317 +0300
1 1
# Copyright 1999-2023 Gentoo Authors
2 2
# Distributed under the terms of the GNU General Public License v2
3 3

  
4
# XXX: atm, libbz2.a is always PIC :(, so it is always built quickly
5
#      (since we're building shared libs) ...
4
EAPI=8
6 5

  
7
EAPI=7
8

  
9
VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/bzip2.gpg
10
inherit toolchain-funcs multilib multilib-minimal usr-ldscript verify-sig
6
inherit meson-multilib usr-ldscript
11 7

  
12 8
DESCRIPTION="A high-quality data compressor used extensively by Gentoo Linux"
13
HOMEPAGE="https://sourceware.org/bzip2/"
14
SRC_URI="https://sourceware.org/pub/${PN}/${P}.tar.gz"
15
SRC_URI+=" verify-sig? ( https://sourceware.org/pub/${PN}/${P}.tar.gz.sig )"
9
HOMEPAGE="https://gitlab.com/bzip2/bzip2"
10
if [[ ${PV} == 9999 ]] ; then
11
	EGIT_REPO_URI="https://gitlab.com/bzip2/bzip2"
12
	inherit git-r3
13
else
14
	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~arm64-macos"
15
fi
16 16

  
17 17
LICENSE="BZIP2"
18 18
SLOT="0/1" # subslot = SONAME
19
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~arm64-macos"
20
IUSE="static static-libs"
21 19

  
22
BDEPEND="
23
	verify-sig? ( sec-keys/openpgp-keys-bzip2 )
24
"
20
IUSE="static-libs"
21

  
25 22
PDEPEND="
26 23
	app-alternatives/bzip2
27 24
"
28 25

  
29
PATCHES=(
30
	"${FILESDIR}"/${PN}-1.0.4-makefile-CFLAGS.patch
31
	"${FILESDIR}"/${PN}-1.0.8-saneso.patch
32
	"${FILESDIR}"/${PN}-1.0.4-man-links.patch #172986
33
	"${FILESDIR}"/${PN}-1.0.6-progress.patch
34
	"${FILESDIR}"/${PN}-1.0.3-no-test.patch
35
	"${FILESDIR}"/${PN}-1.0.8-mingw.patch #393573
36
	"${FILESDIR}"/${PN}-1.0.8-out-of-tree-build.patch
37
)
38

  
39
DOCS=( CHANGES README{,.COMPILATION.PROBLEMS,.XML.STUFF} manual.pdf )
40
HTML_DOCS=( manual.html )
41

  
42
src_prepare() {
43
	default
44

  
45
	# - Use right man path
46
	# - Generate symlinks instead of hardlinks
47
	# - pass custom variables to control libdir
48
	sed -i \
49
		-e 's:\$(PREFIX)/man:\$(PREFIX)/share/man:g' \
50
		-e 's:ln -s -f $(PREFIX)/bin/:ln -s -f :' \
51
		-e 's:$(PREFIX)/lib:$(PREFIX)/$(LIBDIR):g' \
52
		Makefile || die
53
}
54

  
55
bemake() {
56
	emake \
57
		VPATH="${S}" \
58
		CC="$(tc-getCC)" \
59
		AR="$(tc-getAR)" \
60
		RANLIB="$(tc-getRANLIB)" \
61
		"$@"
62
}
26
multilib_src_configure() {
27
	local emesonargs=(
28
		-Ddefault_library=$(usex static-libs both shared)
29
		# Requires whole tex stack
30
		-Ddocs="disabled"
31
	)
63 32

  
64
multilib_src_compile() {
65
	bemake -f "${S}"/Makefile-libbz2_so all
66
	# Make sure we link against the shared lib #504648
67
	ln -s libbz2.so.${PV} libbz2.so || die
68
	bemake -f "${S}"/Makefile all LDFLAGS="${LDFLAGS} $(usex static -static '')"
69
}
70

  
71
multilib_src_test() {
72
	cp "${S}"/sample* "${BUILD_DIR}" || die
73
	bemake -f "${S}"/Makefile check
33
	meson_src_configure
74 34
}
75 35

  
76 36
multilib_src_install() {
77
	into /usr
78

  
79
	# Install the shared lib manually.  We install:
80
	#  .x.x.x - standard shared lib behavior
81
	#  .x.x   - SONAME some distros use #338321
82
	#  .x     - SONAME Gentoo uses
83
	dolib.so libbz2.so.${PV}
84
	local v
85
	for v in libbz2.so{,.{${PV%%.*},${PV%.*}}} ; do
86
		dosym libbz2.so.${PV} /usr/$(get_libdir)/${v}
87
	done
88

  
89
	use static-libs && dolib.a libbz2.a
37
	meson_src_install
90 38

  
91 39
	if multilib_is_native_abi ; then
92 40
		gen_usr_ldscript -a bz2
93

  
94
		dobin bzip2recover$(get_exeext)
95
		into /
96
		newbin bzip2$(get_exeext) bzip2-reference$(get_exeext)
97 41
	fi
98 42
}
99 43

  
100 44
multilib_src_install_all() {
101
	# `make install` doesn't cope with out-of-tree builds, nor with
102
	# installing just non-binaries, so handle things ourselves.
103
	insinto /usr/include
104
	doins bzlib.h
105
	into /usr
106
	dobin bz{diff,grep,more}
107
	doman bz{diff,grep,more}.1
108
	newman bzip2.1 bzip2-reference.1
45
	dodir /bin
46
	mv "${ED}"/usr/bin/bzip2 "${ED}"/bin/bzip2-reference || die
47
	mv "${ED}"/usr/share/man/man1/bzip2{,-reference}.1 || die
48

  
49
	# moved to app-alternatives/bzip2
50
	rm "${ED}"/usr/bin/{bzcat,bunzip2} || die
51
	rm "${ED}"/usr/share/man/man1/{bzcat,bunzip2.1} || die
109 52

  
110 53
	dosym bzdiff /usr/bin/bzcmp
111
	dosym bzdiff.1 /usr/share/man/man1/bzcmp.1
112

  
113 54
	dosym bzmore /usr/bin/bzless
114
	dosym bzmore.1 /usr/share/man/man1/bzless.1
115

  
116
	dosym bzip2-reference.1 /usr/share/man/man1/bzip2recover.1
117 55
	local x
118 56
	for x in bz{e,f}grep ; do
119 57
		dosym bzgrep /usr/bin/${x}
120
		dosym bzgrep.1 /usr/share/man/man1/${x}.1
121 58
	done
122 59

  
123
	einstalldocs
124
}
60
	dosym bzip2-reference.1 /usr/share/man/man1/bzip2recover.1
125 61

  
126
pkg_postinst() {
127
	# ensure to preserve the symlinks before app-alternatives/bzip2
128
	# is installed
129
	local x
130
	for x in bzip2 bunzip2 bzcat; do
131
		if [[ ! -h ${EROOT}/bin/${x} ]]; then
132
			ln -s bzip2-reference$(get_exeext) "${EROOT}/bin/${x}$(get_exeext)" || die
133
		fi
134
	done
62
	einstalldocs
135 63
}
Thank you!