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