Skip to content

Commit 35f9417

Browse files
committed
Allow running cpio and uncpio with sudo
1 parent 5b6d69b commit 35f9417

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ ROOTFS_FORMAT ?= qcow2
243243
ROOTFS_DIR ?= $(ROOTFS_PARENT_DIR)/alpine-$(ARCH)
244244
CPIO_FILE ?= $(ROOTFS_PARENT_DIR)/$$(basename $(ROOTFS_DIR)).cpio.gz
245245
EXT4_SIZE ?= 1G
246+
ifeq ($(SUDO),1)
247+
SUDO := sudo
248+
endif
246249

247250
# The user might set a relative path for `CPIO_FILE`, so we need to get the
248251
# absolute path, as we need to reference it after we've changed directories
@@ -271,13 +274,13 @@ ext4: | $(ROOTFS_DIR)
271274

272275
.PHONY: cpio initramfs
273276
initramfs cpio: | $(ROOTFS_DIR)
274-
(cd $(ROOTFS_DIR) && find . -print0 \
275-
| cpio --null --create --verbose --format=newc) \
277+
(cd $(ROOTFS_DIR) && $(SUDO) find . -print0 \
278+
| $(SUDO) cpio --null --create --verbose --format=newc) \
276279
| gzip --best > $(CPIO_FILE)
277280

278281
.PHONY: uncpio
279282
uncpio: | $(ROOTFS_DIR)
280-
cd $(ROOTFS_DIR) && zcat $(CPIO_FILE) | cpio --extract --make-directories --format=newc --no-absolute-filenames
283+
cd $(ROOTFS_DIR) && zcat $(CPIO_FILE) | $(SUDO) cpio --extract --make-directories --format=newc --no-absolute-filenames
281284

282285
.PHONY: rootfs
283286
rootfs: ext4 cpio

0 commit comments

Comments
 (0)