summaryrefslogtreecommitdiff
blob: c9fff49d3e382a7515181393683f3b2f558fb473 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/bash -eu
# Automatic bug fix script
# sys-apps/portage: bug 493126, 574626
# app-shells/bash: bug 574426
# sys-devel/gettext: bug 564168
# sys-libs/db: bug 578506
# sys-devel/llvm

PORTDIR="${PORTDIR:-/usr/portage}"
TMPDIR="${TMPDIR:-/tmp/autofix}"

if [[ ! -e "${TMPDIR}" ]] ; then
	mkdir -p "${TMPDIR}"
fi

latest_ebuild(){
	local pkg="$1"

	echo $(emerge -qp --color=n ${pkg} 2>/dev/null | grep ${pkg} | gsed "s:.*${pkg}:${pkg}:g" | awk '{print $1}'  | awk -F/ '{print $2}').ebuild
}

fix_portage() {
	# Fix bug 493126 and 574626
	local pkg="sys-apps/portage"
	local ebuild="$(latest_ebuild ${pkg})"

	cp "${TMPDIR}/bug493126.patch" "${PORTDIR}/${pkg}"/files/
	cp "${TMPDIR}/bug574626.patch" "${PORTDIR}/${pkg}"/files/

	patch -p1 "${PORTDIR}/${pkg}/${ebuild}" < "${TMPDIR}/portage_ebuild.patch"
	ebuild "${PORTDIR}/${pkg}/${ebuild}" manifest
}

fix_bash() {
	# Fix bug 574426
	local pkg="app-shells/bash"
	local ebuild="$(latest_ebuild ${pkg})"

	patch -p1 "${PORTDIR}/${pkg}/${ebuild}" < "${TMPDIR}/bug574426.patch"
	ebuild "${PORTDIR}/${pkg}/${ebuild}" manifest
}

fix_gettext() {
	# Fix bug 564168
	local pkg="sys-devel/gettext"
	local ebuild="$(latest_ebuild ${pkg})"

	patch -p1 "${PORTDIR}/${pkg}/${ebuild}" < "${TMPDIR}/bug564168.patch"
	ebuild "${PORTDIR}/${pkg}/${ebuild}" manifest

	echo "dev-libs/libintl-0.19.7" >> ${PORTDIR}/profiles/default/bsd/fbsd/package.provided
}

fix_db(){
	echo "sys-libs/db cxx" >> "${PORTDIR}/profiles/arch/amd64-fbsd/clang/package.use.mask"
}

fix_llvm_ninja(){
	# Traceback (most recent call last):
	#   File "configure.py", line 435, in <module>
	#     if has_re2c():
	#   File "configure.py", line 432, in has_re2c
	#     return int(proc.communicate()[0], 10) >= 1103
	# ValueError: invalid literal for int() with base 10: ''
	#  * ERROR: dev-util/ninja-1.6.0::gentoo failed (compile phase):

	local pkg="sys-devel/llvm"
	local ebuild="$(latest_ebuild ${pkg})"

	gsed -i 's/CMAKE_MAKEFILE_GENERATOR:=ninja/CMAKE_MAKEFILE_GENERATOR:=emake/g' "${PORTDIR}"/${pkg}/*.ebuild
	ebuild "${PORTDIR}/${pkg}/${ebuild}" manifest
}

mk_patches() {
	cat > "${TMPDIR}/bug493126.patch" <<-'EOF'
	diff --git a/portage-2.2.7/pym/portage/process.py b/portage-2.2.7/pym/portage/process.py
	index 9ae7a55..cee2440 100644
	--- a/portage-2.2.7/pym/portage/process.py
	+++ b/portage-2.2.7/pym/portage/process.py
	@@ -55,8 +55,8 @@ for _fd_dir in ("/proc/self/fd", "/dev/fd"):
	 		_fd_dir = None
	 
	 # /dev/fd does not work on FreeBSD, see bug #478446
	-if platform.system() in ('FreeBSD',) and _fd_dir == '/dev/fd':
	-	_fd_dir = None
	+#if platform.system() in ('FreeBSD',) and _fd_dir == '/dev/fd':
	+#	_fd_dir = None
	 
	 if _fd_dir is not None:
	 	def get_open_fds():
	EOF

	cat > "${TMPDIR}/bug574626.patch" <<-'EOF'
	diff --git a/portage-2.2.27/bin/phase-helpers.sh b/portage-2.2.27/bin/phase-helpers.sh
	index 80f5946..69dfe4b 100644
	--- a/portage-2.2.27/bin/phase-helpers.sh
	+++ b/portage-2.2.27/bin/phase-helpers.sh
	@@ -987,6 +987,9 @@ if ___eapi_has_eapply; then
	 		_eapply_patch() {
	 			local f=${1}
	 			local prefix=${2}
	+			local prepend=""
	+
	+			type -P gpatch > /dev/null && prepend="g"
	 
	 			started_applying=1
	 			ebegin "${prefix:-Applying }${f##*/}"
	@@ -995,7 +998,7 @@ if ___eapi_has_eapply; then
	 			# -s to silence progress output
	 			# -g0 to guarantee no VCS interaction
	 			# --no-backup-if-mismatch not to pollute the sources
	-			patch -p1 -f -s -g0 --no-backup-if-mismatch \
	+			${prepend}patch -p1 -f -s -g0 --no-backup-if-mismatch \
	 				"${patch_options[@]}" < "${f}"
	 			failed=${?}
	 			if ! eend "${failed}"; then
	EOF

	cat > "${TMPDIR}/portage_ebuild.patch" <<-'EOF'
	diff --git a/portage-2.2.26.ebuild b/portage-2.2.26.ebuild
	index 982053e..62e9785 100644
	--- a/portage-2.2.26.ebuild
	+++ b/portage-2.2.26.ebuild
	@@ -84,6 +84,8 @@ pkg_setup() {
	 
	 python_prepare_all() {
	 	distutils-r1_python_prepare_all
	+	epatch "${FILESDIR}/bug493126.patch"
	+	epatch "${FILESDIR}/bug574626.patch"
	 
	 	if ! use ipc ; then
	 		einfo "Disabling ipc..."
	EOF

	cat > "${TMPDIR}/bug574426.patch" <<-'EOF'
	diff --git a/bash-4.3_p42-r2.ebuild b/bash-4.3_p42-r2.ebuild
	index c914d04..d4edb87 100644
	--- a/bash-4.3_p42-r2.ebuild
	+++ b/bash-4.3_p42-r2.ebuild
	@@ -39,7 +39,7 @@ SRC_URI="mirror://gnu/bash/${MY_P}.tar.gz $(patches)"
	 LICENSE="GPL-3"
	 SLOT="0"
	 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
	-IUSE="afs bashlogger examples mem-scramble +net nls plugins +readline vanilla"
	+IUSE="afs bashlogger examples mem-scramble +net nls plugins +readline vanilla elibc_FreeBSD"
	 
	 DEPEND=">=sys-libs/ncurses-5.2-r2
	 	readline? ( >=sys-libs/readline-${READLINE_VER} )
	@@ -130,6 +130,10 @@ src_configure() {
	 		myconf+=( --with-installed-readline=. )
	 	fi
	 
	+	# Fix cannot make pipe for process substitution: File exists error.
	+	# Bug 574426
	+	use elibc_FreeBSD && append-cflags -DUSE_MKTEMP=1 -DUSE_MKSTEMP=1
	+
	 	if use plugins; then
	 		append-ldflags -Wl,-rpath,/usr/$(get_libdir)/bash
	 	else
	EOF

	cat > "${TMPDIR}/bug564168.patch" <<-'EOF'
	diff --git a/gettext-0.19.7.ebuild b/gettext-0.19.7.ebuild
	index 7677f88..f959f3e 100644
	--- a/gettext-0.19.7.ebuild
	+++ b/gettext-0.19.7.ebuild
	@@ -17,7 +17,7 @@ SRC_URI="mirror://gnu/${PN}/${P}.tar.gz"
	 LICENSE="GPL-3+ cxx? ( LGPL-2.1+ )"
	 SLOT="0"
	 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
	-IUSE="acl -cvs +cxx doc emacs git java ncurses nls openmp static-libs"
	+IUSE="acl -cvs +cxx doc emacs git java ncurses nls openmp static-libs elibc_glibc elibc_musl"
	 
	 # only runtime goes multilib
	 # Note: expat lacks a subslot because it is dynamically loaded at runtime.  We
	@@ -69,8 +69,6 @@ multilib_src_configure() {
	 		# this will _disable_ libunistring (since it is not bundled),
	 		# see bug #326477
	 		--with-included-libunistring
	-		# Never build libintl since it's in dev-libs/libintl now.
	-		--without-included-gettext
	 
	 		$(use_enable acl)
	 		$(use_enable cxx c++)
	@@ -79,11 +77,23 @@ multilib_src_configure() {
	 		$(usex git --without-cvs $(use_with cvs))
	 		$(use_enable java)
	 		$(use_enable ncurses curses)
	-		$(use_enable nls)
	 		$(use_enable openmp)
	 		$(use_enable static-libs static)
	 	)
	 
	+	# Build with --without-included-gettext (on glibc systems)
	+	if use elibc_glibc || use elibc_musl ; then
	+		myconf+=(
	+			--without-included-gettext
	+			$(use_enable nls)
	+		)
	+	else
	+		myconf+=(
	+			--with-included-gettext
	+			--enable-nls
	+		)
	+	fi
	+
	 	local ECONF_SOURCE=${S}
	 	if ! multilib_is_native_abi ; then
	 		# for non-native ABIs, we build runtime only
	EOF
}

for func in mk_patches fix_portage fix_bash fix_gettext fix_db fix_llvm_ninja
do
	echo "${func}"
	${func}
done