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

Last change on this file since 134 was 134, checked in by amain, 10 years ago

fix bug 17: E: package apt-cross has no installation candidate. Always install apt-cross from sid for squeeze. Unfortunately now some other packages are also installed from sid instead of squeeze.

File size: 7.0 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))
19CHROOT:=sudo chroot $(DEBIAN_BUILD_DIR)
20CHROOT_USER:=$(CHROOT) su - $(USER)
21SB2:=sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "export LC_ALL=C; cd $(SB2_ARCH)-lenny && sb2"
22SB2E:=sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "export LC_ALL=C; cd $(SB2_ARCH)-lenny && sb2 -e"
23SB2EF:=sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "export LC_ALL=C; cd $(SB2_ARCH)-lenny && sb2 -eR"
24
25sb2:
26        $(SB2)
27sb2e:
28        $(SB2E)
29sbef:
30        $(SB2EF)
31ch: chroot
32chu: chroot-user
33chroot:
34        $(CHROOT) bash -c "cd /usr/src; exec bash"
35chroot-user:
36        $(CHROOT_USER) bash -c "cd /usr/src; exec bash"
37
38#debian/buildenv/create: debian/buildenv/prepare debian/buildenv/qemu-build debian/buildenv/scratchbox-prepare
39debian/buildenv/create: debian/buildenv/prepare debian/buildenv/emdebian-prepare
40        touch $@
41
42debian/buildenv/prepare:
43        mkdir -p $(DEBIAN_BUILD_DIR)
44        # Due to various bugs in debootstrap in combination with fakechroot it is not
45        # possible to create a fakechroot here - and therefore we need to use chroot
46        # with sudo
47        #fakeroot fakechroot debootstrap
48                                                #--variant=fakechroot
49        sudo debootstrap    --include=$(subst $(space),$(empty),$(CONFIG_DEBIAN_BUILDENV_INCLUDE_PACKAGES)) \
50                                            $(DEBIAN_BUILD_VERSION) \
51                                                $(DEBIAN_BUILD_DIR) \
52                                                $(CONFIG_DEBIAN_BUILDENV_REPOSITORY)
53        sudo bash -c "echo 127.0.0.1 `hostname -s` >$(DEBIAN_BUILD_DIR)/etc/hosts"
54        sudo bash -c "echo \"$(USER) ALL=(ALL) NOPASSWD: ALL\" >$(DEBIAN_BUILD_DIR)/etc/sudoers"
55        sudo bash -c "echo debwrt-$(call qstrip,$(CONFIG_ARCH))-$(DEBIAN_BUILD_VERSION) > $(DEBIAN_BUILD_DIR)/etc/debian_chroot"
56        sudo bash -c "echo syntax on >$(DEBIAN_BUILD_DIR)/etc/vimrc"
57        sudo bash -c "echo 0 > /proc/sys/vm/mmap_min_addr" # for ARM targets
58        sudo bash -c "echo \"deb $(call qstrip,$(CONFIG_DEBIAN_BUILDENV_REPOSITORY)) $(DEBIAN_BUILD_VERSION) main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
59        sudo bash -c "echo \"deb-src $(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"
89ifeq ($(DEBIAN_BUILD_VERSION),sid)
90        sudo chroot $(DEBIAN_BUILD_DIR) apt-get update
91        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 subversion automake gcc-multilib g++-multilib"
92else
93        sudo bash -c "echo \"deb $(call qstrip,$(CONFIG_DEBIAN_BUILDENV_REPOSITORY)) sid main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
94        sudo bash -c "echo -e \"Package: *\nPin: release a=sid\nPin-Priority: 200\" > $(DEBIAN_BUILD_DIR)/etc/apt/preferences"
95        sudo chroot $(DEBIAN_BUILD_DIR) apt-get update
96        sudo chroot $(DEBIAN_BUILD_DIR) apt-get -y install -t sid apt-cross libmpfr1ldbl
97        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 vim pkg-config dpatch libncurses5-dev devscripts subversion automake gcc-multilib g++-multilib"
98endif
99        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"
100        touch $@
101
102debian/buildenv/qemu-prepare:
103        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"
104        touch $@
105
106debian/buildenv/qemu-build: debian/buildenv/qemu-prepare
107        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"
108        touch $@
109
110debian/buildenv/scratchbox-prepare:
111        sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "mkdir -p $(SB2_ARCH)-lenny"
112        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\""
113        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)"
114        sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c  "cd $(SB2_ARCH)-lenny && sb2 -eR ./debootstrap/debootstrap --second-stage"
115
116debian/buildenv/clean:
117        # sudo should not be needed if fakechroot would have worked
118        sudo rm -rf $(DEBIAN_BUILD_DIR)
119        rm -f debian/buildenv/prepare
120        rm -f debian/buildenv/qemu-prepare
121        rm -f debian/buildenv/qemu-build
122
123.PHONY: debian/clean
124
Note: See TracBrowser for help on using the repository browser.