Changeset 575


Ignore:
Timestamp:
Dec 24, 2013, 12:30:42 PM (6 years ago)
Author:
amain
Message:

rootfs: Fix #990: Can't create tar of rootfs due to mounted /sys

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debian/rootfs/debian.mk

    r567 r575  
    2323DEBIAN_ROOTFS_INCLUDE_PACKAGES_DEBIAN_VERSION:=$(wildcard debian/rootfs/include_packages.list.$(DEBIAN_BUILD_VERSION))
    2424
    25 define qemu-prepare-enter
     25define qemu-prepare
    2626        @if [ ! -x $(QEMU_BIN_STATIC) ]; then echo "E: can't find qemu ($(QEMU_BIN_STATIC))"; fi
    2727        @if [ ! -e /proc/sys/fs/binfmt_misc/qemu-$(TARGET_ARCH) ]; then echo "E: can't find binfmt_misc qemu-$(TARGET_ARCH) ( /proc/sys/fs/binfmt_misc/qemu-$(TARGET_ARCH)).\nE: install qemu-user-static, or\nE: disable second stage with qemu with menuconfig (DEBIAN_ROOTFS_QEMU_2ND_STAGE)."; fi
    28         @if [ ! -x $(QEMU_BIN_STATIC) -o ! -e /proc/sys/fs/binfmt_misc/qemu-$(TARGET_ARCH) ]; then echo "E: abort"; exit 1; fi
    29         @sudo cp $(QEMU_BIN_STATIC) $(ROOTFS_BUILD_DIR)$(QEMU_INTERPRETER)
     28        @if [ ! -x $(QEMU_BIN_STATIC) -o ! -e /proc/sys/fs/binfmt_misc/qemu-$(TARGET_ARCH) ]; then echo "E: abort - qemu not available in chroot"; exit 1; fi
     29        @if [ ! -e $(ROOTFS_BUILD_DIR)$(QEMU_INTERPRETER) ]; then sudo cp $(QEMU_BIN_STATIC) $(ROOTFS_BUILD_DIR)$(QEMU_INTERPRETER); fi
    3030        @if ! sudo chroot $(ROOTFS_BUILD_DIR) /bin/ls >/dev/null; then echo "E: qemu can't execute binaries for $(TARGET_ARCH)"; echo "E: abort"; exit 1; fi
     31        @if ! (mount | grep -q $(ROOTFS_BUILD_DIR)/proc); then sudo chroot $(ROOTFS_BUILD_DIR) mount -t proc none /proc; fi
     32        @if ! (mount | grep -q $(ROOTFS_BUILD_DIR)/sys ); then sudo chroot $(ROOTFS_BUILD_DIR) mount -t sysfs none /sys; fi
     33endef
     34
     35define qemu-cleanup
     36        @sudo chroot $(ROOTFS_BUILD_DIR) umount /proc
     37        @sudo chroot $(ROOTFS_BUILD_DIR) umount /sys
     38        @sudo rm -f $(ROOTFS_BUILD_DIR)$(QEMU_INTERPRETER)
    3139endef
    3240
    3341chr:
    34         $(call qemu-prepare-enter)
     42        $(call qemu-prepare)
    3543        @sudo bash -c "echo "debwrt-$(TARGET_ARCH)" > $(ROOTFS_BUILD_DIR)/etc/debian_chroot"
    3644        @sudo cp $(ROOTFS_BUILD_DIR)/etc/resolv.conf $(ROOTFS_BUILD_DIR)/etc/resolv.conf_debwrt
    3745        @sudo bash -c "cat /etc/resolv.conf | grep nameserver >$(ROOTFS_BUILD_DIR)/etc/resolv.conf"
    3846        @sudo chroot $(ROOTFS_BUILD_DIR)
    39         @sudo rm -f $(ROOTFS_BUILD_DIR)$(QEMU_INTERPRETER)
    4047        @sudo rm -f $(ROOTFS_BUILD_DIR)/etc/debian_chroot
    4148        @sudo cp $(ROOTFS_BUILD_DIR)/etc/resolv.conf_debwrt $(ROOTFS_BUILD_DIR)/etc/resolv.conf
     49        $(call qemu-cleanup)
    4250
    4351debian/rootfs: debian/rootfs/bootstrap         \
     
    167175ifeq ($(DEBIAN_ROOTFS_QEMU_2ND_STAGE),y)
    168176debian/rootfs/second-stage-qemu: debian/rootfs/bootstrap debian/buildenv/qemu-build
    169         $(call qemu-prepare-enter)
     177        $(call qemu-prepare)
    170178        sudo chroot $(ROOTFS_BUILD_DIR) /usr/sbin/PostInstall && sudo rm -f $(ROOTFS_BUILD_DIR)/usr/sbin/PostInstall
    171         sudo rm -f $(ROOTFS_BUILD_DIR)$(QEMU_INTERPRETER)
     179        $(call qemu-cleanup)
    172180else
    173181debian/rootfs/second-stage-qemu: debian/rootfs/bootstrap
Note: See TracChangeset for help on using the changeset viewer.