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