feat(sys-apps/baselayout): New CoreOS specific baselayout package!

This replaces the old Gentoo baselayout and coreos-base packages.

Changes include:
 - Move nss data files from /etc to /usr/share/baselayout
 - Enable nss-usrfiles module to use the new location.
 - Move other misc files from /etc to /usr/share/baselayout, using
   compatibility symlinks in /etc generated by tmpfiles.
 - All base system directories can be generated by tmpfiles.
 - No more /etc/gentoo-release
 - Simplified code, doesn't bother trying to migrate lib symlinks and
   simply fails if the existing filesystem is incorrect.
 - In /usr images the `core` user's UID/GID is now 500 to keep us within
   the reserved system UID/GID space. Eventually once the SDK switches
   to this the `core` user will not conflict with the local developer's
   account. It also makes it clearer what range people can use when
   creating accounts in /usr images. No other UID/GIDs are changing.
 - New eclass to let ebuilds run the equivalent of `tmpfiles --create`.
   In the future this may be replaced by calling `tmpfiles` directly
   once it has a `--root` argument but I haven't pushed those patches
   upstream for review yet.
This commit is contained in:
Michael Marineau 2014-02-14 13:32:02 -08:00
parent b0c4ed9c1b
commit 05b70651dd
18 changed files with 258 additions and 779 deletions

View File

@ -1,216 +0,0 @@
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Distributed under the terms of the GNU General Public License v2
EAPI=5
inherit useradd
DESCRIPTION="ChromeOS specific system setup"
HOMEPAGE="http://src.chromium.org/"
SRC_URI=""
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 arm x86"
IUSE="cros_host"
# We need to make sure timezone-data is merged before us.
# See pkg_setup below as well as http://crosbug.com/27413
# and friends.
DEPEND="sys-apps/baselayout
sys-apps/efunctions
!<sys-libs/timezone-data-2011d
!<=app-admin/sudo-1.8.2
!<sys-apps/mawk-1.3.4
!<app-shells/bash-4.1
!<app-shells/dash-0.5.5
!<net-misc/openssh-5.2_p1-r8
!cros_host? (
sys-libs/timezone-data
)"
RDEPEND="${DEPEND}
sys-apps/systemd
"
# no source directory
S="${WORKDIR}"
# Remove entry from /etc/group
#
# $1 - Group name
remove_group() {
[ -e "${ROOT}/etc/group" ] && sed -i -e /^${1}:.\*$/d "${ROOT}/etc/group"
}
# Adds a "daemon"-type user with no login or shell.
copy_or_add_daemon_user() {
local username="$1"
local uid="$2"
if user_exists "${username}"; then
elog "Removing existing user '$1' for copy_or_add_daemon_user"
remove_user "${username}"
fi
copy_or_add_user "${username}" "*" $uid $uid "" /dev/null /bin/false
if group_exists "${username}"; then
elog "Removing existing group '$1' for copy_or_add_daemon_user"
elog "Any existing group memberships will be lost"
remove_group "${username}"
fi
copy_or_add_group "${username}" $uid
}
# Removes all users from a group in /etc/group.
# No changes if the group does not exist.
remove_all_users_from_group() {
local group="$1"
sed -i "/^${group}:/s/:[^:]*$/:/" "${ROOT}/etc/group"
}
# Removes a list of users from a group in /etc/group.
# No changes if the group does not exist or the user is not in the group.
remove_users_from_group() {
local group="$1"; shift
local username
for username in "$@"; do
sed -i -r "/^${group}:/{s/([,:])${username}(,|$)/\1/; s/,$//}" \
"${ROOT}/etc/group"
done
}
# Adds a list of users to a group in /etc/group.
# No changes if the group does not exist.
add_users_to_group() {
local group="$1"; shift
local username
remove_users_from_group "${group}" "$@"
for username in "$@"; do
sed -i "/^${group}:/{ s/$/,${username}/ ; s/:,/:/ }" "${ROOT}/etc/group"
done
}
pkg_setup() {
if ! use cros_host ; then
# The sys-libs/timezone-data package installs a default /etc/localtime
# file automatically, so scrub that if it's a regular file.
local etc_tz="${ROOT}etc/localtime"
[[ -L ${etc_tz} ]] || rm -f "${etc_tz}"
fi
}
src_install() {
dodir /usr/lib/sysctl.d
insinto /usr/lib/sysctl.d
newins "${FILESDIR}"/sysctl.conf ${PN}.conf
# Add a /srv directory for mounting into later
dodir /srv
keepdir /srv
# target-specific fun
if ! use cros_host ; then
# Make mount work in the way systemd prescribes
dosym /proc/mounts /etc/mtab
# Put resolv.conf in /var/run so root can be read-only
dosym /var/run/resolv.conf /etc/resolv.conf
# Insert a cool motd ;)
insinto /etc
doins "${FILESDIR}"/motd
# Insert empty fstab
doins "${FILESDIR}"/fstab
# Insert a mini vimrc to avoid driving everyone insane
insinto /usr/share/vim
doins "${FILESDIR}"/vimrc
dosym ../../usr/share/vim/vimrc /etc/vim/vimrc
fi
# Add a sudo file for the core use
if [[ -n ${SHARED_USER_NAME} ]] ; then
insinto /etc/sudoers.d
echo "${SHARED_USER_NAME} ALL=(ALL) NOPASSWD: ALL" > 95_core_base
insopts -m 440
doins 95_core_base || die
fi
}
pkg_postinst() {
local x
# We explicitly add all of the users needed in the system here. The
# build of Chromium OS uses a single build chroot environment to build
# for various targets with distinct ${ROOT}. This causes two problems:
# 1. The target rootfs needs to have the same UIDs as the build
# chroot so that chmod operations work.
# 2. The portage tools to add a new user in an ebuild don't work when
# $ROOT != /
# We solve this by having baselayout install in both the build and
# target and pre-create all needed users. In order to support existing
# build roots we copy over the user entries if they already exist.
local system_user="core"
local system_id="1000"
local system_home="/home/${system_user}"
# Add a chronos-access group to provide non-chronos users,
# mostly system daemons running as a non-chronos user, group permissions
# to access files/directories owned by chronos.
# local system_access_user="core-access"
# local system_access_id="1001"
local crypted_password='*'
[ -r "${SHARED_USER_PASSWD_FILE}" ] &&
crypted_password=$(cat "${SHARED_USER_PASSWD_FILE}")
remove_user "${system_user}"
add_user "${system_user}" "x" "${system_id}" \
"${system_id}" "system_user" "${system_home}" /bin/bash
remove_shadow "${system_user}"
add_shadow "${system_user}" "${crypted_password}"
copy_or_add_group "${system_user}" "${system_id}"
# copy_or_add_daemon_user "${system_access_user}" "${system_access_id}"
copy_or_add_daemon_user "messagebus" 201 # For dbus
copy_or_add_daemon_user "syslog" 202 # For rsyslog
copy_or_add_daemon_user "ntp" 203
copy_or_add_daemon_user "sshd" 204
# copy_or_add_daemon_user "polkituser" 206 # For policykit
# copy_or_add_daemon_user "tss" 207 # For trousers (TSS/TPM)
# copy_or_add_daemon_user "pkcs11" 208 # For pkcs11 clients
# copy_or_add_daemon_user "qdlservice" 209 # for QDLService
# copy_or_add_daemon_user "cromo" 210 # For cromo (modem manager)
# copy_or_add_daemon_user "cashew" 211 # Deprecated, do not reuse
# copy_or_add_daemon_user "ipsec" 212 # For strongswan/ipsec VPN
# copy_or_add_daemon_user "cros-disks" 213 # For cros-disks
# copy_or_add_daemon_user "tor" 214 # For tor (anonymity service)
# copy_or_add_daemon_user "tcpdump" 215 # For tcpdump --with-user
# copy_or_add_daemon_user "debugd" 216 # For debugd
# copy_or_add_daemon_user "openvpn" 217 # For openvpn
# copy_or_add_daemon_user "bluetooth" 218 # For bluez
# copy_or_add_daemon_user "wpa" 219 # For wpa_supplicant
# copy_or_add_daemon_user "cras" 220 # For cras (audio)
# copy_or_add_daemon_user "gavd" 221 # For gavd (audio) (deprecated)
# copy_or_add_daemon_user "input" 222 # For /dev/input/event access
# copy_or_add_daemon_user "chaps" 223 # For chaps (pkcs11)
copy_or_add_daemon_user "dhcp" 224 # For dhcpcd (DHCP client)
# copy_or_add_daemon_user "tpmd" 225 # For tpmd
# copy_or_add_daemon_user "mtp" 226 # For libmtp
# copy_or_add_daemon_user "proxystate" 227 # For proxy monitoring
# copy_or_add_daemon_user "power" 228 # For powerd
# copy_or_add_daemon_user "watchdog" 229 # For daisydog
# copy_or_add_daemon_user "devbroker" 230 # For permission_broker
# copy_or_add_daemon_user "xorg" 231 # For Xorg
copy_or_add_daemon_user "etcd" 232 # For etcd
copy_or_add_daemon_user "docker" 233 # For docker
copy_or_add_daemon_user "tlsdate" 234 # For tlsdate
copy_or_add_group "systemd-journal" 248 # For journalctl access
copy_or_add_group "dialout" 249 # For udev rules
# copy_or_add_daemon_user "ntfs-3g" 300 # For ntfs-3g prcoess
# copy_or_add_daemon_user "avfs" 301 # For avfs process
# copy_or_add_daemon_user "fuse-exfat" 302 # For exfat-fuse prcoess
# copy_or_add_group "serial" 402
# Give the core user access to some system tools
add_users_to_group "docker" "${system_user}"
add_users_to_group "systemd-journal" "${system_user}"
}

View File

@ -1,14 +0,0 @@
# /etc/fstab: static file system information.
#
# noatime turns off atimes for increased performance (atimes normally aren't
# needed); notail increases performance of ReiserFS (at the expense of storage
# efficiency). It's safe to drop the noatime options if you want and to
# switch between notail / tail freely.
#
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# See the manpage fstab(5) for more information.
#
# <fs> <mountpoint> <type> <opts> <dump/pass>

View File

@ -1,5 +0,0 @@
______ ____ _____
/ ____/___ ________ / __ \/ ___/
/ / / __ \/ ___/ _ \/ / / /\__ \
/ /___/ /_/ / / / __/ /_/ /___/ /
\____/\____/_/ \___/\____//____/

View File

@ -1,19 +0,0 @@
# sysctl defaults for CoreOS
# Enable IPv4 forwarding to support NAT in containers
net.ipv4.ip_forward = 1
# Enables source route verification
net.ipv4.conf.default.rp_filter = 1
# Enable reverse path
net.ipv4.conf.all.rp_filter = 1
# Set watchdog_thresh
kernel.watchdog_thresh = 5
# When the kernel panics, automatically reboot to preserve dump in ram
kernel.panic = -1
# Reboot on oops as well
kernel.panic_on_oops = 1
# Disable kernel address visibility to non-root users.
kernel.kptr_restrict = 1

View File

@ -1,18 +0,0 @@
" Minimal configuration file for Vim on CoreOS
"
" The vim package is installed with USE=minimal to avoid installing lots of
" extra files but that doesn't mean we like vim acting as if it were vi.
" General settings from Gentoo's default vimrc:
set nocompatible " Use Vim defaults (much better!)
set bs=2 " Allow backspacing over everything in insert mode
set ruler " Show the cursor position all the time
set nomodeline " We don't allow modelines by default
" Read vimrc from the state partition if it exists.
if filereadable("/media/state/etc/vim/vimrc")
source /etc/vim/vimrc
endif
if filereadable("/media/state/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif

View File

@ -101,7 +101,6 @@ RDEPEND="${RDEPEND}
app-arch/gzip
app-arch/tar
app-shells/bash
coreos-base/coreos-base
coreos-base/cros_boot_mode
coreos-base/vboot_reference
coreos-base/update_engine

View File

@ -39,7 +39,6 @@ RDEPEND="${RDEPEND}
app-emulation/qemu
app-text/texi2html
coreos-base/google-breakpad
coreos-base/coreos-base
coreos-base/coreos-installer
coreos-base/cros-devutils[cros_host]
coreos-base/cros-factoryutils

View File

@ -17,7 +17,6 @@ DEPEND="
app-admin/sudo
app-arch/pbzip2
app-shells/bash-completion
coreos-base/coreos-base
coreos-base/hard-host-depends
dev-python/setuptools
dev-util/boost-build

View File

@ -1,6 +0,0 @@
PKG_INSTALL_MASK+=" /etc/sysctl.conf"
INSTALL_MASK+=" /etc/sysctl.conf"
# Don't filter out /etc/init.d/functions.sh
PKG_INSTALL_MASK=${PKG_INSTALL_MASK/\/etc\/init.d}
INSTALL_MASK=${INSTALL_MASK/\/etc\/init.d}

View File

@ -0,0 +1,93 @@
# Copyright 2014 The CoreOS Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: cros-tmpfiles
# @AUTHOR: marineam
# @BLURB: A basic systemd-tmpfiles --create implementation for ebuilds.
# @DESCRIPTION:
# Any location that is outside of /usr must be initialized during the build
# and (re)created during boot if it is missing. To avoid duplicating
# definitions of these directories/symlinks in ebuilds and tmpfiles configs
# packages can instead only install a tmpfiles config and use this eclass to
# create teh paths in an ebuild friendly way.
#
# Note: in the future if we add a --root option to systemd-tmpfiles we can
# switch to calling that instead of using this simplified implementation.
# Enforce use of recent EAPIs for the sake of consistancy/sanity
case "${EAPI:-0}" in
0|1|2|3)
die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
;;
4|5)
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
;;
esac
# Since bash doesn't have a slick syntax for subsituting default values
# for anything other than blank vs. non-blank variables this helps.
# Usage: _tmpfiles_set_defaults mode uid gid age arg
_tmpfiles_do_file() {
[[ ${tmode} == - ]] && tmode=0644
if [[ "${ttype}" == F ]]; then
rm -rf "${ED}/${tpath}"
elif [[ -e "${ED}/${tpath}" ]]; then
return 0
fi
if [[ "${targ}" != - ]]; then
echo "${targ}" > "${ED}/${tpath}" || return 1
else
echo -n > "${ED}/${tpath}" || return 1
fi
chmod "${tmode}" "${ED}/${tpath}" || return 1
chown "${tuid}:${tgid}" "${ED}/${tpath}" || return 1
}
_tmpfiles_do_dir() {
[[ ${tmode} == - ]] && tmode=0755
if [[ "${ttype}" == d && -e "${ED}/${tpath}" ]]; then
return 0
else
rm -rf "${ED}/${tpath}"
fi
mkdir -m "${tmode}" "${ED}/${tpath}" || return 1
chown "${tuid}:${tgid}" "${ED}/${tpath}" || return 1
}
_tmpfiles_do_link() {
if [[ -e "${ED}/${tpath}" || -h "${ED}/${tpath}" ]]; then
return 0
fi
ln -s "${targ}" "${ED}/${tpath}" || return 1
}
_tmpfiles_do_create() {
local ttype tpath tmode tuid tgid tage targ trule
while read ttype tpath tmode tuid tgid tage targ; do
trule="$ttype $tpath $tmode $tuid $tgid $tage $targ"
[[ "${tuid}" == - ]] && tuid=root
[[ "${tgid}" == - ]] && tgid=root
case "${ttype}" in
f|F) _tmpfiles_do_file;;
d|D) _tmpfiles_do_dir;;
L) _tmpfiles_do_link;;
*) ewarn "Skipping tmpfiles rule: ${trule}";;
esac
if [[ $? -ne 0 ]]; then
eerror "Bad tmpfiles rule: ${trule}"
return 1
fi
done
}
tmpfiles_create() {
if [[ $# -eq 0 ]]; then
set -- "${ED}"/usr/lib*/tmpfiles.d/*.conf
fi
local conf
for conf in "$@"; do
_tmpfiles_do_create < "${conf}" || die "Bad tmpfiles config: ${conf}"
done
}

View File

@ -1 +0,0 @@
DIST baselayout-2.2.tar.bz2 40744 SHA256 11d4a223b06da545c3e59e07c9195570f334b5b1be05d995df0ebc8ea2203e98 SHA512 a5199c42e835d9f2683cc94f3c4c47ecdc392316c24e0932845736e2e90479b0c5c8ad72ead8e0537f097405b7d7548d00b87b7ff8c9e3651486e3c5c0970b36 WHIRLPOOL 60cc4f7f76c5a45c15303e526decffb3bad2b50ac659b1dd072d2ed4b0eb0b31929a1a733ddb03a31ee5882b889a4efb87206f63ffaa2b11e26d36afd0933a95

View File

@ -1,241 +0,0 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/baselayout/baselayout-2.2.ebuild,v 1.16 2013/07/27 22:56:21 williamh Exp $
inherit eutils multilib
DESCRIPTION="Filesystem baselayout and init scripts"
HOMEPAGE="http://www.gentoo.org/"
SRC_URI="mirror://gentoo/${P}.tar.bz2
http://dev.gentoo.org/~vapier/dist/${P}.tar.bz2"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
IUSE="build cros_host kernel_linux"
RDEPEND="cros_host? ( !coreos-base/coreos-init )"
pkg_setup() {
multilib_layout
}
# Create our multilib dirs - the Makefile has no knowledge of this
multilib_warn() {
local syms=$1 dirs=$2 def_libdir=$3
[ -z "${syms}${dirs}" ] && return
ewarn "Your system profile has SYMLINK_LIB=${SYMLINK_LIB}, so that means"
if [ -z "${syms}" ] ; then
ewarn "you need to have these paths as symlinks to ${def_libdir}:"
ewarn "$1"
fi
}
multilib_layout() {
local libdir libdirs=$(get_all_libdirs) def_libdir=$(get_abi_LIBDIR $DEFAULT_ABI)
: ${libdirs:=lib} # it isn't that we don't trust multilib.eclass...
[ -z "${def_libdir}" ] && die "your DEFAULT_ABI=$DEFAULT_ABI appears to be invalid"
# figure out which paths should be symlinks and which should be directories
local dirs syms exp d
for libdir in ${libdirs} ; do
exp=( {,usr/,usr/local/}${libdir} )
for d in "${exp[@]/#/${ROOT}}" ; do
# most things should be dirs
if [ "${SYMLINK_LIB}" = "yes" ] && [ "${libdir}" = "lib" ] ; then
[ ! -h "${d}" ] && [ -e "${d}" ] && dirs+=" ${d}"
else
[ -h "${d}" ] && syms+=" ${d}"
fi
done
done
if [ -n "${syms}${dirs}" ] ; then
ewarn "Your system profile has SYMLINK_LIB=${SYMLINK_LIB:-no}, so that means you need to"
ewarn "have these paths configured as follows:"
[ -n "${dirs}" ] && ewarn "symlinks to '${def_libdir}':${dirs}"
[ -n "${syms}" ] && ewarn "directories:${syms}"
ewarn "The ebuild will attempt to fix these, but only for trivial conversions."
ewarn "If things fail, you will need to manually create/move the directories."
echo
fi
# setup symlinks and dirs where we expect them to be; do not migrate
# data ... just fall over in that case.
local prefix
for prefix in "${ROOT}"{,usr/,usr/local/} ; do
if [ "${SYMLINK_LIB}" = yes ] ; then
# we need to make sure "lib" points to the native libdir
if [ -h "${prefix}lib" ] ; then
# it's already a symlink! assume it's pointing to right place ...
continue
elif [ -d "${prefix}lib" ] ; then
# "lib" is a dir, so need to convert to a symlink
ewarn "Converting ${prefix}lib from a dir to a symlink"
rm -f "${prefix}lib"/.keep
if rmdir "${prefix}lib" 2>/dev/null ; then
ln -s ${def_libdir} "${prefix}lib" || die
else
die "non-empty dir found where we needed a symlink: ${prefix}lib"
fi
else
# nothing exists, so just set it up sanely
ewarn "Initializing ${prefix}lib as a symlink"
mkdir -p "${prefix}" || die
rm -f "${prefix}lib" || die
ln -s ${def_libdir} "${prefix}lib" || die
mkdir -p "${prefix}${def_libdir}" #423571
fi
else
# we need to make sure "lib" is a dir
if [ -h "${prefix}lib" ] ; then
# "lib" is a symlink, so need to convert to a dir
ewarn "Converting ${prefix}lib from a symlink to a dir"
rm -f "${prefix}lib" || die
if [ -d "${prefix}lib32" ] ; then
ewarn "Migrating ${prefix}lib32 to ${prefix}lib"
mv "${prefix}lib32" "${prefix}lib" || die
else
mkdir -p "${prefix}lib" || die
fi
elif [ -d "${prefix}lib" ] ; then
# make sure the old "lib" ABI location does not exist; we
# only symlinked the lib dir on systems where we moved it
# to "lib32" ...
case ${CHOST} in
*-gentoo-freebsd*) ;; # We want it the other way on fbsd.
i?86*|x86_64*|powerpc*|sparc*|s390*)
if [ -d "${prefix}lib32" ] ; then
rm -f "${prefix}lib32"/.keep
if ! rmdir "${prefix}lib32" 2>/dev/null ; then
ewarn "You need to merge ${prefix}lib32 into ${prefix}lib"
die "non-empty dir found where there should be none: ${prefix}lib32"
fi
fi
;;
esac
else
# nothing exists, so just set it up sanely
ewarn "Initializing ${prefix}lib as a dir"
mkdir -p "${prefix}" || die
rm -f "${prefix}lib" || die
ln -s ${def_libdir} "${prefix}lib" || die
fi
fi
done
}
pkg_preinst() {
# Bug #217848 - Since the remap_dns_vars() called by pkg_preinst() of
# the baselayout-1.x ebuild copies all the real configs from the user's
# /etc/conf.d into ${D}, it makes them all appear to be the default
# versions. In order to protect them from being unmerged after this
# upgrade, modify their timestamps.
touch "${ROOT}"/etc/conf.d/* 2>/dev/null
# This is written in src_install (so it's in CONTENTS), but punt all
# pending updates to avoid user having to do etc-update (and make the
# pkg_postinst logic simpler).
rm -f "${ROOT}"/etc/._cfg????_gentoo-release
# We need to install directories and maybe some dev nodes when building
# stages, but they cannot be in CONTENTS.
# Also, we cannot reference $S as binpkg will break so we do this.
multilib_layout
if use build ; then
emake -C "${D}/usr/share/${PN}" DESTDIR="${ROOT}" layout || die
fi
rm -f "${D}"/usr/share/${PN}/Makefile
}
src_install() {
emake \
OS=$(usex kernel_FreeBSD BSD Linux) \
DESTDIR="${D}" \
install || die
dodoc ChangeLog.svn
# need the makefile in pkg_preinst
insinto /usr/share/${PN}
doins Makefile || die
# handle multilib paths. do it here because we want this behavior
# regardless of the C library that you're using. we do explicitly
# list paths which the native ldconfig searches, but this isn't
# problematic as it doesn't change the resulting ld.so.cache or
# take longer to generate. similarly, listing both the native
# path and the symlinked path doesn't change the resulting cache.
local libdir ldpaths
for libdir in $(get_all_libdirs) ; do
ldpaths+=":/${libdir}:/usr/${libdir}:/usr/local/${libdir}"
done
echo "LDPATH='${ldpaths#:}'" >> "${D}"/etc/env.d/00basic
# rc-scripts version for testing of features that *should* be present
echo "Gentoo Base System release ${PV}" > "${D}"/etc/gentoo-release
if use !cros_host; then
# Don't install /etc/issue since it is handled by coreos-init
rm "${D}"/etc/issue
fi
}
pkg_postinst() {
local x
# We installed some files to /usr/share/baselayout instead of /etc to stop
# (1) overwriting the user's settings
# (2) screwing things up when attempting to merge files
# (3) accidentally packaging up personal files with quickpkg
# If they don't exist then we install them
for x in master.passwd passwd shadow group fstab ; do
[ -e "${ROOT}etc/${x}" ] && continue
[ -e "${ROOT}usr/share/baselayout/${x}" ] || continue
cp -p "${ROOT}usr/share/baselayout/${x}" "${ROOT}"etc
done
# Force shadow permissions to not be world-readable #260993
for x in shadow ; do
[ -e "${ROOT}etc/${x}" ] && chmod o-rwx "${ROOT}etc/${x}"
done
# Take care of the etc-update for the user
if [ -e "${ROOT}"/etc/._cfg0000_gentoo-release ] ; then
mv "${ROOT}"/etc/._cfg0000_gentoo-release "${ROOT}"/etc/gentoo-release
fi
# whine about users that lack passwords #193541
if [[ -e ${ROOT}/etc/shadow ]] ; then
local bad_users=$(sed -n '/^[^:]*::/s|^\([^:]*\)::.*|\1|p' "${ROOT}"/etc/shadow)
if [[ -n ${bad_users} ]] ; then
echo
ewarn "The following users lack passwords!"
ewarn ${bad_users}
fi
fi
# baselayout leaves behind a lot of .keep files, so let's clean them up
find "${ROOT}"/lib*/rcscripts/ -name .keep -exec rm -f {} + 2>/dev/null
find "${ROOT}"/lib*/rcscripts/ -depth -type d -exec rmdir {} + 2>/dev/null
# whine about users with invalid shells #215698
if [[ -e ${ROOT}/etc/passwd ]] ; then
local bad_shells=$(awk -F: 'system("test -e " $7) { print $1 " - " $7}' /etc/passwd | sort)
if [[ -n ${bad_shells} ]] ; then
echo
ewarn "The following users have non-existent shells!"
ewarn "${bad_shells}"
fi
fi
# http://bugs.gentoo.org/361349
if use kernel_linux; then
mkdir -p "${ROOT}"/run
if ! grep -qs "^tmpfs.*/run " "${ROOT}"/proc/mounts ; then
echo
ewarn "You should reboot the system now to get /run mounted with tmpfs!"
fi
fi
}

View File

@ -1,255 +0,0 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/baselayout/baselayout-2.2.ebuild,v 1.16 2013/07/27 22:56:21 williamh Exp $
inherit eutils multilib
DESCRIPTION="Filesystem baselayout and init scripts"
HOMEPAGE="http://www.gentoo.org/"
SRC_URI="mirror://gentoo/${P}.tar.bz2
http://dev.gentoo.org/~vapier/dist/${P}.tar.bz2"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
IUSE="build cros_host kernel_linux symlink-usr"
RDEPEND="cros_host? ( !coreos-base/coreos-init )"
pkg_setup() {
multilib_layout
}
# Create our multilib dirs - the Makefile has no knowledge of this
multilib_warn() {
local syms=$1 dirs=$2 def_libdir=$3
[ -z "${syms}${dirs}" ] && return
ewarn "Your system profile has SYMLINK_LIB=${SYMLINK_LIB}, so that means"
if [ -z "${syms}" ] ; then
ewarn "you need to have these paths as symlinks to ${def_libdir}:"
ewarn "$1"
fi
}
multilib_layout() {
local libdir libdirs=$(get_all_libdirs) def_libdir=$(get_abi_LIBDIR $DEFAULT_ABI)
: ${libdirs:=lib} # it isn't that we don't trust multilib.eclass...
[ -z "${def_libdir}" ] && die "your DEFAULT_ABI=$DEFAULT_ABI appears to be invalid"
# figure out which paths should be symlinks and which should be directories
local dirs syms exp d
for libdir in ${libdirs} ; do
exp=( {,usr/,usr/local/}${libdir} )
for d in "${exp[@]/#/${ROOT}}" ; do
# most things should be dirs
if [ "${SYMLINK_LIB}" = "yes" ] && [ "${libdir}" = "lib" ] ; then
[ ! -h "${d}" ] && [ -e "${d}" ] && dirs+=" ${d}"
else
[ -h "${d}" ] && syms+=" ${d}"
fi
done
done
if [ -n "${syms}${dirs}" ] ; then
ewarn "Your system profile has SYMLINK_LIB=${SYMLINK_LIB:-no}, so that means you need to"
ewarn "have these paths configured as follows:"
[ -n "${dirs}" ] && ewarn "symlinks to '${def_libdir}':${dirs}"
[ -n "${syms}" ] && ewarn "directories:${syms}"
ewarn "The ebuild will attempt to fix these, but only for trivial conversions."
ewarn "If things fail, you will need to manually create/move the directories."
echo
fi
if use symlink-usr ; then
for libdir in ${libdirs} ; do
if use symlink-usr && [ "${libdir}" != "lib" ] ; then
ln -s usr/${libdir} ${ROOT}/${libdir}
fi
done
fi
# setup symlinks and dirs where we expect them to be; do not migrate
# data ... just fall over in that case.
local prefix
for prefix in "${ROOT}"{,usr/,usr/local/} ; do
if [ "${SYMLINK_LIB}" = yes ] ; then
# we need to make sure "lib" points to the native libdir
if [ -h "${prefix}lib" ] ; then
# it's already a symlink! assume it's pointing to right place ...
continue
elif [ -d "${prefix}lib" ] ; then
# "lib" is a dir, so need to convert to a symlink
ewarn "Converting ${prefix}lib from a dir to a symlink"
rm -f "${prefix}lib"/.keep
if rmdir "${prefix}lib" 2>/dev/null ; then
ln -s ${def_libdir} "${prefix}lib" || die
else
die "non-empty dir found where we needed a symlink: ${prefix}lib"
fi
else
# nothing exists, so just set it up sanely
ewarn "Initializing ${prefix}lib as a symlink"
mkdir -p "${prefix}" || die
rm -f "${prefix}lib" || die
ln -s ${def_libdir} "${prefix}lib" || die
mkdir -p "${prefix}${def_libdir}" #423571
fi
else
# we need to make sure "lib" is a dir
if [ -h "${prefix}lib" ] ; then
# "lib" is a symlink, so need to convert to a dir
ewarn "Converting ${prefix}lib from a symlink to a dir"
rm -f "${prefix}lib" || die
if [ -d "${prefix}lib32" ] ; then
ewarn "Migrating ${prefix}lib32 to ${prefix}lib"
mv "${prefix}lib32" "${prefix}lib" || die
else
mkdir -p "${prefix}lib" || die
fi
elif [ -d "${prefix}lib" ] ; then
# make sure the old "lib" ABI location does not exist; we
# only symlinked the lib dir on systems where we moved it
# to "lib32" ...
case ${CHOST} in
*-gentoo-freebsd*) ;; # We want it the other way on fbsd.
i?86*|x86_64*|powerpc*|sparc*|s390*)
if [ -d "${prefix}lib32" ] ; then
rm -f "${prefix}lib32"/.keep
if ! rmdir "${prefix}lib32" 2>/dev/null ; then
ewarn "You need to merge ${prefix}lib32 into ${prefix}lib"
die "non-empty dir found where there should be none: ${prefix}lib32"
fi
fi
;;
esac
else
# nothing exists, so just set it up sanely
ewarn "Initializing ${prefix}lib as a dir"
mkdir -p "${prefix}" || die
rm -f "${prefix}lib" || die
ln -s ${def_libdir} "${prefix}lib" || die
fi
fi
done
}
pkg_preinst() {
# Bug #217848 - Since the remap_dns_vars() called by pkg_preinst() of
# the baselayout-1.x ebuild copies all the real configs from the user's
# /etc/conf.d into ${D}, it makes them all appear to be the default
# versions. In order to protect them from being unmerged after this
# upgrade, modify their timestamps.
touch "${ROOT}"/etc/conf.d/* 2>/dev/null
# This is written in src_install (so it's in CONTENTS), but punt all
# pending updates to avoid user having to do etc-update (and make the
# pkg_postinst logic simpler).
rm -f "${ROOT}"/etc/._cfg????_gentoo-release
# We need to install directories and maybe some dev nodes when building
# stages, but they cannot be in CONTENTS.
# Also, we cannot reference $S as binpkg will break so we do this.
multilib_layout
if use symlink-usr ; then
for bindir in bin sbin ; do
mkdir -p "${ROOT}"/usr/${bindir}
ln -s usr/${bindir} "${ROOT}"/${bindir}
done
fi
if use build ; then
emake -C "${D}/usr/share/${PN}" DESTDIR="${ROOT}" layout || die
fi
rm -f "${D}"/usr/share/${PN}/Makefile
}
src_install() {
emake \
OS=$(usex kernel_FreeBSD BSD Linux) \
DESTDIR="${D}" \
install || die
dodoc ChangeLog.svn
# need the makefile in pkg_preinst
insinto /usr/share/${PN}
doins Makefile || die
# handle multilib paths. do it here because we want this behavior
# regardless of the C library that you're using. we do explicitly
# list paths which the native ldconfig searches, but this isn't
# problematic as it doesn't change the resulting ld.so.cache or
# take longer to generate. similarly, listing both the native
# path and the symlinked path doesn't change the resulting cache.
local libdir ldpaths
for libdir in $(get_all_libdirs) ; do
ldpaths+=":/${libdir}:/usr/${libdir}:/usr/local/${libdir}"
done
echo "LDPATH='${ldpaths#:}'" >> "${D}"/etc/env.d/00basic
# rc-scripts version for testing of features that *should* be present
echo "Gentoo Base System release ${PV}" > "${D}"/etc/gentoo-release
if use !cros_host; then
# Don't install /etc/issue since it is handled by coreos-init
rm "${D}"/etc/issue
fi
}
pkg_postinst() {
local x
# We installed some files to /usr/share/baselayout instead of /etc to stop
# (1) overwriting the user's settings
# (2) screwing things up when attempting to merge files
# (3) accidentally packaging up personal files with quickpkg
# If they don't exist then we install them
for x in master.passwd passwd shadow group fstab ; do
[ -e "${ROOT}etc/${x}" ] && continue
[ -e "${ROOT}usr/share/baselayout/${x}" ] || continue
cp -p "${ROOT}usr/share/baselayout/${x}" "${ROOT}"etc
done
# Force shadow permissions to not be world-readable #260993
for x in shadow ; do
[ -e "${ROOT}etc/${x}" ] && chmod o-rwx "${ROOT}etc/${x}"
done
# Take care of the etc-update for the user
if [ -e "${ROOT}"/etc/._cfg0000_gentoo-release ] ; then
mv "${ROOT}"/etc/._cfg0000_gentoo-release "${ROOT}"/etc/gentoo-release
fi
# whine about users that lack passwords #193541
if [[ -e ${ROOT}/etc/shadow ]] ; then
local bad_users=$(sed -n '/^[^:]*::/s|^\([^:]*\)::.*|\1|p' "${ROOT}"/etc/shadow)
if [[ -n ${bad_users} ]] ; then
echo
ewarn "The following users lack passwords!"
ewarn ${bad_users}
fi
fi
# baselayout leaves behind a lot of .keep files, so let's clean them up
find "${ROOT}"/lib*/rcscripts/ -name .keep -exec rm -f {} + 2>/dev/null
find "${ROOT}"/lib*/rcscripts/ -depth -type d -exec rmdir {} + 2>/dev/null
# whine about users with invalid shells #215698
if [[ -e ${ROOT}/etc/passwd ]] ; then
local bad_shells=$(awk -F: 'system("test -e " $7) { print $1 " - " $7}' /etc/passwd | sort)
if [[ -n ${bad_shells} ]] ; then
echo
ewarn "The following users have non-existent shells!"
ewarn "${bad_shells}"
fi
fi
# http://bugs.gentoo.org/361349
if use kernel_linux; then
mkdir -p "${ROOT}"/run
if ! grep -qs "^tmpfs.*/run " "${ROOT}"/proc/mounts ; then
echo
ewarn "You should reboot the system now to get /run mounted with tmpfs!"
fi
fi
}

View File

@ -0,0 +1 @@
baselayout-9999.ebuild

View File

@ -0,0 +1,164 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI="5"
CROS_WORKON_PROJECT="coreos/baselayout"
CROS_WORKON_LOCALNAME="baselayout"
CROS_WORKON_REPO="git://github.com"
if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64 ~arm ~x86"
else
CROS_WORKON_COMMIT="0cb1ea85886399fa3077df6866167104932aaed3"
KEYWORDS="amd64 arm x86"
fi
inherit cros-workon cros-tmpfiles eutils multilib
DESCRIPTION="Filesystem baselayout for CoreOS"
HOMEPAGE="http://www.coreos.com/"
SRC_URI=""
LICENSE="GPL-2"
SLOT="0"
IUSE="cros_host symlink-usr"
# This version of baselayout replaces coreos-base
DEPEND="!coreos-base/coreos-base
!<sys-libs/glibc-2.17-r1
!<=sys-libs/nss-usrfiles-2.18.1_pre"
# Make sure coreos-init is not installed in the SDK
RDEPEND="${DEPEND}
sys-apps/efunctions
cros_host? ( !coreos-base/coreos-init )"
declare -A LIB_SYMS # list of /lib->lib64 symlinks
declare -A USR_SYMS # list of /foo->usr/foo symlinks
declare -a BASE_DIRS # list of absolute paths that should be directories
# Check that a pre-existing symlink is correct
check_sym() {
local path="$1" value="$2"
local real_path=$(readlink -f "${ROOT}${path}")
local real_value=$(readlink -f "${ROOT}${path%/*}/${value}")
if [[ -e "${read_path}" && "${read_path}" != "${read_value}" ]]; then
die "${path} is not a symlink to ${value}"
fi
}
pkg_setup() {
local libdirs=$(get_all_libdirs) def_libdir=$(get_abi_LIBDIR $DEFAULT_ABI)
if [[ -z "${libdirs}" || -z "${def_libdir}" ]]; then
die "your DEFAULT_ABI=$DEFAULT_ABI appears to be invalid"
fi
# figure out which paths should be symlinks and which should be directories
local d
for d in bin sbin ${libdirs} ; do
if [[ "${SYMLINK_LIB}" == "yes" && "${d}" == "lib" ]] ; then
if use symlink-usr; then
USR_SYMS["/lib"]="usr/${def_libdir}"
else
LIB_SYMS["/lib"]="${def_libdir}"
fi
LIB_SYMS["/usr/lib"]="${def_libdir}"
LIB_SYMS["/usr/local/lib"]="${def_libdir}"
elif use symlink-usr; then
USR_SYMS["/$d"]="usr/$d"
BASE_DIRS+=( "/usr/$d" "/usr/local/$d" )
else
BASE_DIRS+=( "/$d" "/usr/$d" "/usr/local/$d" )
fi
done
# make sure any pre-existing symlinks map to the expected locations.
local sym
for sym in "${!LIB_SYMS[@]}" ; do
check_sym "${sym}" "${LIB_SYMS[$sym]}"
done
if use symlink-usr; then
for sym in "${!USR_SYMS[@]}" ; do
check_sym "${sym}" "${USR_SYMS[$sym]}"
done
fi
}
src_install() {
# lib symlinks must be in place before make install
dodir "${BASE_DIRS[@]}"
local sym
for sym in "${!LIB_SYMS[@]}" ; do
dosym "${LIB_SYMS[$sym]}" "${sym}"
done
if use symlink-usr; then
for sym in "${!USR_SYMS[@]}" ; do
dosym "${USR_SYMS[$sym]}" "${sym}"
done
fi
emake DESTDIR="${D}" install
# generate a tmpfiles.d config to cover our /usr symlinks
if use symlink-usr; then
local tmpfiles=${D}/usr/lib/tmpfiles.d/baselayout-usr.conf
echo -n > ${tmpfiles} || die
for sym in "${!USR_SYMS[@]}" ; do
echo "L ${sym} - - - - ${USR_SYMS[$sym]}" >> ${tmpfiles}
done
fi
if ! use cros_host; then
# Docker parses /etc/group directly :(
local docker_grp=$(grep "^docker:" "${D}"/usr/share/baselayout/group)
echo "f /etc/group - - - - ${docker_grp}" > \
"${D}"/usr/lib/tmpfiles.d/baselayout-docker.conf || die
fi
# Fill in all other paths defined in tmpfiles configs
tmpfiles_create
# handle multilib paths. do it here because we want this behavior
# regardless of the C library that you're using. we do explicitly
# list paths which the native ldconfig searches, but this isn't
# problematic as it doesn't change the resulting ld.so.cache or
# take longer to generate. similarly, listing both the native
# path and the symlinked path doesn't change the resulting cache.
local libdir ldpaths
for libdir in $(get_all_libdirs) ; do
ldpaths+=":/${libdir}:/usr/${libdir}:/usr/local/${libdir}"
done
echo "LDPATH='${ldpaths#:}'" >> "${D}"/etc/env.d/00basic
if ! use symlink-usr ; then
# modprobe uses /lib instead of /usr/lib
mv "${D}"/usr/lib/modprobe.d "${D}"/lib/modprobe.d || die
# core is UID:GID 1000:1000 in old images
sed -i -e 's/^core:x:500:500:/core:x:1000:1000:/' \
"${D}"/usr/share/baselayout/passwd || die
sed -i -e 's/^core:x:500:/core:x:1000:/' \
"${D}"/usr/share/baselayout/group || die
# make sure the home dir ownership is correct
fowners -R 1000:1000 /home/core
else
fowners -R 500:500 /home/core
fi
if use cros_host; then
# Provided by vim in the SDK
rm -r "${D}"/etc/vim
else
# Don't install /etc/issue since it is handled by coreos-init
rm "${D}"/etc/issue
sed -i -e '%/etc/issue%d' "${D}"/usr/lib/tmpfiles.d/baselayout-etc.conf
# Set custom password for core user
if [[ -r "${SHARED_USER_PASSWD_FILE}" ]]; then
echo "core:$(<${SHARED_USER_PASSWD_FILE}):15887:0:::::" \
> "${D}"/etc/shadow || die
chmod 640 "${D}"/etc/shadow || die
fi
fi
}