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

Last change on this file since 151 was 151, checked in by amain, 12 years ago

debian/buildenv: sudo now installs without interuptuon

File size: 7.1 KB
RevLine 
[9]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
[19]18SB2_ARCH:=$(call qstrip,$(CONFIG_ARCH))
[9]19CHROOT:=sudo chroot $(DEBIAN_BUILD_DIR)
[44]20CHROOT_USER:=$(CHROOT) su - $(USER)
[41]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"
[9]24
25sb2:
26        $(SB2)
27sb2e:
28        $(SB2E)
29sbef:
30        $(SB2EF)
31ch: chroot
32chu: chroot-user
33chroot:
[44]34        $(CHROOT) bash -c "cd /usr/src; exec bash"
[9]35chroot-user:
[44]36        $(CHROOT_USER) bash -c "cd /usr/src; exec bash"
[9]37
[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
[52]40        touch $@
[9]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)
[44]53        sudo bash -c "echo 127.0.0.1 `hostname -s` >$(DEBIAN_BUILD_DIR)/etc/hosts"
[54]54        sudo bash -c "echo debwrt-$(call qstrip,$(CONFIG_ARCH))-$(DEBIAN_BUILD_VERSION) > $(DEBIAN_BUILD_DIR)/etc/debian_chroot"
[44]55        sudo bash -c "echo syntax on >$(DEBIAN_BUILD_DIR)/etc/vimrc"
[9]56        sudo bash -c "echo 0 > /proc/sys/vm/mmap_min_addr" # for ARM targets
[37]57        sudo bash -c "echo \"deb $(call qstrip,$(CONFIG_DEBIAN_BUILDENV_REPOSITORY)) $(DEBIAN_BUILD_VERSION) main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
[101]58        sudo bash -c "echo \"deb-src $(call qstrip,$(CONFIG_DEBIAN_BUILDENV_REPOSITORY)) $(DEBIAN_BUILD_VERSION) main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
[44]59        sudo chown $(USER):$(GROUP) $(DEBIAN_BUILD_DIR)/usr/src
[9]60        sudo chroot $(DEBIAN_BUILD_DIR) apt-get update
61        sudo chroot $(DEBIAN_BUILD_DIR) groupadd -g $(shell id -g) debwrt
62        sudo chroot $(DEBIAN_BUILD_DIR) useradd -g debwrt -s /bin/bash -m -u $(shell id -u) $$USER
[151]63        sudo mkdir -p $(DEBIAN_BUILD_DIR)/etc/sudoers.d
64        sudo bash -c "echo \"$(USER) ALL=(ALL) NOPASSWD: ALL\" >$(DEBIAN_BUILD_DIR)/etc/sudoers.d/debwrt"
65        sudo chmod 0440 $(DEBIAN_BUILD_DIR)/etc/sudoers.d/debwrt
[9]66        touch $@
67
[37]68debian/buildenv/prepare-sb2:
69        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"
70        touch $@
71
72#
73# -- Emdebian sources.list entries
74#
75# deb http://www.emdebian.org/debian/ unstable main
76# deb http://www.emdebian.org/debian/ testing main
77# deb http://www.emdebian.org/debian/ lenny main
78#
79# Once you have that then install whichever version of the tools you want. e.g:
80# 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
81# will install the gcc-4.3 C and C++ toolchain for armel cross-compiling.
[54]82#
83# Use emdebian stable/lenny cross compiler. Unstable seems to be broken now for a long time
84#EMDEBIAN_RELEASE:=$(DEBIAN_BUILD_VERSION)
85EMDEBIAN_RELEASE:=stable
86
87# note: to speed up setting up: do not install devscripts
88# note: a mailservers seems to be installed and started: bad - needs removal
[50]89debian/buildenv/emdebian-prepare: debian/buildenv/prepare
[54]90        sudo bash -c "echo \"deb $(call qstrip,$(CONFIG_EMDEBIAN_BUILDENV_REPOSITORY)) $(EMDEBIAN_RELEASE) main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
[134]91ifeq ($(DEBIAN_BUILD_VERSION),sid)
[37]92        sudo chroot $(DEBIAN_BUILD_DIR) apt-get update
[151]93        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 openssh-client dpkg-cross apt-cross vim pkg-config dpatch libncurses5-dev devscripts subversion automake gcc-multilib g++-multilib"
[134]94else
95        sudo bash -c "echo \"deb $(call qstrip,$(CONFIG_DEBIAN_BUILDENV_REPOSITORY)) sid main\" >> $(DEBIAN_BUILD_DIR)/etc/apt/sources.list"
96        sudo bash -c "echo -e \"Package: *\nPin: release a=sid\nPin-Priority: 200\" > $(DEBIAN_BUILD_DIR)/etc/apt/preferences"
97        sudo chroot $(DEBIAN_BUILD_DIR) apt-get update
98        sudo chroot $(DEBIAN_BUILD_DIR) apt-get -y install -t sid apt-cross libmpfr1ldbl
[151]99        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 openssh-client dpkg-cross vim pkg-config dpatch libncurses5-dev devscripts subversion automake gcc-multilib g++-multilib"
[134]100endif
[44]101        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"
[37]102        touch $@
103
[9]104debian/buildenv/qemu-prepare:
105        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"
106        touch $@
107
108debian/buildenv/qemu-build: debian/buildenv/qemu-prepare
[15]109        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"
[9]110        touch $@
111
112debian/buildenv/scratchbox-prepare:
[15]113        sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c "mkdir -p $(SB2_ARCH)-lenny"
114        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\""
[17]115        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)"
[15]116        sudo chroot $(DEBIAN_BUILD_DIR) su - $(USER) -c bash -c  "cd $(SB2_ARCH)-lenny && sb2 -eR ./debootstrap/debootstrap --second-stage"
[9]117
118debian/buildenv/clean:
119        # sudo should not be needed if fakechroot would have worked
120        sudo rm -rf $(DEBIAN_BUILD_DIR)
[23]121        rm -f debian/buildenv/prepare
[15]122        rm -f debian/buildenv/qemu-prepare
123        rm -f debian/buildenv/qemu-build
[9]124
125.PHONY: debian/clean
126
Note: See TracBrowser for help on using the repository browser.