summaryrefslogtreecommitdiff
blob: 9575601c7c864b8d9ffbf6761a8479d40f1cbb12 (plain)
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
# Copyright 2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

DESCRIPTION="Core of the automatic rebase facility during postinstall on Cygwin"
HOMEPAGE="https://cygwin.com"

LICENSE="GPL-2"
SLOT="0"
IUSE=""

inherit autotools

if [[ ${PV} == 9999 ]]
then
	EGIT_REPO_URI="https://sourceware.org/git/cygwin-apps/rebase.git"
	EGIT_REPO_URI="https://github.com/haubi/cygwin-rebase.git"
	EGIT_BRANCH="gentoo"
	inherit git-r3
else
	# Upstream does not provide archived source tarballs from git release tags,
	# only non archived cygwin distro packages with embedded source tarballs.
	# For now, we download from haubi's github mirror repo, having
	# repo name "cygwin-rebase" and tag names like "rebase-4-4-4".
	MY_PN=cygwin-rebase-rebase
	MY_PV=${PV//./-}
	S="${WORKDIR}/${MY_PN}-${MY_PV}"
	SRC_URI="
		https://github.com/haubi/cygwin-rebase/archive/rebase-${MY_PV}.tar.gz -> ${P}.tar.gz
		https://github.com/haubi/cygwin-rebase/compare/rebase-${MY_PV}...rebase-${MY_PV}_merge-files-flag-0.patch -> ${P}_merge-files-flag-0.patch
	"
	PATCHES=( "${DISTDIR}/${P}_merge-files-flag-0.patch" )
	KEYWORDS="-* ~x64-cygwin"
fi

DEPEND=""
RDEPEND="${DEPEND}"
BDEPEND=""

src_prepare() {
	default
	# do not bother upstream with bug reports yet
	sed -e "/AC_INIT/{s|rebase|${PN}|;s|cygwin@cygwin.com|https://bugs.gentoo.org/|}" \
		-i configure.ac || die
	eautoreconf
}

src_configure() {
	econf --with-posix-shell="${BASH}"
}

src_install() {
	default
	# do not work nor make so much sense in Gentoo Prefix
	rm -f "${ED}"/usr/bin/{rebase,peflags}all || die
}

pkg_preinst() {
	local rebasedb
	local baseaddr
	case ${CHOST} in
	x86_64-*-cygwin*)
		rebasedb=/etc/rebase.db.x86_64
		baseaddr=0x1000000000
		;;
	esac
	[[ ${rebasedb} ]] || die "CHOST ${CHOST} is not supported for ${PN}."

	[[ -s ${EROOT}${rebasedb} ]] && return 0

	einfo "Creating initial rebase database with default base address ${baseaddr}..."
	cp /bin/cygwin1.dll "${T}/initial.dll" || die
	"${ED}/usr/bin/rebase" --verbose "--base=${baseaddr}" --database "${T}/initial.dll" || die
	eend $?
}