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
This commit is contained in:
Jay Faulkner 2021-07-29 14:51:31 -07:00 committed by Jay Faulkner
parent ee4f3a8ec1
commit 68989576e3
1 changed files with 16 additions and 25 deletions

View File

@ -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