From 68989576e3663cdc5a7182eea14d2ed6206d61e0 Mon Sep 17 00:00:00 2001 From: Jay Faulkner Date: Thu, 29 Jul 2021 14:51:31 -0700 Subject: [PATCH] Allow configuration of paths to prune Without this, it makes it impossible to install/use software that depends on this path being available, such as any application which wants to log to its own dir in /var/log. Change-Id: Ie6d6efa7cf7de1dc9cd63031de05f95b2d050935 --- .../cleanup.d/99-ramdisk-create | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/dib/ironic-ramdisk-base/cleanup.d/99-ramdisk-create b/dib/ironic-ramdisk-base/cleanup.d/99-ramdisk-create index 393040d..3e816ca 100755 --- a/dib/ironic-ramdisk-base/cleanup.d/99-ramdisk-create +++ b/dib/ironic-ramdisk-base/cleanup.d/99-ramdisk-create @@ -19,36 +19,27 @@ IMAGE_PATH=$(readlink -f $IMAGE_NAME) cd $TARGET_ROOT DIB_IPA_COMPRESS_CMD="${DIB_IPA_COMPRESS_CMD:-gzip}" +DIB_IPA_PATHS_TO_PRUNE="${DIB_IPA_PATHS_TO_PRUNE:-'./sys/*' './tmp/*' \ + './boot/*' './root/.cache' '*site-packages/babel/locale-data/*' \ + './usr/include/*' './usr/lib/locale/*' './usr/share/doc/*' \ + './usr/share/man/*' './usr/share/GeoIP/*' './usr/share/info/*' \ + './usr/share/licenses/*' './usr/share/locale/*' './usr/share/misc/m*' \ + './usr/src/kernels/*' './var/cache/*' './var/log/*'}" echo "#disabled" > ./tmp/fstab.new sudo mv ./tmp/fstab.new ./etc/fstab sudo ln -s ./sbin/init ./ -# Note: The pci.ids, which is used by lshw, locate on Ubuntu -# in /usr/share/misc. Therefore we are removing only the -# ./usr/share/misc/m* (will remove the magic and magic.mgc files). -# on RHEL pci.ids is locate on /usr/share/hwdata/pci.ids. -sudo find . -xdev \ - -path './sys/*' -prune -o \ - -path './tmp/*' -prune -o \ - -path './boot/*' -prune -o \ - -path './root/.cache' -prune -o \ - -path "*site-packages/babel/locale-data/*" -prune -o \ - -path './usr/include/*' -prune -o \ - -path './usr/lib/locale/*' -prune -o \ - -path './usr/share/doc/*' -prune -o \ - -path './usr/share/man/*' -prune -o \ - -path './usr/share/GeoIP/*' -prune -o \ - -path './usr/share/info/*' -prune -o \ - -path './usr/share/licenses/*' -prune -o \ - -path './usr/share/locale/*' -prune -o \ - -path './usr/share/misc/m*' -prune -o \ - -path './usr/src/kernels/*' -prune -o \ - -path './var/cache/*' -prune -o \ - -path './var/log/*' -prune -o \ - -name '*.pyc' -prune -o \ - -name '*.pyo' -prune -o \ - -print | sudo cpio -o -H newc | ${DIB_IPA_COMPRESS_CMD} > ${IMAGE_PATH}.initramfs +# Build up the command to find files to add to initramfs +# using configurable list of paths to prune +FIND_COMMAND="find . -xdev " +for path in $DIB_IPA_PATHS_TO_PRUNE; do + FIND_COMMAND="$FIND_COMMAND -path $path -prune -o " +done +FIND_COMMAND="$FIND_COMMAND -name '*.pyc' -prune -o " +FIND_COMMAND="$FIND_COMMAND -name '*.pyo' -prune -o -print " + +sudo $FIND_COMMAND | sudo cpio -o -H newc | ${DIB_IPA_COMPRESS_CMD} > ${IMAGE_PATH}.initramfs select_boot_kernel_initrd $TARGET_ROOT sudo cp $BOOTDIR/$KERNEL ${IMAGE_PATH}.kernel