Changeset 307


Ignore:
Timestamp:
Aug 16, 2011, 11:00:33 PM (8 years ago)
Author:
amain
Message:

debian/buildenv/rootfs: execute second stage install with qemu - fixes ticket:138

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Config.in

    r291 r307  
    822822config DEBIAN_BUILDENV_QEMU_VERSION
    823823        string "Qemu version"
    824         default "0.12.4"
     824        default "0.15.0-rc0"
    825825        help
    826826          At least 0.12.2 is needed for mips targets.
     
    834834        default DEBWRT_DEBIAN_RELEASE_SQUEEZE
    835835        help
    836           Select the the Debian release for the root filesystem
     836          Select the the Debian release for the root filesystem. Also sets the build environment release.
    837837
    838838config DEBWRT_DEBIAN_RELEASE_SID
     
    860860          You may use as a start for your own list
    861861          of additional packages.
     862
     863config DEBIAN_ROOTFS_QEMU_2ND_STAGE
     864        bool "Use qemu to perform Debian second stage install on the host"
     865        default y
     866        help
     867      Use qemu to perform Debian root fs second stage install on the host. This
     868      eliminates the need to do the second stage install on the target device. Using
     869      qemu is much faster and easier then doing 2nd stage on the target device.
    862870
    863871endmenu
  • trunk/debian/buildenv

    • Property svn:ignore
      •  

        old new  
        44prepare
        55create
         6build
         7qemu
  • trunk/debian/buildenv/debian.mk

    r275 r307  
    2222SB2E:=sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "export LC_ALL=C; cd $(SB2_ARCH)-lenny && sb2 -e"
    2323SB2EF:=sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "export LC_ALL=C; cd $(SB2_ARCH)-lenny && sb2 -eR"
     24QEMU_BIN=$(DEBIAN_BUILD_DIR)/usr/local/bin/qemu-$(TARGET_ARCH)
     25QEMU_BIN_STATIC=$(QEMU_BIN)-static
     26QEMU_INTERPRETER=$(shell cat /proc/sys/fs/binfmt_misc/qemu-$(TARGET_ARCH) | grep interpreter | awk '{print $$2}')
    2427
    2528sb2:
     
    3740
    3841#debian/buildenv/create: debian/buildenv/prepare debian/buildenv/qemu-build debian/buildenv/scratchbox-prepare
    39 debian/buildenv/create: debian/buildenv/prepare debian/buildenv/emdebian-prepare
     42debian/buildenv/create: debian/buildenv/prepare debian/buildenv/emdebian-prepare debian/buildenv/qemu-build
    4043        touch $@
    4144
     
    5255                                                $(CONFIG_DEBIAN_BUILDENV_REPOSITORY)
    5356        sudo bash -c "echo 127.0.0.1 `hostname -s` localhost >$(DEBIAN_BUILD_DIR)/etc/hosts"
    54         sudo bash -c "echo debwrt-$(call qstrip,$(CONFIG_ARCH))-$(DEBIAN_BUILD_VERSION) > $(DEBIAN_BUILD_DIR)/etc/debian_chroot"
     57        sudo bash -c "echo debwrt-$(TARGET_ARCH)-$(DEBIAN_BUILD_VERSION) > $(DEBIAN_BUILD_DIR)/etc/debian_chroot"
    5558        sudo bash -c "echo syntax on >$(DEBIAN_BUILD_DIR)/etc/vimrc"
    5659        sudo bash -c "echo 0 > /proc/sys/vm/mmap_min_addr" # for ARM targets
     
    103106        touch $@
    104107
     108debian/buildenv/qemu: debian/buildenv/qemu-prepare debian/buildenv/qemu-build
     109        touch $@
     110
     111debian/buildenv/qemu-clean:
     112        rm -rf $(DEBIAN_BUILD_DIR)/usr/src/qemu
     113        rm -f debian/buildenv/qemu-prepare
     114        rm -f debian/buildenv/qemu-build
     115
    105116debian/buildenv/qemu-prepare:
    106         sudo chroot $(DEBIAN_BUILD_DIR) bash -c "cd /usr/src && wget http://download.savannah.gnu.org/releases/qemu/qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)).tar.gz && tar xzf qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)).tar.gz"
     117        $(CHROOT) bash -c "export LC_ALL=C; apt-get -y install libglib2.0-dev"
     118        mkdir -p $(DEBIAN_BUILD_DIR)/usr/src/qemu
     119        wget -O $(DEBIAN_BUILD_DIR)/usr/src/qemu/qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)).tar.gz http://download.savannah.gnu.org/releases/qemu/qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)).tar.gz
     120        tar xzf $(DEBIAN_BUILD_DIR)/usr/src/qemu/qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)).tar.gz -C $(DEBIAN_BUILD_DIR)/usr/src/qemu
    107121        touch $@
    108122
    109123debian/buildenv/qemu-build: debian/buildenv/qemu-prepare
    110         sudo chroot $(DEBIAN_BUILD_DIR) bash -c "cd /usr/src/qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)) && ./configure --target-list=$(SB2_ARCH)-linux-user && make && make install"
     124        $(CHROOT_USER) bash -c "cd /usr/src/qemu/qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)) && ./configure --static --target-list=$(TARGET_ARCH)-linux-user && make"
     125        $(CHROOT) bash -c "cd /usr/src/qemu/qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)) && make install"
     126        $(CHROOT) cp /usr/local/bin/qemu-$(TARGET_ARCH) /usr/local/bin/qemu-$(TARGET_ARCH)-static
     127        $(CHROOT_USER) bash -c "cd /usr/src/qemu/qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)) && ./configure --target-list=$(TARGET_ARCH)-linux-user && make"
     128        $(CHROOT) bash -c "cd /usr/src/qemu/qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)) && make install"
    111129        touch $@
    112130
     
    117135        sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c  "cd $(SB2_ARCH)-lenny && sb2 -eR ./debootstrap/debootstrap --second-stage"
    118136
    119 debian/buildenv/clean:
     137debian/buildenv/clean: debian/buildenv/qemu-clean
    120138        # sudo should not be needed if fakechroot would have worked
    121139        sudo rm -rf $(DEBIAN_BUILD_DIR)
     
    124142        rm -f debian/buildenv/qemu-build
    125143
    126 .PHONY: debian/clean
     144.PHONY: debian/buildenv/clean
    127145
  • trunk/debian/rootfs

    • Property svn:ignore
      •  

        old new  
        66clean-rootfs-dir
        77debwrt-packages
        8 
        98bootstrap
         9second-stage-qemu
  • trunk/debian/rootfs/debian.mk

    r303 r307  
    1717
    1818DEBIAN_ROOTFS_INCLUDE_PACKAGES:=$(call qstrip,$(CONFIG_DEBIAN_ROOTFS_INCLUDE_PACKAGES))
     19DEBIAN_ROOTFS_QEMU_2ND_STAGE:=$(call qstrip, $(CONFIG_DEBIAN_ROOTFS_QEMU_2ND_STAGE))
    1920DEBWRT_EXTRA_ROOTFS_FILES_DIR:=$(TOPDIR)/debian/rootfs/files
    2021DEBWRT_MODULES_ARCHIVE=$(shell ls $(INSTALL_DIR)/debwrt-modules-*.tar.gz 2>/dev/null)
    2122MODULES_VERSION=$(shell echo `basename $(DEBWRT_MODULES_ARCHIVE) 2>/dev/null` | awk -F '-' '{print $$6}')
    2223
    23 debian/rootfs: debian/rootfs/bootstrap debian/rootfs/unpack debian/rootfs/files-install debian/rootfs/debwrt-packages debian/rootfs/modules-install debian/rootfs/post-setup
     24chr: debian/rootfs/qemu-check
     25        @sudo bash -c "echo "debwrt-$(TARGET_ARCH)" > $(ROOTFS_BUILD_DIR)/etc/debian_chroot"
     26        @sudo cp $(ROOTFS_BUILD_DIR)/etc/resolv.conf $(ROOTFS_BUILD_DIR)/etc/resolv.conf_debwrt
     27        @sudo bash -c "cat /etc/resolv.conf | grep nameserver >$(ROOTFS_BUILD_DIR)/etc/resolv.conf"
     28        @sudo chroot $(ROOTFS_BUILD_DIR)
     29        @sudo rm -f $(ROOTFS_BUILD_DIR)$(QEMU_INTERPRETER)
     30        @sudo rm -f $(ROOTFS_BUILD_DIR)/debian_chroot
     31        @sudo cp $(ROOTFS_BUILD_DIR)/etc/resolv.conf_debwrt $(ROOTFS_BUILD_DIR)/etc/resolv.conf
     32
     33debian/rootfs/qemu-check:
     34        @if [ ! -x $(QEMU_BIN_STATIC) ]; then echo "E: can't find qemu ($(QEMU_BIN_STATIC))"; fi
     35        @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
     36        @if [ ! -x $(QEMU_BIN_STATIC) -o ! -e /proc/sys/fs/binfmt_misc/qemu-$(TARGET_ARCH) ]; then echo "E: abort"; exit 1; fi
     37        @sudo cp $(QEMU_BIN_STATIC) $(ROOTFS_BUILD_DIR)$(QEMU_INTERPRETER)
     38        @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
     39
     40debian/rootfs: debian/rootfs/bootstrap         \
     41               debian/rootfs/unpack            \
     42               debian/rootfs/files-install     \
     43               debian/rootfs/debwrt-packages   \
     44               debian/rootfs/modules-install   \
     45               debian/rootfs/post-setup        \
     46               debian/rootfs/second-stage-qemu \
    2447        touch $@
    2548
     
    109132        touch $@
    110133
     134ifeq ($(DEBIAN_ROOTFS_QEMU_2ND_STAGE),y)
     135debian/rootfs/second-stage-qemu: debian/rootfs/bootstrap debian/buildenv/qemu-build debian/rootfs/qemu-check
     136        sudo chroot $(ROOTFS_BUILD_DIR) /debootstrap/debootstrap --second-stage
     137        sudo chroot $(ROOTFS_BUILD_DIR) /usr/sbin/PostInstall && sudo rm -f $(ROOTFS_BUILD_DIR)/usr/sbin/PostInstall
     138        sudo rm -f $(ROOTFS_BUILD_DIR)$(QEMU_INTERPRETER)
     139else
     140debian/rootfs/second-stage-qemu: debian/rootfs/bootstrap debian/buildenv/qemu-build
     141        @echo "I: Qemu 2nd stage install disabled. Second stage needs now to be performend on the target device itself."
     142        @echo "I: Qemu 2nd stage install can be enabled using menuconfig (DEBIAN_ROOTFS_QEMU_2ND_STAGE)."
     143endif
     144        touch $@
     145
    111146debian/rootfs/clean:
    112147        sudo rm -rf $(ROOTFS_BUILD_DIR)
  • trunk/rules/help.txt

    r287 r307  
    4949debian/buildenv/prepare          : Prepare DebWrt build environment
    5050debian/buildenv/emdebian-prepare : Install Emdebin into the DebWrt build environment
    51 debian/buildenv/qemu-prepare     : Setup pre-requisites for Qemu ( currently not used )
    52 debian/buildenv/qemu-build       : Build Qemu ( currently not used )
     51debian/buildenv/qemu-prepare     : Setup pre-requisites for Qemu
     52debian/buildenv/qemu-build       : Build Qemu
    5353debian/buildenv/clean            : Clean build environment ( entire chroot is deleted )
    5454
     
    7171debian/rootfs/post-setup         : Post install
    7272debian/rootfs/clean              : Clean it all
     73debian/rootfs/second-stage-qemu  : Execute Debian second stage for the target root filesystem on the host using Qemu
     74chr                              : Enter the target change root filesystem using qemu ( like ch and chu ) as "root"
    7375
    7476Links:
Note: See TracChangeset for help on using the changeset viewer.