Gentoo Archives: gentoo-commits

From: Benda XU <heroxbd@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/baselayout/
Date: Mon, 04 Sep 2017 06:27:49
Message-Id: 1504506454.d129d916465c0ddb7a67f12c3e928be4a25da214.heroxbd@gentoo
1 commit: d129d916465c0ddb7a67f12c3e928be4a25da214
2 Author: Benda Xu <heroxbd <AT> gentoo <DOT> org>
3 AuthorDate: Mon Sep 4 06:16:45 2017 +0000
4 Commit: Benda XU <heroxbd <AT> gentoo <DOT> org>
5 CommitDate: Mon Sep 4 06:27:34 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d129d916
7
8 sys-apps/baselayout: handle Prefix-related paths more robustly.
9
10 commit 6d45b94abca08b1c124e11 fails with a corner case that EPREFIX
11 contains substring /usr. This commit fix it by using the well tested
12 hprefixify from prefix.eclass.
13
14 Also apply hprefix to other files to simplify the ebuild. Tested on
15 both Prefix and vanilla Gentoo.
16
17 Move the host PATHs to /etc/env.d/99host.
18
19 For Prefix, ROOTPATH will always be used, because it is almost a single
20 user system.
21
22 Package-Manager: Portage-2.3.3, Repoman-2.3.1
23
24 sys-apps/baselayout/baselayout-2.4.1-r2.ebuild | 245 +++++++++++++++++++++++++
25 1 file changed, 245 insertions(+)
26
27 diff --git a/sys-apps/baselayout/baselayout-2.4.1-r2.ebuild b/sys-apps/baselayout/baselayout-2.4.1-r2.ebuild
28 new file mode 100644
29 index 00000000000..a535d30248a
30 --- /dev/null
31 +++ b/sys-apps/baselayout/baselayout-2.4.1-r2.ebuild
32 @@ -0,0 +1,245 @@
33 +# Copyright 1999-2017 Gentoo Foundation
34 +# Distributed under the terms of the GNU General Public License v2
35 +
36 +EAPI=6
37 +
38 +inherit eutils multilib versionator prefix
39 +
40 +DESCRIPTION="Filesystem baselayout and init scripts"
41 +HOMEPAGE="https://www.gentoo.org/"
42 +SRC_URI="https://gitweb.gentoo.org/proj/baselayout.git/snapshot/${P}.tar.bz2"
43 +
44 +LICENSE="GPL-2"
45 +SLOT="0"
46 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
47 +IUSE="build kernel_linux"
48 +
49 +pkg_setup() {
50 + multilib_layout
51 +}
52 +
53 +# Create our multilib dirs - the Makefile has no knowledge of this
54 +multilib_layout() {
55 + local libdir libdirs=$(get_all_libdirs) def_libdir=$(get_abi_LIBDIR $DEFAULT_ABI)
56 + : ${libdirs:=lib} # it isn't that we don't trust multilib.eclass...
57 +
58 + [ -z "${def_libdir}" ] && die "your DEFAULT_ABI=$DEFAULT_ABI appears to be invalid"
59 +
60 + # figure out which paths should be symlinks and which should be directories
61 + local dirs syms exp d
62 + for libdir in ${libdirs} ; do
63 + exp=( {,usr/,usr/local/}${libdir} )
64 + for d in "${exp[@]}" ; do
65 + # most things should be dirs
66 + if [ "${SYMLINK_LIB}" = "yes" ] && [ "${libdir}" = "lib" ] ; then
67 + [ ! -h "${d}" ] && [ -e "${d}" ] && dirs+=" ${d}"
68 + else
69 + [ -h "${d}" ] && syms+=" ${d}"
70 + fi
71 + done
72 + done
73 + if [ -n "${syms}${dirs}" ] ; then
74 + ewarn "Your system profile has SYMLINK_LIB=${SYMLINK_LIB:-no}, so that means you need to"
75 + ewarn "have these paths configured as follows:"
76 + [ -n "${dirs}" ] && ewarn "symlinks to '${def_libdir}':${dirs}"
77 + [ -n "${syms}" ] && ewarn "directories:${syms}"
78 + ewarn "The ebuild will attempt to fix these, but only for trivial conversions."
79 + ewarn "If things fail, you will need to manually create/move the directories."
80 + echo
81 + fi
82 +
83 + # setup symlinks and dirs where we expect them to be; do not migrate
84 + # data ... just fall over in that case.
85 + local prefix
86 + for prefix in "${EROOT}"{,usr/,usr/local/} ; do
87 + if [ "${SYMLINK_LIB}" = yes ] ; then
88 + # we need to make sure "lib" points to the native libdir
89 + if [ -h "${prefix}lib" ] ; then
90 + # it's already a symlink! assume it's pointing to right place ...
91 + continue
92 + elif [ -d "${prefix}lib" ] ; then
93 + # "lib" is a dir, so need to convert to a symlink
94 + ewarn "Converting ${prefix}lib from a dir to a symlink"
95 + rm -f "${prefix}lib"/.keep
96 + if rmdir "${prefix}lib" 2>/dev/null ; then
97 + ln -s ${def_libdir} "${prefix}lib" || die
98 + else
99 + die "non-empty dir found where we needed a symlink: ${prefix}lib"
100 + fi
101 + else
102 + # nothing exists, so just set it up sanely
103 + ewarn "Initializing ${prefix}lib as a symlink"
104 + mkdir -p "${prefix}" || die
105 + rm -f "${prefix}lib" || die
106 + ln -s ${def_libdir} "${prefix}lib" || die
107 + mkdir -p "${prefix}${def_libdir}" #423571
108 + fi
109 + else
110 + # we need to make sure "lib" is a dir
111 + if [ -h "${prefix}lib" ] ; then
112 + # "lib" is a symlink, so need to convert to a dir
113 + ewarn "Converting ${prefix}lib from a symlink to a dir"
114 + rm -f "${prefix}lib" || die
115 + if [ -d "${prefix}lib32" ] ; then
116 + ewarn "Migrating ${prefix}lib32 to ${prefix}lib"
117 + mv "${prefix}lib32" "${prefix}lib" || die
118 + else
119 + mkdir -p "${prefix}lib" || die
120 + fi
121 + elif [ -d "${prefix}lib" ] && ! has lib32 ${libdirs} ; then
122 + # make sure the old "lib" ABI location does not exist; we
123 + # only symlinked the lib dir on systems where we moved it
124 + # to "lib32" ...
125 + case ${CHOST} in
126 + *-gentoo-freebsd*) ;; # We want it the other way on fbsd.
127 + i?86*|x86_64*|powerpc*|sparc*|s390*)
128 + if [ -d "${prefix}lib32" ] ; then
129 + rm -f "${prefix}lib32"/.keep
130 + if ! rmdir "${prefix}lib32" 2>/dev/null ; then
131 + ewarn "You need to merge ${prefix}lib32 into ${prefix}lib"
132 + die "non-empty dir found where there should be none: ${prefix}lib32"
133 + fi
134 + fi
135 + ;;
136 + esac
137 + else
138 + # nothing exists, so just set it up sanely
139 + ewarn "Initializing ${prefix}lib as a dir"
140 + mkdir -p "${prefix}lib" || die
141 + fi
142 + fi
143 + done
144 +}
145 +
146 +pkg_preinst() {
147 + # Bug #217848 - Since the remap_dns_vars() called by pkg_preinst() of
148 + # the baselayout-1.x ebuild copies all the real configs from the user's
149 + # /etc/conf.d into ${D}, it makes them all appear to be the default
150 + # versions. In order to protect them from being unmerged after this
151 + # upgrade, modify their timestamps.
152 + touch "${EROOT}"/etc/conf.d/* 2>/dev/null
153 +
154 + # This is written in src_install (so it's in CONTENTS), but punt all
155 + # pending updates to avoid user having to do etc-update (and make the
156 + # pkg_postinst logic simpler).
157 + rm -f "${EROOT}"/etc/._cfg????_gentoo-release
158 +
159 + # We need to install directories and maybe some dev nodes when building
160 + # stages, but they cannot be in CONTENTS.
161 + # Also, we cannot reference $S as binpkg will break so we do this.
162 + multilib_layout
163 + if use build ; then
164 + emake -C "${ED}/usr/share/${PN}" DESTDIR="${EROOT}" layout || die
165 + fi
166 + rm -f "${ED}"/usr/share/${PN}/Makefile
167 +}
168 +
169 +src_prepare() {
170 + default
171 + if use prefix; then
172 + hprefixify -e "/EUID/s,0,${EUID}," -q '"' etc/profile
173 + hprefixify etc/{env.d/50baselayout,shells} share.Linux/passwd
174 + echo PATH=/usr/bin:/bin >> etc/env.d/99host
175 + echo ROOTPATH=/usr/sbin:/sbin:/usr/bin:/bin >> etc/env.d/99host
176 + fi
177 +
178 + # handle multilib paths. do it here because we want this behavior
179 + # regardless of the C library that you're using. we do explicitly
180 + # list paths which the native ldconfig searches, but this isn't
181 + # problematic as it doesn't change the resulting ld.so.cache or
182 + # take longer to generate. similarly, listing both the native
183 + # path and the symlinked path doesn't change the resulting cache.
184 + local libdir ldpaths
185 + for libdir in $(get_all_libdirs) ; do
186 + ldpaths+=":${EPREFIX}/${libdir}:${EPREFIX}/usr/${libdir}"
187 + ldpaths+=":${EPREFIX}/usr/local/${libdir}"
188 + done
189 + echo "LDPATH='${ldpaths#:}'" >> etc/env.d/50baselayout
190 +
191 + # rc-scripts version for testing of features that *should* be present
192 + echo "Gentoo Base System release ${PV}" > etc/gentoo-release
193 +}
194 +
195 +src_install() {
196 + emake \
197 + OS=$(usex kernel_FreeBSD BSD Linux) \
198 + DESTDIR="${ED}" \
199 + install
200 + dodoc ChangeLog
201 +
202 + # need the makefile in pkg_preinst
203 + insinto /usr/share/${PN}
204 + doins Makefile
205 +}
206 +
207 +pkg_postinst() {
208 + local x
209 +
210 + # We installed some files to /usr/share/baselayout instead of /etc to stop
211 + # (1) overwriting the user's settings
212 + # (2) screwing things up when attempting to merge files
213 + # (3) accidentally packaging up personal files with quickpkg
214 + # If they don't exist then we install them
215 + for x in master.passwd passwd shadow group fstab ; do
216 + [ -e "${EROOT}etc/${x}" ] && continue
217 + [ -e "${EROOT}usr/share/baselayout/${x}" ] || continue
218 + cp -p "${EROOT}usr/share/baselayout/${x}" "${EROOT}"etc
219 + done
220 +
221 + # Force shadow permissions to not be world-readable #260993
222 + for x in shadow ; do
223 + [ -e "${EROOT}etc/${x}" ] && chmod o-rwx "${EROOT}etc/${x}"
224 + done
225 +
226 + # Take care of the etc-update for the user
227 + if [ -e "${EROOT}"etc/._cfg0000_gentoo-release ] ; then
228 + mv "${EROOT}"etc/._cfg0000_gentoo-release "${EROOT}"etc/gentoo-release
229 + fi
230 +
231 + # whine about users that lack passwords #193541
232 + if [[ -e "${EROOT}"etc/shadow ]] ; then
233 + local bad_users=$(sed -n '/^[^:]*::/s|^\([^:]*\)::.*|\1|p' "${EROOT}"/etc/shadow)
234 + if [[ -n ${bad_users} ]] ; then
235 + echo
236 + ewarn "The following users lack passwords!"
237 + ewarn ${bad_users}
238 + fi
239 + fi
240 +
241 + # baselayout leaves behind a lot of .keep files, so let's clean them up
242 + find "${EROOT}"lib*/rcscripts/ -name .keep -exec rm -f {} + 2>/dev/null
243 + find "${EROOT}"lib*/rcscripts/ -depth -type d -exec rmdir {} + 2>/dev/null
244 +
245 + # whine about users with invalid shells #215698
246 + if [[ -e "${EROOT}"etc/passwd ]] ; then
247 + local bad_shells=$(awk -F: 'system("test -e " $7) { print $1 " - " $7}' "${EROOT}"etc/passwd | sort)
248 + if [[ -n ${bad_shells} ]] ; then
249 + echo
250 + ewarn "The following users have non-existent shells!"
251 + ewarn "${bad_shells}"
252 + fi
253 + fi
254 +
255 + # https://bugs.gentoo.org/361349
256 + if use kernel_linux; then
257 + mkdir -p "${EROOT}"run
258 +
259 + if ! grep -qs "^tmpfs.*/run " "${ROOT}"proc/mounts ; then
260 + echo
261 + ewarn "You should reboot the system now to get /run mounted with tmpfs!"
262 + fi
263 + fi
264 +
265 + for x in ${REPLACING_VERSIONS}; do
266 + if ! version_is_at_least 2.4 ${v}; then
267 + ewarn "After updating ${EROOT}etc/profile, please run"
268 + ewarn "env-update and . /etc/profile"
269 + break
270 + fi
271 + done
272 +
273 + if [[ -e "${EROOT}"etc/env.d/00basic ]]; then
274 + ewarn "${EROOT}etc/env.d/00basic is now ${EROOT}etc/env.d/50baselayout"
275 + ewarn "Please migrate your changes."
276 + fi
277 +}