source: debwrt/trunk/debian/rootfs/debian.mk @ 230

Last change on this file since 230 was 230, checked in by stappers, 12 years ago

More cleaning in rootfs, see also r204 and r229.

File size: 4.6 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
18DEBIAN_ROOTFS_INCLUDE_PACKAGES:=$(call qstrip,$(CONFIG_DEBIAN_ROOTFS_INCLUDE_PACKAGES))
19DEBWRT_EXTRA_ROOTFS_FILES_DIR:=$(TOPDIR)/debian/rootfs/files
20DEBWRT_MODULES_ARCHIVE=$(shell ls $(INSTALL_DIR)/debwrt-modules-*.tar.gz 2>/dev/null)
21MODULES_VERSION=$(shell echo `basename $(DEBWRT_MODULES_ARCHIVE) 2>/dev/null` | awk -F '-' '{print $$6}')
22
23debian/rootfs: debian/rootfs/bootstrap debian/rootfs/unpack debian/rootfs/files-install debian/rootfs/debwrt-packages debian/rootfs/modules-install debian/rootfs/post-setup
24        touch $@
25
26debian/rootfs/install: debian/rootfs
27        if [ -d /media/DEBWRT_ROOT ]; then \
28                sudo rm -rf /media/DEBWRT_ROOT/*; \
29                sudo bash -c "tar cf - -C $(ROOTFS_BUILD_DIR) . | tar xf - -C /media/DEBWRT_ROOT"; \
30        fi
31        #touch $@
32
33debian/rootfs/save:
34        if [ -d /media/DEBWRT_ROOT ]; then \
35                sudo bash -c "tar cjf debwrt-rootfs-$(TARGET_ARCH)-$(VERSION).tar.bz2 -C /media/DEBWRT_ROOT ."; \
36        fi
37
38debian/rootfs/files-install: debian/rootfs/bootstrap
39        if [ ! -f $(ROOTFS_BUILD_DIR)/etc/init.d/rcS.debian -a -e $(ROOTFS_BUILD_DIR)/etc/init.d/rcS ]; then \
40                sudo mv -v $(ROOTFS_BUILD_DIR)/etc/init.d/rcS $(ROOTFS_BUILD_DIR)/etc/init.d/rcS.debian; \
41        fi
42        if [ ! -p $(ROOTFS_BUILD_DIR)/dev/initctl ]; then  \
43                sudo mkdir -p $(ROOTFS_BUILD_DIR)/dev;         \
44                sudo mkfifo   $(ROOTFS_BUILD_DIR)/dev/initctl; \
45        fi
46        chmod 600 $(DEBWRT_EXTRA_ROOTFS_FILES_DIR)/etc/ssh/ssh_host_rsa_key
47        chmod 600 $(DEBWRT_EXTRA_ROOTFS_FILES_DIR)/etc/ssh/ssh_host_dsa_key
48        sudo bash -c "tar cf - --exclude=".svn" -C $(DEBWRT_EXTRA_ROOTFS_FILES_DIR) . | tar -xovf - -C $(ROOTFS_BUILD_DIR)"
49        touch $@
50
51debian/rootfs/modules-install: debian/rootfs/bootstrap
52ifneq ($(DEBWRT_MODULES_ARCHIVE),)
53        sudo tar xof $(DEBWRT_MODULES_ARCHIVE) -C $(ROOTFS_BUILD_DIR)
54        #sudo depmod -a -b $(ROOTFS_BUILD_DIR) $(MODULES_VERSION)
55endif
56        touch $@
57
58debian/rootfs/bootstrap: debian/rootfs/clean-rootfs-dir
59        sudo debootstrap --arch=$(TARGET_ARCH)\
60                     --foreign \
61                         --include="$(DEBIAN_ROOTFS_INCLUDE_PACKAGES)" \
62                     $(DEBIAN_BUILD_VERSION) \
63                     $(ROOTFS_BUILD_DIR) \
64                     $(CONFIG_DEBIAN_BUILDENV_REPOSITORY)
65        # complete ROOTFS/dev/ with additional device files
66        sudo bash -c "cd $(ROOTFS_BUILD_DIR)/dev ; /sbin/MAKEDEV -v consoleonly"
67        sudo bash -c "cd $(ROOTFS_BUILD_DIR)/dev ; /sbin/MAKEDEV -v sda"
68        touch $@
69
70debian/rootfs/unpack: debian/rootfs/bootstrap
71        find $(ROOTFS_BUILD_DIR) -name "*.deb" | while read deb; do \
72                n=`basename $$deb`; \
73                echo -n "I: Extracting $${n}..."; \
74                sudo bash -c "ar -p "$$deb" data.tar.gz | zcat | tar -C $(ROOTFS_BUILD_DIR) -xf -"; \
75                echo "done"; \
76        done
77        touch $@
78
79# install all available cross-compiled debwrt debian packages, extect for the kernel-headers packages because it is to big
80debian/rootfs/debwrt-packages: debian/rootfs/bootstrap debian/package/rootfs
81        ls ${INSTALL_DIR_DEBIAN_PACKAGES}/*.deb | grep -v "debwrt-kernel-headers" | while read package; do \
82                pfname=`basename $$package`; \
83                pname=`echo $$pfname | sed 's/_.*//'`; \
84                echo "Installing DebWrt package: $$pname"; \
85                sudo cp $$package $(ROOTFS_BUILD_DIR)/var/cache/apt/archives; \
86                sudo dpkg-deb -x $$package $(ROOTFS_BUILD_DIR); \
87                sudo bash -c "echo \"$$pname /var/cache/apt/archives/$$pfname\" >>$(ROOTFS_BUILD_DIR)/debootstrap/debpaths" ;\
88        done
89        touch $@
90       
91debian/rootfs/clean-rootfs-dir:
92        mkdir -p $(BUILD_DIR_BASE)
93        sudo rm -rf $(ROOTFS_BUILD_DIR)
94        touch $@
95
96debian/rootfs/post-setup: debian/rootfs/bootstrap
97        sudo mkdir -p $(ROOTFS_BUILD_DIR)/etc/apt
98        sudo bash -c "echo \"deb $(DEBIAN_BUILDENV_REPOSITORY) $(DEBIAN_BUILD_VERSION) main\" > $(ROOTFS_BUILD_DIR)/etc/apt/sources.list"
99        touch $@
100
101debian/rootfs/clean: 
102        sudo rm -rf $(ROOTFS_BUILD_DIR)
103        rm -f debian/rootfs/debwrt-packages
104        rm -f debian/rootfs/bootstrap
105        rm -f debian/rootfs/install
106        rm -f debian/rootfs/files-install
107        rm -f debian/rootfs/modules-install
108        rm -f debian/package/rootfs
109        rm -f debian/package/*/deliver
110
111# l l
Note: See TracBrowser for help on using the repository browser.