blob: e7529c97894f51a904353cf1ac45902ba8f0cb84 [file] [log] [blame]
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Distributed under the terms of the GNU General Public License v2
# This ebuild only cares about its own FILESDIR and ebuild file, so it tracks
# the canonical empty project.
inherit cros-workon user udev
DESCRIPTION="ChromeOS specific system setup"
IUSE="ac_only chromeless_tty cros_embedded cros_host pam vtconsole"
# We need to make sure timezone-data is merged before us.
# See pkg_setup below as well as
# and friends.
# Similarly, we have to make sure bash is merged before us.
# We don't need dash because only bash modifies ROOT duing
# pkg_* stages, and depending on dash would disable a little
# bit of possible parallelism.
# See for more details.
!cros_host? (
!pam? (
cros_embedded? (
# The user that all user-facing processes will run as.
# Adds a "daemon"-type user/group pair.
add_daemon_user() {
local username="$1"
local uid="$2"
enewuser "${username}" "${uid}"
enewgroup "${username}" "${uid}"
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}"
# Standard system users/groups. Allow them to get default IDs.
add_daemon_user "root"
add_daemon_user "bin"
add_daemon_user "daemon"
enewgroup "sys"
add_daemon_user "adm"
enewgroup "tty"
enewgroup "disk"
add_daemon_user "lp"
enewgroup "mem"
enewgroup "kmem"
enewgroup "wheel"
enewgroup "floppy"
add_daemon_user "news"
add_daemon_user "uucp"
enewgroup "console"
enewgroup "audio"
enewgroup "cdrom"
enewgroup "tape"
enewgroup "video"
enewgroup "cdrw"
enewgroup "usb"
enewgroup "users"
add_daemon_user "portage"
enewgroup "utmp"
enewgroup "nogroup"
add_daemon_user "nobody"
enewgroup "uinput"
pkg_preinst() {
# Create users and groups that are used by system daemons at runtime.
# Users and groups that are also needed at build time should be
# created in pkg_setup instead.
add_daemon_user "input" # For /dev/input/event access
enewgroup "i2c" # For I2C device node access.
enewgroup "hidraw" # For hidraw device node access.
enewgroup "drm_dp_aux" # For drm_dp_aux device node access.
enewgroup "password-viewers" # For access to the user's password
enewgroup "serial" # For owning access to serial devices.
enewgroup "tun" # For access to /dev/net/tun.
# The user that all user-facing processes will run as.
local system_user="${SHARED_USER_NAME}"
local system_id="1000"
local system_home="/home/${system_user}/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="chronos-access"
local system_access_id="1001"
enewgroup "${system_user}" "${system_id}"
add_daemon_user "${system_user}"
add_daemon_user "${system_access_user}" "${system_access_id}"
# Some default directories. These are created here rather than at
# install because some of them may already exist and have mounts.
local x
for x in /dev /home /media /run /mnt/empty \
/mnt/stateful_partition /proc /root /sys /var/lock; do
[[ -d "${ROOT}/${x}" ]] && continue
install -d --mode=0755 --owner=root --group=root "${ROOT}/${x}"
src_install() {
insinto /etc
doins "${FILESDIR}"/issue
insinto /etc/sysctl.d
doins "${FILESDIR}"/00-sysctl.conf
if use ac_only ; then
doins "${FILESDIR}"/10-ac-only.conf
insinto /etc/profile.d
doins "${FILESDIR}"/
insinto /etc/avahi
doins "${FILESDIR}"/avahi-daemon.conf
# 01editor is currently using /usr/bin/vi, which is available on both
# cros_host and DUT. Please update this when default editor is changed.
insinto /etc/env.d
doins "${FILESDIR}/01editor"
# target-specific fun
if ! use cros_host ; then
dodir /bin /usr/bin
# Install all the udev rules.
udev_dorules "${FILESDIR}"/udev-rules/*.rules
use vtconsole && udev_dorules "${FILESDIR}"/60-X-tty1-tty2-group-rw.rules
# Symlink /etc/localtime to something on the stateful
# partition. At runtime, the system will take care of
# initializing the path in /var.
dosym /var/lib/timezone/localtime /etc/localtime
# We use mawk in the target boards, not gawk.
dosym mawk /usr/bin/awk
# We want dash as our main shell.
dosym dash /bin/sh
# Avoid the wrapper and just link to the only editor we have.
dodir /usr/libexec
dosym /usr/bin/$(usex cros_embedded vi vim) /usr/libexec/editor
dosym /bin/more /usr/libexec/pager
# Install our custom ssh config settings.
insinto /etc/ssh
doins "${FILESDIR}"/ssh{,d}_config
fperms 600 /etc/ssh/sshd_config
if ! use pam ; then
dobin "${FILESDIR}"/sudo
sed -i -e '/^UsePAM/d' "${D}"/etc/ssh/sshd_config || die
# Custom login shell snippets.
insinto /etc/profile.d
doins "${FILESDIR}"/
# Some daemons and utilities access the mounts through /etc/mtab.
dosym /proc/mounts /etc/mtab
insinto /etc/sudoers.d
echo "${SHARED_USER_NAME} ALL=(ALL) ALL" > 95_cros_base
insopts -m 440
doins 95_cros_base