Changeset 694 for trunk/debian/rootfs


Ignore:
Timestamp:
Nov 21, 2015, 10:38:18 PM (4 years ago)
Author:
amain
Message:

Split firmware build from rootfs creation and debian build environment creation

Location:
trunk/debian/rootfs
Files:
1 added
1 edited

Legend:

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

    r676 r694  
    11# DebWrt - Debian on Embedded devices
    22#
    3 # Copyright (C) 2010 Johan van Zoomeren <amain@debwrt.net>
     3# Copyright (C) 2010,2015 Johan van Zoomeren <amain@debwrt.net>
    44#
    55# This program is free software: you can redistribute it and/or modify
     
    1616# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717
    18 DEBIAN_ROOTFS_INCLUDE_PACKAGES:=$(call qstrip,$(CONFIG_DEBIAN_ROOTFS_INCLUDE_PACKAGES))
    19 DEBIAN_ROOTFS_QEMU_2ND_STAGE:=$(call qstrip, $(CONFIG_DEBIAN_ROOTFS_QEMU_2ND_STAGE))
     18QEMU_BIN=/usr/bin/qemu-$(ROOTFS_DEBIAN_ARCH)
     19QEMU_BIN_STATIC=$(QEMU_BIN)-static
     20QEMU_INTERPRETER=$(shell cat /proc/sys/fs/binfmt_misc/qemu-$(ROOTFS_DEBIAN_ARCH) 2>/dev/null | grep interpreter | awk '{print $$2}')
     21
     22ROOTFS_DEBIAN_INCLUDE_PACKAGES:=$(call qstrip,$(CONFIG_ROOTFS_DEBIAN_INCLUDE_PACKAGES))
     23ROOTFS_DEBIAN_QEMU_2ND_STAGE:=$(call qstrip, $(CONFIG_ROOTFS_DEBIAN_QEMU_2ND_STAGE))
    2024DEBWRT_EXTRA_ROOTFS_FILES_DIR:=$(TOPDIR)/debian/rootfs/files/all
    2125DEBWRT_EXTRA_ROOTFS_FILES_BOARD_DIR:=$(TOPDIR)/debian/rootfs/files/$(call qstrip, $(CONFIG_TARGET_BOARD))
    22 DEBWRT_MODULES_ARCHIVE=$(shell ls $(INSTALL_DIR)/debwrt-modules-*.tar.gz 2>/dev/null)
    2326MODULES_VERSION=$(shell echo `basename $(DEBWRT_MODULES_ARCHIVE) 2>/dev/null` | awk -F '-' '{print $$6}')
    24 DEBIAN_ROOTFS_INCLUDE_PACKAGES_DEBIAN_VERSION:=$(wildcard debian/rootfs/include_packages.list.$(DEBIAN_BUILD_VERSION))
     27ROOTFS_DEBIAN_INCLUDE_PACKAGES_DEBIAN_VERSION:=$(wildcard debian/rootfs/include_packages.list.$(ROOTFS_DEBIAN_RELEASE))
    2528
    2629define qemu-prepare
    2730        @if [ ! -x $(QEMU_BIN_STATIC) ]; then echo "E: can't find qemu ($(QEMU_BIN_STATIC))"; fi
    28         @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
    29         @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
     31        @if [ ! -e /proc/sys/fs/binfmt_misc/qemu-$(ROOTFS_DEBIAN_ARCH) ]; then echo "E: can't find binfmt_misc qemu-$(ROOTFS_DEBIAN_ARCH) ( /proc/sys/fs/binfmt_misc/qemu-$(ROOTFS_DEBIAN_ARCH)).\nE: install qemu-user-static, or\nE: disable second stage with qemu with menuconfig (ROOTFS_DEBIAN_QEMU_2ND_STAGE)."; fi
     32        @if [ ! -x $(QEMU_BIN_STATIC) -o ! -e /proc/sys/fs/binfmt_misc/qemu-$(ROOTFS_DEBIAN_ARCH) ]; then echo "E: abort - qemu not available in chroot"; exit 1; fi
    3033        @if [ ! -e $(ROOTFS_BUILD_DIR)$(QEMU_INTERPRETER) ]; then sudo cp $(QEMU_BIN_STATIC) $(ROOTFS_BUILD_DIR)$(QEMU_INTERPRETER); fi
    31         @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
     34        @if ! sudo chroot $(ROOTFS_BUILD_DIR) /bin/ls >/dev/null; then echo "E: qemu can't execute binaries for $(ROOTFS_DEBIAN_ARCH)"; echo "E: abort"; exit 1; fi
    3235        @if ! (mount | grep -q $(ROOTFS_BUILD_DIR)/proc); then sudo chroot $(ROOTFS_BUILD_DIR) mount -t proc none /proc; fi
    3336        @if ! (mount | grep -q $(ROOTFS_BUILD_DIR)/sys ); then sudo chroot $(ROOTFS_BUILD_DIR) mount -t sysfs none /sys; fi
     
    4649         >$(TMP_DIR)/include_packages_list.debwrt-package-deps; \
    4750        grep -hv '^#' \
    48                  $(DEBIAN_ROOTFS_INCLUDE_PACKAGES) \
    49                  $(DEBIAN_ROOTFS_INCLUDE_PACKAGES_DEBIAN_VERSION) \
     51                 $(ROOTFS_DEBIAN_INCLUDE_PACKAGES) \
     52                 $(ROOTFS_DEBIAN_INCLUDE_PACKAGES_DEBIAN_VERSION) \
    5053                 $(TMP_DIR)/include_packages_list.debwrt-package-deps \
    5154          | sort -u | tr '\n' ',' | sed 's/,$$//')
     
    5457chr:
    5558        $(call qemu-prepare)
    56         @sudo bash -c "echo "debwrt-$(TARGET_ARCH)" > $(ROOTFS_BUILD_DIR)/etc/debian_chroot"
     59        @sudo bash -c "echo "debwrt-$(ROOTFS_DEBIAN_ARCH)" > $(ROOTFS_BUILD_DIR)/etc/debian_chroot"
    5760        @sudo cp $(ROOTFS_BUILD_DIR)/etc/resolv.conf $(ROOTFS_BUILD_DIR)/etc/resolv.conf_debwrt
    5861        @sudo bash -c "cat /etc/resolv.conf | grep nameserver >$(ROOTFS_BUILD_DIR)/etc/resolv.conf"
     
    6568               debian/rootfs/unpack               \
    6669               debian/rootfs/files-install        \
    67                debian/rootfs/debwrt-packages      \
    68                debian/rootfs/modules-install      \
    6970               debian/rootfs/post-setup           \
    7071               debian/rootfs/second-stage         \
    7172               debian/rootfs/verify               \
    7273               debian/rootfs/save
    73         @echo "I: root filesystem $(DEBIAN_BUILD_VERSION) $(TARGET_ARCH) prepared in $(ROOTFS_BUILD_DIR)"
    74         @echo "I: if the DebWrt kernel wasn't build, then no kernel modules have been installed, install them by:"
    75         @echo "I: - make openwrt/all"
    76         @echo "I: - make debian/rootfs/modules-install"
    77         @echo "I: - or: install manually from alternative source"
     74        @echo "I: Root filesystem $(ROOTFS_DEBIAN_RELEASE) $(ROOTFS_DEBIAN_ARCH) prepared in $(ROOTFS_BUILD_DIR) and archived in $(ROOTFS_INSTALL_DIR)/$(ROOTFS_TAR_BZ2)."
    7875        @echo "I:"
    79         @echo "I: install the image to USB-Disk/USB-Stick/SD-Card (make sure it is already mounted at /media/DEBWRT_ROOTFS)"
     76        @echo "I: Install the image to USB-Disk/USB-Stick/SD-Card (make sure it is already mounted at /media/DEBWRT_ROOTFS)"
    8077        @echo "I: - make debian/rootfs/install"
    8178        @echo "I:"
    82         @echo "I: enter the change root(with qemu) and perform additional post install steps:"
     79        @echo "I: Enter the change root(with qemu) and perform additional post install steps:"
    8380        @echo "I: - make chr"
    8481        @echo "I: - apt-get update # example statement ;-) - networking works!"
     
    103100
    104101debian/rootfs/save:
    105 ifeq ($(DEBIAN_ROOTFS_QEMU_2ND_STAGE),y)
    106         sudo bash -c "tar cjf $(INSTALL_DIR)/$(ROOTFS_TAR_BZ2) -C $(ROOTFS_BUILD_DIR) ."
    107 else
    108         if [ -d /media/DEBWRT_ROOT ]; then \
    109                 sudo bash -c "tar cjf $(ROOTFS_TAR_BZ2) -C /media/DEBWRT_ROOT ."; \
    110         fi
    111 endif
     102        mkdir -p $(ROOTFS_INSTALL_DIR)
     103        sudo bash -c "tar cjf $(ROOTFS_INSTALL_DIR)/$(ROOTFS_TAR_BZ2) -C $(ROOTFS_BUILD_DIR) ."
     104#ifeq ($(ROOTFS_DEBIAN_QEMU_2ND_STAGE),y)
     105#else
     106#       if [ -d /media/DEBWRT_ROOT ]; then \
     107#               sudo bash -c "tar cjf $(ROOTFS_TAR_BZ2) -C /media/DEBWRT_ROOT ."; \
     108#       fi
     109#endif
    112110
    113111debian/rootfs/files-install: debian/rootfs/bootstrap
     
    129127        touch $@
    130128
    131 debian/rootfs/modules-install: debian/rootfs/bootstrap
    132 ifneq ($(DEBWRT_MODULES_ARCHIVE),)
    133         sudo tar xof $(DEBWRT_MODULES_ARCHIVE) -C $(ROOTFS_BUILD_DIR)
    134         #sudo depmod -a -b $(ROOTFS_BUILD_DIR) $(MODULES_VERSION)
    135 else
    136         @echo "W: Can't install kernel module to the change root. Kernel modules archive missing. ($(DEBWRT_MODULES_ARCHIVE))"
    137 endif
    138         touch $@
    139 
    140129# Fow now: Include debwrt-packages dependencies staticly. This
    141130#          list(DEBWRT_ROOTFS_PKGLST_DEPS) is managed in debian/package/debian.mk.
    142131debian/rootfs/bootstrap: debian/rootfs/clean-rootfs-dir
    143         sudo debootstrap --arch=$(TARGET_ARCH)\
     132        mkdir -p $(ROOTFS_BUILD_DIR)
     133        sudo debootstrap --arch=$(ROOTFS_DEBIAN_ARCH)\
    144134                     --foreign \
    145135                     --include=$(call rootfs-package-list) \
    146                      $(DEBIAN_BUILD_VERSION) \
     136                     $(ROOTFS_DEBIAN_RELEASE) \
    147137                     $(ROOTFS_BUILD_DIR) \
    148138                     $(CONFIG_DEBIAN_BUILDENV_REPOSITORY)
     
    163153# install all available cross-compiled debwrt debian packages, except for the kernel-headers package and the cross packages
    164154
    165 ifeq ($(CONFIG_DEBIAN_ROOTFS_INCLUDE_DEBWRT_PACKAGES),y)
    166 debian/rootfs/debwrt-packages: debian/rootfs/bootstrap debian/package/rootfs
    167         ls ${INSTALL_DIR_DEBIAN_PACKAGES}/*.deb | grep -v "debwrt-kernel-headers" | grep -v "cross" | while read package; do \
    168                 pfname=`basename $$package`; \
    169                 pname=`echo $$pfname | sed 's/_.*//'`; \
    170                 echo "Installing DebWrt package: $$pname"; \
    171                 sudo cp $$package $(ROOTFS_BUILD_DIR)/var/cache/apt/archives; \
    172                 sudo dpkg-deb -x $$package $(ROOTFS_BUILD_DIR); \
    173                 sudo bash -c "echo \"$$pname /var/cache/apt/archives/$$pfname\" >>$(ROOTFS_BUILD_DIR)/debootstrap/debpaths" ;\
    174                 sudo sed -i "s/$$/$$pname /" $(ROOTFS_BUILD_DIR)/debootstrap/base ;\
    175         done
    176         touch $@
    177 else
    178 debian/rootfs/debwrt-packages:
    179         @echo "Not installing DebWrt Debian packages in target root filesystem."
    180         touch $@
    181 endif
    182        
    183155debian/rootfs/clean-rootfs-dir:
    184156        mkdir -p $(BUILD_DIR_BASE)
     
    189161        sudo mkdir -p $(ROOTFS_BUILD_DIR)/etc/apt
    190162        # note: unfortunately /etc/apt/sources.list is cleaned after running second stage install
    191         sudo bash -c "echo \"deb http://ftp.debian.org/debian $(DEBIAN_BUILD_VERSION) main\" > $(ROOTFS_BUILD_DIR)/etc/apt/sources.list"
     163        sudo bash -c "echo \"deb http://ftp.debian.org/debian $(ROOTFS_DEBIAN_RELEASE) main\" > $(ROOTFS_BUILD_DIR)/etc/apt/sources.list"
    192164        sudo bash -c "echo \"$(DEBWRTVERSION)\" >$(ROOTFS_BUILD_DIR)/etc/debwrt_version"
    193         sudo bash -c "echo \"$(DEBIAN_BUILD_VERSION)\" >$(ROOTFS_BUILD_DIR)/etc/debian_release"
     165        sudo bash -c "echo \"$(ROOTFS_DEBIAN_RELEASE)\" >$(ROOTFS_BUILD_DIR)/etc/debian_release"
    194166        touch $@
    195167
    196 ifeq ($(DEBIAN_ROOTFS_QEMU_2ND_STAGE),y)
     168ifeq ($(ROOTFS_DEBIAN_QEMU_2ND_STAGE),y)
    197169debian/rootfs/second-stage: debian/rootfs/bootstrap debian/buildenv/qemu
    198170        $(call qemu-prepare)
     
    202174debian/rootfs/second-stage: debian/rootfs/bootstrap
    203175        @echo "I: Qemu 2nd stage install disabled. Second stage needs now to be performend on the target device itself."
    204         @echo "I: Qemu 2nd stage install can be enabled using menuconfig (DEBIAN_ROOTFS_QEMU_2ND_STAGE)."
     176        @echo "I: Qemu 2nd stage install can be enabled using menuconfig (ROOTFS_DEBIAN_QEMU_2ND_STAGE)."
    205177endif
    206178        touch $@
     
    208180debian/rootfs/clean:
    209181        sudo rm -rf $(ROOTFS_BUILD_DIR)
    210         rm -f debian/rootfs/debwrt-packages
    211182        rm -f debian/rootfs/bootstrap
    212183        rm -f debian/rootfs/install
    213184        rm -f debian/rootfs/files-install
    214         rm -f debian/rootfs/modules-install
    215185
Note: See TracChangeset for help on using the changeset viewer.