Ignore:
Timestamp:
Oct 4, 2015, 1:33:25 AM (4 years ago)
Author:
amain
Message:

Add Jessie support. Allow skipping cross-compiling of DebWrt Debian packages.

File:
1 edited

Legend:

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

    r579 r675  
    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 SB2_ARCH:=$(call qstrip,$(CONFIG_ARCH))
    1918CHROOT:=sudo chroot $(DEBIAN_BUILD_DIR)
    2019CHROOT_USER:=$(CHROOT) su - $(USER)
    21 SB2:=sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "export LC_ALL=C; cd $(SB2_ARCH)-lenny && sb2"
    22 SB2E:=sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "export LC_ALL=C; cd $(SB2_ARCH)-lenny && sb2 -e"
    23 SB2EF:=sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "export LC_ALL=C; cd $(SB2_ARCH)-lenny && sb2 -eR"
    24 QEMU_BIN=$(DEBIAN_BUILD_DIR)/usr/local/bin/qemu-$(TARGET_ARCH)
    25 QEMU_BIN_STATIC=$(QEMU_BIN)-static
    26 QEMU_INTERPRETER=$(shell cat /proc/sys/fs/binfmt_misc/qemu-$(TARGET_ARCH) 2>/dev/null | grep interpreter | awk '{print $$2}')
    2720
    28 sb2:
    29         $(SB2)
    30 sb2e:
    31         $(SB2E)
    32 sbef:
    33         $(SB2EF)
    3421ch: chroot
    3522chu: chroot-user
     
    3926        $(CHROOT_USER) bash -c "cd /usr/src; exec bash"
    4027
    41 debian/buildenv/create: debian/buildenv/prepare debian/buildenv/emdebian-prepare debian/buildenv/qemu-build
    42         touch $@
     28include $(TOPDIR)/debian/buildenv/buildenv.mk
     29include $(TOPDIR)/debian/buildenv/qemu.mk
     30include $(TOPDIR)/debian/buildenv/emdebian.mk
    4331
    44 debian/buildenv/prepare:
    45         mkdir -p $(DEBIAN_BUILD_DIR)
    46         # Due to various bugs in debootstrap in combination with fakechroot it is not
    47         # possible to create a fakechroot here - and therefore we need to use chroot
    48         # with sudo
    49         #fakeroot fakechroot debootstrap
    50                                                 #--variant=fakechroot
    51         sudo debootstrap    --include=$(subst $(space),$(empty),$(CONFIG_DEBIAN_BUILDENV_INCLUDE_PACKAGES)) \
    52                                             $(DEBIAN_BUILD_VERSION) \
    53                                                 $(DEBIAN_BUILD_DIR) \
    54                                                 $(CONFIG_DEBIAN_BUILDENV_REPOSITORY)
    55         sudo bash -c "echo 127.0.0.1 `hostname -s` localhost >$(DEBIAN_BUILD_DIR)/etc/hosts"
    56         sudo bash -c "echo debwrt-$(TARGET_ARCH)-$(DEBIAN_BUILD_VERSION) > $(DEBIAN_BUILD_DIR)/etc/debian_chroot"
    57         sudo bash -c "echo syntax on >$(DEBIAN_BUILD_DIR)/etc/vimrc"
    58         sudo bash -c "echo 0 > /proc/sys/vm/mmap_min_addr" # for ARM targets
    59         sudo bash -c "echo \"deb $(call qstrip,$(CONFIG_DEBIAN_BUILDENV_REPOSITORY)) $(DEBIAN_BUILD_VERSION) main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
    60         sudo bash -c "echo \"deb-src $(call qstrip,$(CONFIG_DEBIAN_BUILDENV_REPOSITORY)) $(DEBIAN_BUILD_VERSION) main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
    61         sudo chown $(USER):$(GROUP) $(DEBIAN_BUILD_DIR)/usr/src
    62         sudo chroot $(DEBIAN_BUILD_DIR) apt-get update
    63         sudo chroot $(DEBIAN_BUILD_DIR) groupadd -g $(shell id -g) debwrt
    64         sudo chroot $(DEBIAN_BUILD_DIR) useradd -g debwrt -s /bin/bash -m -u $(shell id -u) $$USER
    65         sudo mkdir -p $(DEBIAN_BUILD_DIR)/etc/sudoers.d
    66         sudo bash -c "echo \"$(USER) ALL=(ALL) NOPASSWD: ALL\" >$(DEBIAN_BUILD_DIR)/etc/sudoers.d/debwrt"
    67         sudo chmod 0440 $(DEBIAN_BUILD_DIR)/etc/sudoers.d/debwrt
    68         touch $@
     32.PHONY: ch \
     33        chu \
     34        chroot \
     35        chroot-user
    6936
    70 debian/buildenv/prepare-sb2:
    71         sudo chroot $(DEBIAN_BUILD_DIR) bash -c "export LC_ALL=C; apt-get -y --force-yes install g++-4.3-$(SB2_ARCH)-linux-gnu libc6-dev-$(SB2_ARCH)-cross build-essential debootstrap fakeroot zlib1g-dev qemu-user scratchbox2 dh-make"
    72         touch $@
    73 
    74 #
    75 # -- Emdebian sources.list entries
    76 #
    77 # deb http://www.emdebian.org/debian/ unstable main
    78 # deb http://www.emdebian.org/debian/ testing main
    79 # deb http://www.emdebian.org/debian/ lenny main
    80 #
    81 # Once you have that then install whichever version of the tools you want. e.g:
    82 # apt-get install libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi gcc-4.3-arm-linux-gnueabi g++-4.3-arm-linux-gnueabi
    83 # will install the gcc-4.3 C and C++ toolchain for armel cross-compiling.
    84 #
    85 # Use emdebian stable/lenny cross compiler. Unstable seems to be broken now for a long time
    86 #
    87 # Emdebian suggests to use squeeze, even if on wheezey or higher:
    88 # Currently, toolchains for Squeeze are preferred. If using Wheezy or unstable, add
    89 # a Squeeze source for your own architecture using your normal Debian mirror for
    90 # dependencies which are no longer in wheezy or unstable.
    91 #
    92 #EMDEBIAN_RELEASE:=$(DEBIAN_BUILD_VERSION)
    93 EMDEBIAN_RELEASE:=squeeze
    94 
    95 # Automatic installing of build dependencies
    96 #
    97 # <= Lenny = apt-cross
    98 # >  Lenny = xapt
    99 #
    100 # Squeeze needs some backorts to get xapt working, so from now on
    101 # DebWrt will only support wheezy and up.
    102 #
    103 # Link: https://wiki.debian.org/EmdebianToolchain
    104 
    105 # note: to speed up setting up: do not install devscripts
    106 # note: a mailservers seems to be installed and started: bad - needs removal
    107 
    108 debian/buildenv/emdebian-prepare: debian/buildenv/prepare
    109         @echo "I: Adding squeeze source incase Emdebiand squeeze is missing packages in wheezy or higher..."
    110         sudo bash -c "echo \"deb $(call qstrip,$(CONFIG_EMDEBIAN_BUILDENV_REPOSITORY)) $(EMDEBIAN_RELEASE) main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
    111         sudo bash -c "echo \"deb $(call qstrip,$(CONFIG_DEBIAN_BUILDENV_REPOSITORY)) squeeze main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
    112         sudo bash -c "echo \"deb-src $(call qstrip,$(CONFIG_DEBIAN_BUILDENV_REPOSITORY)) squeeze main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
    113         # Add lenny repo, just for apt-cross
    114         #sudo bash -c "echo \"deb  http://archive.debian.org/debian lenny main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
    115         #sudo bash -c "echo -e \"Package: *\nPin: release a=lenny\nPin-Priority: 200\" > $(DEBIAN_BUILD_DIR)/etc/apt/preferences"
    116         sudo chroot $(DEBIAN_BUILD_DIR) apt-get update
    117         #sudo chroot $(DEBIAN_BUILD_DIR) apt-get -y install apt-cross
    118         #sudo chroot $(DEBIAN_BUILD_DIR) apt-get -y install libmpfr1ldbl
    119         sudo chroot $(DEBIAN_BUILD_DIR) apt-get -y install emdebian-archive-keyring xapt dpkg-cross
    120         sudo chroot $(DEBIAN_BUILD_DIR) bash -c "export LC_ALL=C; apt-get -y --force-yes install build-essential dh-make debootstrap fakeroot zlib1g-dev openssh-client vim pkg-config dpatch libncurses5-dev devscripts subversion automake gcc-multilib g++-multilib quilt"
    121 ifeq ($(TARGET_ARCH),arm)
    122         sudo chroot $(DEBIAN_BUILD_DIR) bash -c "export LC_ALL=C; apt-get -y --force-yes install libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi gcc-4.3-arm-linux-gnu g++-4.4-arm-linux-gnueabi linux-kernel-headers-armel-cross"
    123 else
    124         sudo chroot $(DEBIAN_BUILD_DIR) bash -c "export LC_ALL=C; apt-get -y --force-yes install libc6-$(TARGET_ARCH)-cross libc6-dev-$(TARGET_ARCH)-cross binutils-$(TARGET_ARCH)-linux-gnu gcc-4.3-$(TARGET_ARCH)-linux-gnu g++-4.3-$(TARGET_ARCH)-linux-gnu linux-kernel-headers-$(TARGET_ARCH)-cross"
    125 endif
    126         touch $@
    127 
    128 debian/buildenv/qemu: debian/buildenv/qemu-prepare debian/buildenv/qemu-build
    129         touch $@
    130 
    131 debian/buildenv/qemu-clean:
    132         rm -rf $(DEBIAN_BUILD_DIR)/usr/src/qemu
    133         rm -f debian/buildenv/qemu-prepare
    134         rm -f debian/buildenv/qemu-build
    135 
    136 debian/buildenv/qemu-prepare:
    137         $(CHROOT) bash -c "export LC_ALL=C; apt-get -y install libglib2.0-dev"
    138         mkdir -p $(DEBIAN_BUILD_DIR)/usr/src/qemu
    139         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
    140         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
    141         touch $@
    142 
    143 debian/buildenv/qemu-build: debian/buildenv/qemu-prepare
    144         $(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"
    145         $(CHROOT) bash -c "cd /usr/src/qemu/qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)) && make install"
    146         $(CHROOT) cp /usr/local/bin/qemu-$(TARGET_ARCH) /usr/local/bin/qemu-$(TARGET_ARCH)-static
    147         $(CHROOT_USER) bash -c "cd /usr/src/qemu/qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)) && ./configure --target-list=$(TARGET_ARCH)-linux-user && make"
    148         $(CHROOT) bash -c "cd /usr/src/qemu/qemu-$(call qstrip,$(CONFIG_DEBIAN_BUILDENV_QEMU_VERSION)) && make install"
    149         touch $@
    150 
    151 debian/buildenv/scratchbox-prepare:
    152         sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "mkdir -p $(SB2_ARCH)-lenny"
    153         sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "cd $(SB2_ARCH)-lenny && sb2-init -c /usr/local/bin/qemu-$(SB2_ARCH) MIPS \"$(SB2_ARCH)-linux-gnu-gcc\""
    154         sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "fakeroot /usr/sbin/debootstrap --include=file,iputils-ping,netbase,strace,vim,wget,tcpdump --variant=scratchbox --foreign --arch $(SB2_ARCH) lenny $(SB2_ARCH)-lenny/ $(CONFIG_DEBIAN_BUILDENV_REPOSITORY)"
    155         sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c  "cd $(SB2_ARCH)-lenny && sb2 -eR ./debootstrap/debootstrap --second-stage"
    156 
    157 debian/buildenv/clean: debian/buildenv/qemu-clean
    158         # sudo should not be needed if fakechroot would have worked
    159         sudo rm -rf $(DEBIAN_BUILD_DIR)
    160         rm -f debian/buildenv/prepare
    161         rm -f debian/buildenv/qemu-prepare
    162         rm -f debian/buildenv/qemu-build
    163 
    164 .PHONY: debian/buildenv/clean debian/buildenv
    165 
Note: See TracChangeset for help on using the changeset viewer.