Browse code

screen update

Hanno Böck authored on06/03/2021 11:09:04
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,158 @@
1
+# Copyright 1999-2021 Gentoo Authors
2
+# Distributed under the terms of the GNU General Public License v2
3
+
4
+EAPI=7
5
+
6
+inherit autotools flag-o-matic pam tmpfiles toolchain-funcs
7
+
8
+DESCRIPTION="screen manager with VT100/ANSI terminal emulation"
9
+HOMEPAGE="https://www.gnu.org/software/screen/"
10
+
11
+if [[ "${PV}" != 9999 ]] ; then
12
+	SRC_URI="mirror://gnu/${PN}/${P}.tar.gz"
13
+	KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
14
+else
15
+	inherit git-r3
16
+	EGIT_REPO_URI="https://git.savannah.gnu.org/git/screen.git"
17
+	EGIT_CHECKOUT_DIR="${WORKDIR}/${P}" # needed for setting S later on
18
+	S="${WORKDIR}"/${P}/src
19
+fi
20
+
21
+LICENSE="GPL-2"
22
+SLOT="0"
23
+IUSE="debug nethack pam selinux multiuser"
24
+
25
+CDEPEND="
26
+	>=sys-libs/ncurses-5.2:0=
27
+	pam? ( sys-libs/pam )"
28
+RDEPEND="${CDEPEND}
29
+	acct-group/utmp
30
+	selinux? ( sec-policy/selinux-screen )"
31
+DEPEND="${CDEPEND}
32
+	sys-apps/texinfo"
33
+
34
+PATCHES=(
35
+	# Don't use utempter even if it is found on the system.
36
+	"${FILESDIR}"/${PN}-4.3.0-no-utempter.patch
37
+	"${FILESDIR}"/${PN}-4.6.2-utmp-exit.patch
38
+	"${FILESDIR}"/${PN}-CVE-2021-26937.patch
39
+)
40
+
41
+src_prepare() {
42
+	default
43
+
44
+	# sched.h is a system header and causes problems with some C libraries
45
+	mv sched.h _sched.h || die
46
+	sed -i '/include/ s:sched.h:_sched.h:' screen.h || die
47
+
48
+	# Fix manpage.
49
+	sed -i \
50
+		-e "s:/usr/local/etc/screenrc:${EPREFIX}/etc/screenrc:g" \
51
+		-e "s:/usr/local/screens:${EPREFIX}/tmp/screen:g" \
52
+		-e "s:/local/etc/screenrc:${EPREFIX}/etc/screenrc:g" \
53
+		-e "s:/etc/utmp:${EPREFIX}/var/run/utmp:g" \
54
+		-e "s:/local/screens/S\\\-:${EPREFIX}/tmp/screen/S\\\-:g" \
55
+		doc/screen.1 || die
56
+
57
+	if [[ ${CHOST} == *-darwin* ]] || use elibc_musl ; then
58
+		sed -i -e '/^#define UTMPOK/s/define/undef/' acconfig.h || die
59
+	fi
60
+
61
+	# disable musl dummy headers for utmp[x]
62
+	use elibc_musl && append-cppflags "-D_UTMP_H -D_UTMPX_H"
63
+
64
+	# reconfigure
65
+	eautoreconf
66
+}
67
+
68
+src_configure() {
69
+	append-cppflags "-DMAXWIN=${MAX_SCREEN_WINDOWS:-100}"
70
+
71
+	if [[ ${CHOST} == *-solaris* ]] ; then
72
+		# enable msg_header by upping the feature standard compatible
73
+		# with c99 mode
74
+		append-cppflags -D_XOPEN_SOURCE=600
75
+	fi
76
+
77
+	use nethack || append-cppflags "-DNONETHACK"
78
+	use debug && append-cppflags "-DDEBUG"
79
+
80
+	local myeconfargs=(
81
+		--with-sys-screenrc="${EPREFIX}/etc/screenrc"
82
+		--with-pty-mode=0620
83
+		--with-pty-group=5
84
+		--enable-rxvt_osc
85
+		--enable-telnet
86
+		--enable-colors256
87
+		$(use_enable pam)
88
+	)
89
+	econf "${myeconfargs[@]}"
90
+}
91
+
92
+src_compile() {
93
+	LC_ALL=POSIX emake comm.h term.h
94
+	emake osdef.h
95
+
96
+	emake -C doc screen.info
97
+	default
98
+}
99
+
100
+src_install() {
101
+	local DOCS=(
102
+		README ChangeLog INSTALL TODO NEWS* patchlevel.h
103
+		doc/{FAQ,README.DOTSCREEN,fdpat.ps,window_to_display.ps}
104
+	)
105
+
106
+	emake DESTDIR="${D}" SCREEN="${P}" install
107
+
108
+	local tmpfiles_perms tmpfiles_group
109
+
110
+	if use multiuser || use prefix ; then
111
+		fperms 4755 /usr/bin/${P}
112
+		tmpfiles_perms="0755"
113
+		tmpfiles_group="root"
114
+	else
115
+		fowners root:utmp /usr/bin/${P}
116
+		fperms 2755 /usr/bin/${P}
117
+		tmpfiles_perms="0775"
118
+		tmpfiles_group="utmp"
119
+	fi
120
+
121
+	newtmpfiles - screen.conf <<<"d /tmp/screen ${tmpfiles_perms} root ${tmpfiles_group}"
122
+
123
+	insinto /usr/share/${PN}
124
+	doins terminfo/{screencap,screeninfo.src}
125
+
126
+	insinto /etc
127
+	doins "${FILESDIR}"/screenrc
128
+
129
+	if use pam; then
130
+		pamd_mimic_system screen auth
131
+	fi
132
+
133
+	dodoc "${DOCS[@]}"
134
+}
135
+
136
+pkg_postinst() {
137
+	if [[ -z ${REPLACING_VERSIONS} ]]
138
+	then
139
+		elog "Some dangerous key bindings have been removed or changed to more safe values."
140
+		elog "We enable some xterm hacks in our default screenrc, which might break some"
141
+		elog "applications. Please check /etc/screenrc for information on these changes."
142
+	fi
143
+
144
+	# Add /tmp/screen in case it doesn't exist yet. This should solve
145
+	# problems like bug #508634 where tmpfiles.d isn't in effect.
146
+	local rundir="${EROOT}/tmp/${PN}"
147
+	if [[ ! -d ${rundir} ]] ; then
148
+		if use multiuser || use prefix ; then
149
+			tmpfiles_group="root"
150
+		else
151
+			tmpfiles_group="utmp"
152
+		fi
153
+		mkdir -m 0775 "${rundir}"
154
+		chgrp ${tmpfiles_group} "${rundir}"
155
+	fi
156
+
157
+	ewarn "This revision changes the screen socket location to ${rundir}"
158
+}