From e2c20bf2cff0721fc1724afe1d979a382bfdbe04 Mon Sep 17 00:00:00 2001 From: Neil Hanlon Date: Tue, 21 Nov 2023 16:28:47 -0500 Subject: [PATCH] several random fixes need to rebase --- .../elements/rpm-distro/pre-install.d/00-fix-requiretty | 8 +++++--- .../rpm-distro/pre-install.d/00-usr-local-bin-secure-path | 6 ++++-- .../elements/yum/cleanup.d/99-remove-yum-repo-conf | 5 ----- .../elements/yum/post-install.d/99-reset-yum-conf | 8 +++++--- diskimage_builder/lib/disk-image-create | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/diskimage_builder/elements/rpm-distro/pre-install.d/00-fix-requiretty b/diskimage_builder/elements/rpm-distro/pre-install.d/00-fix-requiretty index 4ebeb28d..7d326ce7 100755 --- a/diskimage_builder/elements/rpm-distro/pre-install.d/00-fix-requiretty +++ b/diskimage_builder/elements/rpm-distro/pre-install.d/00-fix-requiretty @@ -11,6 +11,8 @@ set -o pipefail # activity, that's not how we're using these. Remove the setting, and the # comments about it -sed -i -e '/^Defaults\s*requiretty/d' -e '/Disable "ssh hostname/d' /etc/sudoers -sed -i -e '/You have to run/d' /etc/sudoers -visudo -c +if [[ -f /etc/sudoers ]]; then + sed -i -e '/^Defaults\s*requiretty/d' -e '/Disable "ssh hostname/d' /etc/sudoers + sed -i -e '/You have to run/d' /etc/sudoers + visudo -c +fi diff --git a/diskimage_builder/elements/rpm-distro/pre-install.d/00-usr-local-bin-secure-path b/diskimage_builder/elements/rpm-distro/pre-install.d/00-usr-local-bin-secure-path index 664db11d..c95034e3 100755 --- a/diskimage_builder/elements/rpm-distro/pre-install.d/00-usr-local-bin-secure-path +++ b/diskimage_builder/elements/rpm-distro/pre-install.d/00-usr-local-bin-secure-path @@ -6,5 +6,7 @@ fi set -eu set -o pipefail -sed -i -e "/secure_path/ s@\([\'\"]\?\)\$@:/usr/local/bin/\1@" /etc/sudoers -visudo -c +if [[ -f /etc/sudoers ]]; then + sed -i -e "/secure_path/ s@\([\'\"]\?\)\$@:/usr/local/bin/\1@" /etc/sudoers + visudo -c +fi diff --git a/diskimage_builder/elements/yum/cleanup.d/99-remove-yum-repo-conf b/diskimage_builder/elements/yum/cleanup.d/99-remove-yum-repo-conf index bf159b92..7795146d 100755 --- a/diskimage_builder/elements/yum/cleanup.d/99-remove-yum-repo-conf +++ b/diskimage_builder/elements/yum/cleanup.d/99-remove-yum-repo-conf @@ -6,11 +6,6 @@ fi set -eu set -o pipefail -if [[ -n ${DIB_YUM_DNF_CONTENTDIR:-''} ]]; then - sudo mv /etc/dnf/vars/contentdir.bak /etc/dnf/vars/contentdir - sudo sed -i -e 's,^#mirrorlist,mirrorlist,' -e 's,^baseurl,#baseurl,' /etc/yum.repos.d/*.repo -fi - # exit directly if DIB_YUM_REPO_CONF is not defined properly if [ -z "${DIB_YUM_REPO_CONF:-}" ] ; then echo "DIB_YUM_REPO_CONF is not set - no repo configurations will be cleaned up" diff --git a/diskimage_builder/elements/yum/post-install.d/99-reset-yum-conf b/diskimage_builder/elements/yum/post-install.d/99-reset-yum-conf index 5004c658..582bc94e 100755 --- a/diskimage_builder/elements/yum/post-install.d/99-reset-yum-conf +++ b/diskimage_builder/elements/yum/post-install.d/99-reset-yum-conf @@ -7,9 +7,11 @@ set -eu set -o pipefail -# if [[ -n ${DIB_YUM_DNF_CONTENTDIR:-''} ]]; then -# sudo sed -i 's,^#mirrorlist,mirrorlist,' -e 's,^baseurl,#baseurl,' /etc/yum.repos.d/rocky.repo -# fi +if [[ -n ${DIB_YUM_DNF_CONTENTDIR:-''} ]]; then + sudo mv /etc/dnf/vars/contentdir.bak /etc/dnf/vars/contentdir + sudo sed -i -e 's,^#mirrorlist,mirrorlist,' -e 's,^baseurl,#baseurl,' /etc/yum.repos.d/*.repo +fi + if [[ ${YUM} == "dnf" ]]; then cfg=/etc/dnf/dnf.conf diff --git a/diskimage_builder/lib/disk-image-create b/diskimage_builder/lib/disk-image-create index a79686a4..999dd73d 100644 --- a/diskimage_builder/lib/disk-image-create +++ b/diskimage_builder/lib/disk-image-create @@ -567,7 +567,7 @@ for X in ${!IMAGE_TYPES[@]} ; do fi else sudo tar -C ${TMP_BUILD_DIR}/mnt -cf $IMAGE_NAME.tar --exclude ./sys \ - --exclude ./proc --xattrs --xattrs-include=\* . + --exclude ./proc --exclude ./dev/* --xattrs --xattrs-include=\* . fi sudo chown $USER: $IMAGE_NAME.${IMAGE_TYPES[$X]} unset IMAGE_TYPES[$X]