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" ]
|
|
|
|
|
2016-08-19 16:04:32 +00:00
|
|
|
USER=${USER:-$(whoami)}
|
|
|
|
|
2014-06-27 11:54:29 +00:00
|
|
|
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 ./
|
|
|
|
|
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 \
|
2016-06-24 16:28:24 +00:00
|
|
|
-path './usr/include/*' -prune -o \
|
2015-10-26 02:19:28 +00:00
|
|
|
-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 \
|
2016-06-24 16:28:24 +00:00
|
|
|
-path './usr/src/kernels/*' -prune -o \
|
|
|
|
-path './var/cache/*' -prune -o \
|
|
|
|
-name '*.pyc' -prune -o \
|
|
|
|
-name '*.pyo' -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
|
2016-06-16 19:51:50 +00:00
|
|
|
sudo chown $USER: ${IMAGE_PATH}.kernel
|
2015-08-07 12:45:12 +00:00
|
|
|
|
|
|
|
# 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
|
2016-06-16 19:51:50 +00:00
|
|
|
ln ${IMAGE_PATH}.kernel ${IMAGE_PATH}.vmlinuz
|