ubuntu: produce a valid Debian installer initrd.gz
The code which applies initrd patch(es) produces a half-broken initrd which is a) not compressed, b) contains a chunk of itself. Fortunately the initrd is still able to boot, however, it's 2.5x larger than the original. This slows down the provisioning and puts an extra load on the master node. Closes-bug: #1397845 blueprint support-ubuntu-trusty Change-Id: I666a4395e577b917016c2220a760a4cf340a54d2
This commit is contained in:
parent
1981bc0e24
commit
63882d8747
@ -95,7 +95,6 @@ $(BUILD_DIR)/iso/isoroot-ubuntu.done: \
|
||||
mkdir -p $(ISOROOT)/ubuntu
|
||||
rsync -rp $(LOCAL_MIRROR_UBUNTU_OS_BASEURL)/ $(ISOROOT)/ubuntu/
|
||||
rsync -rp $(LOCAL_MIRROR)/ubuntu-packages.changelog $(ISOROOT)
|
||||
rsync -p $(BUILD_DIR)/packages/deb/debian-boot/initrd.gz $(ISOROOT)/ubuntu/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz
|
||||
cat $(ISOROOT)/ubuntu/dists/$(UBUNTU_RELEASE)/main/binary-amd64/Packages | $(SOURCE_DIR)/iso/pkg-versions.awk > $(ISOROOT)/ubuntu/ubuntu-versions.yaml
|
||||
$(ACTION.TOUCH)
|
||||
endif
|
||||
|
@ -7,19 +7,55 @@ ifeq ($(USE_MIRROR),none)
|
||||
NETBOOT_URL:=$(MIRROR_UBUNTU)/ubuntu/dists/$(UBUNTU_RELEASE)-updates/main/installer-amd64/current/images/$(UBUNTU_NETBOOT_FLAVOR)/netboot.tar.gz
|
||||
endif
|
||||
|
||||
# debian isolinux files
|
||||
patched_di_initrd_img:=$(LOCAL_NETBOOT_DIR)/ubuntu-installer/amd64/initrd.gz
|
||||
di_initrd_img:=$(BUILD_DIR)/ubuntu/ubuntu-installer/$(UBUNTU_ARCH)/initrd.gz
|
||||
|
||||
# download the Debian installer netboot
|
||||
$(LOCAL_NETBOOT_TGZ):
|
||||
@mkdir -p $(@D)
|
||||
wget -nv -O $@.tmp $(NETBOOT_URL)
|
||||
mv $@.tmp $@
|
||||
tar -xzf $@ -C $(@D)
|
||||
|
||||
$(BUILD_DIR)/mirror/ubuntu/boot.done: $(LOCAL_NETBOOT_TGZ)
|
||||
$(di_initrd_img): tmpdir=$(LOCAL_NETBOOT_DIR)_tmp
|
||||
|
||||
# extract the kernel and initrd from the netboot
|
||||
$(di_initrd_img): $(LOCAL_NETBOOT_TGZ)
|
||||
mkdir -p $(tmpdir)
|
||||
mkdir -p $(dir $@)
|
||||
tar -xzf $< -C $(tmpdir)
|
||||
mv $(tmpdir)/ubuntu-installer/amd64/initrd.gz $@.tmp
|
||||
rsync -avH $(tmpdir)/ $(LOCAL_NETBOOT_DIR)/
|
||||
-rm -rf $(tmpdir)
|
||||
mv $@.tmp $@
|
||||
|
||||
$(patched_di_initrd_img): initrd_dir=$(dir $(di_initrd_img))initrd_dir
|
||||
# script which mounts /proc in /target. linux-image* preinst script uses
|
||||
# /proc without checking if its mounted, hence this work around:
|
||||
$(patched_di_initrd_img): hook_script:=$(SOURCE_DIR)/mirror/ubuntu/boot/01_mount_target_proc.sh
|
||||
# Debian installer runs scripts located in this directory before installing
|
||||
# the kernel (and after the base has been installed)
|
||||
$(patched_di_initrd_img): hook_target_dir:=/usr/lib/post-base-installer.d
|
||||
|
||||
# unpack the initrd, apply patches, and repack it
|
||||
$(patched_di_initrd_img): $(di_initrd_img)
|
||||
mkdir -p $(initrd_dir)
|
||||
set -e; cd $(initrd_dir); \
|
||||
zcat $< | sudo cpio -di; \
|
||||
sudo chown -R `whoami` .; \
|
||||
patch -p1 < $(SOURCE_DIR)/mirror/ubuntu/boot/preseed-retry.patch; \
|
||||
mkdir -p .$(hook_target_dir); \
|
||||
cp $(hook_script) .$(hook_target_dir); \
|
||||
find . | cpio --create --format='newc' --owner=root:root | gzip -9 > $@.tmp
|
||||
mv $@.tmp $@
|
||||
-rm -rf $(initrd_dir)
|
||||
|
||||
$(BUILD_DIR)/mirror/ubuntu/boot.done: $(patched_di_initrd_img)
|
||||
$(ACTION.TOUCH)
|
||||
|
||||
di_initrd_img:=$(LOCAL_NETBOOT_DIR)/ubuntu-installer/amd64/initrd.gz
|
||||
di_kernel_modules_dir=$(shell zcat $(di_initrd_img) | cpio --list 'lib/modules/*/kernel')
|
||||
UBUNTU_INSTALLER_KERNEL_VERSION=$(strip $(patsubst lib/modules/%/kernel,%,$(di_kernel_modules_dir)))
|
||||
|
||||
$(BUILD_DIR)/ubuntu_installer_kernel_version.mk: $(LOCAL_NETBOOT_TGZ)
|
||||
$(BUILD_DIR)/ubuntu_installer_kernel_version.mk: $(di_initrd_img)
|
||||
echo 'UBUNTU_INSTALLER_KERNEL_VERSION:=$(UBUNTU_INSTALLER_KERNEL_VERSION)' > $@
|
||||
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
NETBOOT_PATH=$(LOCAL_MIRROR)/ubuntu/installer-amd64/current/images/netboot/ubuntu-installer/amd64
|
||||
|
||||
# script which mounts /proc in /target. linux-image* preinst script uses
|
||||
# /proc without checking if its mounted, hence this work around:
|
||||
hook_script:=$(SOURCE_DIR)/packages/deb/debian-boot/01_mount_target_proc.sh
|
||||
# Debian installer runs scripts located in this directory before installing
|
||||
# the kernel (and after the base has been installed)
|
||||
hook_target_dir:=/usr/lib/post-base-installer.d
|
||||
|
||||
$(BUILD_DIR)/packages/deb/debian-boot/initrd.done:\
|
||||
$(BUILD_DIR)/mirror/ubuntu/boot.done
|
||||
mkdir -p $(@D)
|
||||
cd $(@D) && gunzip -c $(NETBOOT_PATH)/initrd.gz | sudo cpio -di
|
||||
cd $(@D) && sudo patch -p1 < $(SOURCE_DIR)/packages/deb/debian-boot/preseed-retry.patch
|
||||
# copy helper script into a directory where the installer expects to find it
|
||||
sudo mkdir -p $(@D)$(hook_target_dir)
|
||||
sudo cp $(hook_script) $(@D)$(hook_target_dir)
|
||||
cd $(@D) && sudo find . | sudo cpio --create --format='newc' > $(BUILD_DIR)/packages/deb/debian-boot/initrd.gz
|
||||
$(ACTION.TOUCH)
|
@ -1,9 +0,0 @@
|
||||
.PHONY: clean-ubuntu-packages
|
||||
include $(SOURCE_DIR)/packages/deb/debian-boot/initrd.mk
|
||||
|
||||
clean-ubuntu-packages:
|
||||
sudo rm -rf $(BUILD_DIR)/packages/deb/
|
||||
|
||||
$(BUILD_DIR)/packages/deb/debian-boot/build.done: \
|
||||
$(BUILD_DIR)/packages/deb/debian-boot/initrd.done
|
||||
$(ACTION.TOUCH)
|
@ -1,7 +1,5 @@
|
||||
.PHONY: clean clean-deb
|
||||
|
||||
include $(SOURCE_DIR)/packages/deb/debian-boot/module.mk
|
||||
|
||||
clean: clean-deb
|
||||
|
||||
clean-deb:
|
||||
@ -63,5 +61,3 @@ ifneq (0,$(strip $(BUILD_DEB_PACKAGES)))
|
||||
$(BUILD_DIR)/packages/deb/build.done: $(BUILD_DIR)/packages/deb/repo.done
|
||||
endif
|
||||
|
||||
$(BUILD_DIR)/packages/deb/build.done: $(BUILD_DIR)/packages/deb/debian-boot/build.done
|
||||
$(ACTION.TOUCH)
|
||||
|
Loading…
Reference in New Issue
Block a user