Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH] Support disabling stripping for binary packages
Date: Mon, 05 Nov 2018 19:39:25
Message-Id: 20181105193916.16394-1-mgorny@gentoo.org
1 Similarly to FEATURES=binpkg-docompress, implement
2 FEATURES=binpkg-dostrip that controls whether stripping occurs before or
3 after building the binary package.
4
5 This makes it possible to build binary packages with some debug
6 information that is stripped upon installing. Afterwards, the binary
7 packages can be reinstalled with debug info (either via nostrip or
8 splitdebug). Real usability of this feature will be limited by
9 optimization levels applied but still, it's better than nothing.
10
11 Signed-off-by: Michał Górny <mgorny@g.o>
12 ---
13 bin/misc-functions.sh | 34 ++++++++++++++++++++++++++--------
14 cnf/make.globals | 4 ++--
15 lib/portage/const.py | 3 ++-
16 man/make.conf.5 | 8 +++++++-
17 4 files changed, 37 insertions(+), 12 deletions(-)
18
19 Note:
20 Tested it with both FEATURES=binpkg-dostrip states, and -K installs
21 of package with stripping on, nostrip and splitdebug.
22
23 diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
24 index 3b3a5e09c..5de26b44d 100755
25 --- a/bin/misc-functions.sh
26 +++ b/bin/misc-functions.sh
27 @@ -1,5 +1,5 @@
28 #!/bin/bash
29 -# Copyright 1999-2018 Gentoo Foundation
30 +# Copyright 1999-2018 Gentoo Authors
31 # Distributed under the terms of the GNU General Public License v2
32 #
33 # Miscellaneous shell functions that make use of the ebuild env but don't need
34 @@ -117,13 +117,18 @@ install_qa_check() {
35 "${PORTAGE_BIN_PATH}"/ecompress --dequeue
36 fi
37
38 - export STRIP_MASK
39 - if ___eapi_has_dostrip; then
40 - "${PORTAGE_BIN_PATH}"/estrip --queue "${PORTAGE_DOSTRIP[@]}"
41 - "${PORTAGE_BIN_PATH}"/estrip --ignore "${PORTAGE_DOSTRIP_SKIP[@]}"
42 - "${PORTAGE_BIN_PATH}"/estrip --dequeue
43 - else
44 - prepallstrip
45 + # If binpkg-dostrip is enabled, apply stripping before creating
46 + # the binary package.
47 + # Note: disabling it won't help with packages calling prepstrip directly.
48 + if has binpkg-dostrip ${FEATURES}; then
49 + export STRIP_MASK
50 + if ___eapi_has_dostrip; then
51 + "${PORTAGE_BIN_PATH}"/estrip --queue "${PORTAGE_DOSTRIP[@]}"
52 + "${PORTAGE_BIN_PATH}"/estrip --ignore "${PORTAGE_DOSTRIP_SKIP[@]}"
53 + "${PORTAGE_BIN_PATH}"/estrip --dequeue
54 + else
55 + prepallstrip
56 + fi
57 fi
58
59 if has chflags $FEATURES ; then
60 @@ -186,6 +191,19 @@ __dyn_instprep() {
61 "${PORTAGE_BIN_PATH}"/ecompress --dequeue
62 fi
63
64 + # If binpkg-dostrip is disabled, apply stripping before creating
65 + # the binary package.
66 + if ! has binpkg-dostrip ${FEATURES}; then
67 + export STRIP_MASK
68 + if ___eapi_has_dostrip; then
69 + "${PORTAGE_BIN_PATH}"/estrip --queue "${PORTAGE_DOSTRIP[@]}"
70 + "${PORTAGE_BIN_PATH}"/estrip --ignore "${PORTAGE_DOSTRIP_SKIP[@]}"
71 + "${PORTAGE_BIN_PATH}"/estrip --dequeue
72 + else
73 + prepallstrip
74 + fi
75 + fi
76 +
77 if has chflags ${FEATURES}; then
78 # Restore all the file flags that were saved earlier on.
79 mtree -U -e -p "${ED}" -k flags < "${T}/bsdflags.mtree" &> /dev/null
80 diff --git a/cnf/make.globals b/cnf/make.globals
81 index 72b567e98..d394a1890 100644
82 --- a/cnf/make.globals
83 +++ b/cnf/make.globals
84 @@ -1,4 +1,4 @@
85 -# Copyright 1999-2013 Gentoo Foundation
86 +# Copyright 1999-2018 Gentoo Authors
87 # Distributed under the terms of the GNU General Public License v2
88 # System-wide defaults for the Portage system
89
90 @@ -50,7 +50,7 @@ RESUMECOMMAND_SSH=${FETCHCOMMAND_SSH}
91 FETCHCOMMAND_SFTP="bash -c \"x=\\\${2#sftp://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port= ; eval \\\"declare -a ssh_opts=(\\\${3})\\\" ; exec sftp \\\${port:+-P \\\${port}} \\\"\\\${ssh_opts[@]}\\\" \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" sftp \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
92
93 # Default user options
94 -FEATURES="assume-digests binpkg-docompress binpkg-logs
95 +FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs
96 config-protect-if-modified distlocks ebuild-locks
97 fixlafiles merge-sync multilib-strict news
98 parallel-fetch preserve-libs protect-owned
99 diff --git a/lib/portage/const.py b/lib/portage/const.py
100 index a343fc040..602caeb34 100644
101 --- a/lib/portage/const.py
102 +++ b/lib/portage/const.py
103 @@ -1,5 +1,5 @@
104 # portage: Constants
105 -# Copyright 1998-2018 Gentoo Foundation
106 +# Copyright 1998-2018 Gentoo Authors
107 # Distributed under the terms of the GNU General Public License v2
108
109 from __future__ import unicode_literals
110 @@ -123,6 +123,7 @@ EBUILD_PHASES = (
111 SUPPORTED_FEATURES = frozenset([
112 "assume-digests",
113 "binpkg-docompress",
114 + "binpkg-dostrip",
115 "binpkg-logs",
116 "binpkg-multi-instance",
117 "buildpkg",
118 diff --git a/man/make.conf.5 b/man/make.conf.5
119 index ec03c93ca..44640238a 100644
120 --- a/man/make.conf.5
121 +++ b/man/make.conf.5
122 @@ -1,4 +1,4 @@
123 -.TH "MAKE.CONF" "5" "Feb 2016" "Portage VERSION" "Portage"
124 +.TH "MAKE.CONF" "5" "Nov 2018" "Portage VERSION" "Portage"
125 .SH "NAME"
126 make.conf \- custom settings for Portage
127 .SH "SYNOPSIS"
128 @@ -281,6 +281,12 @@ package. When this option is enabled (the default), documentation files are
129 already compressed inside binary packages. When it is disabled, binary packages
130 contain uncompressed documentation and Portage compresses it before installing.
131 .TP
132 +.B binpkg\-dostrip
133 +Perform file stripping before creating binary package. When this option is
134 +enabled (the default), executables are already stripped inside binary packages.
135 +When it is disabled, binary packages contain unstripped executables and Portage
136 +strips (or splits) them before installing.
137 +.TP
138 .B binpkg\-logs
139 Keep logs from successful binary package merges. This is relevant only when
140 \fBPORT_LOGDIR\fR is set.
141 --
142 2.19.1