Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
krnowak committed Aug 26, 2024
1 parent eabadb5 commit d746d41
Showing 1 changed file with 52 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [[ "${PV}" == 9999 ]]; then
inherit git-r3
KEYWORDS="~amd64 ~arm64"
else
EGIT_COMMIT="937a45faef0f7fa88d3d2c3f7ba60a7f3e2e82f7" # flatcar-master
EGIT_COMMIT="5c2e6b87b0b495013c14817f8f8f141d6da9b1e9" # krnowak/merged-usr
SRC_URI="https://github.com/flatcar/baselayout/archive/${EGIT_COMMIT}.tar.gz -> flatcar-${PN}-${EGIT_COMMIT}.tar.gz"
S="${WORKDIR}/${PN}-${EGIT_COMMIT}"
KEYWORDS="amd64 arm64"
Expand Down Expand Up @@ -36,15 +36,9 @@ RDEPEND="${DEPEND}
>=sys-apps/gentoo-functions-0.10
cros_host? ( !coreos-base/coreos-init )"

MOUNT_POINTS=(
/dev
/proc
/sys
)

declare -A USR_SYMS # list of /foo->usr/foo symlinks
declare -A EXTRA_SYMS # list of additional symlinks baked inside /usr
declare -a BASE_DIRS # list of absolute paths that should be directories
declare -A USR_SYMS # list of /foo->usr/foo symlinks
declare -A EXTRA_SYMS # list of additional symlinks baked inside /usr
declare -a BASE_DIRS # list of absolute paths that should be directories

pkg_setup() {
local libdirs=$(get_all_libdirs)
Expand All @@ -67,67 +61,30 @@ pkg_setup() {
EXTRA_SYMS['/usr/local/sbin']='bin'
}

src_compile() {
default

# generate a tmpfiles.d config to cover our /usr symlinks
local tmpfiles="${T}/baselayout-usr.conf"
echo -n > ${tmpfiles} || die
for sym in "${!USR_SYMS[@]}" ; do
echo "L+ ${sym} - - - - ${USR_SYMS[$sym]}" >> ${tmpfiles}
done
}

src_install() {
# PRE INST
keepdir "${BASE_DIRS[@]}"
local sym target
for sym in "${!EXTRA_SYMS[@]}"; do
target=${EXTRA_SYMS["${sym}"]}
dosym "${target}" "${sym}"
done


# DROP IT, THE GENERATION OF CORE HOME CAN BE DONE WITH MY FAKE TMPFILES.D SCRIPT
src_prepare() {
if use cros_host; then
# Since later systemd-tmpfiles --root is used only users from
# /etc/passwd are considered but we don't want to add core there
# because it would make emerge overwrite the system's database on
# installation when the SDK user is already there. Instead, just
# create the folder manually and remove the tmpfile directive.
rm "${S}/tmpfiles.d/baselayout-home.conf"
keepdir /home/core
fowners 500:500 /home/core
# Undesirable in the SDK
rm -f lib/tmpfiles.d/baselayout-etc-profile-flatcar-profile.conf
# Provided by vim in the SDK
rm -f lib/tmpfiles.d/baselayout-etc-vim.conf
# Don't initialize /etc/passwd, group, and friends on boot.
rm -f bin
rm -f lib/systemd
# Inject custom SSL configuration required for signing
# payloads from the SDK container using OpenSSL.
mkdir -p etc/ssl
cp -a share/baselayout/pkcs11.cnf etc/ssl
else
# Initialize /etc/passwd, group, and friends now, so
# systemd-tmpfiles can resolve user information in ${D}
# rootfs.
bash "scripts/flatcar-tmpfiles" "${D}" "${S}/baselayout" || die
# Don't install /etc/issue since it is handled by coreos-init right now
rm -f lib/tmpfiles.d/baselayout-etc-issue.conf
fi

# DUNNO, KEEP IT
dotmpfiles "${T}/baselayout-usr.conf"
# PROBABLY JUST DROP IT, make install SHOULD NOT NEED THIS TO WORK
systemd-tmpfiles --root="${D}" --create

emake DESTDIR="${D}" install

# PROBABLY USE FAKE TMPFILES.D SCRIPT, THAT INSTALLS FILES AND THEIR PARENT DIRECTORIES
# Fill in all other paths defined in tmpfiles configs
systemd-tmpfiles --root="${D}" --create

# PROBABLY GET RID OF IT
# The above created a few mount points but leave those out of the
# package since they may be mounted read-only. postinst can make them.
local mnt
for mnt in "${MOUNT_POINTS[@]}"; do
rmdir "${D}${mnt}" || die
done

# DROP IT, SEEMS POINTLESS AS IT'S ALREADY INSTALLED BY MAKEFILE
doenvd "env.d/99flatcar_ldpath"
# sssd not yet building on arm64
if use arm64; then
sed -i -e 's/ sss//' share/baselayout/nsswitch.conf || die
sed -i -e '/pam_sss.so/d' lib/pam.d/* || die
fi

# MOVE IT TO SRC_PREPARE
# 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
Expand All @@ -138,80 +95,60 @@ src_install() {
for libdir in $(get_all_libdirs) ; do
ldpaths+=":/${libdir}:/usr/${libdir}:/usr/local/${libdir}"
done
echo "LDPATH='${ldpaths#:}'" >> "${D}"/etc/env.d/00basic || die
echo "LDPATH='${ldpaths#:}'" >> etc/env.d/00basic || die

# MOVE IT TO SRC PREPARE
# Add oem/lib64 to search path towards end of the system's list.
# This simplifies the configuration of OEMs with dynamic libs.
ldpaths=
for libdir in $(get_all_libdirs) ; do
ldpaths+=":/oem/${libdir}"
done
echo "LDPATH='${ldpaths#:}'" >> "${D}"/etc/env.d/80oem || die
echo "LDPATH='${ldpaths#:}'" >> etc/env.d/80oem || die
}

# SHOULD BE IN SRC_PREPARE TOO
if use arm64; then
sed -i 's/ sss//' "${D}"/usr/share/baselayout/nsswitch.conf || die
fi
src_compile() {
default

# MAKE INSTALL_SDK AND MAKE INSTALL_GENERIC?
if use cros_host; then
# Provided by vim in the SDK
rm -r "${D}"/etc/vim || die
# Undesirable in the SDK
rm "${D}"/etc/profile.d/flatcar-profile.sh || die
else
# Don't install /etc/issue since it is handled by coreos-init right now
rm "${D}"/etc/issue || die
sed -i -e '/\/etc\/issue/d' \
"${D}"/usr/lib/tmpfiles.d/baselayout-etc.conf || die

# Initialize /etc/passwd, group, and friends on boot.
dosbin "scripts/flatcar-tmpfiles"
systemd_dounit "scripts/flatcar-tmpfiles.service"
systemd_enable_service sysinit.target flatcar-tmpfiles.service
fi
# generate a tmpfiles.d config to cover our /usr symlinks
local tmpfiles="${T}/baselayout-usr.conf"
echo -n > ${tmpfiles} || die
for sym in "${!USR_SYMS[@]}" ; do
echo "L+ ${sym} - - - - ${USR_SYMS[$sym]}" >> ${tmpfiles}
done
}

# SHOULD BE IN SRC_PREPARE TOO
# sssd not yet building on arm64
if use arm64; then
sed -i -e '/pam_sss.so/d' "${D}"/usr/lib/pam.d/* || die
fi
src_install() {
dotmpfiles "${T}/baselayout-usr.conf"

# MAKE INSTALL_SDK?
if use cros_host; then
# inject custom SSL configuration required for signing payloads from the SDK container using OpenSSL.
insinto "/etc/ssl/"
doins "${S}/baselayout/pkcs11.cnf"
fi
emake DESTDIR="${ED}" install
# GID 190 is taken from acct-group/systemd-journal eclass
SYSTEMD_JOURNAL_GID=${ACCT_GROUP_SYSTEMD_JOURNAL_ID:-190} ROOT_UID=0 ROOT_GID=0 CORE_UID=500 CORE_GID=500 DESTDIR=${D} ./stuff.sh --exclude d "${ED}/usr/lib/tmpfiles.d"

insinto /usr/share/baselayout
doins Makefile
doexe stuff.sh
}

pkg_preinst() {
local libdirs=$(get_all_libdirs)
emake -C "${ED}/usr/share/${PN}" DESTDIR="${EROOT}" LIBDIRS="${libdirs}" layout
rm -f "${ED}"/usr/share/${PN}/Makefile || die
}
SYSTEMD_JOURNAL_GID=${ACCT_GROUP_SYSTEMD_JOURNAL_ID:-190} ROOT_UID=0 ROOT_GID=0 CORE_UID=500 CORE_GID=500 DESTDIR=${D} "${ED}/usr/share/${PN}/stuff.sh" "${ED}/usr/lib/tmpfiles.d"
rm -f "${ED}/usr/share/${PN}/Makefile" "${ED}/usr/share/${PN}/stuff.sh" || die

pkg_postinst() {
# best-effort creation of mount points
local mnt
for mnt in "${MOUNT_POINTS[@]}"; do
[[ -d "${ROOT}${mnt}" ]] || mkdir "${ROOT}${mnt}"
done
# Set up /usr/lib/debug to match the root filesystem layout
# FIXME: This is done in postinst right now and all errors are ignored
# as a transitional scheme, this isn't important enough to migrate
# existing SDK environments.
local dir sym
for dir in "${BASE_DIRS[@]}"; do
mkdir -p "${ROOT}/usr/lib/debug/${dir}"
mkdir -p "${EROOT}/usr/lib/debug/${dir}"
done
for sym in "${!USR_SYMS[@]}" ; do
ln -sfT "${USR_SYMS[$sym]}" "${ROOT}/usr/lib/debug/${sym}"
ln -sfT "${USR_SYMS[$sym]}" "${EROOT}/usr/lib/debug/${sym}"
done
for sym in "${!EXTRA_SYMS[@]}" ; do
ln -sfT "${EXTRA_SYMS[$sym]}" "${ROOT}/usr/lib/debug/${sym}"
ln -sfT "${EXTRA_SYMS[$sym]}" "${EROOT}/usr/lib/debug/${sym}"
done
}

pkg_postinst() {
# The default passwd/group files must exist in the SDK for some ebuilds
if use cros_host; then
touch "${ROOT}/etc/"{group,gshadow,passwd,shadow}
Expand Down

0 comments on commit d746d41

Please sign in to comment.