Makefile: make the $(RAW_IMAGE) target install the stage4 files.

The raw image making was kind of split up, with different targets to create
the image, partition, copy files, install grub, etc.  This change makes it
all one target.  After "make image" is done, or, e.g., "make images/base.img"
then the resulting file will be built and contain all the necessary files.

This make the $(RAW_IMAGE) target more uniform with the other image/
targets.  It will also make the other image/ targets easier to satify.
This commit is contained in:
Albert Hopkins 2015-02-28 22:27:39 +00:00
parent e28fcda122
commit dff2e32481
1 changed files with 12 additions and 19 deletions

View File

@ -93,21 +93,7 @@ unexport PKGDIR ARCH
all: image
$(RAW_IMAGE): $(STAGE4_TARBALL)
rm -f $(RAW_IMAGE)
qemu-img create -f raw $(RAW_IMAGE).tmp $(DISK_SIZE)
mv $(RAW_IMAGE).tmp $(RAW_IMAGE)
partitions: $(RAW_IMAGE)
@scripts/echo Creating partition layout
parted -s $(RAW_IMAGE) mklabel gpt
parted -s $(RAW_IMAGE) mkpart primary 1 $(DISK_SIZE)
parted -s $(RAW_IMAGE) set 1 boot on
losetup --show --find --partscan $(RAW_IMAGE) > partitions.tmp
mv partitions.tmp partitions
sync
mkfs.ext4 -O sparse_super,^has_journal -L "$(APPLIANCE)"_root -m 0 `cat partitions`p1
image: $(RAW_IMAGE)
portage-snapshot.tar.bz2:
@scripts/echo You do not have a portage snapshot. Consider \"make sync_portage\"
@ -276,23 +262,30 @@ ifneq ($(PKGLIST),0)
endif
touch $(SOFTWARE)
device-map: $(RAW_IMAGE)
echo '(hd0) ' $(RAW_IMAGE) > device-map
image: $(STAGE4_TARBALL) partitions device-map scripts/grub.shell scripts/motd.sh
$(RAW_IMAGE): $(STAGE4_TARBALL) scripts/grub.shell scripts/motd.sh
@scripts/echo Installing files to $(RAW_IMAGE)
qemu-img create -f raw $(RAW_IMAGE).tmp $(DISK_SIZE)
parted -s $(RAW_IMAGE).tmp mklabel gpt
parted -s $(RAW_IMAGE).tmp mkpart primary 1 $(DISK_SIZE)
parted -s $(RAW_IMAGE).tmp set 1 boot on
sync
losetup --show --find --partscan $(RAW_IMAGE).tmp > partitions
mkfs.ext4 -O sparse_super,^has_journal -L "$(APPLIANCE)"_root -m 0 `cat partitions`p1
mkdir $(CHROOT)
mount -o noatime `cat partitions`p1 $(CHROOT)
tar -xf $(STAGE4_TARBALL) --numeric-owner $(COPY_ARGS) -C $(CHROOT)
scripts/motd.sh $(EXTERNAL_KERNEL) $(VIRTIO) $(DISK_SIZE) $(SWAP_SIZE) $(DASH) $(ARCH) > $(CHROOT)/etc/motd
ifneq ($(EXTERNAL_KERNEL),YES)
echo '(hd0) ' $(RAW_IMAGE).tmp > device-map
$(CHROOT)/sbin/grub --device-map=device-map --no-floppy --batch < scripts/grub.shell
endif
umount -l $(CHROOT)
umount $(CHROOT)
rmdir $(CHROOT)
sync
losetup --detach `cat partitions`
rm -f partitions device-map
mv $(RAW_IMAGE).tmp $(RAW_IMAGE)
$(QCOW_IMAGE): image
@scripts/echo Creating $(QCOW_IMAGE)