2014-06-27 11:54:29 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-04-08 05:46:21 +00:00
|
|
|
# dib-lint: disable=safe_sudo
|
|
|
|
|
2014-09-04 04:56:29 +00:00
|
|
|
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
2014-06-27 11:54:29 +00:00
|
|
|
set -eu
|
|
|
|
set -o pipefail
|
|
|
|
|
2014-09-04 04:56:29 +00:00
|
|
|
|
2014-06-27 11:54:29 +00:00
|
|
|
[ -n "$TARGET_ROOT" ]
|
|
|
|
|
|
|
|
source $_LIB/img-functions
|
|
|
|
|
2014-12-13 17:14:06 +00:00
|
|
|
IMAGE_PATH=$(readlink -f $IMAGE_NAME)
|
2014-06-27 11:54:29 +00:00
|
|
|
cd $TARGET_ROOT
|
|
|
|
|
|
|
|
echo "#disabled" > ./tmp/fstab.new
|
|
|
|
sudo mv ./tmp/fstab.new ./etc/fstab
|
|
|
|
sudo ln -s ./sbin/init ./
|
|
|
|
|
2015-09-08 10:43:09 +00:00
|
|
|
# Remove python object files, they're not particularly useful for a ramdisk
|
2015-10-01 23:26:22 +00:00
|
|
|
sudo find ./usr -name "*.pyc" -or -name "*.pyo" -delete
|
2015-09-08 10:43:09 +00:00
|
|
|
|
2016-03-07 08:12:13 +00:00
|
|
|
# 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.
|
2015-10-26 02:19:28 +00:00
|
|
|
sudo find . -xdev \
|
|
|
|
-path './sys/*' -prune -o \
|
|
|
|
-path './tmp/*' -prune -o \
|
|
|
|
-path './boot/*' -prune -o \
|
|
|
|
-path './root/.cache' -prune -o \
|
|
|
|
-path './usr/lib/locale/*' -prune -o \
|
|
|
|
-path './usr/share/doc/*' -prune -o \
|
|
|
|
-path './usr/share/man/*' -prune -o \
|
|
|
|
-path './usr/share/info/*' -prune -o \
|
|
|
|
-path './usr/share/licenses/*' -prune -o \
|
2016-03-07 08:12:13 +00:00
|
|
|
-path './usr/share/misc/m*' -prune -o \
|
2015-10-26 02:19:28 +00:00
|
|
|
-print | sudo cpio -o -H newc | gzip > ${IMAGE_PATH}.initramfs
|
2014-06-27 11:54:29 +00:00
|
|
|
|
|
|
|
select_boot_kernel_initrd $TARGET_ROOT
|
2015-08-07 12:45:12 +00:00
|
|
|
sudo cp $BOOTDIR/$KERNEL ${IMAGE_PATH}.kernel
|
|
|
|
|
|
|
|
# TODO(lucasagomes): Create a hard link for the .vmlinuz file to keep
|
|
|
|
# it backward compatible. Remove it after it has been consistent and
|
|
|
|
# documented in both places for at least one full OpenStack release cycle
|
|
|
|
echo "WARNING: The kernel extension .vmlinuz has been deprecated. Please rely on the file with the extension .kernel instead."
|
2015-09-30 09:37:28 +00:00
|
|
|
sudo rm -f ${IMAGE_PATH}.vmlinuz
|
2015-08-07 12:45:12 +00:00
|
|
|
sudo ln ${IMAGE_PATH}.kernel ${IMAGE_PATH}.vmlinuz
|