source: debwrt/trunk/debian/buildenv/debian.mk @ 54

Last change on this file since 54 was 54, checked in by amain, 9 years ago

Make debwrt-kernel-headers auto use compiled openwrt kernel-headers or if not the default in the svn repo

File size: 6.1 KB
Line 
1# DebWrt - Debian on Embedded devices
2#
3# Copyright (C) 2010 Johan van Zoomeren <amain@debwrt.net>
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18SB2_ARCH:=$(call qstrip,$(CONFIG_ARCH))
19TARGET_ARCH:=$(call qstrip,$(CONFIG_ARCH))
20CHROOT:=sudo chroot $(DEBIAN_BUILD_DIR)
21CHROOT_USER:=$(CHROOT) su - $(USER)
22SB2:=sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "export LC_ALL=C; cd $(SB2_ARCH)-lenny && sb2"
23SB2E:=sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "export LC_ALL=C; cd $(SB2_ARCH)-lenny && sb2 -e"
24SB2EF:=sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "export LC_ALL=C; cd $(SB2_ARCH)-lenny && sb2 -eR"
25
26sb2:
27        $(SB2)
28sb2e:
29        $(SB2E)
30sbef:
31        $(SB2EF)
32ch: chroot
33chu: chroot-user
34chroot:
35        $(CHROOT) bash -c "cd /usr/src; exec bash"
36chroot-user:
37        $(CHROOT_USER) bash -c "cd /usr/src; exec bash"
38
39#debian/buildenv/create: debian/buildenv/prepare debian/buildenv/qemu-build debian/buildenv/scratchbox-prepare
40debian/buildenv/create: debian/buildenv/prepare debian/buildenv/emdebian-prepare
41        touch $@
42
43debian/buildenv/prepare:
44        mkdir -p $(DEBIAN_BUILD_DIR)
45        # Due to various bugs in debootstrap in combination with fakechroot it is not
46        # possible to create a fakechroot here - and therefore we need to use chroot
47        # with sudo
48        #fakeroot fakechroot debootstrap
49                                                #--variant=fakechroot
50        sudo debootstrap    --include=$(subst $(space),$(empty),$(CONFIG_DEBIAN_BUILDENV_INCLUDE_PACKAGES)) \
51                                            $(DEBIAN_BUILD_VERSION) \
52                                                $(DEBIAN_BUILD_DIR) \
53                                                $(CONFIG_DEBIAN_BUILDENV_REPOSITORY)
54        sudo bash -c "echo 127.0.0.1 `hostname -s` >$(DEBIAN_BUILD_DIR)/etc/hosts"
55        sudo bash -c "echo \"$(USER) ALL=(ALL) NOPASSWD: ALL\" >$(DEBIAN_BUILD_DIR)/etc/sudoers"
56        sudo bash -c "echo debwrt-$(call qstrip,$(CONFIG_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 chown $(USER):$(GROUP) $(DEBIAN_BUILD_DIR)/usr/src
61        sudo chroot $(DEBIAN_BUILD_DIR) apt-get update
62        sudo chroot $(DEBIAN_BUILD_DIR) groupadd -g $(shell id -g) debwrt
63        sudo chroot $(DEBIAN_BUILD_DIR) useradd -g debwrt -s /bin/bash -m -u $(shell id -u) $$USER
64        touch $@
65
66debian/buildenv/prepare-sb2:
67        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"
68        touch $@
69
70#
71# -- Emdebian sources.list entries
72#
73# deb http://www.emdebian.org/debian/ unstable main
74# deb http://www.emdebian.org/debian/ testing main
75# deb http://www.emdebian.org/debian/ lenny main
76#
77# Once you have that then install whichever version of the tools you want. e.g:
78# 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
79# will install the gcc-4.3 C and C++ toolchain for armel cross-compiling.
80#
81# Use emdebian stable/lenny cross compiler. Unstable seems to be broken now for a long time
82#EMDEBIAN_RELEASE:=$(DEBIAN_BUILD_VERSION)
83EMDEBIAN_RELEASE:=stable
84
85# note: to speed up setting up: do not install devscripts
86# note: a mailservers seems to be installed and started: bad - needs removal
87debian/buildenv/emdebian-prepare: debian/buildenv/prepare
88        sudo bash -c "echo \"deb $(call qstrip,$(CONFIG_EMDEBIAN_BUILDENV_REPOSITORY)) $(EMDEBIAN_RELEASE) main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
89        sudo chroot $(DEBIAN_BUILD_DIR) apt-get update
90        sudo chroot $(DEBIAN_BUILD_DIR) bash -c "export LC_ALL=C; apt-get -y --force-yes install build-essential debootstrap fakeroot zlib1g-dev dh-make sudo openssh-client dpkg-cross apt-cross vim pkg-config dpatch libncurses5-dev devscripts"
91        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"
92        touch $@
93
94debian/buildenv/qemu-prepare:
95        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"
96        touch $@
97
98debian/buildenv/qemu-build: debian/buildenv/qemu-prepare
99        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"
100        touch $@
101
102debian/buildenv/scratchbox-prepare:
103        sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "mkdir -p $(SB2_ARCH)-lenny"
104        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\""
105        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)"
106        sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c  "cd $(SB2_ARCH)-lenny && sb2 -eR ./debootstrap/debootstrap --second-stage"
107
108debian/buildenv/clean:
109        # sudo should not be needed if fakechroot would have worked
110        sudo rm -rf $(DEBIAN_BUILD_DIR)
111        rm -f debian/buildenv/prepare
112        rm -f debian/buildenv/qemu-prepare
113        rm -f debian/buildenv/qemu-build
114
115.PHONY: debian/clean
116
Note: See TracBrowser for help on using the repository browser.