Skip to content

Commit 816458b

Browse files
committed
Correctly handle relative paths for CPIO_FILE
1 parent 84534e4 commit 816458b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ INITRAMFS_DIR ?= $(ROOTFS_DIR)
246246
CPIO_FILE ?= $(ROOTFS_PARENT_DIR)/$$(basename $(INITRAMFS_DIR)).cpio.gz
247247
EXT4_SIZE ?= 1G
248248

249+
# The user might set a relative path for `CPIO_FILE`, so we need to get the
250+
# absolute path, as we need to reference it after we've changed directories
251+
CPIO_FILE := $(shell realpath $(CPIO_FILE))
252+
249253
$(ROOTFS_DIR):
250254
mkdir -p $(ROOTFS_DIR)
251255

@@ -269,14 +273,14 @@ ext4: | $(ROOTFS_DIR)
269273

270274
.PHONY: cpio initramfs
271275
initramfs cpio: | $(INITRAMFS_DIR)
272-
cd $(INITRAMFS_DIR) && find . -print0 \
273-
| cpio --null --create --verbose --format=newc \
276+
(cd $(INITRAMFS_DIR) && find . -print0 \
277+
| cpio --null --create --verbose --format=newc) \
274278
| gzip --best > $(CPIO_FILE)
275279

276280
.PHONY: uncpio
277281
uncpio:
278282
mkdir -p $(INITRAMFS_DIR)
279-
cd $(INITRAMFS_DIR) && zcat ../$(CPIO_FILE) | cpio --extract --make-directories --format=newc --no-absolute-filenames
283+
cd $(INITRAMFS_DIR) && zcat $(CPIO_FILE) | cpio --extract --make-directories --format=newc --no-absolute-filenames
280284

281285
.PHONY: rootfs
282286
rootfs: ext4 cpio

0 commit comments

Comments
 (0)