Files
fedora-bootc/build_files/cleanup.sh
Dave Jansen 705e83eafb
Some checks failed
Build container image / Build and push image (push) Failing after 4m0s
I always forget.
2025-12-01 21:32:01 +09:00

85 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
set -ouex pipefail
echo "Let's see."
echo "/etc/passwd contents:"
cat /etc/passwd
echo "/usr/lib/passwd contents:"
cat /usr/lib/passwd
echo ""
echo "/etc/group contents:"
cat /etc/group
echo "/usr/lib/group contents:"
cat /usr/lib/group
## Handle files that rpm-ostree would normally remove
## Adapted from: https://github.com/hhd-dev/rechunk/blob/master/1_prune.sh#L33
if [ -f /etc/passwd ]; then
out=$(grep -v "root" /etc/passwd)
if [[ ! -z "$out" ]]; then
echo
echo Appending the following passwd users to /usr/lib/passwd
echo "$out"
echo "$out" >>/usr/lib/passwd
fi
fi
if [ -f /etc/group ]; then
out=$(grep -v "root\|wheel" /etc/group)
if [[ ! -z "$out" ]]; then
echo
echo Appending the following group entries to /usr/lib/group
echo "$out"
echo "$out" >>/usr/lib/group
fi
fi
if [ -f /etc/passwd ] || [ -f /etc/group ]; then
echo
echo "Warning: Make sure processed users and groups are from installed programs!"
fi
# # Create defaults for /etc/passwd, /etc/group
# cat <<EOT >/etc/passwd
# root:x:0:0:root:/root:/bin/bash
# EOT
# cat <<EOT >/etc/group
# root:x:0:
# wheel:x:10:
# EOT
# Extra lock files created by container processes that might cause issues
rm -rf \
/etc/.pwd.lock \
/etc/passwd- \
/etc/group- \
/etc/shadow- \
/etc/gshadow- \
/etc/subuid- \
/etc/subgid- \
/.dockerenv
# # Merge /usr/etc to /etc
# # OSTree will error out if both dirs exist
# # And rpm-ostree will be confused and use only one of them
# if [ -d /usr/etc ]; then
# echo
# echo WARNING: FOUND /usr/etc. MERGING TO ETC FOR COMPATIBILITY
# echo EXPECT PERMISSIONS ISSUES ON THE MERGED PATHS
# echo The following files from /usr/etc will be merged to /etc:
# tree /usr/etc
#
# echo
# rsync -aAX --numeric-ids --checksum --links /usr/etc/ /etc
# rm -rf /usr/etc
# fi
#
# # Move /etc to /usr/etc
# mv /etc /usr/
# ...normal ublue-inspired steps continue.